I have a chart that I can generate with the code (see "Chart by Code").
I want it to look like this (see Chart Example):
The code is setting the Primary Category Axis Category Labels as such:
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 25, 2];
How do I set the Primary Category Axis to have these Grades grouped by the fiscal year?
|
chart.PrimaryCategoryAxis.NoMultiLevelLabel = false; |
Okay, I tried this and it still does not want to work quite right. If I open the generated PPTX file and then edit the chart axis, the "Multi-level Category Labels" option isn't there initially. If I go in to edit the data and then try to edit the axis, then the option is there. Then, if I manually check it, it does what I want it to do. It just doesn't seem to want to work through the code.
I am using version 19.2.0.55 of the Presentation (Syncfusion.Presentation.Net.Core)
Code Snippet:
IOfficeChartSerie seriesFiscalYear = chart.Series.Add("Fiscal Year");
seriesFiscalYear.Values = chart.ChartData[2, 3, rowIndex, 3];
seriesFiscalYear.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
seriesFiscalYear.DataPoints.DefaultDataPoint.DataLabels.Size = 10;
seriesFiscalYear.DataPoints.DefaultDataPoint.DataLabels.NumberFormat = "0%";
seriesFiscalYear.DataPoints.DefaultDataPoint.DataLabels.Bold = true;
//Set the Data Point Colors
rowIndex = 0;
foreach (DataRow row in MyDataTable.Rows)
{
if ((int)row.ItemArray[1] == 0)
{
dataPointColor = YearZeroColor;
}
else
{
dataPointColor = DataPointColor;
}
seriesFiscalYear.DataPoints[rowIndex].DataFormat.Fill.ForeColor = dataPointColor;
rowIndex++;
}
chart.ChartType = OfficeChartType.Column_Clustered;
chart.ChartTitle = "";
chart.HasLegend = false;
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, totalRowCount + 1, 2];
chart.PrimaryCategoryAxis.NoMultiLevelLabel = false;
chart.PrimaryCategoryAxis.Border.LineColor = Syncfusion.Drawing.Color.FromArgb(217, 217, 217);
chart.PrimaryValueAxis.NumberFormat = "0%";
chart.PrimaryValueAxis.MajorGridLines.LineProperties.LineColor = Syncfusion.Drawing.Color.FromArgb(217, 217, 217);
chart.PrimaryValueAxis.Border.LineColor = Syncfusion.Drawing.Color.FromArgb(255, 255, 255);