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 { /// /// info.xaml 的交互逻辑 /// public partial class info : UserControl { public info() { InitializeComponent(); DataContext = this; //new infoModel(); } public void DataAdd() { } private readonly Random _random = new Random(); private readonly List _values = new List(); private readonly DateTimeAxis _customAxis; public ObservableCollection Series { get; set; } public static ObservableCollection 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 MTH_values; private void UserControl_Loaded(object sender, RoutedEventArgs e) { var MTH_items = new List(); MTH_values = new ObservableCollection(MTH_items); Series = new ObservableCollection { new LineSeries { 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, } }; } } }