Hi,
I have following problem with creating column chart:
static void Main(string[] args)
{
Workbook workbook = new Workbook();
int sheetIndex = workbook.Worksheets.Add();
Worksheet worksheet = workbook.Worksheets[sheetIndex];
Style styl = new Style();
styl.Number = 15;
worksheet.Cells["A3"].PutValue("Series 1");
worksheet.Cells["A5"].PutValue("Series 2");
worksheet.Cells["A7"].PutValue("Series 3");
worksheet.Cells["A9"].PutValue("Series 4");
worksheet.Cells["B3"].PutValue(1.44);
worksheet.Cells["C3"].PutValue(0.2);
worksheet.Cells["D3"].PutValue(3.6);
worksheet.Cells["E3"].PutValue(4.5);
worksheet.Cells["F3"].PutValue(5.17);
worksheet.Cells["B5"].PutValue(1.1);
worksheet.Cells["C5"].PutValue(1.2);
worksheet.Cells["D5"].PutValue(3.5);
worksheet.Cells["E5"].PutValue(4.5);
worksheet.Cells["F5"].PutValue(5.7);
worksheet.Cells["B7"].PutValue(1.4);
worksheet.Cells["C7"].PutValue(1.32);
worksheet.Cells["D7"].PutValue(5.0);
worksheet.Cells["E7"].PutValue(4.9);
worksheet.Cells["F7"].PutValue(3.7);
worksheet.Cells["B9"].PutValue(1.4);
worksheet.Cells["C9"].PutValue(1.2);
worksheet.Cells["D9"].PutValue(3);
worksheet.Cells["E9"].PutValue(4.5);
worksheet.Cells["F9"].PutValue(5.7);
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Line, 10, 10, 20, 20);
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
chart.NSeries.Add("A2:F9", false);
chart.NSeries[0].Name = "=A2";//fake
chart.NSeries[0].LegendEntry.IsDeleted = true;
chart.NSeries[0].Type=ChartType.Column;
chart.NSeries[0].PlotOnSecondAxis = true;
chart.NSeries[1].Name = "=A3";
chart.NSeries[1].Type = ChartType.Column;
chart.NSeries[1].PlotOnSecondAxis = false;
chart.NSeries[2].Name = "=A4";//fake
chart.NSeries[2].LegendEntry.IsDeleted = true;
chart.NSeries[2].Type = ChartType.Column;
chart.NSeries[2].PlotOnSecondAxis = false;
chart.NSeries[3].Name = "=A5";
chart.NSeries[3].Type = ChartType.Column;
chart.NSeries[3].PlotOnSecondAxis = true;
chart.NSeries[4].Name = "=A6";//fake
chart.NSeries[4].LegendEntry.IsDeleted = true;
chart.NSeries[4].Type = ChartType.Column;
chart.NSeries[4].PlotOnSecondAxis = false;
chart.NSeries[5].Name = "=A7";
chart.NSeries[5].Type = ChartType.Column;
chart.NSeries[5].PlotOnSecondAxis = true;
chart.NSeries[6].Name = "=A8";//fake
chart.NSeries[6].LegendEntry.IsDeleted = true;
chart.NSeries[6].Type = ChartType.Column;
chart.NSeries[6].PlotOnSecondAxis = true;
chart.NSeries[7].Name = "=A9";
chart.NSeries[7].Type = ChartType.Column;
chart.NSeries[7].PlotOnSecondAxis = false;
chart.SecondValueAxis.IsVisible = true;
chart.SecondValueAxis.CrossType = CrossType.Automatic;
chart.PlotArea.Area.ForegroundColor = Color.White;
workbook.Save("C:\\book1.xlsx");
}
I have no idea how to correctly remove empty (fake) series labels from the legend. The problem also appears when I add another series type (line, area) to chart.
Best regards
Piotr