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:
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
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