I have an application like this:
With the text fields below the chart, the user can set the minimum and maximum value of the X axis of the chart. This is the code for it:
private void textBoxXaxisMin_TextChanged(object sender, EventArgs e)
{
double x;
if (Double.TryParse(this.textBoxXaxisMin.Text, out x))
{
this.textBoxXaxisMin.BackColor = Color.White;
chart1.ChartAreas[0].AxisX.Minimum = Convert.ToDouble(this.textBoxXaxisMin.Text);
}
else
this.textBoxXaxisMin.BackColor = Color.Orange;
double y;
if (Double.TryParse(this.textBoxXaxisMax.Text, out y) && y > chart1.ChartAreas[0].AxisX.Minimum)
{
this.textBoxXaxisMax.BackColor = Color.White;
chart1.ChartAreas[0].AxisX.Maximum = Convert.ToDouble(this.textBoxXaxisMax.Text);
}
else
this.textBoxXaxisMax.BackColor = Color.Orange;
}
Now I would like the Y axis to be scaled automatically. Y-min should be calculated as the minimum value of all series in the section (X-min and X-max), and Y-max should be calculated as the maximum of all series in the selected section. My problem is implementation.
In this example, Y-min should be changed to about 50.
I posted here an example of an example of holes in GitHup .