Multiple custom Y axis


Author
Message
Daniela Rybarova
Daniela Rybarova
Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)
Group: Forum Members
Posts: 16, Visits: 1
I've changed the Visible property of primaryY axis to false and modified the anchors of the custom axis and it it works. Thank you.
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Filip,

You can use only custom axes - the only restriction is that you cannot delete the standard axes.

The following code snippet shows how to create three line series, each scaling on a custom Y axis:

  private void Form1_Load(object sender, EventArgs e)
  {
   NChart chart = nChartControl1.Charts[0];

   NLineSeries line1 = CreateLineSeries(Color.Red);
   chart.Series.Add(line1);

   NLineSeries line2 = CreateLineSeries(Color.Green);
   chart.Series.Add(line2);

   NLineSeries line3 = CreateLineSeries(Color.Blue);
   chart.Series.Add(line3);

   chart.Axis(StandardAxis.PrimaryY).Visible = false;

   NAxis customAxis1 = CreateCustomAxis(chart, Color.Red);
   line1.DisplayOnAxis((int)StandardAxis.PrimaryY, false);
   line1.DisplayOnAxis(customAxis1.AxisId, true);

   NAxis customAxis2 = CreateCustomAxis(chart, Color.Green);
   line2.DisplayOnAxis((int)StandardAxis.PrimaryY, false);
   line2.DisplayOnAxis(customAxis2.AxisId, true);

   NAxis customAxis3 = CreateCustomAxis(chart, Color.Blue);
   line3.DisplayOnAxis((int)StandardAxis.PrimaryY, false);
   line3.DisplayOnAxis(customAxis3.AxisId, true);
  }

  private NAxis CreateCustomAxis(NChart chart, Color color)
  {
   NAxis customAxis = ((NCartesianAxisCollection)chart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft);

   // modify the anchor so that it creates a new zone levek
   customAxis.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, true);

   NLinearScaleConfigurator scale = customAxis.ScaleConfigurator as NLinearScaleConfigurator;

   scale.RulerStyle.BorderStyle.Color = color;

   return customAxis;
  }

  Random rand = new Random();

  private NLineSeries CreateLineSeries(Color color)
  {
   NLineSeries line = new NLineSeries();

   line.DataLabelStyle.Visible = false;
   line.BorderStyle.Color = color;


   for (int i = 0; i < 10; i++)
   {
    line.Values.Add(rand.Next(100));
   }

   return line;
  }

Probably in your code you have to touch the axis anchor a bit (so that it does not creaete a separate scale level - check out Axes\General\Ruler Size example).

Hope this helps - let us know if you meet any problems.

 



Best Regards,
Nevron Support Team


Daniela Rybarova
Daniela Rybarova
Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)
Group: Forum Members
Posts: 16, Visits: 1
Hello, I would ask - when I want to have three and more Y axis in the one chart must I use PrimaryY, SecondaryY and customY axis or can I use three and more customY axis? I've tried to use three custom axis and it's look like on the enclosed picture.
Attachments
axis.png (61 views, 28.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search