Page 1 of 1

Line Series and Axes Automatic Scaling

Posted: Thu Jan 28, 2016 10:39 am
by 9339158
Hi There

I'm adding a Styles.Line series to a chart which has the axes scaling set to Automatic.

Adding the series is causing the X axis scaling to change with undesirable results.

I would like to keep the Automatic scaling as it works well for the data series - is there a way to prevent it from changing the scale when certain Line series are added to the chart?

Many Thanks

Re: Line Series and Axes Automatic Scaling

Posted: Mon Feb 01, 2016 1:35 pm
by Christopher
Hello Jon,
JonM wrote: I would like to keep the Automatic scaling as it works well for the data series - is there a way to prevent it from changing the scale when certain Line series are added to the chart?
One way to do this would be to disable Automatic scaling when adding in certain line series, e.g.

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      tChart1.Series.Add(typeof(Line)).FillSampleValues();
    }

    private void button4_Click(object sender, EventArgs e)
    {
      tChart1.Axes.Bottom.Automatic = false;

      Random rnd = new Random();
      tChart1.Series.Add(typeof(Line));
      for (int i = 0; i < 100; i++)
      {
        tChart1[1].Add(i, rnd.Next(2000));
      }
    }
however, what this does mean is that when you turn Automatic back to true, the bottom axes will readjust to fit all the values on the next repaint. The only way to maintain control of axes min and max, when wanting all series visible, is to control the values manually (Maximum, Minimum properties, or SetMinMax() method).