Jump to content
We've recently updated our Privacy Statement, available here ×

mtrbojevic

Members
  • Posts

    2
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Posts posted by mtrbojevic

  1. 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.

×
×
  • Create New...