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:
This is what I want to have:
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.
精彩评论