0
votes

I am developing the stacked area chart and it is giving problem while plotting. I need to start and ends plotting with exact x axis values but currently my chart plotting with middle of the x axis value.

Current output:

enter image description here

Needs to ends and start with Type 3 position for red value.

enter code here:

chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickU‌​nits()); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelsVisible(true);

1
Do you have something close to this, so that readers can see your code and suggest modifications?halfer
^ Please delete that from comments, and edit it into your question, using the formatting tool provided. If you can explain what that does, and how it is different to your requirements, that would be excellent.halfer
hard to say whats wrong without a sscce but it could be because you have a value for the green series at Type 3 or you are using a Category rather then an XY SeriesGrahamA

1 Answers

0
votes

I had the same issue. I solved it with making the data for the other StackedAreas a near zero number vs zero itself. Here is the JFree forum post I made with code and solution.

It seems as though this will be an issue anytime data is listed with a 0 value for the lower bound of a StackedAreaRenderer. In my code I now do a check to see if the data is zero and replace the data point with a near zero value instead, which gets me the plot I'm looking for.