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

Free Support Forum - aspose.com

How do I create a clustered chart ?!

Hello,

I would like to create a clustered chart (see attached spreadsheet).
I have the below data which I wish to create a chart out of:

Territory

RO Label

This Month (Jun)

Last Month (May)

Previous Month (Apr)

Previous 3 Months (Jan - Mar)

Last 12 Months (Jul-Jun)

UK

Parlophone

50

41

40

42

34

UK

EMI Marketing

21

34

30

25

41

UK

Capitol

14

12

2

10

9

UK

Virgin

50

41

40

42

34

US

EMI Marketing

21

34

30

25

41

US

VRA - Virgin

14

12

2

10

9

US

Blue Note

14

12

2

10

9

US

Capitol

50

41

40

42

34

I think the problem I have is defining the series correctly, so far I have been playing around with the following code:

int chartIndex = worksheet.Charts.Add(ChartType.Column3DClustered, 9, 9, 21, 15);
Chart chart = worksheet.Charts[chartIndex];chart.NSeries.Add(string.Format(@"A1:A9), true);
chart.NSeries.Add(string.Format(@"B1:B9), true);
chart.NSeries.Add(string.Format(@"C1:C9), true);
chart.NSeries.Add(string.Format(@"D1: D9), true);
chart.NSeries.Add(string.Format(@"E1:E9), true);
chart.NSeries.Add(string.Format(@"F1:F9), true);
chart.NSeries.Add(string.Format(@"G2:G9), true);
chart.NSeries.CategoryData = "A1:G1";

Any ideas on how I can generate a chart as in the attachment ?

Please try the following code:


int chartIndex = excel.Worksheets[0].Charts.Add(ChartType.Column3DClustered, 10, 1, 31, 14);
Chart chart = excel.Worksheets[0].Charts[0];
chart.NSeries.Add("C2:G9", true);
chart.NSeries.CategoryData = "A2:B9";
chart.NSeries[0].Name = "=C1";
chart.NSeries[1].Name = "=D1";
chart.NSeries[2].Name = "=E1";
chart.NSeries[3].Name = "=F1";
chart.NSeries[4].Name = "=G1";

Laurence, that is simply superb Idea

Thank you very much for your help ! Cool

@stevepuri,
Aspose.Excel has been discarded and no more actively developed now. It is replaced by Aspose.Cells that is much advanced and contains all the features of different versions of MS Excel. You can create variety of charts using Aspose.Cells including Column3DClustered chart as demonstrated in the following sample code.

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Put data
sheet.Cells[0, 0].PutValue("BarCol 1");
sheet.Cells[0, 1].PutValue(5);
sheet.Cells[0, 2].PutValue(10);
sheet.Cells[0, 3].PutValue(6);
sheet.Cells[0, 4].PutValue(4);
sheet.Cells[0, 5].PutValue(8);
sheet.Cells[1, 0].PutValue("BarCol 2");
sheet.Cells[1, 1].PutValue(7);
sheet.Cells[1, 2].PutValue(4);
sheet.Cells[1, 3].PutValue(8);
sheet.Cells[1, 4].PutValue(3);
sheet.Cells[1, 5].PutValue(2);



//Generate the first chart
int chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.BarStacked, 2, 0, 20, 7);
Chart chart = sheet.Charts[chartIndex];

//Insert series
chart.NSeries.Add("B1: F1", false);
chart.NSeries.Add("B2: F2", false);
chart.NSeries.CategoryData = "A1: A2";

chart.ShowLegend = false;

chart.PlotArea.X = 0;
chart.PlotArea.Y = 0;
chart.PlotArea.Width = 3300;



//Generate the second chart
chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column3DClustered, 21, 0, 39, 10);
chart = sheet.Charts[chartIndex];

//Insert series
chart.NSeries.Add("B1: F1", false);
chart.NSeries.Add("B2: F2", false);
chart.NSeries.CategoryData = "A1: A2";

chart.ShowLegend = false;

chart.PlotArea.X = 0;
chart.PlotArea.Y = 0;
chart.PlotArea.Width = 3300;

workbook.Save(@"Column3DClustered.xlsx");

You may follow the link below to get more information about the charts.
Charts

Download the free trial version of this new product here:
Aspose.Cells for .NET (Latest Version)

A comprehensive runnable solution can be downloaded here to test the features of this new product.