Zooming & selection not working for C# chart with x-axis of the type Time

Viewed 12715

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.

enter image description here

But when I set the series value type to series1.XValueType = ChartValueType.Time;, I won't be able to zoom in the x-axis.

enter image description here

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?

2 Answers
Related