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

Problem with autorange on a Y axis

3 Answers 75 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 15 Apr 2011, 10:30 PM
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!

3 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 20 Apr 2011, 01:16 PM
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
0
Andre
Top achievements
Rank 1
answered on 20 Apr 2011, 07:33 PM
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
0
Yavor
Telerik team
answered on 26 Apr 2011, 07:43 AM
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
Tags
Chart
Asked by
Bruno
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Andre
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or