String legendLabel1 = "Legend Label 1";
String legendLabel2 = "Legend Label 2";
String legendLabel3 = "Legend Label 3";
//IAxisDataSeries dataSeries = new DataSeries( xAxisLabels, null, null, title );
IAxisDataSeries dataSeries = new DataSeries( xAxisLabels, "X Axis title", "Left Y Axis title", title );
String[] legendLabelsClust = {legendLabel1, legendLabel2};
Paint[] clustPaints = new Paint[]{Color.pink, Color.blue};
String[] legendLabelsLine = {legendLabel3};
Paint[] linePaints = new Paint[]{Color.green};
//------------On r�cup�re une 2�me �chelle "secondScale"------------------
//------------et on fait un traitement pour les nombres n�gatifs----------
//------------We get back the 2nd scale "secondScale"---------------------
//-------------and we handle the negative numbers---------------------
//On identifie la valeur maximum absolue des data Clustered Bar
//et on compte le nombre de z�ro et le nombre de chiffres n�gatifs
// We identify the absolute maximum value of the data in the Clustered Bar
// and we count the number of zero and negative digits
for (int k=0; k<2; k++) {
for (int j=0; j<xAxisLabels.length; j++) {
if (maxDataClustAbs < (Math.abs(dataClust[k][j])) && (dataClust[k][j]!=0) ) {
maxDataClustAbs=(Math.abs(dataClust[k][j]));
}
if (dataClust[k][j]<0) {
numberOfNegativ+=1;
}
if (dataClust[k][j]==0) {
numberOfZero+=1;
}
}
}
//On identifie la valeur maximum absolue des data Line
//et on compte le nombre de z�ro et le nombre de chiffres n�gatifs
// We identify the absolute maximum value of the data lines
// and we count the number of zero and negative digits
for (int j=0; j<xAxisLabels.length; j++) {
if (maxDataLineAbs < (Math.abs(dataLine[0][j])) && (dataLine[0][j]!=0) ) {
maxDataLineAbs=(Math.abs(dataLine[0][j]));
}
if (dataLine[0][j]<0) {
numberOfNegativ+=1;
}
if (dataLine[0][j]==0) {
numberOfZero+=1;
}
}
//On d�finit la valeur de la seconde �chelle si les ordres de grandeurs
//sont tr�s diff�rent (de l'ordre de 10).
//We define the value of the second scale if the increment is an order of
//magnitude greater
if (maxDataClustAbs>10*maxDataLineAbs) {
axisProperties.getYAxisProperties().setShowRightAxis(true);
secondScale=Math.round(maxDataClustAbs/(maxDataLineAbs));
axisProperties.getYAxisProperties().setSecondScaleRight((float) (secondScale) );
ChartFont axisScaleFontRight = new ChartFont( new Font("Arial Narrow", Font.PLAIN, 10), Color.green.darker() );
axisProperties.getYAxisProperties().setScaleChartFontRight( axisScaleFontRight );
}
//On v�rifie s'il y a des valeurs n�gatives
// Check if there are negative numbers
if (numberOfNegativ>0) {
if ((maxDataLineAbs*secondScale)>maxDataClustAbs) {
axisProperties.getYAxisProperties().setMinRightAxis((double) (-maxDataLineAbs*secondScale));
//Si les valeurs ne sont pas toutes n�gatives on affiche l'axe des ordonn�es
//de mani�re a ce que le z�ro soit centr�
// If the numbers are not all negative we center the ordinal axis around zero
if (numberOfNegativ!=(3*xAxisLabels.length-numberOfZero)) {
axisProperties.getYAxisProperties().setMaxRightAxis((double) (maxDataLineAbs*secondScale));
}
} else {
axisProperties.getYAxisProperties().setMinRightAxis((double) (-maxDataClustAbs));
if (numberOfNegativ!=(3*xAxisLabels.length-numberOfZero)) {
axisProperties.getYAxisProperties().setMaxRightAxis((double) (maxDataClustAbs));
}
}
}
dataSeries.addIAxisPlotDataSet( new AxisChartDataSet( dataClust, legendLabelsClust, clustPaints, ChartType.BAR_CLUSTERED, clusteredBarChartProperties ) );
dataSeries.addIAxisPlotDataSet( new AxisChartDataSet( dataLine, legendLabelsLine, linePaints, ChartType.LINE, lineChartProperties ) );
AxisChart axisChart = new AxisChart( dataSeries, chartProperties, axisProperties, legendProperties, width, height );
ServletEncoderHelper.encodeJPEG13( axisChart, 1.0f, httpServletResponse );
}
catch( Throwable throwable ) {