图表x轴显示优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using OxyPlot.Series;
|
||||
using OxyPlot;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Prism.Mvvm;
|
||||
using NCalc;
|
||||
@@ -52,7 +53,7 @@ namespace UIShare.UIViewModel
|
||||
|
||||
// ===== 数据存储 =====
|
||||
/// <summary>所有采样数据点(线程安全),与 OxyPlot 无关</summary>
|
||||
public ConcurrentQueue<(double Time, double RawValue, double DisplayValue)> DataPoints { get; } = new();
|
||||
public ConcurrentQueue<(DateTime Time, double RawValue, double DisplayValue)> DataPoints { get; } = new();
|
||||
|
||||
/// <summary>最大缓冲数据点数,超出则丢弃最旧的</summary>
|
||||
public int MaxBuffer { get; set; } = 5000;
|
||||
@@ -67,7 +68,7 @@ namespace UIShare.UIViewModel
|
||||
|
||||
// ===== 辅助方法 =====
|
||||
/// <summary>记录一个数据点:RawValue 经数学变换后得到 DisplayValue,一并入队</summary>
|
||||
public void Record(double time, double rawValue)
|
||||
public void Record(DateTime time, double rawValue)
|
||||
{
|
||||
double displayValue = rawValue;
|
||||
|
||||
@@ -82,7 +83,7 @@ namespace UIShare.UIViewModel
|
||||
// 如果正在显示,同步到 Series
|
||||
if (_series != null)
|
||||
{
|
||||
_series.Points.Add(new DataPoint(time, displayValue));
|
||||
_series.Points.Add(new DataPoint(time.ToOADate(), displayValue));
|
||||
while (_series.Points.Count > 10000)
|
||||
{
|
||||
_series.Points.RemoveAt(0);
|
||||
|
||||
Reference in New Issue
Block a user