Problem with my dates in Axis X

4 posts, 0 answers
  1. Aurélien Dubosson
    Aurélien Dubosson avatar
    38 posts
    Member since:
    Apr 2010

    Posted 20 May 2010 Link to this post

    Hi everyone,

    I have the following problem with my chart :

    I have 4 datas, the value on axis X is DateTime and the value on axis Y is double.

    My datas are the following : 

    2010-03-16T16:56:40 (startTime variable) : 2.21  
    2010-04-16T17:04:40 : 2.51
    2010-05-01T17:04:10 : 3.16
    2010-05-16T17:03:10 (endTime variable) : 4.23

    My chart configuration is the following : 

    SeriesMapping valueMapping = new SeriesMapping();
    valueMapping.ItemMappings.Add(new ItemMapping("Date", DataPointMember.XValue));
    valueMapping.ItemMappings.Add(new ItemMapping("M", DataPointMember.YValue));
    valueMapping.SeriesDefinition = new LineSeriesDefinition();
    Chart.SeriesMappings.Add(valueMapping);
    Chart.DefaultView.ChartTitle.Content = "M";
    Chart.DefaultView.ChartArea.AxisY.AutoRange = false;
    Chart.DefaultView.ChartArea.AxisY.AddRange(0, 5, 0.5);
    Chart.DefaultView.ChartArea.AxisY.Title = "M values";

    Chart.DefaultView.ChartArea.AxisX.AutoRange=falseChart.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible;
    Chart.DefaultView.ChartArea.AxisX.IsDateTime = true;
    Chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM/yy";
    Chart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 270;
    Chart.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
    Chart.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Visible;
    Chart.DefaultView.ChartArea.AxisY.MinorGridLinesVisibility = Visibility.Visible;
    Chart.DefaultView.ChartArea.AxisY.StripLinesVisibility = Visibility.Collapsed;
    Chart.ItemsSource = dt;
    Chart.DefaultView.ChartArea.AxisX.MinValue = startTime.ToOADate();
    Chart.DefaultView.ChartArea.AxisX.MaxValue = endTime.ToOADate();
    double step = startTime.AddYears(1).ToOADate() - startTime.ToOADate();
    System.Diagnostics.Debug.WriteLine(step);
    Chart.DefaultView.ChartArea.AxisY.AddRange(startTime.ToOADate(), endTime.ToOADate(), step);

    when I start my application, no data appears and I have the "No Dataseries" but with auto-range it's working.

  2. Aurélien Dubosson
    Aurélien Dubosson avatar
    38 posts
    Member since:
    Apr 2010

    Posted 20 May 2010 Link to this post

    I just correct this line  :

    Chart.DefaultView.ChartArea.AxisX.AddRange(startTime.ToOADate(), endTime.ToOADate(), step);

    but it doesn't work. I don't understand why nothing appears ?

  3. Aurélien Dubosson
    Aurélien Dubosson avatar
    38 posts
    Member since:
    Apr 2010

    Posted 21 May 2010 Link to this post

    I try another approach for my problem.

    I keep the autorange in true for axis X.

    But I use the ZoomScrollSettingsX to adapt the graph to display by hours , days, weeks, ..
    My following code : 

    private void Hour_Click(object sender, RoutedEventArgs e)
            {
                double diff = endTime.ToOADate() - startTime.ToOADate();
                double step = startTime.AddHours(1).ToOADate() - startTime.ToOADate();
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 1.0 -(step/diff);
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1.0;
            }

            private void Day_Click(object sender, RoutedEventArgs e)
            {
                double diff = endTime.ToOADate() - startTime.ToOADate();
                double step = startTime.AddDays(1).ToOADate() - startTime.ToOADate();
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 1.0 - (step / diff);
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1.0;
            }

            private void Week_Click(object sender, RoutedEventArgs e)
            {
                double diff = endTime.ToOADate() - startTime.ToOADate();
                double step = startTime.AddDays(7).ToOADate() - startTime.ToOADate();
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 1.0 - (step / diff);
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1.0;
            }

            private void Month_Click(object sender, RoutedEventArgs e)
            {
                double diff = endTime.ToOADate() - startTime.ToOADate();
                double step = startTime.AddMonths(1).ToOADate() - startTime.ToOADate();
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 1.0 - (step / diff);
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1.0;
            }

            private void Year_Click(object sender, RoutedEventArgs e)
            {
                double diff = endTime.ToOADate() - startTime.ToOADate();
                double step = startTime.AddYears(1).ToOADate() - startTime.ToOADate();
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 1.0 - (step / diff);
                Chart.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1.0;
            }

    The problem now it's working when I have at least two points to display the line. In my case for the month and year displays.
    But for one hour, one day, one week I have "No Dataseries" .

    In your example for Chart demo "Chart/ZoomScroll" you can scroll the points, in my case the first point stay in the left and the second in the right. The rest of the line disappears in other side.

    Why the points don't follow when I'm scrolling the bar ?

    Best regards.

    Aurélien Dubosson
  4. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 25 May 2010 Link to this post

    Hello Aurélien,

    Generally, the "No DataSeries..." appears when the chart is zoomed, so that there is no DataPoint within the zoom range. You can find this problem discussed in this forum thread.

    Kind regards,
    Ves
    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.
Back to Top