How can I control chart scaling ability in c # winform?

I have a chart, it has one chart with the x axis axis axis. First of all, I have to set it scalable,

chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true; chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true; 

By default, if I select a rectangular area with the mouse, the chart will expand to the selected area. But it is quite annoying because it is subject to false operation. But if I do this:

 chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = false; chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = false; 

Axes will not increase even if I call

 chart1.ChartAreas[0].AxisX.ScaleView.Zoom(a, b); 

So, I want chartarea to be scalable, but I don't like the ability to select the mouse.

I found a method

 void chart1_SelectionRangeChanged(object sender, CursorEventArgs e) 

It seems that when I select a new scope, this method will be called, but it is not intended to be overridden. What can I do? Thanks!

+4
source share
1 answer

try the following:

 var ca = chart1.ChartAreas["ChartArea1"].CursorX; ca.CursorX.IsUserEnabled = false; ca.CursorX.IsUserSelectionEnabled = false; 

(and the same for CursorY, and replacing "ChartArea1" with the name of your chart area if it differs).

This will disable mouse selection, so you will no longer risk random scaling.

+2
source

All Articles