How to get new point index after zoom

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
scott
Newbie
Newbie
Posts: 13
Joined: Fri Mar 09, 2007 12:00 am

How to get new point index after zoom

Post by scott » Mon Jun 11, 2007 6:17 am

I draw a fastline in webchart.
When user zoom the webchart, how can I get the new point index.

Example:
If this fastline has 100 point.
And when user zoom the webchart(if user select index 30 to 40).
Webchart will show new scale in point 30 to 40.
How can I know user zoom index 30 to 40.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Mon Jun 11, 2007 10:31 am

Hi scott

You can know the user zoom index, as below code:

Code: Select all

 protected void Page_Load(object sender, EventArgs e)
    {
       Steema.TeeChart.Chart ch1 = WebChart1.Chart;
       MemoryStream tmpChart = new MemoryStream();

      if (Session["ch1"] == null)
      {
          //setup Chart
          ch1.Aspect.View3D = false;

          if (ch1.Series.Count < 1)
              ch1.Series.Add(new Steema.TeeChart.Styles.Points());

          ch1.Series[0].FillSampleValues(36);
          //export Chart to a MemoryStream template
          ch1.Export.Template.Save(tmpChart);
          //save template to a Session variable
          Session.Add("ch1", tmpChart);
      }
      else
      {
          //retrieve the session stored Chart
          tmpChart = (MemoryStream)Session["ch1"];
          //set the Stream position to 0 as the last read/write
          //will have moved the position to the end of the stream
          tmpChart.Position = 0;
          //import saved Chart
          WebChart1.Chart.Import.Template.Load(tmpChart);

          //check whether zoom request is being sent
          CheckZoom(WebChart1);

          //User zoom index:
          Bitmap bmp = WebChart1.Chart.Bitmap((int)WebChart1.Width.Value, (int)WebChart1.Height.Value);
          int first = WebChart1.Chart.Series[0].FirstVisibleIndex; 
          int last = WebChart1.Chart.Series[0].LastVisibleIndex;
          WebChart1.Chart.Header.Text = "first : " + first.ToString() + " last: " + last.ToString();
      }

    }

    private void CheckZoom(WebChart wChart)
    { 
        ArrayList zoomedState = (ArrayList)Session[wChart.ID + "Zoomed"]; 
        zoomedState = ((Steema.TeeChart.Tools.ZoomTool)wChart.Chart.Tools[0]).SetCurrentZoom(Request, zoomedState); 
        if (zoomedState == null) 
            Session.Remove(wChart.ID + "Zoomed");
        else         
            Session.Add(wChart.ID + "Zoomed", zoomedState); 
    } 
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Post Reply