Profile Picture

Multiple custom Y axis

Posted By Filip Mergental 13 Years Ago
Author
Message
Filip Mergental
Posted 13 Years Ago
View Quick Profile
Junior Member

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
Last Active: 11 Years Ago
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 (48 views, 28.00 KB)
Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

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



Filip Mergental
Posted 13 Years Ago
View Quick Profile
Junior Member

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
Last Active: 11 Years Ago
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.



Similar Topics


Reading This Topic