DocIO Category Axes for each serie.

IOfficeChartSerie serieA = chart.Series.Add("Number of Bridges");
            serieA.Values = chart.ChartData[2, 2, 10, 2];
            serieA.SerieType = OfficeChartType.Line_Markers;
            IOfficeChartSerie serieB = chart.Series.Add("Poor Bridges");
            serieB.Values = chart.ChartData[2, 3, 10, 3];
            serieB.SerieType = OfficeChartType.Line_Markers;
            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 10, 1];
            chart.PrimaryCategoryAxis.Font.Size = 8;
            chart.PrimarySeriesAxis.Title = "Number of Bridges";

How do I add second Category Axes for the serieB (Poor Bridges) on the right site of the chart?

1 Reply

MJ Mohanaselvam Jothi Syncfusion Team June 8, 2018 02:08 PM UTC

Hi Natalia,

Thank you for contacting Syncfusion support.

In line chart, secondary axes are preserved at top and bottom position. To achieve your requirement, we suggest you to set chart type as Bar chart. Thus, it preserves secondary category axes at left and right side of the chart. To use secondary axes, we suggest to set
UsePrimaryAxis property as false and enables SecondaryCategoryAxis.Visible property to view the secondary category axes.

Please refer the below code example to achieve your requirement:
 
//Set chart type. 
chart.ChartType = OfficeChartType.Bar_Clustered; 
 
//Set values and labels for serieA. 
IOfficeChartSerie serieA = chart.Series[0]; 
serieA.Values = chart.ChartData[2, 2, 10, 2];
serieA.CategoryLabels = chart.ChartData[2, 1, 6, 1];
 
 
//Set values and labels for serieB. 
IOfficeChartSerie serieB = chart.Series[1]; 
serieB.Values = chart.ChartData[2, 3, 10, 3];
serieB.CategoryLabels = chart.ChartData[2, 1, 6, 1];
 
 
//Set UsePrimaryAxis as false, to use seconday axis. 
serieB.UsePrimaryAxis = false; 
//Enable to visible SecondaryCategoryAxis. 
chart.SecondaryCategoryAxis.Visible = true; 
chart.SecondaryValueAxis.IsMaxCross = true; 



Please let us know if you have any other questions.

Regards,
Mohanaselvam J

 


Loader.
Up arrow icon