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

.net, c#, mschart

Solution

Your zoom most likely does not work because your test time values are all too close to each other. The zoom must be able to pick a start and end point from the user selection. If start == end, a reasonable behaviour for the scale view is to do nothing.

Problem

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?

Original source