【问题标题】:How to delete blank lines in chart line in jasper report如何在碧玉报告中删除图表行中的空白行
【发布时间】:2019-01-26 18:09:09
【问题描述】:

我想删除作为值出现在图表线中的水平线,但在图表的属性中找不到正确的选项:

我希望图表看起来像这样:

【问题讨论】:

    标签: jasper-reports jfreechart linechart


    【解决方案1】:

    JasperReports 图表元素模型不公开该属性。您需要编写一个图表定制器(或主题)以便进行设置。

    定制器类如下所示:

    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);
        }
    }
    

    然后您需要为图表元素设置定制器类:

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

    【讨论】:

    • 感谢您的回答。我正在使用 Jasperreport 6.5.1。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多