Incorrect DateTime labels

6 posts, 0 answers
  1. SteveL
    SteveL avatar
    68 posts
    Member since:
    Apr 2009

    Posted 08 Apr 2009 Link to this post

    I need to add a data point to a line chart periodically, with intervals between a few seconds and a few minutes. This seems to work OK, except that the date/time labels for all except the first point are strange - and they change.

    My test adds points on a timer as follows:

        private void timer_Tick(object sender, EventArgs e) 
            { 
                DataPoint dataPoint = new DataPoint(); 
     
                dataPoint.XValue = DateTime.Now.ToOADate(); 
                dataPoint.YValue = random.Next(0, 100); 
                dataSeries.Add(dataPoint); 
            } 




    The first point gets the correct date and time, but the second one seems to have 12 hours added to it. When the third point is added, that one has 16 hours added to it, and the second one changes to be only 8 hours ahead, and so on. What am I doing wrong, please?

    My other issue is that every point added gets a label on the X-axis, so after a few points have been added, the axis becomes very messy. How can I stop it labelling every point?

    Steve
  2. Velin
    Admin
    Velin avatar
    391 posts

    Posted 10 Apr 2009 Link to this post

    Hi Steve,

    Unfortunately, RadChart does not provide data binding support for the X axis and that is the reason for the unexpected results you've got. We have considered to implement this functionality in a future release.
     
    Please, accept our apologies for the inconvenience.

    Regards,
    Velin
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Gizi
    Gizi avatar
    1 posts
    Member since:
    Apr 2009

    Posted 19 Apr 2009 Link to this post

    Is there a "workaround" so we can display our date values on the X axis?
    I have to display live exchange rate values which vary every second.
     Gizi
  5. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 21 Apr 2009 Link to this post

    Hi Gizi,

    We have addressed your inquiry in the support ticket labeled "Silveright Chart Time Scale" -- essentially you need to set the actual axis item tick point values like this:

    DataSeries series = new DataSeries();  
    series.Definition = new LineSeriesDefinition();  
    series.Add(new DataPoint(DateTime.Now.ToOADate(), 70));  
    series.Add(new DataPoint(DateTime.Now.AddHours(1).ToOADate(), 50));  
    series.Add(new DataPoint(DateTime.Now.AddHours(2).ToOADate(), 60));  
      
    RadChart1.DefaultView.ChartArea.DataSeries.Add(series);  
      
    for (int index = 0; index < RadChart1.DefaultView.ChartArea.AxisX.TickPoints.Count; index++)  
    {  
        TickPoint tickPoint = RadChart1.DefaultView.ChartArea.AxisX.TickPoints[index];  
        tickPoint.Label = DateTime.FromOADate(series[index].XValue).ToString("G");  
    }  


    Regards,
    Manuel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. SteveL
    SteveL avatar
    68 posts
    Member since:
    Apr 2009

    Posted 22 Apr 2009 Link to this post

    This is fine so long as your data points are at regular intervals. If they are not, they still get plotted at fixed intervals on the chart. Is there any way to get the X-axis drawn correctly according to the actual times between the points?

    Steve
  7. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 24 Apr 2009 Link to this post

    Hello Steve,

    Unfortunately the current version of the control does not support what we call "strict mode" for the XAxis (that means the control will not respect the XValues passed to it and will always draw linear values).

    We will do our best to address this limitation for the Q2 release in July.


    All the best,
    Manuel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner