Displaying Values on Data Points for Jfree Chart in Jasper

Posted on by By Satya Gopi, in Jaspersoft | 0

Prerequisites:Jasper Server 7.1 community version,Jasper Studio 6.3
Database:Foodmart

Created a Sample Report which represents the Year wise sale bChart, the Line Chart ,but here we have came across one issue is not able to see the values on the data points

jFree Chart

So to overcome the above issue we need to use chart customizer

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Get your 30 Days Trail Version

Use below JavaCode to display the Values on Data Points

public class LineChart implements JRChartCustomizer {
@Override
public void customize(JFreeChart chart, JRChart jasperChart)
{
CategoryPlot categoryPlot = (CategoryPlot)chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) categoryPlot.getRangeAxis();
rangeAxis.setUpperMargin(0.25);
LineAndShapeRenderer lineAndShapeRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
lineAndShapeRenderer.setBaseItemLabelsVisible(Boolean.TRUE);

lineAndShapeRenderer.setItemMargin(0.0D);
lineAndShapeRenderer.setBaseItemLabelFont(font3);
lineAndShapeRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
}
}

Create a Jar with above javacode and use the java class in chart customizer

Edit Customizer

Add this JAR file to the Report

Edit Jasperreport

Check the Result by executing the Report in Jasper Server

Output

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

In case if you have any queries please get us at support@helicaltech.com

Thank You
Satya Gopi
Helical IT Solutions Pvt Ltd

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments