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

XAxis with more than 200 points shows date as 12/30/1899

1 Answer 44 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Boots
Top achievements
Rank 1
Boots asked on 13 Oct 2011, 03:11 PM
Hello,

I'm hitting a problem when the RadChart is displaying more than 200 points all it displays for date is 12/30/2011.

Here is a quick sample that repeats the problem.

<UserControl 
    x:Class="ChartTest.MainPage"
    mc:Ignorable="d"
    Loaded="UserControl_Loaded"
    d:DesignHeight="300" d:DesignWidth="400">
 
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadChart x:Name="chart">
            <telerik:RadChart.SeriesMappings>
                <telerik:SeriesMapping>
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:AreaSeriesDefinition AxisName="YAxis" ShowItemLabels="False" ShowPointMarks="False">
                            <telerik:AreaSeriesDefinition.InteractivitySettings>
                                <telerik:InteractivitySettings SelectionMode="Single" SelectionScope="Item" HoverScope="Item" />
                            </telerik:AreaSeriesDefinition.InteractivitySettings>
                        </telerik:AreaSeriesDefinition>
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SeriesMapping.ItemMappings>
                        <telerik:ItemMapping FieldName="Date" DataPointMember="XCategory" />
                        <telerik:ItemMapping FieldName="Count" DataPointMember="YValue" />
                    </telerik:SeriesMapping.ItemMappings>
                </telerik:SeriesMapping>
                <telerik:SeriesMapping>
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:LineSeriesDefinition AxisName="SecondYAxis"  ShowItemLabels="False" ShowPointMarks="False">
                            <telerik:LineSeriesDefinition.InteractivitySettings>
                                <telerik:InteractivitySettings SelectionMode="Single" SelectionScope="Item" HoverScope="Item" />
                            </telerik:LineSeriesDefinition.InteractivitySettings>
                        </telerik:LineSeriesDefinition>
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SeriesMapping.ItemMappings>
                        <telerik:ItemMapping FieldName="Date" DataPointMember="XCategory" />
                        <telerik:ItemMapping FieldName="Quantity" DataPointMember="YValue" />
                    </telerik:SeriesMapping.ItemMappings>
                </telerik:SeriesMapping>
            </telerik:RadChart.SeriesMappings>
            <telerik:RadChart.DefaultView>
                <telerik:ChartDefaultView ChartLegendPosition="Bottom">
                    <telerik:ChartDefaultView.ChartArea>
                        <telerik:ChartArea LabelFormatBehavior="HumanReadable">
                            <telerik:ChartArea.AxisY>
                                <telerik:AxisY AxisName="YAxis" Title="Deliveries"  />
                            </telerik:ChartArea.AxisY>
                            <telerik:ChartArea.AdditionalYAxes>
                                <telerik:AxisY AxisName="SecondYAxis" Title="Quantity" />
                            </telerik:ChartArea.AdditionalYAxes>
                            <telerik:ChartArea.AxisX>
                                <telerik:AxisX LabelRotationAngle="90" LabelStep="2" DefaultLabelFormat="d"  />
                            </telerik:ChartArea.AxisX>
                        </telerik:ChartArea>
                    </telerik:ChartDefaultView.ChartArea>
                    <telerik:ChartDefaultView.ChartTitle>
                        <telerik:ChartTitle Visibility="Collapsed" />
                    </telerik:ChartDefaultView.ChartTitle>
                    <telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartLegend Visibility="Collapsed" />
                    </telerik:ChartDefaultView.ChartLegend>
                </telerik:ChartDefaultView>
            </telerik:RadChart.DefaultView>
        </telerik:RadChart>
    </Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
 
namespace ChartTest
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
 
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            List<Driver> drivers = new List<Driver>();
            Random random = new Random();
            drivers = Enumerable.Range(0, 200).Select(i => new Driver() { Count = random.Next(), Quantity = random.Next(), Date = DateTime.Now.AddDays(i) }).ToList<Driver>();
            this.chart.ItemsSource = drivers;
        }
    }
 
    public class Driver
    {
        private int _count;
        private double _quantity;
        private DateTime _date;
 
        public int Count
        {
            get { return this._count; }
            set { this._count = value; }
        }
         
        public double Quantity
        {
            get { return this._quantity; }
            set { this._quantity = value; }
        }
         
        public DateTime Date
        {
            get { return this._date; }
            set { this._date = value; }
        }
    }
}

Any idea's what I'm doing wrong?

Thanks much,
~Boots

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 18 Oct 2011, 09:12 AM
Hi Boots,

When there are more then 200 data points, the chart sampling functionality is enabled, also in your case you are using XCategory as a DataPointMember which cannot be sampled, as these values are strings. To resolve that, use XValue instead, or turn off the sampling feature.

More about sampling can be found here.

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