I have a combined chart and 5 data series, 2 of them are empty, and the last one is shown as Area and plot on 2nd y axis, others are shown as Column plot on primary axis, and I want to hide the legends of empty data but it doesn't seem working correctly. Please see the
Please see the screenshot being attached.
var workbook = new Workbook();
int sheetIndex = workbook.Worksheets.Add();
Worksheet worksheet = workbook.Worksheets[sheetIndex];
Style style = new Style();
style.Number = 11;
worksheet.Cells["B2"].PutValue(1.4);
worksheet.Cells["C2"].PutValue(1.32);
worksheet.Cells["D2"].PutValue(5.0);
worksheet.Cells["E2"].PutValue(4.9);
worksheet.Cells["F2"].PutValue(3.7);
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);
// B4:F4 is empty area
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);
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 8, 1, 25, 15);
var chart = worksheet.Charts[chartIndex];
chart.NSeries.Add("B2:F2", false);
chart.NSeries.Add("B3:F3", false);
var idx = chart.NSeries.Add("B4:F4", false);
chart.NSeries[idx].LegendEntry.IsDeleted = true;
idx = chart.NSeries.Add("B4:F4", false);
chart.NSeries[idx].LegendEntry.IsDeleted = true;
idx = chart.NSeries.Add("B5:F5", false);
chart.NSeries[idx].Type = ChartType.Area;
chart.NSeries[idx].PlotOnSecondAxis = true;
chart.SecondValueAxis.IsVisible = true;
chart.SecondValueAxis.CrossType = CrossType.Automatic;
chart.PlotArea.Area.ForegroundColor = Color.White;
workbook.Save("book1.xlsx");