开发者

How to add values legend to a line chart?

开发者 https://www.devze.com 2023-03-25 08:36 出处:网络
I\'am using JasperRepor开发者_Go百科t and ireport 4.0, I want to add to my charts values like the following:

I'am using JasperRepor开发者_Go百科t and ireport 4.0,

I want to add to my charts values like the following:

This is what I have now:

How to add values legend to a line chart?

This is what I want to have:

How to add values legend to a line chart?


there is no 'Show Labels' attribute for the line plot. But you can render the labels visible using a chart customizer:

public void customize(JFreeChart chart, JRChart jasperChart){
LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)chart.getCategoryPlot().getRenderer();
lineRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
lineRenderer.setBaseItemLabelsVisible(true);
}

If it's an XY line chart, use an XYPlot and a StandardXYItemLabelGenerator in the above code snippet.

0

精彩评论

暂无评论...
验证码 换一张
取 消