In JFreeChart
I'm trying to color different regions of an XY line chart/curve based on y
value. I'm overriding the XYLineAndShapeRenderer
's getItemPaint(int row, int col)
, however I'm not sure how it handles the coloring of the line between the x
s since it's only getting itemPaint
on the x
(integer values).
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
@Override
@Override
public Paint getItemPaint(int row, int col) {
System.out.println(col+","+dataset.getY(row, col));
double y=dataset.getYValue(row, col);
if(y<=3)return ColorUtil.hex2Rgb("#7DD2F7");
if(y<=4)return ColorUtil.hex2Rgb("#9BCB3B");
if(y<=5)return ColorUtil.hex2Rgb("#FFF100");
if(y<=6)return ColorUtil.hex2Rgb("#FAA419");
if(y<=10)return ColorUtil.hex2Rgb("#ED1B24");
//getPlot().getDataset(col).
return super.getItemPaint(row,col);
}
}