且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Jfreechart中更改图形的X轴起始值

更新时间:2023-10-08 17:27:28

您可以更改域轴的下限并设置系列绘制,如下所示。默认的 XYBarPainter 有一个渐变颜色突出显示,所以我使用了 StandardXYBarPainter

You can change the lower bound of the domain axis and set the series paint as shown below. The default XYBarPainter has a gradient color highlight, so I used a StandardXYBarPainter.

XYPlot plot = (XYPlot) chart.getPlot();
ValueAxis axis = plot.getDomainAxis();
axis.setLowerBound(0);
XYBarRenderer r = (XYBarRenderer) plot.getRenderer();
r.setBarPainter(new StandardXYBarPainter());
r.setSeriesPaint(0, Color.blue);