我正在自定义Jasper Reports生成的默认图表,但找不到使轴线变粗的方法。
到目前为止,我很容易找到更改颜色的示例:
http://www.jfree.org/forum/viewtopic.php?f=3&t=11639,但是编辑者更容易更改。
我附上一张图片,以说明与当前厚度相比的预期厚度。
这是我当前的定制器:
public void customize(JFreeChart jFreeChart, JRChart jrChart) {
CategoryPlot plot = (CategoryPlot) jFreeChart.getPlot();
plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
barRenderer.setItemMargin(0.0);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
NumberFormat numberFormat= NumberFormat.getNumberInstance();
numberFormat.setMaximumFractionDigits(2);
numberFormat.setMinimumFractionDigits(2);
rangeAxis.setNumberFormatOverride(numberFormat);
rangeAxis.setUpperMargin(0.2);
rangeAxis.setAutoRange(true); //make sure that fixed range is not set
}
GitHub:https://github.com/MichaelKnight/jaspertest.git
最佳答案
要设置CategoryAxis
和NumberAxis
的Stroke,请在customize
中添加以下代码:
CategoryAxis categoryAxis = plot.getDomainAxis();
categoryAxis.setAxisLineStroke(new BasicStroke(2f)); //see API link below for BasicStroke
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAxisLineStroke(new BasicStroke(2f));
BasicStroke API