We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Stacked Chart how to add Horizontal axis with multiple label (grouping)


I have Horizontal axis with multiple levels like as below

Label 1, Label 2, Label 3, Label 4, Label 5
Label 1, Label 2 - Category 1, Label 3 - Category 2, Label 4, Label 5 - Category 3.
Category 1,Category 2 - Group 1, Category 3 - Group 2.

How can i show this?


Could you create a simple chart in MS Excel manually to accomplish your task, save the Excel file and post us here, we will check how to do it via Aspose.Cells APIs.

Thank you.

I am uploading here test chart in excel please find attachment.


Thanks for the template file containing the chart.

Please see the sample code below for your reference. I have used the existing data source in your template file for the chart, I have added a new sheet to the workbook and inserted the stacked column chart to whose horizontal axis has multiple level labels as per your requirements. Please refer to the sample code and write/ update your own codes accordingly for your needs.
Sample code:

Workbook workbook1 = new Workbook(“e:\test2\TestChart.xlsx”);
Worksheet sheet = workbook1.Worksheets[workbook1.Worksheets.Add()];
Cells cells = sheet.Cells;
int chartIndex = sheet.Charts.Add(ChartType.ColumnStacked, 1, 1, 25, 15);
Chart chart = sheet.Charts[chartIndex];
chart.NSeries.Add(“Sheet1!$B$30:$H$42”, true);
chart.NSeries.CategoryData = “Sheet1!$B$31:$D$42”;

for (int i = 0; i < chart.NSeries.Count; i++)
chart.NSeries[i].GapWidth = 150;
chart.NSeries[i].Overlap = 100;


chart.CategoryAxis.HasMultiLevelLabels = true;

chart.Title.Text = “Test Chart1”;


Hope, this helps a bit.

Thank you.