GoesSoftware.SuperSDK.Plot 7.14.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package GoesSoftware.SuperSDK.Plot --version 7.14.9
                    
NuGet\Install-Package GoesSoftware.SuperSDK.Plot -Version 7.14.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GoesSoftware.SuperSDK.Plot" Version="7.14.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GoesSoftware.SuperSDK.Plot" Version="7.14.9" />
                    
Directory.Packages.props
<PackageReference Include="GoesSoftware.SuperSDK.Plot" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GoesSoftware.SuperSDK.Plot --version 7.14.9
                    
#r "nuget: GoesSoftware.SuperSDK.Plot, 7.14.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GoesSoftware.SuperSDK.Plot@7.14.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GoesSoftware.SuperSDK.Plot&version=7.14.9
                    
Install as a Cake Addin
#tool nuget:?package=GoesSoftware.SuperSDK.Plot&version=7.14.9
                    
Install as a Cake Tool

SuperSDK.Plot

GoesSoftware.SuperSDK.Plot · v1.0.0 · .NET 9 · Avalonia 11

SuperSDK.Plot 是 SuperSDK 生态的绘图与 SPC 分析 UI 组件库,提供四类即插即用图表控件,每个控件同时支持直接 API 调用GzMessage 消息驱动两种数据注入方式。


安装

通过 NuGet 包引用:

<PackageReference Include="GoesSoftware.SuperSDK.Plot" Version="1.0.0" />

初始化(必须)

在应用 Program.cs 或启动入口的 SuperApp.Initialize() 配置块中注册 Plot 库的托管 UI:

using SuperSDK.App;
using SuperSDK.Plot.UI.CurveDraw;
using SuperSDK.Plot.UI.HistogramChart;
using SuperSDK.Plot.UI.IndividualChart;
using SuperSDK.Plot.UI.MovingRangeChart;

SuperApp.Initialize(app =>
{
    // 注册需要用到的图表窗口(GzWindow 托管,关闭隐藏而非销毁)
    app.AddManagedUI<GzCurveDrawWindow>();
    app.AddManagedUI<GzHistogramChartSettingsWindow>();
    app.AddManagedUI<GzIndividualChartSettingsWindow>();
    app.AddManagedUI<GzMovingRangeChartSettingsWindow>();
});

只注册需要使用的窗口即可,未使用的可以省略。


文件夹结构

SuperSDK.Plot/
  UI/
    CurveDraw/          曲线绘制(View + Window)
    HistogramChart/     直方图(View + SettingsWindow)
    IndividualChart/    个值图 X-Chart(View + SettingsWindow)
    MovingRangeChart/   移动极差图(View + SettingsWindow)
  Messages/             所有 GzMessage 定义
  Models/               图表设置数据模型

一、CurveDraw — 曲线绘制

1.1 GzCurveDrawView(嵌入式 UserControl)

在 AXAML 中直接嵌入:

xmlns:plot="clr-namespace:SuperSDK.Plot.UI.CurveDraw;assembly=SuperSDK.Plot"

<plot:GzCurveDrawView WindowId="chart1"/>
属性 类型 说明
WindowId string? 路由 ID,匹配消息中的 WindowId

1.2 GzCurveDrawWindow(独立弹窗)

继承 GzWindow,支持侧边曲线列表(切换可见性 / 删除单条曲线)。

var win = SuperApp.GetManagedUI<GzCurveDrawWindow>();
win.WindowId = "chart1";
win.Show();

// 直接 API
win.AddCurve("温度", color: "#FF5722", lineWidth: 1.5, showMarkers: false);
win.AppendCurveData("温度", yValues: new[] { 25.1, 25.3, 25.0 });
win.HideCurve("温度", hidden: true);
win.DeleteCurve("温度");
win.ClearCurves();
方法 参数 说明
AddCurve(name, color?, lineWidth, showMarkers) 添加命名曲线
AppendCurveData(curveName, yValues, xValues?) 追加数据点
HideCurve(curveName, hidden) 显示 / 隐藏曲线
DeleteCurve(curveName) 删除曲线
ClearCurves() 清空所有曲线

