You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.8 KiB
112 lines
3.8 KiB
using LiveChartsCore;
|
|
using LiveChartsCore.Defaults;
|
|
using LiveChartsCore.Kernel.Sketches;
|
|
using LiveChartsCore.SkiaSharpView;
|
|
using LiveChartsCore.SkiaSharpView.Painting;
|
|
using Newtonsoft.Json.Linq;
|
|
using ScottPlot.Plottables;
|
|
using SkiaSharp;
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Animation;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Media.Media3D;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.UserControls
|
|
{
|
|
/// <summary>
|
|
/// info.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class info : UserControl
|
|
{
|
|
public info()
|
|
{
|
|
InitializeComponent();
|
|
DataContext = this; //new infoModel();
|
|
}
|
|
|
|
public void DataAdd()
|
|
{
|
|
}
|
|
private readonly Random _random = new Random();
|
|
private readonly List<DateTimePoint> _values = new List<DateTimePoint>();
|
|
private readonly DateTimeAxis _customAxis;
|
|
public ObservableCollection<ISeries> Series { get; set; }
|
|
public static ObservableCollection<ObservableValue> ObservableValues { get; set; }
|
|
|
|
//x轴时间格式
|
|
public Axis[] XAxes { get; set; } =
|
|
{
|
|
new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("HH:mm"))
|
|
{
|
|
MinLimit = DateTime.Now.AddHours(-6).Ticks,
|
|
MaxLimit = DateTime.Now.AddHours(0.5).Ticks,
|
|
CrosshairLabelsBackground = SKColors.DarkGray.AsLvcColor(),
|
|
CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkSlateBlue, 1),
|
|
CrosshairPaint = new SolidColorPaint(SKColors.DarkSlateGray, 1),
|
|
},
|
|
};
|
|
//颜色
|
|
private static readonly SKColor s_blue = new SKColor(25, 118, 210);
|
|
private static readonly SKColor s_red = new SKColor(229, 57, 53);
|
|
public ICartesianAxis[] YAxes { get; set; } ={
|
|
new Axis //y在此轴上缩放
|
|
{
|
|
MinLimit =0,
|
|
MaxLimit =160,
|
|
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
|
|
Padding = new LiveChartsCore.Drawing.Padding(0, 0, 20, 0),
|
|
TextSize = 12,
|
|
LabelsPaint = new SolidColorPaint(s_blue),
|
|
TicksPaint = new SolidColorPaint(s_blue),
|
|
SubticksPaint = new SolidColorPaint(s_blue),
|
|
DrawTicksPath = true,
|
|
CrosshairSnapEnabled = true,
|
|
Position = LiveChartsCore.Measure.AxisPosition.Start
|
|
},//温度轴
|
|
|
|
};
|
|
|
|
private static ObservableCollection<DateTimePoint> MTH_values;
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
var MTH_items = new List<DateTimePoint>();
|
|
MTH_values = new ObservableCollection<DateTimePoint>(MTH_items);
|
|
|
|
Series = new ObservableCollection<ISeries>
|
|
{
|
|
new LineSeries<DateTimePoint>
|
|
{
|
|
Name = Properties.Resources.Temperature,
|
|
Values = MTH_values,
|
|
Stroke = new SolidColorPaint(s_red, 2),
|
|
GeometrySize = 0,
|
|
GeometryStroke = new SolidColorPaint(s_red, 2),
|
|
Fill = null,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 2,
|
|
}
|
|
};
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|