且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

mpandroidchart我想获得第三个值

更新时间:2023-01-31 12:17:53

您需要创建:

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

此后,您需要为每个条目添加要显示的颜色的值,您需要将代码修改为:

After that you need to add values for each entry which color you want to show, you need to modify your code as:

ArrayList<Entry> value1 = new ArrayList<>();

for (int i = 0; i < 10; i++) 
{  
   float y = (float) Math.random();
   value1.add(new Entry(i, y));
// add your condition here
if(y>10)
 {
   color.add(getContext().getResources().getColor(R.color.colorPrimary));
 }
else
   color.add(getContext().getResources().getColor(R.color.colorAccent));
}

完成颜色数组列表后,可以将颜色设置为:

When you complete your colors arraylist then you can set colors as:

dataSet.setColors(color);