Hi Steve,
I think you may modify your code a bit, see the following your updated code:
.............
/*
***************************************************************
** Setup the chart
*/
Charts charts = linechart.getCharts();
//Adding a chart to the worksheet
Chart chart = charts.addChart(ChartType.LINE,0,0,42,20);
//Set the title
Title title = chart.getTitle();
title.setText("Work Server %busy");
Font titleFont = title.getFont();
titleFont.setBold(true);
title.setFont(titleFont);
// Reset total number of rows to chart for now
if (iTotRows > iMaxRows)
iTotRows = iMaxRows;
NSeries nSeries = chart.getNSeries();
//Adding NSeries (chart data source) to the chart ranging from "B5" cell to "C7"
String cellName = null;
String lastCellName = null;
StringBuilder dataString = null;;
ASeries aSeries = null;
// Loop through all columns B-G (1-6)
for (int i=1; i<7; i++) {
cell = cells.getCell (4, i);
cellName = cell.getName();
cell = cells.getCell (iTotRows + 4, i);
lastCellName = cell.getName();
/* Build string of the data range */
dataString = new StringBuilder("'");
dataString.append("CPU Data" + "'!" + cellName + ":" + lastCellName);
int iSeriesIndex = nSeries.add(dataString.toString(), true);
aSeries = nSeries.get(iSeriesIndex);
aSeries.getArea().setForegroundColor(lineColors[i-1]);
aSeries.getBorder().setColor(lineColors[i-1]);
cell = cells.getCell (4, i);
cellName = cell.getName();
aSeries.setName("='" + "CPU Data" + "'!" + cellName);
}
//Setting the data source for the category data of NSeries
cell = cells.getCell (4, 0);
cellName = cell.getName();
cell = cells.getCell (iTotRows + 4, 0);
lastCellName = cell.getName();
/* Build string of the data range */
dataString = new StringBuilder("'");
dataString.append("CPU Data" + "'!" + cellName + ":" + lastCellName);
nSeries.setCategoryData(dataString.toString());
// Try again
CategoryAxis catAxis = chart.getCategoryAxis();
catAxis.setCategoryType(CategoryType.CATEGORY_SCALE);
catAxis.setTickLabelSpacing(12);
ValueAxis valAxis = chart.getValueAxis();
valAxis.setMaxValue(1.0);
//Set the Value Axis title
Title vTitle = valAxis.getTitle();
vTitle.setText("%busy");
vTitle.setRotation(90);
chart.getValueAxis().setMinValue(0.0);
// Remove any leading sheets before the ones we created.
for(int i = worksheets.size() - (iNewSheets + 1); i >= 0; --i) {
worksheets.removeSheet(i);
}
workbook.save(outputPath, fileFormatType);
}
Thank you.