From 65c7232efa55e73a15bb6c8f79b88ddd7546900d Mon Sep 17 00:00:00 2001 From: "David P.G" Date: Fri, 3 Oct 2025 11:58:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8VariableHistoryView=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=E5=9B=BE=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/VariableHistoryViewModel.cs | 38 ++++++++++--------- DMS.WPF/Views/VariableHistoryView.xaml | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/DMS.WPF/ViewModels/VariableHistoryViewModel.cs b/DMS.WPF/ViewModels/VariableHistoryViewModel.cs index e55597a..0f5de0a 100644 --- a/DMS.WPF/ViewModels/VariableHistoryViewModel.cs +++ b/DMS.WPF/ViewModels/VariableHistoryViewModel.cs @@ -108,21 +108,21 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable private void OnVariableValueChanged(object? sender, VariableValueChangedEventArgs e) { - if (e.Variable.Id != CurrentVariable.Id) - { - return; - } - - var variableHistory = new VariableHistoryDto() - { - VariableId = CurrentVariable.Id, - Timestamp = DateTime.Now, - Value = e.Variable.DataValue - }; - _variableHistoryList.Add(variableHistory); - - // 更新图表数据 - UpdateChartData(); + // if (e.Variable.Id != CurrentVariable.Id) + // { + // return; + // } + // + // var variableHistory = new VariableHistoryDto() + // { + // VariableId = CurrentVariable.Id, + // Timestamp = DateTime.Now, + // Value = e.Variable.DataValue + // }; + // _variableHistoryList.Add(variableHistory); + // + // // 更新图表数据 + // UpdateChartData(); } /// @@ -256,11 +256,12 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable // 创建线性序列 var series = new LineSeries { - Name = "变量值", + Name = CurrentVariable?.Name ?? "变量值", Values = values, Fill = null, Stroke = new SolidColorPaint(new SKColor(41, 128, 185)) { StrokeThickness = 2 }, - GeometrySize = 0 // 不显示数据点,只显示线条 + GeometrySize = 6, // 显示数据点,圆点大小为6 + LineSmoothness = 0 // 使用直线连接点,也可以设为其他值实现曲线 }; // 更新序列集合 @@ -279,7 +280,8 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable { new Axis { - Name = "值" + Name = CurrentVariable?.Name ?? "值", + MinLimit = 0 // 设置Y轴从0开始 } }; diff --git a/DMS.WPF/Views/VariableHistoryView.xaml b/DMS.WPF/Views/VariableHistoryView.xaml index ca955a1..d9a6ae9 100644 --- a/DMS.WPF/Views/VariableHistoryView.xaml +++ b/DMS.WPF/Views/VariableHistoryView.xaml @@ -120,7 +120,7 @@ SelectionMode="Single" Style="{StaticResource DataGridBaseStyle}"> - +