aardio调用OxyPlot画波形图曲线

By admin at 2022-11-23 • 1人收藏 • 1703人看过

screenshots.gif

_images/example1.png

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();


示例工程下载:

Debug.zip


image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png


10 个回复 | 最后更新于 2023-06-21
2022-11-23   #1

现在画图的dll越来越多了

2022-11-23   #2

实时更新数据:

GIF.gif

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();


2022-11-23   #3

2022-11-25   #4

漂亮

2023-05-30   #5

一次性显示几十万个数据用什么曲线控件比较好

2023-05-30   #6

回复#5 @zhlzhang :

scottplot官方演示里说500w不卡顿

image.png

如果要求性能更高, 用

lightningchat , 使用gpu绘图, 速度杠杠的, 三维图都及其流畅

2023-06-02   #7

对于C#中添加水平线的方法,通过查询官方文档和API,可以使用OxyPlot.Annotations.LineAnnotation中的LineAnnotation类来添加Y轴上的水平直线。具体步骤如下:

创建LineAnnotation对象,并设置好其Type属性为LineAnnotationType.Horizontal,表示这是一条水平线。

var lineAnnotation = new LineAnnotation()
{
     Type = LineAnnotationType.Horizontal
};
  1. 指定水平线的位置,可以使用X或Y属性来指定该线所在的坐标轴的坐标位置,例如:

lineAnnotation.X = 0.5; // 表示该水平线在X=0.5位置
lineAnnotation.Y = 50; // 表示该水平线在Y=50的位置


屏幕截图 2023-06-05 091301.png



image.png

大佬,我是下载这个Debug.zip的例子,一点都没改变,直接运行的,但是报错,我查找了半天,也对着您附图的代码看了,没找到错误,请指导下,非常感谢微信截图_20230619140935.png微信截图_20230619141300.png


当前已输入76个字符, 您还可以输入59924个字符。


2023-06-20   #9

回复#8 @鸿湖重工业株式会社 :

你下载的是顶楼的那个吗?

我刚刚又下载运行了下, 没问题, 

image.png


这个是c#编写的dll , 所以需要c# .net framework runtime 运行时,  我估计你电脑中没用安装这个运行时.

这个dll需要电脑中安装  .net Framework 4.5以上才能正常使用.

[assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]

你下载安装下应该就可以了

回复#9 @admin :

谢谢大佬,我下载安装这个framework后,再次下载顶楼的示例工程Debug,运行成功了,非常感谢大佬。

看来是电脑系统的问题。

我这几天一直在研究官方文档,学习到一些基本用法。

登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...