Jump to content
Changes to the Jaspersoft community edition download ×

line chart help


puneety

Recommended Posts

  • 2 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Here's how it can be done:

 

You should use a customizer class that looks something like this:

/**
 *
 */
package name_of_your_package;

import java.text.DecimalFormat;

import org.jfree.chart.JFreeChart;

import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartCustomizer;

import org.jfree.chart.plot.CategoryPlot;

import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;

import org.jfree.chart.renderer.category.LineAndShapeRenderer;

public class LineChartCustomizer implements JRChartCustomizer {

    public void customize(JFreeChart jFreeChart, JRChart jrChart)

    {

        CategoryPlot plot = jFreeChart.getCategoryPlot();
       
        DecimalFormat dfKey = new DecimalFormat("###,###");

        StandardCategoryItemLabelGenerator labelGenerator

                = new StandardCategoryItemLabelGenerator("{2}", dfKey);
/* {0} - label would be equal to Series expression, {1} - label would be equal to Category expression, {2} - label would be equal to Value expression
*/
       
        LineAndShapeRenderer renderer = new LineAndShapeRenderer();
       
        renderer.setBaseItemLabelsVisible(true);
       
        renderer.setBaseItemLabelGenerator(labelGenerator);
       
        plot.setRenderer(renderer);

    }

}

 

and write the name of the class in "Customizer class" field of your line chart.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...