1.3 消息驱动

PlotCurveDataReady — 一次性批量设置多条曲线
MBus.Pub(new PlotCurveDataReady
{
    Title = "实时监控",
    XLabel = "时间(s)",
    YLabel = "温度(℃)",
    Append = false,   // true = 追加模式,false = 清空重绘
    Series = new List<PlotCurveSeries>
    {
        new() { Name = "通道1", YValues = data1, Color = "#FF5722" },
        new() { Name = "通道2", YValues = data2, Color = "#2196F3" },
    }
});
PlotAddCurve — 动态添加单条曲线
MBus.Pub(new PlotAddCurve
{
    Name        = "压力",
    Color       = "#9C27B0",
    LineWidth   = 2.0,
    ShowMarkers = true,
    WindowId    = "chart1"   // 省略则广播到所有实例
});
PlotAppendCurveData — 追加数据点
MBus.Pub(new PlotAppendCurveData
{
    CurveName = "压力",
    YValues   = new[] { 1.02, 1.05, 0.98 },
    WindowId  = "chart1"
});
PlotHideCurve — 显示 / 隐藏
MBus.Pub(new PlotHideCurve { CurveName = "压力", Hidden = true, WindowId = "chart1" });
PlotDeleteCurve — 删除曲线
MBus.Pub(new PlotDeleteCurve("压力") { WindowId = "chart1" });
PlotClearCurves — 清空全部曲线
MBus.Pub(new PlotClearCurves());

二、HistogramChart — 直方图

2.1 GzHistogramChartView(嵌入式 UserControl)

xmlns:plot="clr-namespace:SuperSDK.Plot.UI.HistogramChart;assembly=SuperSDK.Plot"

<plot:GzHistogramChartView x:Name="HistChart" WindowId="hist1"/>

直接 API:

HistChart.SetData(
    title:   "工序A 直方图",
    counts:  new double[] { 2, 8, 15, 20, 18, 12, 5 },
    binEdges: new double[] { 9.5, 10.0, 10.5, 11.0, 11.5, 12.0, 12.5, 13.0 },
    mean:    11.2,
    usl:     12.5,
    lsl:     9.5
);
参数 类型 说明
title string 图表标题
counts double[] 各分箱计数(Y 轴高度)
binEdges double[] 分箱边界值(长度 = counts.Length + 1)
mean double? 均值竖线(可选)
usl double? 规格上限竖线(可选)
lsl double? 规格下限竖线(可选)

2.2 消息驱动 — PlotSetHistogramData

MBus.Pub(new PlotSetHistogramData
{
    Title          = "工序A 直方图",
    HistogramCounts = new double[] { 2, 8, 15, 20, 18, 12, 5 },
    BinEdges       = new double[] { 9.5, 10.0, 10.5, 11.0, 11.5, 12.0, 12.5, 13.0 },
    Mean           = 11.2,
    USL            = 12.5,
    LSL            = 9.5,
    WindowId       = "hist1"   // 省略则广播到所有实例
});

三、IndividualChart — 个值图(X-Chart)

3.1 GzIndividualChartView(嵌入式 UserControl)

xmlns:plot="clr-namespace:SuperSDK.Plot.UI.IndividualChart;assembly=SuperSDK.Plot"

<plot:GzIndividualChartView x:Name="XChart" WindowId="xchart1"/>

直接 API:

XChart.SetData(
    title:    "尺寸 X",
    values:   new double[] { 10.1, 10.3, 9.9, 10.2, 10.4 },
    mean:     10.18,
    ucl:      10.62,
    lcl:       9.74,
    usl:      10.8,
    lsl:       9.6,
    itemName: "直径(mm)"
);
参数 类型 说明
title string 图表标题
values double[] 时序数据
mean double? 均值控制线(绿色)
ucl / lcl double? 上 / 下控制限(红色)
usl / lsl double? 规格上 / 下限(橙色)
itemName string? 图例标签
rowIndices int[]? X 轴自定义行索引(可选)

