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

Incorrect X values of data points in line series

3 Answers 56 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 09 Dec 2010, 02:05 PM
Hi,

Our users have discovered that the X values of data points in line series charts are not always correct. See attached picture of a simple plot of 7 data points. The labels are correct, but notice that the points (2,2), (5,4) and (6,6) are not in the correct position on the X axis.

I hope you agree that incorrectly-plotted data is a serious issue - if this is a bug please fix urgently. Apologies if we are doing something wrong in the chart setup. The chart was created using the following simple XAML:

<telerik:RadChart Height="480" HorizontalAlignment="Left" Name="chart" VerticalAlignment="Top" Width="640" />

And the following code behind:

public MainPage()
{
    InitializeComponent();
 
    chart.SeriesMappings.Add(CreateSeriesMapping());
    chart.ItemsSource = CreateSeries();
 
    chart.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible;
    chart.DefaultView.ChartArea.AxisX.MinorGridLinesVisibility = Visibility.Visible;
    chart.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Visible;
    chart.DefaultView.ChartArea.AxisY.MinorGridLinesVisibility = Visibility.Visible;
}
 
private SeriesMapping CreateSeriesMapping()
{
    SeriesMapping seriesMapping = new SeriesMapping();
    LineSeriesDefinition lineSeriesDefinition = new LineSeriesDefinition();
    lineSeriesDefinition.ItemLabelFormat = "#X, #Y";
    seriesMapping.SeriesDefinition = lineSeriesDefinition;
 
    seriesMapping.ItemMappings.Add(new ItemMapping("Key", DataPointMember.XValue));
    seriesMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
 
    return seriesMapping;
}
 
private List<KeyValuePair<int, int>> CreateSeries()
{
    List<KeyValuePair<int, int>> series = new List<KeyValuePair<int, int>>();
    series.Add(new KeyValuePair<int, int>(0, 1));
    series.Add(new KeyValuePair<int, int>(2, 2));
    series.Add(new KeyValuePair<int, int>(1, 3));
    series.Add(new KeyValuePair<int, int>(5, 4));
    series.Add(new KeyValuePair<int, int>(3, 5));
    series.Add(new KeyValuePair<int, int>(6, 6));
    series.Add(new KeyValuePair<int, int>(4, 7));
    return series;
}

It seems that there is difficulty whenever a data point's X value is less than the previous data point's X value. I even wondered whether the line is able to go "backwards" at all - we have managed to do this, but with interesting results (e.g. the same position in the graph being labelled twice!).

Regards

Ed

3 Answers, 1 is accepted

Sort by
0
Edward
Top achievements
Rank 1
answered on 09 Dec 2010, 03:42 PM
Just to say that we have worked around this by simply sorting the series by X value. Fortunately we actually have a scatter chart so the order of the data points doesn't matter - the workaround wouldn't be valid for a line chart.

Ed
0
Evgeni "Zammy" Petrov
Telerik team
answered on 14 Dec 2010, 10:24 AM
Hello Edward,

 This bug has been fixed in our weekly builds and it should be out with SP1.

All the best,
Evgeni "Zammy" Petrov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Edward
Top achievements
Rank 1
answered on 14 Dec 2010, 12:14 PM
Many thanks indeed for the quick response.

Regards

Ed
Tags
Chart
Asked by
Edward
Top achievements
Rank 1
Answers by
Edward
Top achievements
Rank 1
Evgeni "Zammy" Petrov
Telerik team
Share this question
or