rym
rym

Reputation: 545

How to add values legend to a line chart?

I'am using JasperReport and ireport 4.0,

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

This is what I have now:

enter image description here

This is what I want to have: enter image description here

Upvotes: 3

Views: 2040

Answers (1)

GobyDot
GobyDot

Reputation: 483

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.

Upvotes: 1

Related Questions