Controlling zoom and scroll level

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
IliaStoilov
Newbie
Newbie
Posts: 15
Joined: Tue Nov 17, 2015 12:00 am

Controlling zoom and scroll level

Post by IliaStoilov » Tue Nov 24, 2015 7:56 am

I have a candle chart, which can be zoomed and scrolled only horizontally. The series contain 30 to 180 candles. I am trying to limit the max zoom level to 10 candles but I can't figure it out. I can disable the zoom once there are only 10 candles visible (using first visible and last visible), but I can't turn it back on. The next issue is that I can't limit the scrolling to not exceed the first value of the series.

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

Re: Controlling zoom and scroll level

Post by Christopher » Tue Nov 24, 2015 8:55 am

Hello Ilia,
IliaStoilov wrote:I have a candle chart, which can be zoomed and scrolled only horizontally. The series contain 30 to 180 candles. I am trying to limit the max zoom level to 10 candles but I can't figure it out. I can disable the zoom once there are only 10 candles visible (using first visible and last visible), but I can't turn it back on. The next issue is that I can't limit the scrolling to not exceed the first value of the series.
This code may give you some pointers toward a possible solution:

Code: Select all


    Candle candle1;
    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      candle1 = new Candle(tChart1.Chart);
      candle1.FillSampleValues(100);

      tChart1.Zoom.Direction = ZoomDirections.Horizontal;
      tChart1.Zoomed += TChart1_Zoomed;
      tChart1.Scroll += TChart1_Scroll;
    }

    private void TChart1_Scroll(object sender, EventArgs e)
    {
      double first = candle1.XValues.First;

      if(tChart1.Axes.Bottom.Maximum < first)
      {
        tChart1.Axes.Bottom.Maximum = first;
      }
    }

    private void TChart1_Zoomed(object sender, EventArgs e)
    {
      List<double> xvalues = candle1.XValues.Value.ToList();
      double first = xvalues.First(x => x >= tChart1.Axes.Bottom.Minimum);
      int firstIndex = xvalues.IndexOf(first);
      double last = xvalues[firstIndex + 9];

      tChart1.Axes.Bottom.Maximum = last;
    }
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