3.2 消息驱动 — PlotSetIndividualData

MBus.Pub(new PlotSetIndividualData
{
    Title    = "尺寸 X",
    ItemName = "直径(mm)",
    Values   = new double[] { 10.1, 10.3, 9.9, 10.2, 10.4 },
    Mean     = 10.18,
    UCL      = 10.62,
    LCL      =  9.74,
    USL      = 10.8,
    LSL      =  9.6,
    WindowId = "xchart1"
});

四、MovingRangeChart — 移动极差图(MR-Chart)

4.1 GzMovingRangeChartView(嵌入式 UserControl)

xmlns:plot="clr-namespace:SuperSDK.Plot.UI.MovingRangeChart;assembly=SuperSDK.Plot"

<plot:GzMovingRangeChartView x:Name="MrChart" WindowId="mr1"/>

直接 API:

MrChart.SetData(
    title:        "移动极差",
    movingRanges: new double[] { 0.2, 0.4, 0.3, 0.2, 0.5 },
    mrMean:       0.32,
    mrUCL:        1.05
);
参数 类型 说明
title string 图表标题
movingRanges double[] 移动极差数组
mrMean double? 极差均值线(绿色)
mrUCL double? 极差上控制限(红色)

4.2 消息驱动 — PlotSetMovingRangeData

MBus.Pub(new PlotSetMovingRangeData
{
    Title        = "移动极差",
    MovingRanges = new double[] { 0.2, 0.4, 0.3, 0.2, 0.5 },
    MrMean       = 0.32,
    MrUCL        = 1.05,
    WindowId     = "mr1"
});

消息汇总

消息类 触发方向 说明
PlotCurveDataReady 外部 → View 批量设置多曲线数据(支持追加)
PlotAddCurve 外部 → View/Window 动态添加单条曲线
PlotAppendCurveData 外部 → View/Window 向已有曲线追加数据点
PlotHideCurve 外部 → View/Window 显示 / 隐藏指定曲线
PlotDeleteCurve 外部 → View/Window 删除指定曲线
PlotClearCurves 外部 → View/Window 清空所有曲线
PlotSetHistogramData 外部 → View 设置直方图数据
PlotSetIndividualData 外部 → View 设置个值图数据
PlotSetMovingRangeData 外部 → View 设置移动极差图数据
PlotSpcSettingsChanged 设置窗口 → 外部 用户在设置窗口确认后广播(可订阅)

WindowId 路由规则:消息的 WindowIdnull 时广播到所有匹配类型的实例;非空时仅路由到 WindowId 相同的控件实例。

多实例示例

同一页面放多个独立的曲线图:


<plot:GzCurveDrawView WindowId="pressure" />
<plot:GzCurveDrawView WindowId="temperature" />
// 只给压力图追加数据
MBus.Pub(new PlotAppendCurveData { CurveName = "P1", YValues = pressureData, WindowId = "pressure" });

// 只给温度图追加数据
MBus.Pub(new PlotAppendCurveData { CurveName = "T1", YValues = tempData,     WindowId = "temperature" });

// 广播幸一两个图同时清空(WindowId 省略时)
MBus.Pub(new PlotClearCurves());

数据模型(Models)

PlotIndividualChartSettings

属性 默认值 说明
DataLineWidth 0.8f 数据线宽
ControlLineWidth 1.0f 控制限线宽
SpecLineWidth 1.0f 规格限线宽
MarkerSize 3.0f 数据点标记大小
DataLineColor #0000FF 数据线颜色
MeanLineColor #008000 均值线颜色
ControlLimitColor #FF0000 控制限线颜色
SpecLimitColor #FF8000 规格限线颜色
TitleFontSize 14f 标题字号

PlotMovingRangeChartSettings

