We are using Aspose.Cells for creating combination charts (custom charts). More than 2 charts will be shown which usually comprise of Area, Line, Trend chart. I want to achieve below look graph which was generated using MS Excel charting feature (MSExcelChart.png). It contains 3 charts 2 area chart and one line chart.
Using Aspose.Cells charting features I tried a lot get this kind of charting, but am facing below issues with that.
- Line chart covers hides the other two area charts.
- When I delete the line chart by selecting it, area charts are shown behind it.
- Secondary axis is not working as expected; the second Y axis is not shown on right hand side of the graph.
- Its very difficult to achieve the same look and feel of MSExcelChart.png.
I have attached the Aspose.Cells chart image and also sample excel file containing data with small code snippet.
Workbook test = new Workbook(@"C:\TechWrk\DataFile\DualAccessChart.xlsx"); Worksheet wrktest = test.Worksheets["__lun"];
//Adding a new worksheet to the Workbook object int sheetIndex = test.Worksheets.Add(SheetType.Chart);
//Obtaining the reference of the newly added worksheet by passing its sheet index Worksheet worksheet = test.Worksheets[sheetIndex];
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Area, 1, 1, 25, 10);
//Accessing the instance of the newly added chart Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4" chart.NSeries.Add("__lun!B2:D168", true);
chart.NSeries.CategoryData = "__lun!A1:A168"; chart.NSeries.SecondCatergoryData = "__lun!A1:A168";
////Setting the chart type of 2nd NSeries to display as line chart chart.NSeries[0].Name = "Area One";
chart.NSeries[0].Type = Aspose.Cells.Charts.ChartType.Area;
chart.NSeries[1].Name = "Area Two"; chart.NSeries[1].Type = Aspose.Cells.Charts.ChartType.Line;
//Plot the second series on second axis line. chart.NSeries[1].PlotOnSecondAxis = true; chart.NSeries[1].Line.IsVisible = true; chart.SecondCategoryAxis.IsVisible = true;
chart.NSeries[2].Name = "Area Three"; chart.NSeries[2].Type = Aspose.Cells.Charts.ChartType.Area;
////Saving the Excel file test.Save(@"C:\TechWrk\DataFile\DualAccessChart.xlsx");
|