Pre-Requisites: Jasper soft studio 6.0 and above.
Description: We often come across a situation where we need to remove the label shadow, label outline and label background from the Pie Chart in Jasper. We can remove them by using a java code adding to it. Here in this blog, I am listing down the code using which we can remove the above-mentioned labels from pie chart.
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Code: package com.customchart.PieChart; import java.awt.Color; import net.sf.jasperreports.engine.JRChart; import net.sf.jasperreports.engine.JRChartCustomizer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.block.BlockBorder; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.title.LegendTitle; public class PiePlotEnclosingReport implements JRChartCustomizer { public void customize(JFreeChart chart, JRChart jasperChart) { Log log = LogFactory.getLog(PiePlotEnclosingReport.class); LegendTitle legend = chart.getLegend(); PiePlot plot = (PiePlot)chart.getPlot(); plot.setLabelBackgroundPaint(null); plot.setLabelOutlinePaint(null); plot.setLabelShadowPaint(null); plot.setShadowXOffset(0.0D); plot.setShadowYOffset(0.0D); legend.setFrame(BlockBorder.NONE); } }
There is no big deal in adding the above code to the report, You just need to convert it into a jar file and add the file to report in server(UI) level and add the com.customchart.PieChart.PiePlotEnclosingReport class in the pie chart customizer class block, that’s it your report will automatically appear without the above labels by utilizing the above-customized code.
Before
After
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Best Open Source Business Intelligence Software Helical Insight is Here
A Business Intelligence Framework
If you have any queries please get us at support@helicaltech.com
Thanks,
Prashanth Kasoji
Helical IT Solutions Pvt Ltd