ARTICLE AD BOX
I have to create a 3D barchart with Jasper on a percentage data. There are 2 series of data: A and 100-A. The idea is to have a graph of this type:

My issue is when A is equal to 100 and so 100 - A = 0.
The result is like this :

The top is already in blue !!
I understood that it was a known concern of Jasper.
So I decide to customise my chart and "delete" the 2nd dataset (100 - A) if is equal to 0.
I write this class :
public class InputPowerChartCustomizer implements JRChartCustomizer { private static final Color USED_RED = new Color(0xFF5555); private static final Color UNUSED_BLUE = new Color(0x5555FF); @Override public void customize(JFreeChart chart, JRChart jasperChart) { CategoryPlot plot = chart.getCategoryPlot(); CategoryDataset dataset = plot.getDataset(); LegendItemCollection legendItems = plot.getLegendItems(); plot.setFixedLegendItems(legendItems); if (!(plot.getRenderer() instanceof StackedBarRenderer3D)) { return; } StackedBarRenderer3D renderer = (StackedBarRenderer3D) plot.getRenderer(); // Série 0 = Used // Série 1 = Unused renderer.setSeriesPaint(0, USED_RED); renderer.setSeriesPaint(1, UNUSED_BLUE); renderer.setItemMargin(0.0); renderer.setDrawBarOutline(false); int columnCount = dataset.getColumnCount(); for (int col = 0; col < columnCount; col++) { Number used = dataset.getValue(0, col); // Si Used == 100%, on ne dessine pas Unused if (used != null && used.doubleValue() >= 99.999) { renderer.setSeriesVisible(1, Boolean.FALSE); } } } }But I still have the problem.
Any idea to fix this ?
1552 silver badges10 bronze badges
Explore related questions
See similar questions with these tags.
