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

Y-Axis value is all zero

4 Answers 71 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Seo
Top achievements
Rank 1
Seo asked on 08 Dec 2010, 03:58 AM
Hi

I have a grid and chart with the same data.
When the data is all zero, an exception occurred but the grid is fine and the chart isn't.
In addition y-axis of the chart does not show.
The exception says that Value does not fall within the expected range.
The attached file contains the exception and normal case.

Codes are:
I have a grid and chart with the same data.
When the data is all zero, an exception occurred but the grid is fine and the chart isn't.
In addition y-axis of the chart does not show.
The exception says that Value does not fall within the expected range.
The attached file contains the exception and normal case.

Codes are:
I have a grid and chart with the same data.
When the data is all zero, an exception occurred but the grid is fine and the chart isn't.
In addition y-axis of the chart does not show.
The exception says that Value does not fall within the expected range.
The attached file contains the exception and normal case.

Codes are:
// The data with all zero
 
result = e.Result;
 
#region All Zero Test
result.Clear();
 
for (int j = 1; j <= 2; j++)
{
for (int i = 0; i < 7; i++)
{
    result.Add(new SQLExecStatsAnalItemsRetData
    {
        LEV = (i + 1).ToString()
        ,VALUE = "0"
        ,VALUE_RATE = "0"
        ,TOTAL = "0"
        ,TOTAL_RATE = "0"
        ,INSTANTSHOT_NO = (j + 100).ToString()
    });
}
}
#endregion
 
 
// Xaxis
#region All Zero Test
xAxis = new string[] { "101", "102" };
instantShotInfo["101"] = "2010-11-11";
instantShotInfo["102"] = "2010-12-11";
#endregion
 
 
// Set the data for chart
for (int i = 0; i < xAxis.Length; i++)
{
    tmpResultForChart = new List<double>();
 
    for (int j = 0; j < result.Count; j++)
    {
        if ((result[j].INSTANTSHOT_NO).Equals(xAxis[i]))
        {
            tmpResultForChart.Add(Convert.ToDouble(result[j].TOTAL_RATE));
        }
    }
 
    resultForChart[xAxis[i]] = tmpResultForChart;
}
 
for (int i = 0; i < xAxis.Length; i++)
{
    List<double> tmp = resultForChart[xAxis[i]];
     
    dataSeries1.Add(new DataPoint() { YValue = tmp[0], XCategory = xAxis[i] });
    dataSeries2.Add(new DataPoint() { YValue = tmp[1], XCategory = xAxis[i] });
    dataSeries3.Add(new DataPoint() { YValue = tmp[2], XCategory = xAxis[i] });
    dataSeries4.Add(new DataPoint() { YValue = tmp[3], XCategory = xAxis[i] });
    dataSeries5.Add(new DataPoint() { YValue = tmp[4], XCategory = xAxis[i] });
    dataSeries6.Add(new DataPoint() { YValue = tmp[5], XCategory = xAxis[i] });
    dataSeries7.Add(new DataPoint() { YValue = tmp[6], XCategory = xAxis[i] });
}
 
// Chart properties
chtResult.MinWidth = 1200;
chtResult.Height = 330;
chtResult.Background = new SolidColorBrush(Colors.White);
chtResult.BorderBrush = new SolidColorBrush(Colors.Transparent);
chtResult.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
 
chtResult.DefaultView.ChartArea.DataSeries.Clear();
chtResult.DefaultView.ChartArea.SmartLabelsEnabled = false;
chtResult.DefaultView.ChartArea.FontSize = 10;
chtResult.DefaultView.ChartLegend.Header = string.Empty;
chtResult.DefaultView.ChartLegend.FontSize = 10;
chtResult.DefaultView.ChartLegend.LegendItemMarkerShape = MarkerShape.Circle;
chtResult.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Inside;
chtResult.DefaultView.ChartArea.AxisX.LabelRotationAngle = -30;
chtResult.DefaultView.ChartArea.AxisY.MinValue = 0;
chtResult.DefaultView.ChartArea.AxisY.MaxValue = 100;
chtResult.DefaultView.ChartArea.AxisY.ExtendDirection = AxisExtendDirection.Smart;
chtResult.DefaultView.ChartArea.AxisY.DefaultLabelFormat = numberFormatString;
 
CustomGridLine fifty = new CustomGridLine();
fifty.Visibility = System.Windows.Visibility.Visible;
fifty.StrokeThickness = 1;
fifty.Opacity = 30;
fifty.Stroke = new SolidColorBrush(Colors.Red);
fifty.YIntercept = 50;
 
chtResult.DefaultView.ChartArea.Annotations.Add(fifty);
 
Border border = new Border();
border.BorderThickness = new Thickness(2);
border.CornerRadius = new CornerRadius(5);
border.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 173, 216, 230));
border.Child = new TextBlock()
{
    Text = MaeStrings.esains_CHART_TITLE,
    Margin = new Thickness(7, 3, 7, 3),
    FontSize = 12
};
chtResult.DefaultView.ChartTitle.Content = border;
 
chtResult.DefaultView.ChartTitle.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

If you want more information, please tell me.

Thanks in advance and sorry for my English.

4 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 13 Dec 2010, 07:59 AM
Hello Seo,

It is hard for us to reproduce the issue you are facing from the given information. Could you strip down the project and send it in new Support thread? That way we will be able to investigate the issue you are facing and help you.

Looking forward to hearing from you!

Best wishes,
Evgenia
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Seo
Top achievements
Rank 1
answered on 15 Dec 2010, 04:02 AM
Hi Evgenia

Thank you for your reply.

Unfortunately, it is difficult to strip down the project with problem.
Because it is the part of the huge solution and involved in some security issues.
I'm so sorry for that.

Instead, if neccesary, I have an intention of offering a project doing with the same problem.
But it may take time to create it.

Thanks and happy new year
0
Accepted
Giuseppe
Telerik team
answered on 20 Dec 2010, 04:44 PM
Hello Seo,

We were able to pinpoint the problem in the described scenario -- your chart setup uses automatic AxisY range (you have specified MinValue / MaxValue but you need to set AutoRange property to false if you would like to set the range manually) and when all data is zero, the AxisY does not have any range (i.e. it is zero). At the same time, you are trying to add custom gridline at YIntercept=50, hence you get the "Value does not fall within the expected range." exception as indeed 50 is out of the current axis range.

We would suggest you to manually set the AxisY range like this and this should solve your issue:
RadChart1.DefaultView.ChartArea.AxisY.AutoRange = false;
RadChart1.DefaultView.ChartArea.AxisY.AddRange(0, 100, 10);

Hope this helps.


Regards,
Freddie
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Seo
Top achievements
Rank 1
answered on 21 Dec 2010, 08:36 AM
Hi Freddie

Thank you for reply.

It worked perfectly. I had not fully understood the properties of the chart.
Now I'm using the codes of yours and mine to draw a chart depending on the situation.

Thanks
Tags
Chart
Asked by
Seo
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Seo
Top achievements
Rank 1
Giuseppe
Telerik team
Share this question
or