【发布时间】:2019-01-26 18:09:09
【问题描述】:
我想删除作为值出现在图表线中的水平线,但在图表的属性中找不到正确的选项:
我希望图表看起来像这样:
【问题讨论】:
标签: jasper-reports jfreechart linechart
我想删除作为值出现在图表线中的水平线,但在图表的属性中找不到正确的选项:
我希望图表看起来像这样:
【问题讨论】:
标签: jasper-reports jfreechart linechart
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">
...
【讨论】: