This Question has been languishing un-answered on the MSChart forum for over a year.
I'm continually getting an overflow exception on a chart. I'm setting up my chart as follows:
InstrChart.Legends.Clear(); dataArea = InstrChart.ChartAreas.Add("Instr1"); dataArea.AxisX.MajorGrid.Enabled = false; dataArea.AxisY.MajorGrid.Enabled = false; dataArea.CursorX.IsUserSelectionEnabled = true;
I'm then adding 12 series with about 10000 points each.
The exception occurs when I zoom down to show only 3 or 4 point per series. Immediately after I release the mouse button for a zoom I get the following exception:
System.OverflowException was caught Message="Overflow error." Source="System.Drawing" StackTrace: at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
(etc - see link above for full trace.)
I've removed all event handler for the chart with no luck in stopping zooming from eventuall causing this exception. I've set IsUserSelectionEnabled to false for the chart and done zooming from code with no luck.
Any help on this issue would be great. Cheers.
This exception appears to occur anytime you zoom down "too far" (the meaning of which may vary), regardless of how the rest of the chart is configured. Several people have reported this issue. The exception helper indicates that it's in System.Drawing.dll.
Anyone here have any clues or workarounds?
I encountered the same problem today when mistakenly setting the zoom with identical start and end values.
chartarea.AxisX.ScaleView.Zoom(chartarea.CursorX.SelectionStart, chartarea.CursorX.SelectionStart); // second argument should have been chartarea.CursorX.SelectionEnd
I then tried the following as an experiment:
chartarea.AxisX.ScaleView.Zoom(chart.CursorX.SelectionStart, chartarea.CursorX.SelectionStart + 0.00000001); // crash
chartarea.AxisX.ScaleView.Zoom(chart.CursorX.SelectionStart, chartarea.CursorX.SelectionStart + 0.0000001); // no crash
Is it possible that your data points are so close together that the distance between your start and end point is below the threshold observed above? I would recommend you try multiplying your time values by 100 or 1000 and see if the problem disappear.
Another way to eliminate this problem is to set the MinSize on ScaleView.
chartarea.AxisX.ScaleView.MinSize = 0.0001; // something bigger than 0.0000001 works for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With