axisHyperlinkProvider);
}
}
else if (mainPlot instanceof XYPlot)
{
XYPlot xyPlot = (XYPlot) mainPlot;
xyPlot.setRangeAxisLocation(0, getChartAxisLocation(axis));
if (axisHyperlinkProvider != null)
{
multiHyperlinkProvider.addHyperlinkProvider(xyPlot.getDataset(), axisHyperlinkProvider);
}
}
}
// Now handle all the extra axes, if any.
int axisNumber = 0;
while (iter.hasNext())
{
axisNumber++;
JRFillChartAxis chartAxis = (JRFillChartAxis)iter.next();
JRFillChart fillChart = chartAxis.getFillChart();
JFreeChart axisChart = fillChart.evaluateChart(evaluation);
ChartHyperlinkProvider axisHyperlinkProvider = fillChart.getHyperlinkProvider();
// In JFreeChart to add a second chart type to an existing chart
// you need to add an axis, a data series and a renderer. To
// leverage existing code we simply create a new chart for the
// axis and then pull out the bits we need and add them to the multi
// chart. Currently JFree only supports category plots and xy plots
// in a multi-axis chart, and you can not mix the two.
if (mainPlot instanceof CategoryPlot)
{
CategoryPlot mainCatPlot = (CategoryPlot)mainPlot;
if (!(axisChart.getPlot() instanceof CategoryPlot))
{
throw new JRException("You can not mix plot types in a MultiAxisChart");
}
// Get the axis and add it to the multi axis chart plot
CategoryPlot axisPlot = (CategoryPlot)axisChart.getPlot();
mainCatPlot.setRangeAxis(axisNumber, axisPlot.getRangeAxis());
mainCatPlot.setRangeAxisLocation(axisNumber, getChartAxisLocation(chartAxis));
// Add the data set and map it to the recently added axis
mainCatPlot.setDataset(axisNumber, axisPlot.getDataset());
mainCatPlot.mapDatasetToRangeAxis(axisNumber, axisNumber);
// Set the renderer to use to draw the dataset.
mainCatPlot.setRenderer(axisNumber, axisPlot.getRenderer());
// Handle any color series for this chart
configureAxisSeriesColors(axisPlot.getRenderer(), fillChart.getPlot());
if (axisHyperlinkProvider != null)
{
multiHyperlinkProvider.addHyperlinkProvider(axisPlot.getDataset(),
axisHyperlinkProvider);
}
}
else if (mainPlot instanceof XYPlot)
{
XYPlot mainXyPlot = (XYPlot)mainPlot;
if (!(axisChart.getPlot() instanceof XYPlot))
{
throw new JRException("You can not mix plot types in a MultiAxisChart");
}
// Get the axis and add it to the multi axis chart plot
XYPlot axisPlot = (XYPlot)axisChart.getPlot();
mainXyPlot.setRangeAxis(axisNumber, axisPlot.getRangeAxis());
mainXyPlot.setRangeAxisLocation(axisNumber, getChartAxisLocation(chartAxis));
// Add the data set and map it to the recently added axis
mainXyPlot.setDataset(axisNumber, axisPlot.getDataset());
mainXyPlot.mapDatasetToRangeAxis(axisNumber, axisNumber);
// Set the renderer to use to draw the dataset.
mainXyPlot.setRenderer(axisNumber, axisPlot.getRenderer());
// Handle any color series for this chart
configureAxisSeriesColors(axisPlot.getRenderer(), fillChart.getPlot());
if (axisHyperlinkProvider != null)
{
multiHyperlinkProvider.addHyperlinkProvider(axisPlot.getDataset(),
axisHyperlinkProvider);
}
}
else
{