Gaps in StackedAreaChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Bowser
Posts: 10
Joined: Thu Jun 26, 2008 5:27 pm

Gaps in StackedAreaChart

Post by Bowser » Fri Jun 27, 2008 10:19 am

Hello folks,

I am a new User of JFreeChart an i've got a Problem with the StackedAreaChart.
My Dataset works fine and this is how i create the Chart:

Code: Select all

 JFreeChart chart = ChartFactory.createStackedAreaChart(
            "MYStackedAreaChart",      
            "Category",                
            "Value",                   
            dataset,                  
            PlotOrientation.VERTICAL,  
            true,                     
            true,
            false
        );
When I create that Chart it has gaps between every Data at the Category. So in fact it looks like a Stacked Bar Chart.
I Don't know why the Chart is creating the gaps...
I don't have special settings for the plot or something else. Just the create Statements that i've posted.

I hope you can help me, that i'm able to fix the Problem.
Thank you!!!!

Bowser
Posts: 10
Joined: Thu Jun 26, 2008 5:27 pm

Post by Bowser » Fri Jun 27, 2008 10:21 am

Maybe my Dataset is interesting for you. So it looks like this:

Code: Select all

		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		dataset.setValue(1.0, series1, category1);
		dataset.setValue(3.0, series2, category1);
		dataset.setValue(5.0, series1, category2);
		dataset.setValue(2.0, series2, category2);
Here is the Problem as a Picture:

[img=http://img382.imageshack.us/img382/3427 ... emojy7.png[/img]

Bowser
Posts: 10
Joined: Thu Jun 26, 2008 5:27 pm

Post by Bowser » Mon Jun 30, 2008 6:48 am

Hi Guys,

unfortunately it seems, that I am the only one who has this problem!
Could i get some Feedback please....
I'm not sure where the Problem is. I'm trying to resolve it but it looks not good...

please Help me!

Thank You

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Post by paradoxoff » Mon Jun 30, 2008 7:27 am

Have you tried

Code: Select all

JFreeChart.getCategoryPlot().getDomainAxis().setCategoryMargin(0.0)

Bowser
Posts: 10
Joined: Thu Jun 26, 2008 5:27 pm

Post by Bowser » Mon Jun 30, 2008 8:23 am

Hello paradoxoff,

that works!
Thank You!
I don't know that such method exists. Thank you.
By the way is there any Method where i can set the colours for the series?
Something like series1.setColour(0,0,0)

Thank you!!!!

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Post by paradoxoff » Mon Jun 30, 2008 11:21 am

A CategoryPlot manages a list of datasets and a list of renderers. These can be assigned to the plot via

Code: Select all

plot.setDataset(int index, CatgoryDataset set)
and

Code: Select all

plot.setRenderer(int index, CategoryItemRenderer renderer)
The i-th dataset is visualized by the i-th renderer.
Within a dataset, you can have several series. The format for the series can be determined by one of the many methods declared in CategoryItemRenderer and defined in AbstractRenderer or any concrete implementation of CategoryItemRenderer. When you look at the API docs for AbstractRenderer, you will find lots of methods with a signature like

Code: Select all

setSeriesShape(int series, java.awt.Shape shape)
.
where the series index refers to the index of the series within the dataset.
In order to change the color (or more generally the paint) for the ith-series of the jth-dataset to red, you will have to write

Code: Select all

plot.getRenderer(j).setSeriesPaint(i,Color.RED);

Locked