Displaying Full Label Name using Jfree Chart in Jasper Studio

Posted on by By Satya Gopi, in Jaspersoft | 0

Perquisites : JasperStudio ,Eclipse

We came across one issue, when we created a Stacked Bar Chart using JFree chart the label names are not visible totally as below Screenshot.

Query results:



Stacked Bar Chart:

By using class customizer we can solve the above problem

Step 1: Create a Java Project and create a java class as below

package com.customchart.StackedBar;

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.axis.CategoryAxis;
import org.jfree.chart.plot.CategoryPlot;

public class PlotBarchartEnclosing
  implements JRChartCustomizer
{
  public void customize(JFreeChart chart, JRChart jasperChart)
  {
    Log log = LogFactory.getLog(PlotBarchartEnclosing.class);

    CategoryPlot plot = (CategoryPlot)chart.getPlot();

    CategoryAxis categoryAxis = plot.getDomainAxis();

    categoryAxis.setMaximumCategoryLabelLines(3);
    categoryAxis.setMaximumCategoryLabelWidthRatio(3.0F);
  }
}

Step 2 : Export the project to JAR

Step 3 : Add the JAR in Jasper studio

Step 4 : Attach this JAR to class customizer by giving packagename.classname in class customizer

Step 5 : Run the report and see the output as follows with full label names:

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

Thank You
Satya Gopi
BI Developer
Helical IT Solutions Pvt Ltd

logo

Best Open Source Business Intelligence Software Helical Insight Here

logo

A Business Intelligence Framework


logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

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