Mayca
Mayca

Reputation: 29

How to delete blank lines in chart line in jasper report

I want to delete the horizontal lines that appear in a chart line as values, but I can´t find the correct option in properties of the chart:

chart line with blank lines

I want the chart to look like this instead:

Chart line without blank lines

Upvotes: 1

Views: 378

Answers (1)

dada67
dada67

Reputation: 5103

The JasperReports chart element model does not expose that attribute. You'll need to write a chart customizer (or theme) so set it.

The customizer class would look like this:

package my.code;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;

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

public class LineChartCustomizer extends JRAbstractChartCustomizer
{
    @Override
    public void customize(JFreeChart chart, JRChart jasperChart)
    {
        CategoryPlot plot = chart.getCategoryPlot();
        plot.setRangeGridlinesVisible(false);
    }
}

You would then need to set the customizer class for the chart element:

        <lineChart>
            <chart customizerClass="my.code.LineChartCustomizer">
            ...

Upvotes: 2

Related Questions