Hello,
I created a StackedBar item and want to eliminate the space between the bars. I wrote the following customerize, but the bars are sill spaced, any idea ?
thanks in advnace.
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.*;
public class CustomizeBarChart extends JRAbstractChartCustomizer {
@Override
public void customize(JFreeChart chart, JRChart jasperChart) {
CategoryPlot categoryPlot = chart.getCategoryPlot();
StackedBarRenderer renderer = (StackedBarRenderer) categoryPlot.getRenderer();
chart.setTitle("Hello");
renderer.setItemMargin(0.0); }}
update:
Here is the scala version of the same code:
import net.sf.jasperreports.engine.JRAbstractChartCustomizer;
1 Answer:
Chech this post by Matt http://mdahlman.wordpress.com/2011/04/17/chart-customizers-2/ He has a chart customizer there that does exatly what you are looking for (scroll down to "Space between bars").
But answering your question the propertly you want to change is "setCategoryMargin" not setItemMargin this post on StackOverflow helped me understand where are all the margind in JFree Charts.
@marianol, worked like a charm. Many thanks.