Home › Forums › WinForms controls › Xceed Chart for WinForms › Another DateTime axis question
-
AuthorPosts
-
#18722 |
Im trying to create a chart that shows a line series with values over time.
I have created the line series, and set the x-axis to DateTime, eg.
//Format datetime axis
Axis xaxis = Chart.Charts[0].Axis(StandardAxis.PrimaryX);
xaxis.ScaleMode = AxisScaleMode.DateTime;
xaxis.ValueFormatting.Format = ValueFormat.CustomDateTime;
xaxis.ValueFormatting.CustomFormat = “DD/MM/YYYY hh:mm”;I am adding values with eg.
AddXY(value, Timestamp.ToOADate())This works fine, and I can add new values OK and they are displayed correctly. However, I want to automatically scroll the
chart when more than eg. 100 values are displayed. I tried to use the code from the examples eg.if (m_Line1.Values.Count > nMaxCount)
{
int nCount = m_Line1.Values.Count – nMaxCount;
m_Line1.Values.RemoveRange(0, nCount);
m_Line2.Values.RemoveRange(0, nCount);
this.Chart.Charts[0].Axis(StandardAxis.PrimaryX).Labels.RemoveRange(0, nCount); //Exception – Count = 0
}but it seems that i have no labels since the axis is set to DateTime.
How do I go about setting/refreshing the x-axis to the first DateTime value in the updated data set? If i dont change any properties on the axis, and simply delete the values the chart screws up (displaying values in the wrong location). Is there any automatic way to remove both the X/Y values and update the chart?
thx
SteveImported from legacy forums. Posted by steve (had 2751 views)
First, you must make sure you set the line series to use the XValues when you first set it up :
<i>
m_Line1.UseXValues = true;
</i>
Second, you must also remove the XValues from the line series :
<i>
m_Line1.Values.RemoveRange(0, nCount);
m_Line1.XValues.RemoveRange(0, nCount);
chartControl1.Refresh();
</i>
This way, the chart will continue to display the DataPoints at the corresponding location on the DateTime axis.Imported from legacy forums. Posted by André (had 178 views)
Great. That fixed it. Thanks for the quick response.
/steve
Imported from legacy forums. Posted by steve (had 3671 views)
-
AuthorPosts
- You must be logged in to reply to this topic.