ScottPlot5 Blazor WebAssembly测试

本文介绍了如何在BlazorWebAssembly环境中使用ScottPlot5创建图表,并测试了20条曲线下的性能,发现随着曲线数量增加,性能下降。同时提到中文显示存在异常,尚未解决。
摘要由CSDN通过智能技术生成

ScottPlot5 Blazor WebAssembly测试

ScottPlot5 是.Net的一个图表控件库;支持WPF,WindowsForm,Avalonia, Eto, WinUI, Blazor(仅WebAssembly),本次测试只有BlazorWebAssembly,其他的官网有;
ScottPlot5 Github地址;本文章源码
本人还测试了ScottPlot5在Avalonia环境下在安卓,Windows,Linux各个平台上正常运行且无中文显示问题; ScottPlot5测试文章

步骤

  1. 使用.Net8创建名为BlazorApp1的Web工程并选择混合渲染模式
  2. Client工程引用如下三个包
<PackageReference Include="ScottPlot.Blazor" Version="5.0.18" />
<PackageReference Include="SkiaSharp" Version="2.88.7" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="2.88.7" />
  1. 写代码
  2. 启动BlazorApp1工程

关键代码

  1. Blazor界面
@page "/scottplot5"
@rendermode InteractiveWebAssembly
@using ScottPlot
@using ScottPlot.Blazor
<h5>
    ScottPlot5 Test:
    <InputNumber @bind-Value="LineCount"></InputNumber>
    <button class="btn btn-primary" @onclick="StartPlot">Start</button>
</h5>
<BlazorPlot Style="width:100%;height:80%;" @ref="plot"></BlazorPlot>
  1. 界面cs脚本
    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;
    }
  1. 效果
    本人电脑配置i5-1035G1,浏览器:Chrome 120.0.6099.225
    20条曲线的情况下刚开始有20FPS,后面只有8FPS,性能较低
    在这里插入图片描述

已知问题

  1. 中文显示异常,暂时无法解决
  • 19
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

文光山石

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值