我将绘制一条折线图,该折线图将从实线变为虚线,以指示实际数据和预测数据.我不确定是否需要扩展一些类,如XYLineAndShapeRenderer或其他类,或者可能有一些方便的方法来实现这一点?
这是使用Excel绘制的演示图.

我在谈论图中的灰线.这就是我想要的.我不知道是否有渲染器允许我指示哪个范围是虚线还是实线
在JFreeChart我试图根据y值为XY线图/曲线的不同区域着色.我重写XYLineAndShapeRenderer的 getItemPaint(int row, int col),但我不知道它是如何处理的线的着色x小号,因为它只是让itemPaint上x(整数值).
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);
}
}
Run Code Online (Sandbox Code Playgroud)