3

I want to set the max and min values of the axes. Following code are valid for only one Y-Axis. I want to set 3 Y-Axis.

graphPane1.YAxis.Scale.Min = 0;

graphPane1.YAxis.Scale.Max = 100;

Here is my codes:

var y1 = graphPane1.AddYAxis("YAxis-1");

var y2 = graphPane1.AddYAxis("YAxis-2");

var y3 = graphPane1.AddYAxis("YAxis-3");

LineItem myCurve1 = graphPane1.AddCurve(txtPlotTitle.Text, first_pointsList, Color.Blue, SymbolType.None);
myCurve.YAxisIndex = y1;

LineItem myCurve2 = graphPane1.AddCurve(txtPlotTitle.Text, second_pointsList, Color.Yellow, SymbolType.None);
myCurve.YAxisIndex = y2;

LineItem myCurve3 = graphPane1.AddCurve(txtPlotTitle.Text, third_pointsList, Color.Green, SymbolType.None);
myCurve.YAxisIndex = y3;

Edit: When I try to run this code, program gave an error. Also I want that graphs are auto-scaled when I don't write anything in textboxes. I tryed to if loop for that, but it doesn't work.

var y1 = graphPane1.AddYAxis("YAxis-1");
var y2 = graphPane1.AddYAxis("YAxis-2");
var y3 = graphPane1.AddYAxis("YAxis-3");

LineItem myCurve1 = graphPane1.AddCurve(txtPlotTitle.Text, first_pointsList, Color.Blue, SymbolType.None);

myCurve.YAxisIndex = y1;         

graphPane1.YAxisList[y1].Scale.Min = double.Parse(textBox1.Text);
graphPane1.YAxisList[y1].Scale.Max = double.Parse(textBox2.Text);

LineItem myCurve2 = graphPane1.AddCurve(txtPlotTitle.Text, second_pointsList, Color.Yellow, SymbolType.None);

myCurve2.YAxisIndex = y2;
graphPane1.YAxisList[y2].Scale.Min = double.Parse(textBox3.Text);
graphPane1.YAxisList[y2].Scale.Max = double.Parse(textBox4.Text);

LineItem myCurve3 = graphPane1.AddCurve(txtPlotTitle.Text, third_pointsList, Color.Green, SymbolType.None);

myCurve3.YAxisIndex = y3;
graphPane1.YAxisList[y3].Scale.Min = double.Parse(textBox5.Text);
graphPane1.YAxisList[y3].Scale.Max = double.Parse(textBox6.Text);
TheLethalCoder
  • 6,668
  • 6
  • 34
  • 69

1 Answers1

1

You can loop through them in your graphPane :

foreach(var axis in graphPane1.YAxisList)
{
  axis.Scale.Min = 0;
  axis.Scale.Max = 100;
}

EDIT to answer OP in comment:

You have the indices stored in y1, y2 and y3 so you can easily access them individually:

graphPane1.YAxisList[y2].Scale.Max = 500 // set Max of y2 to 500 
Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122