MPAndroidChart,设置不同的颜色以y轴上的值以条形图吧
问题描述:
我在策划使用MPAndroid图表柱状图。现在,我所有的酒吧有同样的颜色,但我想不同的颜色,基于Y轴值的吧,就像如果值> 100。颜色=红色,就像下面的图片。那可能吗?有人请帮助我。
I'm plotting a bar chart using MPAndroid chart. Now all my bars have the same color but I want different colors for the bars based on Y axis values, like if value >100. color = red, like in the picture below. Is that possible? someone please help me.
问候。
答
您可以了解从的这个链接
LineDataSet setComp1 = new LineDataSet(valsComp1, "Company 1");
// sets colors for the dataset, resolution of the resource name to a "real" color is done internally
setComp1.setColors(new int[] { R.color.red1, R.color.red2, R.color.red3, R.color.red4 }, Context);
LineDataSet setComp2 = new LineDataSet(valsComp2, "Company 2");
setComp2.setColors(new int[] { R.color.green1, R.color.green2, R.color.green3, R.color.green4 }, Context);