Page 1 of 1

Zoom Out after programmatically setting axis bounds

Posted: Fri Oct 03, 2014 3:11 pm
by 15670310
I have a line chart displaying data in the x-range of 0...360. Using the mouse I can zoom in and out on that data.

But then I programmatically set the x-axis as follows:

mChart.Axes.Bottom.Automatic = false;
mChart.Axes.Bottom.Minimum = 20;
mChart.Axes.Bottom.Maximum = 100;

After that the chart displays the x-axis as expected.

But then my problem: I can now not zoom out using the mouse anymore. The chart remains "stuck" on the range of 20...100 instead of letting me zoom out again to 0..360.

Question: How can I programmatically "zoom in" (set x-axes bounds) and still be able to zoom out again using the mouse?

Re: Zoom Out after programmatically setting axis bounds

Posted: Tue Oct 07, 2014 7:56 am
by Christopher
arnadan wrote:Question: How can I programmatically "zoom in" (set x-axes bounds) and still be able to zoom out again using the mouse?
Sorry for the slight delay in this reply. You can try something like this:

Code: Select all

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

    void tChart1_UndoneZoom(object sender, EventArgs e)
    {
      if (savedScales != null)
        tChart1.Chart.RestoreScales(savedScales);
    }

    private Steema.TeeChart.Chart.AllAxisSavedScales savedScales;
    private void button1_Click(object sender, EventArgs e)
    {
      if(savedScales == null)
        savedScales = tChart1.Chart.SaveScales();
      tChart1.Axes.Bottom.Automatic = false;
      tChart1.Axes.Bottom.Minimum = 2;
      tChart1.Axes.Bottom.Maximum = 10;
    }