user984859
user984859

Reputation: 55

JFreeChart Stacked Area Chart not continous

I used the createStackedAreaChart(), but the stacked area chart I got is not continous. There are gaps between categories (just look like stacked bar chart). But If I use createAreaChart() for the same dataset (DefaultCategoryDataset), the area chart is fine. What's wrong with the stacked area chart? I would really appreciate any help.

Upvotes: 0

Views: 1768

Answers (3)

mc03lbj
mc03lbj

Reputation: 1

In StackedAreaRenderer.java, the coordinate of Path has decimals, path is discontinuous in ANTIALIAS. Modify StackedAreaRenderer#drawItem with Math.round like AreaRenderer.java.

Upvotes: 0

user984859
user984859

Reputation: 55

I got it. Somehow, I have to set the category margin to avoid the gaps in the chart. domainAxis.setCategoryMargin(0);

Upvotes: 2

trashgod
trashgod

Reputation: 205785

Using the CategoryDataset returned by createDataset() in BarChartDemo1, the static factory method ChartFactory.createStackedAreaChart() produces the following chart with no gaps. You should examine your data set critically.

StackedAreaChart

Upvotes: 1

Related Questions