My application allows for the possibility of the user requesting a single chart or multiple charts to be created in the same spreadsheet, so I'm not hardcoding the data ranges for the series. I'll try to explain what I'm doing so that it makes sense.
int chartIndex = chartSheet.Charts.Add(ChartType.LineWithDataMarkers, chartStartRow, 0, chartStartRow + 28, 9); //chartStartRow is the starting row for the current chart being created
Aspose.Cells.Chart newChart = chartSheet.Charts[chartIndex];
newChart.SecondValueAxis.IsVisible = true;
newChart.ValueAxis.MajorGridLines.IsVisible = true;
newChart.CategoryAxis.CategoryType = CategoryType.TimeScale;
//Next, I call a function to configure the series that will be in the chart and pass the nseries collection as a parameter
ConfigureSeries(newChart.NSeries, dataRange); //dataRange is the cell range that contains the data for the current chart
//the following code is from my ConfigureSeries function
ConfigureSeries(Aspose.Cells.NSeries chartSeries, Aspose.Cells.Range dataRange)
{
chartSeries.CategoryData = "Data!A" + (dataRange.FirstRow + 1) + ":" + "A" + (dataRange.FirstRow + dataRange.RowCount); //If I'm generating a single chart, this ends up being "A5:A9"
for(int i = 0; i < 7; i++)
{
chartSeries.Add("Data!" + dataRange[0, i].Name + ":" + dataRange[dataRange.RowCount - 1, i].Name, true);
{
}
So if I'm just creating a single chart, the range for the first series ends up being "B5:B9", the second is "C5:C9" all the way through the 7th series which is "H5:H9". This all works correctly. If I look at the data source settings for the chart, all of the data ranges are set correctly.
I also set line marker styles, line colors, marker foreground and background colors, and I mark series 1, 2, 3, and 4 to be plotted on the secondary axis.
chartSeries[1].PlotOnSecondAxis = true; //etc. for series 1, 2, 3, 4
After all of this is done, the data sources for each series is set just as I expected it to be, but for some reason the last 3 series are being set as columns instead of lines with markers.