2

默认情况下,我几乎已经设置了所有内容,它适用于较小的数字 (9.22337 × 109),但是当我尝试将更大的数字 (9.9E+37) 添加到系列时,控件会崩溃。进一步检查堆栈跟踪后,似乎是双->十进制转换错误?

我想我只是想知道这是否是控件的限制,或者是否需要其他配置。仅仅从正在发生的事情来看,我猜这是一个限制,但我想在放弃并试图找出不同的方式之前我会在这里问。

System.OverflowException occurred
   HResult=-2146233066
   Message=Value was either too large or too small for a Decimal.
   Source=mscorlib
   StackTrace:
       at System.Decimal..ctor(Double value)
       at System.Decimal.op_Explicit(Double value)
       at System.Windows.Forms.DataVisualization.Charting.Axis.RoundedValues(Double inter, Boolean shouldStartFromZero, Boolean autoMax, Boolean autoMin, Double& min, Double& max)
       at System.Windows.Forms.DataVisualization.Charting.Axis.EstimateNumberAxis(Double& minimumValue, Double& maximumValue, Boolean shouldStartFromZero, Int32 preferredNumberOfIntervals, Boolean autoMaximum, Boolean autoMinimum)
       at System.Windows.Forms.DataVisualization.Charting.Axis.EstimateAxis(Double& minimumValue, Double& maximumValue, Boolean autoMaximum, Boolean autoMinimum)
       at System.Windows.Forms.DataVisualization.Charting.Axis.EstimateAxis()
       at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetDefaultAxesValues()
       at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetData(Boolean initializeAxes, Boolean checkIndexedAligned)
       at System.Windows.Forms.DataVisualization.Charting.ChartArea.ReCalcInternal()
       at System.Windows.Forms.DataVisualization.Charting.ChartPicture.Paint(Graphics       graph, Boolean paintTopLevelElementOnly)
  InnerException: 

这是我从 dotPeek 中挑选出来的“反汇编” System.Windows.Forms.DataVisualization.Charting.Axis.RoundedValues 函数。

internal double RoundedValues(double inter, bool shouldStartFromZero, bool autoMax, bool autoMin, ref double min, ref double max)
    {
      if (this.axisType == AxisName.X || this.axisType == AxisName.X2)
      {
        if (this.margin == 0.0 && !this.roundedXValues)
          return inter;
      }
      else if (this.margin == 0.0)
        return inter;
      if (autoMin)
        min = min < 0.0 || !shouldStartFromZero && !this.ChartArea.stacked ? (double) (Decimal.op_Decrement((Decimal) Math.Ceiling(min / inter)) * (Decimal) inter) : 0.0;
      if (autoMax)
        max = max > 0.0 || !shouldStartFromZero ? (double) (Decimal.op_Increment((Decimal) Math.Floor(max / inter)) * (Decimal) inter) : 0.0;
      return inter;
    }
4

0 回答 0