This is a migrated thread and some comments may be shown as answers.

RADChart Exception - "Value was either too large or too small for a Decimal."

3 Answers 385 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
LJ
Top achievements
Rank 1
LJ asked on 08 Dec 2009, 06:28 AM

Hi All,

I have a custom web part which includes RAD Chart control.
This web part is used in WSS 3.0.

SharePoint List data is displayed in RAD Chart.

I added series to RAD Chart.

Series max Y value is 1.5E+28 and min Y value is 1.5E+28

 

double seriesMaxYVal = radChartObj.Series.GetMaxYValue();   
 
double seriesMinYVal = radChartObj.Series.GetMinYValue();   
 

 

 

 

I set Y-axis isLogarithmic property as true.
  

 

 

radChartObj.PlotArea.YAxis.IsLogarithmic = true;    
 

  

 

 

 

But RenderContents function is throwing exception.

Inner Exception: 
{"Value was either too large or too small for a Decimal."}

Stack Trace: 
"   at System.Decimal..ctor(Double value)\r\n   at Telerik.Charting.ChartYAxis.Initialize(Double min, Double max)\r\n   at Telerik.Charting.ChartYAxis.InitializeItems()\r\n   at Telerik.Charting.ChartPlotArea.InitializeAxes()\r\n   at Telerik.Charting.RenderEngine.InitializeChartElements()\r\n   at Telerik.Charting.Chart.GetImage(Int32 width, Int32 height)"


Please let me know if there is any limitaion of series item value in RADChart.

Please suggest a solution.

Thanking you in anticipation.

Regards,
LJ

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 10 Dec 2009, 07:33 AM
Hello LJ,

Axes values are decimals, so RadChart would not be able to display values greater than decimal.MaxValue which is close to 8E+28. Note that automatic axis values calculation would require some margin as the calculations start from a wider range, which is then narrowed to a meaningful range which will accommodate the chart values. 

That said, there should be no problem displaying 1.5E+28 with linear Y axis as it would yield a max value of 1.6E+28 which is within the decimal values. However, in logarithmic mode the MaxValue in this case would be 1E+29 which is greater than decimal.MaxValue -- hence the error. With the default value of LogarithmBase=10 RadChart will display correctly when the max value is 1E+28.


Greetings,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
John Davis
Top achievements
Rank 2
answered on 02 Feb 2010, 10:52 PM

I sometimes get the error:
  Value was either too large or too small for a Decimal.
on the statement:
   RadChart2.DataBind();

However the data going to the y axis is integer data so it cannot be a problem for decimal data type.
I am not sure what is happening with the x axis data, because it is text.  Some of the items are numeric but others are non numeric.
Because some x axis labels were not displaying correctly, Telerik support advised how to manually set the x axis as shown in the code below.

How can I debug or fix this problem?

Steve

Here is code for the data source.  Y axis data is in the "Cnt" field that is integer.  X axis data is in the UserID field that is string.

  int iMaxVal = int.MaxValue;

...

  List<UserPerfGraphEntity> L5 = new List<UserPerfGraphEntity>();
                 UserPerfGraphEntity l5;
                 foreach (var q in Pn)
                 {
                 l5 = new UserPerfGraphEntity();
                 l5.UserID=q.Usr;
                 if (q.Cnt > iMaxVal) { l5.Cnt = iMaxVal; } else { l5.Cnt = Convert.ToInt32(q.Cnt); }
                 L5.Add(l5);
                 }
                 return L5;

<rad:RadChart ID="RadChart2" runat="Server" Width="733px" AutoLayout="true"
Skin="Mac" Height="413px">
<PlotArea>
<EmptySeriesMessage Visible="True">  
<Appearance Visible="True">  
</Appearance>
<TextBlock Text="No data for current settings"> 
</TextBlock> 
</EmptySeriesMessage>
<XAxis>
<Appearance Color="134, 134, 134" MajorTick-Color="134, 134, 134">
<MajorGridLines Color="209, 222, 227" PenStyle="Solid" />
<TextAppearance TextProperties-Color="51, 51, 51">
</TextAppearance>
</Appearance>
<AxisLabel>
<TextBlock>
  <Appearance TextProperties-Color="51, 51, 51">
  </Appearance>
