.net - 缩放后MSChart未处理的溢出异常

标签 .net system.drawing mschart

This Question在MSChart论坛上一直无人问津。

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.



无论您将“图表”的其余部分配置为什么,只要将其“缩小”得太远(其含义可能会有所不同),就似乎会发生此异常。有几个人报告了此问题。异常帮助程序指示它位于System.Drawing.dll中。

这里有人有任何线索或解决方法吗?

最佳答案

今天,我错误地将缩放值设置为相同的开始和结束值时遇到了相同的问题。

chartarea.AxisX.ScaleView.Zoom(chartarea.CursorX.SelectionStart, chartarea.CursorX.SelectionStart); // second argument should have been chartarea.CursorX.SelectionEnd

然后,我尝试了以下作为实验:
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

您的数据点是否可能如此靠近,以至于您的起点和终点之间的距离低于上面观察到的阈值?我建议您尝试将时间值乘以100或1000,然后看问题是否消失。

解决此问题的另一种方法是在ScaleView上设置MinSize。
chartarea.AxisX.ScaleView.MinSize = 0.0001; // something bigger than 0.0000001 works for me

关于.net - 缩放后MSChart未处理的溢出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3826724/

相关文章:

c# - .Net chart control XY graph 当所有X值都相同时输出错误

c# - 如何在饼图中的图例中设置不同的标签

ASP.NET 图表 : ToolTips on X and Y axis labels?

c# - 如何解析 CET/CEST 日期时间?

.net - 将一个程序集安装到 GAC 上,用于 mono/.NET

c# - JSON 到 C# 类 - 未知的属性名称

c# - 如何将.Net Core应用程序连接到Azure SQL数据库

c# - 三角形列表的路径 (.NET/C#)

c# - DrawToBitmap - System.ArgumentException : Parameter is not valid

.net - 将 System.Drawing.Color 转换为 System.Windows.Media.Color