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
Zoom don't "freeze" after a simple !IsPostBack
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:
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:
Regards,
Marc Meuman
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
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);
}
Marc Meuman
Steema Support