</TextBlock>
</AxisLabel>
</XAxis>
<YAxis>
<Appearance Color="134, 134, 134" MajorTick-Color="134, 134, 134"
MinorTick-Color="134, 134, 134" MinorTick-Width="0">
<MajorGridLines Color="209, 222, 227" />
<MinorGridLines Color="233, 239, 241" />
<TextAppearance TextProperties-Color="51, 51, 51">
</TextAppearance>
</Appearance>
<AxisLabel>
<TextBlock>
  <Appearance TextProperties-Color="51, 51, 51">
  </Appearance>
</TextBlock>
</AxisLabel>
</YAxis>
<Appearance>
<FillStyle FillType="Solid" MainColor="White">
</FillStyle>
<Border Color="134, 134, 134" />
</Appearance>
</PlotArea>
<Appearance Corners="Round, Round, Round, Round, 6">
<FillStyle FillType="Image">
<FillSettings BackgroundImage="{chart}" ImageDrawMode="Flip" ImageFlip="FlipX">
</FillSettings>
</FillStyle>
<Border Color="138, 138, 138" />
</Appearance>
<ClientSettings EnableZoom="false" ScrollMode="XOnly" XScale="4" />
<Series>
<rad:ChartSeries DataYColumn="MyColumn" Type="Line">
<Appearance FillStyle-MainColor="223, 87, 60">
<FillStyle MainColor="223, 87, 60" SecondColor="22, 85, 161">
<FillSettings GradientMode="Vertical">
</FillSettings>
</FillStyle>
<TextAppearance TextProperties-Color="Black">
</TextAppearance>
</Appearance>
</rad:ChartSeries>
</Series>
<ChartTitle>
<Appearance Position-AlignedPosition="Top">
<FillStyle MainColor="">
</FillStyle>
</Appearance>
<TextBlock>
<Appearance TextProperties-Font="Tahoma, 13pt">
</Appearance>
</TextBlock>
</ChartTitle>
<Legend visible="false">
<Appearance 
Position-AlignedPosition="TopRight" Visible="False">
<ItemMarkerAppearance Figure="Square">
<Border Color="134, 134, 134" />
</ItemMarkerAppearance>
<FillStyle MainColor="">
</FillStyle>
<Border color="Transparent" />
</Appearance>
</Legend>
</rad:RadChart>

***************************************************

  private void SetupChart1()
    {
        List<Entity.UserPerfGraphEntity> MyList = Manager.MgtPickLineManager.GetChartResultSourceByUser(
    1
    , Convert.ToDateTime(RadDatePicker1.DbSelectedDate)
    , Convert.ToDateTime(RadDatePicker2.DbSelectedDate)
    , Convert.ToInt32(ddPhase.SelectedValue) //Convert.ToInt32(lblPhase.Text)
    , Convert.ToInt32(ddY.SelectedValue)
    , ""
    , ""
    , 0 //Convert.ToInt32(ddX.SelectedValue)
    );

        RadChart2.ClientSettings.ScrollMode = Telerik.Web.UI.ChartClientScrollMode.None;
        RadChart2.Series[0].Type = ChartSeriesType.Bar;
        RadChart2.DataSource = MyList;
        RadChart2.Series[0].DataYColumn = "Cnt";
 
        RadChart2.PlotArea.XAxis.DataLabelsColumn = "UserID";
        RadChart2.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font
         = new System.Drawing.Font("Ariel", 8);
        RadChart2.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 300;
        RadChart2.ChartTitle.TextBlock.Text = GetTitle();
        RadChart2.BeforeLayout += new EventHandler<EventArgs>(RadChart2_BeforeLayout);
        RadChart2.DataBind();
    }
    void RadChart2_BeforeLayout(object sender, EventArgs e) //manual x-axis bind avoids auto interp as int rather than string
    {
        for (int i = 0; i < RadChart2.PlotArea.XAxis.Items.Count; i++)
        {
            ChartAxisItem axisItem = RadChart2.PlotArea.XAxis.Items[i];
            axisItem.TextBlock.Text = (RadChart2.DataSource as List<Entity.UserPerfGraphEntity>)[i].UserID;
        }
    }

0
Ves
Telerik team
answered on 05 Feb 2010, 09:01 AM
Hello John,

Can you send us a runnable example with the specific data, which triggers this exception? Thanks.

Sincerely,
Ves
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Chart (Obsolete)
Asked by
LJ
Top achievements
Rank 1
Answers by
Ves
Telerik team
John Davis
Top achievements
Rank 2
Share this question
or