I am new to JFreeChart and I am trying to see what action do what.
In my chart I only have one series, and I would like -according to the value- to set a different color for the bar. For example : 0-20 -> RED, 20-80 -> YELLOW, 80-100 -> GREEN
CategoryPlot plot = chart.getCategoryPlot();
CategoryDataset dataset = plot.getDataset(0);
Number value = dataset.getValue(dataset.getRowKey(0), dataset.getColumnKey(0));
Double val = value.doubleValue();
if (val <= 20.0) {
BarRenderer renderer = (BarRenderer) plot.getRenderer();
Paint tmp = renderer.getItemPaint(row, column);
/*
** Help Please
*/
}
return chart;
This is where I reached, I am stuck here and don't know really where to go. I saw in the documentation that Paint is an interface but none of the class implementing this interface does provide a setXXX() method. So, my two questions are :
- How do I set a color to a single Bar ?
- How do I apply that to my chart ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…