Here is a sample code for the StackedArea and Area charts.
I've found a different behaviour for these two charts.
Code: Select all
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.CategoryDataset;
import org.jfree.data.DatasetUtilities;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class AreaBehaviour extends ApplicationFrame {
public AreaBehaviour(String title) {
super(title);
double[][] data = new double[][] {
{4.0, 3.0, 2.0, 3.0, 6.0, 3.0, 4.0, 3.0 }};
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data);
JFreeChart chart = ChartFactory.createStackedAreaChart(
"Stacked Area Chart",
"Category",
"Value",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
// add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
public static void main(String[] args) {
StackedAreaChartDemo demo = new StackedAreaChartDemo("Stacked Area Chart Demo");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
The begining and ending lines of this chart are vertical.
Now just replace
Code: Select all
JFreeChart chart = ChartFactory.createStackedAreaChart(
Code: Select all
JFreeChart chart = ChartFactory.createAreaChart(
The begining and ending lines of the chart aren't vertical now.
It seems that the Area chart begins from a point having a zero range value.
Is this a normal behaviour or a real problem ?
Thanks in advance,
Fabrice