Page 1 of 1

Unzoom not correctly displaying the min max values

Posted: Thu Oct 05, 2006 1:16 pm
by 9642161
Hi

I need to capture the min and max values of the axis when doing a zoom and unzoom. Attached to following code for the Zoom and UnZoom events

private void chart_Zoomed(object sender, EventArgs e)
{
lblMinAbsTime.Text = System.TimeZone.CurrentTimeZone.ToLocalTime(DateTime.FromOADate(chart.Axes.Bottom.Minimum)).ToString("dd-MMM-yyyy HH:mm:ss");
lblMaxAbsTime.Text = System.TimeZone.CurrentTimeZone.ToLocalTime(DateTime.FromOADate(chart.Axes.Bottom.Maximum)).ToString("dd-MMM-yyyy HH:mm:ss");
}

private void chart_UndoneZoom(object sender, EventArgs e)
{
lblMinAbsTime.Text = System.TimeZone.CurrentTimeZone.ToLocalTime(DateTime.FromOADate(chart.Axes.Bottom.Minimum)).ToString("dd-MMM-yyyy HH:mm:ss");
lblMaxAbsTime.Text = System.TimeZone.CurrentTimeZone.ToLocalTime(DateTime.FromOADate(chart.Axes.Bottom.Maximum)).ToString("dd-MMM-yyyy HH:mm:ss");

}

When a zoom occurs the labels will display the correct values. If I create a button an attach the following code

chart.Zoom.Undo();

The chart will correctly reset to the original display and the event will fire but the min and max will not change from the zoomed values. I wait a second and press the button again to do a chart.Zoom.Undo(); and the values will then display the correct unzoom values.

Posted: Thu Oct 05, 2006 2:02 pm
by narcis
Hi histry,

For this to work you just need to make a call to the Refresh method before updating the labels:

Code: Select all

    private void tChart1_UndoneZoom(object sender, EventArgs e)
    {
      tChart1.Refresh();
      lblMinAbsTime.Text = System.TimeZone.CurrentTimeZone.ToLocalTime(DateTime.FromOADate(tChart1.Axes.Bottom.Minimum)).ToString("dd-MMM-yyyy HH:mm:ss");
      lblMaxAbsTime.Text = System.TimeZone.CurrentTimeZone.ToLocalTime(DateTime.FromOADate(tChart1.Axes.Bottom.Maximum)).ToString("dd-MMM-yyyy HH:mm:ss"); 
    }

Unzoom not correctly displaying the min max values

Posted: Thu Oct 05, 2006 2:23 pm
by 9642161
That corrects the issue

Thanks