Share via

SelectionRangeChanged and AxisViewChanged do not fire when ZoomReset is called.

Mark Nelson 1 Reputation point
2022-01-10T00:35:06.753+00:00

(C#)
I have a Chart that where the X & Y axis are zoomable. When I Zoom in using the mouse both SelectionRangeChanged and AxisViewChanged are called.

However, when either Zoom(Int32, Int32), ZoomReset() or ZoomReset(Int32) are fired neither SelectionRangeChanged nor AxisViewChanged are fired.

Is this a bug? If not, how do I fix this so that I get some indication when Zoom, ZoomReset() and ZoomReset(Int32) are fired?

The salient functions in InitializeComponent() are:

this.chart2.SelectionRangeChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CursorEventArgs>(this.chart2_SelectionRangeChanged);
            this.chart2.AxisViewChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(this.chart2_AxisViewChanged);

The salient functions in the class are:

     int index = 0;
    private void chart2_SelectionRangeChanged(object sender, System.Windows.Forms.DataVisualization.Charting.CursorEventArgs e)
    {
           //Fires when the chart is zoomed by the mouse
           //Doesn't fire when called by chart2.ChartAreas[0].AxisX.ScaleView.ZoomReset();
           Console.WriteLine("chart2_SelectionRangeChanged " + index.ToString());
           ++index;
    }

    private void chart2_AxisViewChanged(object sender, System.Windows.Forms.DataVisualization.Charting.ViewEventArgs e)
    {
           //Fires when the chart is zoomed by the mouse
           //Doesn't fire when called by chart2.ChartAreas[0].AxisX.ScaleView.ZoomReset();
           Console.WriteLine("chart2_AxisViewChanged " + index.ToString());
            ++index;
    }

    private void buttonZoomReset_Click(object sender, EventArgs e)
    {
           //This doesn't fire chart2_AxisViewChanged nor chart2_SelectionRangeChanged
           chart2.ChartAreas[0].AxisX.ScaleView.ZoomReset();
    }

   private void buttonZoom_Click(object sender, EventArgs e)
   {
           //This doesn't fire chart2_AxisViewChanged nor chart2_SelectionRangeChanged
         chart2.ChartAreas[0].AxisX.ScaleView.Zoom(2, 7);
   }
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.