如何在条形图上设置基准线?

编程入门 行业动态 更新时间:2024-10-07 08:19:59
本文介绍了如何在条形图上设置基准线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们正在使用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>

更多推荐

如何在条形图上设置基准线?

本文发布于:2023-07-18 08:14:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1142741.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:基准线   条形   图上   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!