There is a bug when presenting multiple dataseries (DateTime) with different starting points.
All series are shifted to the same starting point (to the left).
The bug is easy to reproduce, and I have attached some sample code (updated for better formatting).
Is this possible to get around?
Also, is there a way to get a smaller presentation (eg. day/month/yr) of the dates along the x-axis? (so they do not overlap).
Best regards,
Tomas Wangen.
Window1.xaml
All series are shifted to the same starting point (to the left).
The bug is easy to reproduce, and I have attached some sample code (updated for better formatting).
Is this possible to get around?
Also, is there a way to get a smaller presentation (eg. day/month/yr) of the dates along the x-axis? (so they do not overlap).
Best regards,
Tomas Wangen.
Window1.xaml
| <Window x:Class="GraphTest.Window1" |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" |
| Title="Window1" Height="400" Width="600" Loaded="Window_Loaded"> |
| <Grid> |
| <telerik:RadChart x:Name="MainChart"></telerik:RadChart> |
| </Grid> |
| </Window> |
Window1.xaml.cs
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Text; |
| using System.Windows; |
| using System.Windows.Controls; |
| using System.Windows.Data; |
| using System.Windows.Documents; |
| using System.Windows.Input; |
| using System.Windows.Media; |
| using System.Windows.Media.Imaging; |
| using System.Windows.Navigation; |
| using System.Windows.Shapes; |
| using Telerik.Windows.Controls.Charting; |
| namespace GraphTest |
| { |
| /// <summary> |
| /// Interaction logic for Window1.xaml |
| /// </summary> |
| public partial class Window1 : Window |
| { |
| public Window1() |
| { |
| InitializeComponent(); |
| } |
| class DataEntry |
| { |
| public DateTime dt { get; set; } |
| public double value { get; set; } |
| } |
| private void Window_Loaded(object sender, RoutedEventArgs e) |
| { |
| MainChart.DefaultView.ChartArea.AxisX.IsDateTime = true; |
| ISeriesDefinition definition = new StackedBarSeriesDefinition(); |
| DataSeries dataSeries1 = new DataSeries() { Definition = definition }; |
| DataSeries dataSeries2 = new DataSeries() { Definition = definition }; |
| DateTime time1 = DateTime.Today; |
| DateTime time2 = time1 + new TimeSpan(1, 0, 0, 0); |
| DateTime time3 = time2 + new TimeSpan(1, 0, 0, 0); |
| DateTime time4 = time3 + new TimeSpan(1, 0, 0, 0); |
| List<DataEntry> testData1 = new List<DataEntry>() { |
| new DataEntry() { dt = time1, value = 10.0 }, |
| new DataEntry() { dt = time2, value = 15.0 }, |
| new DataEntry() { dt = time3, value = 20.0 }}; |
| // notice that testData2 is shiftet 24 hrs from testData1 |
| List<DataEntry> testData2 = new List<DataEntry>() { |
| new DataEntry() { dt = time2, value = 30.0 }, |
| new DataEntry() { dt = time3, value = 40.0 }, |
| new DataEntry() { dt = time4, value = 20.0 }}; |
| foreach (DataEntry entry in testData1) |
| dataSeries1.Add( new DataPoint(entry.dt) { YValue = (double)entry.value }); |
| foreach (DataEntry entry in testData2) |
| dataSeries2.Add(new DataPoint(entry.dt) { YValue = (double)entry.value }); |
| MainChart.DefaultView.ChartArea.DataSeries.Add(dataSeries1); |
| MainChart.DefaultView.ChartArea.DataSeries.Add(dataSeries2); |
| } |
| } |
| } |