How to remove space betwwen bars on a category in iReport?

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

I have a graph with two bars on each category value. How can we remove sapce beween bar on a category value. Space between bar of of with different category value should not be removed.

回答1:

I worked on this case using java customizer as follow:

public class BarChartCustomizerExIm implements JRChartCustomizer{      @Override     public void customize(JFreeChart chart, JRChart jasperChart) {            BarRenderer barRenderer = (BarRenderer)plot.getRenderer();           barRenderer.setItemMargin(0);    } 

}

Put jar for this class in your class path and in customizer field in your ireport specify the classname.



回答2:

Write your own ChartCustomizer as follow:

public class CustomizeBarChart extends JRAbstractChartCustomizer {      /**      * Customizer for BarChart.      *      * @param chart the chart      * @param jasperChart the jasperChart      *      * @see net.sf.jasperreports.engine.JRChartCustomizer#customize(org.jfree.chart.JFreeChart, net.sf.jasperreports.engine.JRChart)      */     public void customize(JFreeChart chart, JRChart jasperChart) {          CategoryPlot categoryPlot = chart.getCategoryPlot();         BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();          //Spaces between bars         renderer.setItemMargin(0.01);     } } 

And add it as Customizer class in your chart preferences.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!