Files
WCTDataMiner/src/WCTDataMiner.Wpf/ViewModels/QfodChartViewModel.cs
ssss 52435ab8cd feat(wpf): 实现场景列表加载、筛选与消息导航功能
- ScenarioService新增筛选查询方法和动态筛选选项
- 使用WeakReferenceMessenger实现导入完成通知和导航消息
- ViewModel改为Singleton生命周期确保消息订阅正确工作
- 场景列表支持数据库加载和按维度筛选
- ScenarioId类型从int改为Guid

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 10:23:41 +08:00

67 lines
1.7 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using Microsoft.Extensions.Logging;
using WCTDataMiner.Core.Services;
namespace WCTDataMiner.Wpf.ViewModels;
/// <summary>
/// Qfod 折线图 ViewModel
/// </summary>
public partial class QfodChartViewModel : ObservableObject
{
private readonly ScenarioService _scenarioService;
private readonly ILogger<QfodChartViewModel> _logger;
[ObservableProperty]
private Guid _scenarioId;
[ObservableProperty]
private ISeries[] _series;
[ObservableProperty]
private Axis[] _xAxes;
[ObservableProperty]
private Axis[] _yAxes;
public QfodChartViewModel(
ScenarioService scenarioService,
ILogger<QfodChartViewModel> logger)
{
_scenarioService = scenarioService;
_logger = logger;
// 初始化图表配置
Series = Array.Empty<ISeries>();
XAxes = new Axis[] { new Axis { Name = "Coil Index" } };
YAxes = new Axis[] { new Axis { Name = "Q Value" } };
}
public async Task LoadDataAsync()
{
try
{
// TODO: 从数据库加载 Qfod 数据并构建图表
Series = new ISeries[]
{
new LineSeries<double>
{
Name = "DeltaQ",
Values = new double[] { 25, 30, 28 }
},
new LineSeries<double>
{
Name = "CurrentQ",
Values = new double[] { 45.5, 50.2, 48.8 }
}
};
}
catch (Exception ex)
{
_logger.LogError(ex, "加载 Qfod 图表数据失败: ScenarioId={ScenarioId}", ScenarioId);
}
}
}