开发者

How to add values legend to a line chart?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