属性 默认值 说明
DataLineWidth 0.8f 数据线宽
ControlLineWidth 1.0f 控制限线宽
MarkerSize 3.0f 数据点标记大小
DataLineColor #0000FF 数据线颜色
MeanLineColor #008000 极差均值线颜色
ControlLimitColor #FF0000 UCL 线颜色
TitleFontSize 14f 标题字号

PlotHistogramChartSettings

属性 默认值 说明
NormalCurveLineWidth 2.0f 正态曲线线宽
MeanLineWidth 1.5f 均值线宽
SpecLineWidth 1.5f 规格限线宽
NormalCurveColor #FF5722 正态曲线颜色
MeanLineColor #008000 均值线颜色
SpecLimitColor #FF0000 规格限颜色
BarFillColor #2196F3 柱体填充颜色
TitleFontSize 14f 标题字号

PlotCurveDrawSettings(数据库实体)

属性 默认值 说明
Id GUID 主键
WindowId "default" 对应 GzCurveDrawView.WindowId,多实例各存一条
Title "Curve Chart" 图表标题
XLabel "" X 轴标签
YLabel "" Y 轴标签
ShowGrid true 显示网格
ShowLegend true 显示图例
TitleFontSize 6f 标题字号
LabelFontSize 5f 轴标签字号
DefaultLineWidth 1.5 新曲线默认线宽
DefaultShowMarkers false 新曲线默认显示数据标记
DisplayModeValue 0 显示模式(0=追加,1=示波器)
BufferSize 2000 示波器模式缓冲区大小(点数)

DatabaseName = "PlotSettings"TableName = "CurveDrawSettings",存储在 PlotSettings.db


数据持久化(可选)

PlotCurveDrawSettings 实现了 IEntity / IDatabaseEntity / ITableEntity 接口,可通过 SuperSDK.Data 持久化曲线图表的用户设置。

注册步骤

在应用启动时(Program.csSuperApp.Initialize 之后、DbContextFactory.EnsureInitialized() 之前)注册:

using SuperSDK.Data;
using SuperSDK.Plot.Models;

// 注册 CurveDraw 设置实体(如需持久化图表配置则添加此行)
DbContextFactory.RegisterEntity<PlotCurveDrawSettings>();

// 初始化所有已注册实体
DbContextFactory.EnsureInitialized();

读写示例

using SuperSDK.Data;
using SuperSDK.Plot.Models;

// 加载指定 WindowId 的设置(不存在时返回 null)
var saved = EntityStore.FindFirst<PlotCurveDrawSettings>(s => s.WindowId == "chart1");

// 保存 / 更新
if (saved == null)
    EntityStore.Insert(new PlotCurveDrawSettings { WindowId = "chart1", Title = "实时监控" });
else
{
    saved.Title = "实时监控";
    EntityStore.Update(saved);
}

如果应用无需持久化图表配置,可以跳过本节,CurveDraw 控件仍可正常使用(设置仅在内存中有效)。


所有图表控件自动跟随 SuperSDK.UI.ThemeManager 的明暗主题切换,无需额外配置。


依赖

说明
ScottPlot / ScottPlot.Avalonia 5.x 图表渲染引擎
Avalonia 11.x UI 框架
Semi.Avalonia 主题组件
SuperSDK.Core 消息总线 MessageBus
SuperSDK.App SuperApp 生命周期管理
SuperSDK.UI GzWindowThemeManager、控件库
SuperSDK.Data 图表设置持久化(PlotCurveDrawSettings 实体)
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.15.0 0 4/12/2026
7.14.12 0 4/12/2026
7.14.11 0 4/12/2026
7.14.9 0 4/12/2026
7.14.8 0 4/12/2026
7.14.7 0 4/12/2026
7.14.6 0 4/12/2026
7.14.5 0 4/12/2026
7.14.3 0 4/11/2026
7.14.2 0 4/11/2026
7.14.0 33 4/10/2026

test demo