Zoom don't "freeze" after a simple !IsPostBack

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
else
Newbie
Newbie
Posts: 17
Joined: Fri May 21, 2004 4:00 am
Location: Germany
Contact:

Zoom don't "freeze" after a simple !IsPostBack

Post by else » Mon Sep 12, 2005 8:04 am

Hi Steema-team!
I have added a zoom-tool to my WebChart and it works very good. But if I had zoomed in the chart, and click a button (!IsPostBack) the chart is going on zooming in! Is it possible to stopp this and to keep the zoomed chart?

Best regards!

else

Marc
Site Admin
Site Admin
Posts: 1265
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Mon Sep 12, 2005 8:56 pm

Hello else,

When the button on the form posts back (the same applies to other postback elements such as a dropdownlist) it preserves the url that was previously sent. If the last action was a zoom then the zoom will be resent.

A fix will be built into the next maintenance release to resolve this, in the meantime there is a workaround to the problem. As zoomable Charts are not postback elements you could do a check for a postback and block attempts to zoom when a postback action (such as a button press) occurs.

eg. Check for postback events:

Code: Select all

public bool CheckPostData(System.Collections.Specialized.NameValueCollection postCollection)
{
	if (postCollection!=null)
		return false;
	else
		return true;
}

private bool isChart=false;

private void Page_Load(object sender, System.EventArgs e)
{
	isChart=CheckPostData(DeterminePostBackMode());

...............etc 
Do not re-apply the last zoom url if the page load is called via a postback event. Modify the CheckZoom method to check for non-Chart calls:

Code: Select all

private void CheckZoom(WebChart wChart)
{
  ArrayList zoomedState=(ArrayList)Session[wChart.ID+"Zoomed"];
  if (isChart)
  {
    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);
   }
   else if (zoomedState!=null)
     SetSavedZoom(wChart,zoomedState);
}

/// <summary>
/// Set zoomed Charts to current zoomed state when postback event fired
/// </summary>
private void SetSavedZoom(WebChart wChart,ArrayList zoomedState)
{
  wChart.Chart.Axes.Left.SetMinMax(((PointF)zoomedState[0]).X,
		((PointF)zoomedState[0]).Y);
  wChart.Chart.Axes.Bottom.SetMinMax(((PointF)zoomedState[3]).X,
		((PointF)zoomedState[3]).Y);
  wChart.Chart.Axes.Top.SetMinMax(((PointF)zoomedState[1]).X,
		((PointF)zoomedState[1]).Y);
  wChart.Chart.Axes.Right.SetMinMax(((PointF)zoomedState[2]).X,
		((PointF)zoomedState[2]).Y);
}
Regards,
Marc Meuman
Steema Support

else
Newbie
Newbie
Posts: 17
Joined: Fri May 21, 2004 4:00 am
Location: Germany
Contact:

Post by else » Tue Sep 13, 2005 7:37 am

Hi Steema-team!

Thank you for the useful advice! Now it's perfect! :D

Best regards,
else

Post Reply