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

Incorrect DateTime labels

5 Answers 127 Views
Chart
This is a migrated thread and some comments may be shown as answers.
SteveL
Top achievements
Rank 2
SteveL asked on 08 Apr 2009, 08:18 AM
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

5 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 10 Apr 2009, 02:42 PM
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.
0
Gizi
Top achievements
Rank 1
answered on 19 Apr 2009, 11:23 AM
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
0
Giuseppe
Telerik team
answered on 21 Apr 2009, 09:28 AM
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.
0
SteveL
Top achievements
Rank 2
answered on 22 Apr 2009, 06:50 PM
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
0
Giuseppe
Telerik team
answered on 24 Apr 2009, 10:49 AM
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.
Tags
Chart
Asked by
SteveL
Top achievements
Rank 2
Answers by
Velin
Telerik team
Gizi
Top achievements
Rank 1
Giuseppe
Telerik team
SteveL
Top achievements
Rank 2
Share this question
or