com.extentech.formats.XLS.Boundsheet sht= parentChart.getSheet();
java.util.Vector s = this.getAllSeries(-1);
// Category values *******************************************************************************
if (s.size() > 0) {
try {
CellRange cr = new CellRange(((Series) s.get(0)).getCategoryValueAi().toString(), parentChart.wbh, true);
CellHandle[] ch = cr.getCells();
if (ch != null) { // found a template with a chart with series but no categories
categories = new Object[ch.length];
for (int j = 0; j < ch.length; j++) {
try {
categories[j] = ch[j].getFormattedStringVal(true);
} catch (IllegalArgumentException e) { // catch format exceptions
categories[j]= ch[j].getStringVal();
}
}
} else if (s.size() > 0) {
cr = new CellRange(((Series) s.get(0)).getSeriesValueAi().toString(), parentChart.wbh, true);
int sz= cr.getCells().length;
categories= new Object[sz];
for (int j= 0; j < sz; j++)
categories[j]= Integer.valueOf(j + 1).toString();
}
} catch (Exception e) {
Logger.logWarn("ChartSeries.getMinMax: " + e.toString());
}
}
// Series colors, labels and values ***************************************************************
double yMax = 0.0, yMin = Double.MAX_VALUE;
int nseries = 0;
seriescolors = null;
legends = null;
int charttype = co.getChartType();
// obtain/store series colors, store series values and trap maximum and
// minimun values so can be used below for axis scale
/*
* A Scatter chart has two value axes, showing one set of numerical data along the x-axis and another along the y-axis.
* It combines these values into single data points and displays them in uneven intervals, or clusters
*/
if (charttype != PIECHART && charttype != DOUGHNUTCHART) {
seriescolors = new String[s.size()];
legends = new String[s.size()];
for (int i = 0; i < s.size(); i++) {
Series myseries = ((Series) s.get(i));
seriescolors[i] = myseries.getSeriesColor();
legends[i] = com.extentech.formats.XLS.OOXMLAdapter.stripNonAscii(myseries.getLegendText()).toString();
CellRange cr = new CellRange(myseries.getSeriesValueAi().toString(), parentChart.wbh, true);
CellHandle[] ch = cr.getCells();
nseries = Math.max(nseries, ch.length);
double[] seriesvals;
String[] sranges;
// String[] series_strings;
if (!myseries.hasBubbleSizes()) {
seriesvals= new double[nseries];
sranges= new String[nseries];
} else {
seriesvals = new double[nseries * 2];
sranges= new String[nseries * 2];
}
// series_strings = new String[seriesvals.length];
for (int j = 0; j < ch.length; j++) {
try {
sranges[j]= ch[j].getCellAddressWithSheet();
seriesvals[j] = ch[j].getDoubleVal();
if (Double.isNaN(seriesvals[j]))
seriesvals[j] = 0.0;
yMax = Math.max(yMax, seriesvals[j]);
yMin = Math.min(yMin, seriesvals[j]);
} catch (NumberFormatException n) {
;
}
}
if (myseries.hasBubbleSizes()) { // append bubble sizes to series values ... see BubbleChart.getSVG for parsing
int z = ch.length;
CellRange crb= new CellRange(myseries.getBubbleValueAi().toString(), parentChart.wbh, true);
CellHandle[] chb = crb.getCells();
for (int j = 0; j < ch.length; j++) {
seriesvals[j + z] = chb[j].getDoubleVal();
sranges[j + z]= chb[j].getCellAddressWithSheet();
}
}
seriesvalues.add(seriesvals); // trap and add series value points
seriesranges.add(sranges); // trap series range
}
} else if (charttype == DOUGHNUTCHART && s.size() > 1) { // like a PIE chart but can have multiple series
legends = new String[categories.length]; // for PIE/DONUT charts, legends are actually category labels, not series labels
for (int i = 0; i < categories.length; i++)
legends[i] = com.extentech.formats.XLS.OOXMLAdapter.stripNonAscii(categories[i].toString()).toString();
for (int i = 0; i < s.size(); i++) {
Series myseries = ((Series) s.get(i));
// legends[i]=
// com.extentech.formats.XLS.OOXMLAdapter.stripNonAscii(myseries.getLegend());
CellRange cr = new CellRange(myseries.getSeriesValueAi().toString(), parentChart.wbh, true);
CellHandle[] ch = cr.getCells();
double[] seriesvals= new double[ch.length];
String[] sranges= new String[ch.length];
if (seriescolors == null)
seriescolors = new String[ch.length];
for (int j = 0; j < ch.length; j++) {
try {
seriesvals[j] = ch[j].getDoubleVal();
if (ch[j].getWorkSheetHandle().getMysheet().equals(sht))
sranges[j]= ch[j].getCellAddress();
yMax = Math.max(yMax, seriesvals[j]);
yMin = Math.min(yMin, seriesvals[j]);
if (i == 0) { // only do for 1st series; will be the
// same for rest
seriescolors[j] = myseries.getPieSliceColor(j);
/*if (seriescolors[j] == 0x4D
|| seriescolors[j] == 0x4E)
seriescolors[j] = com.extentech.formats.XLS.FormatConstants.COLOR_WHITE;*/
}
} catch (NumberFormatException n) {
;
}
}
seriesvalues.add(seriesvals); // trap and add series value points
seriesranges.add(sranges); // trap series range
}
} else { // PIES - only 1 series
if (s.size() > 0) {
// PIE: 1 series data
CellHandle[] cats = new CellRange(((Series)s.get(0)).getCategoryValueAi().toString(), parentChart.wbh, true).getCells();
if (cats != null) {
nseries = cats.length;
legends = new String[cats.length]; // for PIE charts, legends are actually category labels, not series labels
for (int i = 0; i < cats.length; i++)
legends[i] = cats[i].getFormattedStringVal(true);
}
seriescolors = new String[nseries];
Series myseries = ((Series) s.get(0));
try {
CellRange cr = new CellRange(myseries.getSeriesValueAi().toString(), parentChart.wbh, true);
CellHandle[] ch = cr.getCells();
// error trap - shouldn't happen
if (ch.length != nseries) {
Logger.logWarn("ChartHandle.getSeriesInfo: unexpected Pie Chart structure");
nseries = Math.min(nseries, ch.length);
}