代码拉取完成,页面将自动刷新
<PackageReference Include="ScottPlot.Blazor" Version="5.0.18" />
<PackageReference Include="SkiaSharp" Version="2.88.7" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="2.88.7" />
Avalonia是.Net跨平台的UI库,支持Windows,Linux,iOS,MacOS,Android; ScottPlot为跨平台的UI控件库,支持Avalonia,Windows,Eto,WebAssembly等平台
<PackageReference Include="ScottPlot.Avalonia" Version="5.0.20" />
本人电脑配置i5-1035G1,浏览器:Chrome 120.0.6099.225,虚拟机:VMware Workstation 16.2.3 Player;曲线数量20条;
Avalonia On Windows 32FPS
Avalonia On WebAssembly FPS为1,最小化浏览器时不渲染
Avalonia On Linux 在虚拟机中运行FPS为1
Avalonia On Android
<PackageReference Include="ScottPlot.Avalonia" Version="5.0.20" />
<PackageReference Include="ScottPlot.WinForms" Version="5.0.20" />
private void Form1_Load(object? sender, EventArgs e)
{
if (first)
{
StartPlot();
}
first = false;
}
private void StartPlot()
{
InitLines();
if (timer == null)
{
timer = new(); // 每隔1秒触发一次
timer.Interval = 1000;
timer.Tick += TimerElapsed;
timer.Start();
}
}
private void InitLines()
{
if (plot == null) return;
// PlotFont = Fonts.Detect("实时数据");
plot.Plot.Axes.Title.Label.Text = "RealTime Data:实时数据";
plot.Plot.Axes.Title.Label.FontName = PlotFont;
plot.Plot.Clear();
Lines = new LineModel[LineCount];
DateTime start = DateTime.Now;
for (int i = 0; i < LineCount; i++)
{
Lines[i] = new LineModel();
Lines[i].Init(i + 1, plot.Plot, start);
}
plot.Plot.Benchmark.IsVisible = true;
}
public void UpdateData(DateTime ts, double[] data)
{
int Min = Math.Min(data.Length, Lines.Length);
if (Min <= 0) return;
for (int i = 0; i < Min; i++)
{
UpdateData(i, ts, data[i]);
}
Render();
}
private void UpdateData(int i, DateTime ts, double latestValue)
{
var tmp = Lines[i];
tmp.UpdateData(ts, latestValue);
}
public void Render()
{
plot.Plot.Axes.AutoScale();
plot.Refresh();
}
private void TimerElapsed(object? sender, EventArgs e)
{
//InvokeAsync(() =>
double[] data = new double[LineCount];
for (int i = 0; i < LineCount; i++)
{
data[i] = Generate.RandomData.RandomNumber(100);
}
UpdateData(DateTime.Now, data);
}
刚启动时FPS有80,稳定后约50FPS
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。