0
我在表單應用程序中處理實時數據。我的數據將會實時工作,並且會隨着示波器的波動而滑動。用oxyplot進行表格應用的實時數據圖表
我該怎麼做?我只是看到庫文檔中的Wpf示例,但我必須工作表單應用程序。
我是oxyplot的新手。對不起,如果我錯了
另外,我可以使用另一個圖庫,如果你建議。
在此先感謝
我在表單應用程序中處理實時數據。我的數據將會實時工作,並且會隨着示波器的波動而滑動。用oxyplot進行表格應用的實時數據圖表
我該怎麼做?我只是看到庫文檔中的Wpf示例,但我必須工作表單應用程序。
我是oxyplot的新手。對不起,如果我錯了
另外,我可以使用另一個圖庫,如果你建議。
在此先感謝
我假設你正在使用Visual Studio中創建一個WinForms應用程序。如果是這種情況,我會使用工具箱中的數據下的Chart工具代替OxyPlot。當您將其拖動時,默認情況下名稱將爲Chart1。它還將添加一個通用系列。以下功能將生成平滑曲線:
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);
}
}
}
問題是什麼? –