I have the following graphic in my Windows Form
:
I set the X axis to display Time, as shown below:
Here are the methods I call to
you could set the Format like this:
this.chart1.ChartAreas[0].AxisX.LabelStyle.Format = "mm:ss";
if you have a sampling rate of 4 Hz you could also use seconds and milliseconds:
this.chart1.ChartAreas[0].AxisX.LabelStyle.Format = "ss.fff";
EDIT:
I would suggest to catch the sampling times in an extra List<DateTime>
and feed the chart via AddXY
with values. Here is a simple programm that draws a curve with a timer. The timer is set to 500 msec.
// Constructor
public Form1()
{
InitializeComponent();
// Format
this.chart1.ChartAreas[0].AxisX.LabelStyle.Format = "ss.fff";
// this sets the type of the X-Axis values
chart1.Series[0].XValueType = ChartValueType.DateTime;
timer1.Start();
}
int i = 0;
List<DateTime> TimeList = new List<DateTime>();
private void timer1_Tick(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
TimeList.Add(now);
chart1.Series[0].Points.AddXY(now, Math.Sin(i / 60.0));
i+=2;
}
Now you can watch the x-axis values increment in the format that you like. Hope this helps