aardio调用OxyPlot画波形图曲线
By
admin
at 2022-11-23 • 1人收藏 • 513人看过
OxyPlot是一款开源免费的波形图绘制控件,功能包括 柱状图,饼图,热力图,曲线图 ,由c#编写, 漂亮稳定流畅是它的特点, 更多参数请参考官方文档:
https://oxyplot.readthedocs.io/en/latest/index.html
鼠标右键长按拖动 , 左键长按显示单点数据 , 鼠标中键长按拖动缩放框选区域, 双击鼠标中键重置波形图.
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=658;bottom=429;bgcolor=10789024) winform.add( custom={cls="custom";text="自定义控件";left=23;top=21;right=634;bottom=410;bgcolor=12639424;db=1;dl=1;dr=1;dt=1;z=1} ) /*}}*/ import dotNet import System.Windows.Forms; //声明 var Plotdll = dotNet.load("/OxyPlot.dll"); var Formsdll = dotNet.load("/OxyPlot.WindowsForms.dll"); //绑定窗体 var plotView1 = Formsdll.new("OxyPlot.WindowsForms.PlotView"); System.Windows.Forms.CreateEmbed(plotView1,winform.custom); var OxyPlot = Plotdll.import("OxyPlot"); var myModel = OxyPlot.PlotModel(); myModel.Title = "OxyPlot Example 1"; myModel.Background=OxyPlot.OxyColors.White; //模拟数据 var lines = OxyPlot.Series.LineSeries(); //lines.LabelFormatString = "{1}";//格式化显示每个数据点值 lines.Title = "line1"; lines.Color = OxyPlot.OxyColors.Orange; lines.StrokeThickness = 2; lines.MarkerSize = 3; lines.MarkerStroke = OxyPlot.OxyColors.DarkGreen; lines.MarkerType = OxyPlot.MarkerType.Diamond; for(i=0;30 + 0.1 * 0.5;0.1){ var point = OxyPlot.DataPoint(i, math.cos(i)); lines.Points.Add(point); } myModel.Series.Add(lines); //显示 plotView1.Model = myModel; //实例图例对象 var legend = OxyPlot.Legends.Legend(); //将图例对象添加到绘图模块中 plotView1.Model.Legends.Add(legend); winform.show(); win.loopMessage();
示例工程下载:
4 个回复 | 最后更新于 2022-11-25
实时更新数据:
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=658;bottom=491;bgcolor=10789024) winform.add( button={cls="button";text="动起来";left=123;top=437;right=493;bottom=484;db=1;dl=1;dr=1;z=2}; custom={cls="custom";text="自定义控件";left=23;top=21;right=634;bottom=410;bgcolor=12639424;db=1;dl=1;dr=1;dt=1;z=1} ) /*}}*/ import dotNet import System.Windows.Forms; //声明 var Plotdll = dotNet.load("/OxyPlot.dll"); var Formsdll = dotNet.load("/OxyPlot.WindowsForms.dll"); //绑定窗体 var plotView1 = Formsdll.new("OxyPlot.WindowsForms.PlotView"); System.Windows.Forms.CreateEmbed(plotView1,winform.custom); var OxyPlot = Plotdll.import("OxyPlot"); var myModel = OxyPlot.PlotModel(); myModel.Title = "OxyPlot Example 1"; myModel.Background=OxyPlot.OxyColors.White; //模拟数据 var lines = OxyPlot.Series.LineSeries(); lines.Title = "line1"; lines.Color = OxyPlot.OxyColors.Orange; lines.StrokeThickness = 2; lines.MarkerSize = 3; lines.MarkerStroke = OxyPlot.OxyColors.DarkGreen; lines.MarkerType = OxyPlot.MarkerType.Diamond; myModel.Series.Add(lines); //显示 plotView1.Model = myModel; //实例图例对象 var legend = OxyPlot.Legends.Legend(); //将图例对象添加到绘图模块中 plotView1.Model.Legends.Add(legend); var index = 0; winform.button.oncommand = function(id,event){ winform.setInterval( 100,function(){ lines.Points.Add(OxyPlot.DataPoint(index, math.cos(index*0.1))); if (lines.Points.Count > 100) { lines.Points.RemoveAt(0); } index++; plotView1.InvalidatePlot(true); } ); } winform.show(); win.loopMessage();
登录后方可回帖
现在画图的dll越来越多了