How to change dot colors if value is higher than constant in MPAndroidChart

前端 未结 1 1737
谎友^
谎友^ 2020-12-22 10:40

I need to draw red circles if value higher than 3. How to realize that? I\'ve read that I should override method drawCircles but I dont understand where I should do this.

相关标签:
1条回答
  • 2020-12-22 11:22

    Try with this:

    Define one ArrayList:

    ArrayList<Integer> color = new ArrayList<>();
    

    And add your condition as:

    if (YOUR_CONDITION) {
        color.add(ColorTemplate.rgb("#f8bf94"));
        yVals1.add(new Entry(VALUE, COUNTER));
    } else {
        color.add(ColorTemplate.rgb("#e0e0e0"));
        yVals1.add(new Entry(VALUE, COUNTER));
    }
    

    And before adding dataset, add

    set1.setColors(color);
    

    For your reference, you can check this link.

    Hope this answer will help you.

    0 讨论(0)
提交回复
热议问题