I work on real time data in a form application. My data will be work real time and it will slides as oscilloscope waves.
How can I do that? I just see Wpf example in library documents but I have to work form application.
I am rookie at oxyplot. Sorry about if I am wrong
Also I can use another graph library if you suggest.
Thanks in advance
I assume you are using Visual Studio creating a WinForms application. If that the case I would use the Chart tool found under Data in the toolbox instead of OxyPlot. When you drag it on, by default the name will be Chart1. It will also have a generic series already added. The following function will generate a smooth curve:
private void GenerateCurve()
{
chart1.ChartAreas[0].Position.Auto = true;
chart1.ChartAreas[0].AxisY.Title = "SIN()";
chart1.ChartAreas[0].AxisX.Title = "Degrees";
// Set graph limits
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisX.Maximum = 200;
chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chart1.ChartAreas[0].AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.FixedCount;
chart1.ChartAreas[0].AxisX.Interval = 90;
chart1.ChartAreas[0].AxisX.MinorTickMark.Enabled = true;
chart1.ChartAreas[0].AxisX.MinorTickMark.Interval = 10;
chart1.ChartAreas[0].AxisY.Minimum = -1;
chart1.ChartAreas[0].AxisY.Maximum = 1;
chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
chart1.ChartAreas[0].AxisY.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.FixedCount;
chart1.ChartAreas[0].AxisY.Interval = .1;
chart1.ChartAreas[0].AxisY.MinorTickMark.Enabled = true;
// Set spline instead of line
chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
// Generate points
for (int x = 0; x < 1000; x++)
{
double y = Math.Sin(x);
chart1.Series[0].Points.AddXY((double)x, Math.Sin(x));
if (chart1.Series[0].Points.Count > 100)
{
chart1.Series[0].Points.RemoveAt(0);
chart1.ChartAreas[0].AxisX.Minimum = chart1.Series[0].Points[0].XValue;
chart1.ChartAreas[0].AxisX.Maximum = x;
Application.DoEvents();
System.Threading.Thread.Sleep(100);
}
}
}