I'm using the following code to allow my parts of chart to be selected and zoomed:
chart1.ChartAreas[0].CursorX.IsUserEnabled = true;
chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
chart1.ChartAreas[0].CursorY.IsUserEnabled = true;
chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = true;
It works for a chart with both x and y axes of the type Integer.
But when I set the series value type to series1.XValueType = ChartValueType.Time;
, I won't be able to zoom in the x-axis.
When I set both axes value types for auto and add points using, for example, chart1.Series[0].Points.AddXY(DateTime.Now.ToLongTimeString(), rand.Next(10, 20));
, then the zoom works.
How can I have my x-axis to be a Time and still be able to zoom?
You need to set the Interval on the Cursor by default it is 1.0, I had the problem with percentages so I set my interval to 0.01 e.g 1% as shown below. You want want to set IntervalType on the Cursor as this accepts datetime types.
chart1.ChartAreas[0].CursorX.Interval = 0.01