Zoom Out after programmatically setting axis bounds

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
arnadan
Newbie
Newbie
Posts: 5
Joined: Mon Sep 29, 2014 12:00 am

Zoom Out after programmatically setting axis bounds

Post by arnadan » Fri Oct 03, 2014 3:11 pm

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?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Zoom Out after programmatically setting axis bounds

Post by Christopher » Tue Oct 07, 2014 7:56 am

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;
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply