View a stacked bar chart containing no values

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
behnil
Posts: 2
Joined: Thu Apr 21, 2011 12:25 pm
antibot: No, of course not.

View a stacked bar chart containing no values

Post by behnil » Wed May 04, 2011 3:41 pm

Hi guys,

I have a 3D stacked bar chart and i have a problem with rendering it with DefaultCategoryDataset containing one category with 3 series and zero values.

The first image below represents the expected behavior. Ignore the vertical dashed line, it's just an annotation.
Image
The settings I've used for this chart is:

Code: Select all

NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperMargin(0d);
rangeAxis.setNumberFormatOverride(new DecimalFormat("0%"));

StackedBarRenderer3D stackedBarRenderer3d = (StackedBarRenderer3D) plot.getRenderer();
stackedBarRenderer3d.setRenderAsPercentages(true);
stackedBarRenderer3d.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
stackedBarRenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%")));
stackedBarRenderer3d.setBaseItemLabelsVisible(true);	
Everything is fine. Ok, now I need the same chart but this time without adding bars to 100%. The settings is the same except:

Code: Select all

numberAxis.setNumberFormatOverride(null);
numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
stackedBarRenderer3d.setRenderAsPercentages(false);
and the result with the same dataset is below:
Image

I'm I missing something? Why is the zero value in the middle? And why is there a bar at all? It should look like the first image.
Thanks.

Locked