using CommunityToolkit.Mvvm.ComponentModel; using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using Microsoft.Extensions.Logging; using WCTDataMiner.Core.Services; namespace WCTDataMiner.Wpf.ViewModels; /// /// Qfod 折线图 ViewModel /// public partial class QfodChartViewModel : ObservableObject { private readonly ScenarioService _scenarioService; private readonly ILogger _logger; [ObservableProperty] private Guid _scenarioId; [ObservableProperty] private ISeries[] _series; [ObservableProperty] private Axis[] _xAxes; [ObservableProperty] private Axis[] _yAxes; public QfodChartViewModel( ScenarioService scenarioService, ILogger logger) { _scenarioService = scenarioService; _logger = logger; // 初始化图表配置 Series = Array.Empty(); 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 { Name = "DeltaQ", Values = new double[] { 25, 30, 28 } }, new LineSeries { Name = "CurrentQ", Values = new double[] { 45.5, 50.2, 48.8 } } }; } catch (Exception ex) { _logger.LogError(ex, "加载 Qfod 图表数据失败: ScenarioId={ScenarioId}", ScenarioId); } } }