Y-Axis value is all zero

5 posts, 1 answers
  1. Seo
    Seo avatar
    16 posts
    Member since:
    Sep 2010

    Posted 07 Dec 2010 Link to this post

    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.
  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 13 Dec 2010 Link to this post

    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
  3. Seo
    Seo avatar
    16 posts
    Member since:
    Sep 2010

    Posted 14 Dec 2010 Link to this post

    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
  4. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 20 Dec 2010 Link to this post

    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
  5. Seo
    Seo avatar
    16 posts
    Member since:
    Sep 2010

    Posted 21 Dec 2010 Link to this post

    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
Back to Top