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

Wrong values shown using large data set

1 Answer 55 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Brendan
Top achievements
Rank 1
Brendan asked on 15 Aug 2011, 06:54 AM
I am trying to chart data with around 20k - 40k records, however I have noticed the data shown on the chart is incorrect. Below is a simple example which replicates the issue and I've also attached a screenshot.

There are two problems:
  1. Even though the values are integers, the chart displays them as floating point numbers.
  2. When one value or a small set is a much different range then the rest, the chart displays a completely wrong value. 
I'm not really bothered too much about the first issue however the second is a major problem as when viewing the data at a glance as per the screenshot, it is wildly inaccurate.
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
     
    <telerik:RadGridView x:Name="GridData" Grid.Row="0" />
 
    <telerik:RadChart x:Name="ChartData" Grid.Row="1">               
        <telerik:RadChart.SeriesMappings>
            <telerik:SeriesMapping>
                 
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:LineSeriesDefinition ShowPointMarks="False" />
                </telerik:SeriesMapping.SeriesDefinition>
                 
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="XValue" FieldName="Row" />
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="Value" />
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
        </telerik:RadChart.SeriesMappings>
    </telerik:RadChart>
</Grid>


public class Data
{
    public int Row { get; set; }
    public int Value { get; set; }
}
 
public partial class MainPage : UserControl
{
    private Random _rand = new Random();
 
    public MainPage()
    {
        InitializeComponent();
 
        List<Data> data = GenerateData().ToList();
 
        for (int i = 5000; i < 5100; ++i)
        {
            data[i].Value = 100;
        }
 
        GridData.ItemsSource = data;
        ChartData.ItemsSource = data;
    }
 
    private IEnumerable<Data> GenerateData()
    {
        for (int i = 1; i < 25000; ++i)
        {
            yield return new Data()
            {
                Row = i,
                Value = RandomNumber()
            };
        }
    }
 
    private int RandomNumber()
    {
        return _rand.Next(400, 450);
    }
}

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 17 Aug 2011, 03:13 PM
Hello Brendan,

When the chart is populated by thousands of items, the visual representation might not be that clear. It is possible that there are two or more DataPoints shown with a very close Y and X values. This is where sampling comes in handy. The chart combines the items, so that the DataPoints are limited to a certain number (200 by default). The sampling engine does not detect/determine whether the datapoints will be on similar pixel coordinates. Instead, it visualizes a subset of the original data.

The value of 164.4 that you see is the average value of a group of items. If you set the SamplingThreshold of 200 and you have 4000 item points then you will have 20 groups each consisted of 200 items.

The way in which RadChart combines the DataPoints depends on the value of the SamplingFunction property of the SamplingSettings. You could also create a custom SamplingFunction.

You can find more about Sampling and Sampling Functions here.

All the best,
Peshito
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Tags
Chart
Asked by
Brendan
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or