Problem with autorange on a Y axis

4 posts, 0 answers
  1. Bruno
    Bruno avatar
    6 posts
    Member since:
    Mar 2011

    Posted 15 Apr 2011 Link to this post

    Hi, I have a chart that is being carried out by two sets of data,consisting of dates and decimal values​​, where dates are mapped to the X axis and the values ​​for the Y axis. A series of data has null values ​​and the other contains contains random decimal values​​.

    When the first series to be loaded is the one with null values​​, the variation of the Y-axis scale is not recalculated automatically and  the base value (minimum) axis is always zero.

    I need that the minimum value be recalculated dynamically according to data from the two curves drawn on the chart.

    Please check the attached image.


    Thank you for your attention!
  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 20 Apr 2011 Link to this post

    Hello Bruno,
    The result you describe is expected, because in the calculations for the AutoRange functionality, the null values are treated as 0. In this case, I would recommend that after the chart is databound, you check all data points in the DataSeries collection of the chart and remove those series that contain only null points. For example:
    void RadChart1_DataBound(object sender, ChartDataBoundEventArgs e)
    {
        Func<DataPoint, bool> pointPredicate = point => point.YValue == 0;
        var dataSeries = RadChart1.DefaultView.ChartArea.DataSeries.Where(item => item.ToList().All(pointPredicate));
        foreach (DataSeries series in dataSeries)
        {
            series.Definition.Visibility = SeriesVisibility.Collapsed;
        }
    }


    The other approach that you can use, it not to use the AutoRange option and define the values of the YAxis manually. Please refer to our online documentation for information how to do this - http://www.telerik.com/help/silverlight/radchart-features-axes-overview.html.

    Regards,
    Tsvetie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Andre
    Andre avatar
    31 posts
    Member since:
    Feb 2011

    Posted 20 Apr 2011 Link to this post

    Hi Tsvetie,

    I believe this could be considered a problem for many applications.

    Zero is a valid value. Something has zero as a value, it could be one, two, whatever, but it's zero.
    Null is different from zero. Null is when something has no value. It means you don't have an Y value for that X.

    It's the same issue that took you to implement EmptyPointBehavior = Gap for line series.

    That being said, AutoRange should never consider null in it's calculations. It's just wrong to assume null as zero as explained above.

    Using a function to remove all series where all their YValues equal zero would remove both all-null-series and all-zero-series, which is wrong since all-zero-series are valid series.

    I believe that users setting EmptyPointBehavior = Gap expect this behavior for AutoRange as well.

    Please, let me know what your thoughts are.

    Cheers,

    André Carlucci
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 26 Apr 2011 Link to this post

    Hi Andre,

    Indeed, you have a valid point here. Presently, the control behaves as described, due to the null values, and their internal handling. We will keep your feedback in mind, when improving this behavior in the future. Presently, you can turn off the autorange for the YAxis, to eliminate this behavior.

    Greetings,
    Yavor
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top