本文介绍了如何在条形图上设置基准线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在使用jfreechart与Jasper报告,我们正在努力将基准线放在条形图上。
We are using the jfreechart with Jasper reports and we are struggling to put the benchmark line on the bar chart.
如何使用jasper报告实现这一目标?
How can this be achieved using jasper reports?
推荐答案要在jasper报告中自定义条形图,请创建一个自定义程序类(ChartCustomizer),扩展 JRChartCustomizer 。
To customize your bar chart in jasper report create a customizer class (ChartCustomizer) extending the JRChartCustomizer.
public void customize(JFreeChart chart, ChartComponent chartComponent) { //get the ploy CategoryPlot plot = (CategoryPlot) chart.getPlot(); //Now add your markers ValueMarker vm = new ValueMarker(200); //200 is the position you like it to be vm.setPaint(Color.RED); vm.setStroke(new BasicStroke(1)); vm.setLabel("BeanchMark value"); //The label vm.setLabelAnchor(RectangleAnchor.TOP); vm.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); plot.addRangeMarker(vm); }将类添加到classpath并在jrxml中设置 customizerClass attribute
add the class to classpath and in jrxml set the customizerClass attribute
<barChart> <chart customizerClass="my.package.ChartCustomizer"> .... </chart> ... </barChart>更多推荐
如何在条形图上设置基准线?
发布评论