如何在 JFreeChart 中设置多个系列的线条粗细?
How to set line thickness for multiple series in JFreeChart?
我创建了很多图表。在他们每个人中我都需要打电话
renderer.setSeriesStroke( i, new BasicStroke( 2.0f ) );
每个系列。 (renderer
是 chart.getXYPlot().getRenderer()
)。
请问有没有办法全局设置厚度
调用渲染器的setBaseStroke()
setDefaultStroke()
方法,就像他们说的here, and change the autoPopulateSeriesStroke
flag, like they say here.
//renderer.setBaseStroke(new BasicStroke(2.0f));
renderer. setDefaultStroke(new BasicStroke(2.0f));
renderer.setAutoPopulateSeriesStroke(false);
v1.5 的答案 and show the new method name when migrating。
对于 Jfreechart 1.5.0:
XYItemRenderer renderer = lineChart.getXYPlot().getRenderer();
renderer.setDefaultStroke(new BasicStroke(2.0f));
((AbstractRenderer) renderer).setAutoPopulateSeriesStroke(false);
来自 Jfreechart 1.5.0
和使用 ChartFactory.createLineChart(...)
创建的折线图
JFreeChart lineChart = ChartFactory.createLineChart(...);
LineAndShapeRenderer renderer = (LineAndShapeRenderer) lineChart.getCategoryPlot().getRenderer();
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f));
我创建了很多图表。在他们每个人中我都需要打电话
renderer.setSeriesStroke( i, new BasicStroke( 2.0f ) );
每个系列。 (renderer
是 chart.getXYPlot().getRenderer()
)。
请问有没有办法全局设置厚度
调用渲染器的setBaseStroke()
setDefaultStroke()
方法,就像他们说的here, and change the autoPopulateSeriesStroke
flag, like they say here.
//renderer.setBaseStroke(new BasicStroke(2.0f));
renderer. setDefaultStroke(new BasicStroke(2.0f));
renderer.setAutoPopulateSeriesStroke(false);
v1.5 的答案
对于 Jfreechart 1.5.0:
XYItemRenderer renderer = lineChart.getXYPlot().getRenderer();
renderer.setDefaultStroke(new BasicStroke(2.0f));
((AbstractRenderer) renderer).setAutoPopulateSeriesStroke(false);
来自 Jfreechart 1.5.0
和使用 ChartFactory.createLineChart(...)
JFreeChart lineChart = ChartFactory.createLineChart(...);
LineAndShapeRenderer renderer = (LineAndShapeRenderer) lineChart.getCategoryPlot().getRenderer();
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f));