Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am doing a charting project and I am supposed to save the charts into its individual image files.

If I were to do a trend data of 1 to 2 months are 1 minute interval, I do not face any problem. However if I expand the trend to 3 months or more, I get an OverflowException when saving.

Any advice is greatly appreciated.

The exception trace is as follows:
C#
at System.Decimal..ctor(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)
at System.Windows.Forms.DataVisualization.Charting.ChartImage.GetImage(Single resolution)
at System.Windows.Forms.DataVisualization.Charting.Chart.SaveImage(Stream imageStream, ChartImageFormat format)
at System.Windows.Forms.DataVisualization.Charting.Chart.SaveImage(String imageFileName, ChartImageFormat format)


What I have tried:

I am currently using Single/float values in my series so I am not sure why this kind of exception is thrown.
Posted
Comments
Richard MacCutchan 19-Jun-18 6:44am    
The message means that the system has encountered a value that is too large to be represented in the relevant variable type. You need to use your debugger to find out which variable and corresponding value are the cause. See also Floating-Point Types Table (C# Reference) | Microsoft Docs[^]
amsga 19-Jun-18 7:44am    
All the values that I am using are Single/float datatypes. I don't think there are any values that are larger than what a Decimal can represent.
Richard MacCutchan 19-Jun-18 12:15pm    
Well you need to use your debugger to find the actual value that causes the exception.
Jochen Arndt 19-Jun-18 7:12am    
The execption occurs in the Decimal constructor accepting a double: Decimal Constructor (Double)
See the link for the possible sources of the excpetion.

Are there values greater ~1E30 for the longer period?
amsga 19-Jun-18 7:42am    
Not that I am aware of.
If I happen to trend for a particular month, there isn't any issues.
If I happen to trend for 3 months or more, the exception is thrown.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900