如何在JFreeChart图表上画线?

chr*_*sto 5 java jfreechart

我有可更新的OHLCChart.我需要在图表上划一条线.

怎么实现呢?

Bal*_*ick 21

如果要在轴上的给定位置绘制垂直或水平线,可以使用ValueMarker:

ValueMarker marker = new ValueMarker(position);  // position is the value on the axis
marker.setPaint(Color.black);
//marker.setLabel("here"); // see JavaDoc for labels, colors, strokes

XYPlot plot = (XYPlot) chart.getPlot();
plot.addDomainMarker(marker);
Run Code Online (Sandbox Code Playgroud)

plot.addRangeMarker()如果要绘制水平线,请使用.

  • 您可以使用 getXYPlot() 代替 getPlot() 和转换。 (3认同)