Creating a second Y axis

hi experts

I create new Y-axes for each new graph, but the axes are created to the left of the previous axis. Is it possible to create these axes to the right of the previous one.

I create axes like this:

ChartSeries series = new ChartSeries();
ChartAxis newYaxis = new ChartAxis();
newYaxis.GridLineType.ForeColor = Color.LightGray;
newYaxis.Orientation = ChartOrientation.Vertical;
chartControl1.Axes.Add(newYaxis);

I drew what it should look like ;)


Attachment: image_87ce3716.zip

1 Reply 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team February 14, 2022 10:44 AM UTC

Hi Dmitriy Shilin, 
 
You can achieve your requirement “Adding axes to the right of the previous axis” by using ChartArea.YLayouts property of ChartControl in WinForms chart. Please find the following code example below. 
 
CodeSnippet: 
 
ChartAxis newYaxis = new ChartAxis(); 
newYaxis.ForeColor = System.Drawing.Color.Red; 
newYaxis.Orientation = ChartOrientation.Vertical; 
chartControl1.Axes.Insert(chartControl1.Axes.Count, newYaxis); 
 
ChartAxis newYaxis1 = new ChartAxis(); 
newYaxis1.ForeColor = System.Drawing.Color.Blue; 
newYaxis1.Orientation = ChartOrientation.Vertical; 
chartControl1.Axes.Insert(chartControl1.Axes.Count, newYaxis1); 
 
ChartAxisLayout layout = new ChartAxisLayout();             
layout.Axes.Add(newYaxis1); 
layout.Axes.Add(newYaxis); 
layout.Axes.Add(this.chartControl1.PrimaryYAxis); 
chartControl1.ChartArea.YLayouts.Add(layout); 
 
 
Also, I have attached the sample for your reference. Please find the sample from the below link. 
 
  
Output: 
  
 
Please let us know if you have any concern. 
 
Regards, 
Yuvaraj. 


Marked as answer
Loader.
Up arrow icon