4
在JFreeChart
我试图根据y
值为XY线图/曲线的不同区域着色。我重写XYLineAndShapeRenderer
的getItemPaint(int row, int col)
,但我不确定它是如何处理x
之间的线的颜色,因为它只在x
(整数值)上获得itemPaint
。JFreeChart对于相同的数据在不同地区的不同颜色系列
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);
}
}
这是一个美妙的解决方案! – user121196 2012-08-15 13:51:49