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

核能气质少年 提交于 2019-12-10 11:58:20

问题


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.



来源:https://stackoverflow.com/questions/30208461/how-to-remove-space-betwwen-bars-on-a-category-in-ireport

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