//get data
XYDataset[] datasets = createDatasets(chartType, costValues);
int numGraphs = datasets.length;
CombinedDataset data = new CombinedDataset();
//first add the dataset for the reference line
XYDataset refLineDataset = liftChartBuilder.buildRefDataset(chartType);
data.add(new SubSeriesDataset(refLineDataset, 0));
//now add in the datasets for the lines.
for(int i=0;i<numGraphs;i++){
XYDataset dataset = datasets;
data.add(new SubSeriesDataset(dataset, 0));
}
JFreeChart chart = null;
try {
// common horizontal and vertical axes
HorizontalNumberAxis xAxis = null;
VerticalNumberAxis yAxis = null;
yAxis = new VerticalNumberAxis( yAxisLabel,
Axis.DEFAULT_AXIS_LABEL_FONT,
0.01,
100);
xAxis = new HorizontalNumberAxis(xAxisLabel,
Axis.DEFAULT_AXIS_LABEL_FONT,
0.01,
100);
CombinedPlot overlaidPlot = new CombinedPlot(xAxis, yAxis);
//add the reference line, and the sub-plots
for(int i=0;i<numGraphs+1;i++){
CombinedChart cc =
ChartFactory.createCombinableXYChart(xAxis, yAxis, new SubSeriesDataset(data, i));
overlaidPlot.add(cc);
}