facebooktwittermenuarrow-up

GemBox Support Forum

Multiple category fields

Hi,

I am trying to create a spreadsheet/graph like this using code. I mainly want to generate this to go into a presentation but having issues, have 2 category columns as shown in the image.

Questions i have:

Thanks,
Nathan

Hi Nathan,

Please try again with this bugfix:
https://www.gemboxsoftware.com/spreadsheet/nightlybuilds/GBS47v1278.zip

Or this NuGet package:
Install-Package GemBox.Spreadsheet -Version 47.0.1278-hotfix

We have added support for the CategoryAxis.MultiLevelLabels property.
For example, try the following:

var chart = worksheet.Charts.Add<ColumnChart>(ChartGrouping.Stacked, "F2", "T28");

chart.CategoryLabelsReference = "Sheet1!A2:B9";
chart.Axes.HorizontalCategory.MultiLevelLabels = true;

chart.Series.Add("=Sheet1!C1", "Sheet1!C2:C9");
chart.Series.Add("=Sheet1!D1", "Sheet1!D2:D9");

chart.Title.Text = "Chart Title";
chart.Legend.IsVisible = true;
chart.Legend.Position = ChartLegendPosition.Bottom;

Does this solve your issue?

Regards,
Mario

Thanks for that Mario.

I am actually using an embedded graph in a presentation and it isnt reflected correctly until in powerpoint i choose “Edit data”. Once i do that it works fine and i see the multi level labels. I am guessing i need to call some sort of calculate or something after this? I have the column graph in a “template” pptx, which i load, I then find the graph. I then update the data. then i do this code

var chart = get chart..

chart.CategoryLabelsReference = "Sheet1!A2:B9";
chart.Axes.HorizontalCategory.MultiLevelLabels = true;

chart.Series.Add("=Sheet1!C1", "Sheet1!C2:C9");
chart.Series.Add("=Sheet1!D1", "Sheet1!D2:D9");

chart.Title.Text = "Chart Title";
chart.Legend.IsVisible = true;
chart.Legend.Position = ChartLegendPosition.Bottom;

Any suggestions would be greatly appreciated.
If this doesn’t make sense i can put together an example.
Cheers,
Nathan

Hi,

Did you create the column graph in the “template” PPTX manually (using Microsoft Office) or with GemBox components?
If you did it manually, can you send us that file?
If you did it via code, can you send us that code?

We’ll try to reproduce your issue and investigate this problem.

Regards,
Mario

Hi Mario,

It is from a MS Office create PPTX. I populate the underlying data from a data table from a Stored proc.

How do i go about attaching a file?
Thanks,
Nathan

Hi Nathan,

You can create a support ticket and attach the file to it.

Regards,
Mario