|
settng color of bar in Bar Chart |
Posted by Priyank Joshi on Sep-17-2010 15:00 |
|
Hi All,
In Bar Chart, I want to set a different color for a specific bar based on condition.
For example, bar graph is generated on following data
double[] data = {85, 156, 179.5, 211, 123};
Suppose color set for bar graph is green, but i want to set red color for bars which are exceeding 150.
Please suggest. |
Re: settng color of bar in Bar Chart |
Posted by Peter Kwan on Sep-17-2010 16:57 |
|
Hi Priyank,
There is a sample code "Multi-Color Bar Chart" included in ChartDirector, which demonstrates that how you can control the color of individual bars.
For example, according to your requirement (in Java):
int[] color = new int[data.length];
for (int i = 0; i < color.length; ++i)
color[i] = (data[i] > 150) ? 0xff0000 : 0x00cc00;
c.addBarLayer3(data, colors);
Hope this can help.
Regards
Peter Kwan |
|