染色机计算机
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.

150 lines
6.3 KiB

using LiveChartsCore.SkiaSharpView;
using LiveChartsCore;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static DyeingComputer.UserClass.SqliteHelper;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.SkiaSharpView.Painting;
using ScottPlot.Colormaps;
using System.Drawing;
using System.Windows.Media.TextFormatting;
using System.Xml.Linq;
using SkiaSharp;
using LiveChartsCore.Defaults;
using static System.Net.WebRequestMethods;
namespace DyeingComputer.ViewModel
{
public partial class CurveDiagramViewModel : ObservableObject//ViewModelBase
{
public ISeries[] Series { get; set; } =
{
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"2",
Values = new DateTimePoint[]
{
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 24),
new DateTimePoint(Convert.ToDateTime( "2024-01-02 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-03 09:08:00"), 67),
new DateTimePoint(Convert.ToDateTime( "2024-01-04 09:08:00"), 32),
new DateTimePoint(Convert.ToDateTime( "2024-01-05 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-06 09:08:00"), 27),
new DateTimePoint(Convert.ToDateTime( "2024-01-07 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-8 09:08:00"), 17),
},
Stroke = new SolidColorPaint(s_blue, 2),
GeometrySize = 1,
GeometryStroke = new SolidColorPaint(s_blue, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
},
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"2",
Values = new DateTimePoint[]
{
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 424),
new DateTimePoint(Convert.ToDateTime( "2024-01-02 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-03 09:08:00"), 647),
new DateTimePoint(Convert.ToDateTime( "2024-01-04 09:08:00"), 532),
new DateTimePoint(Convert.ToDateTime( "2024-01-05 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-06 09:08:00"), 287),
new DateTimePoint(Convert.ToDateTime( "2024-01-07 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-8 09:08:00"), 17),
},
Fill = null,
Stroke = new SolidColorPaint(s_blue, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue, 2),
LineSmoothness = 0,
ScalesYAt = 0,
},
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Flowmeter,
Values = new DateTimePoint[]
{
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 4),
new DateTimePoint(Convert.ToDateTime( "2024-01-02 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-03 09:08:00"), 647),
new DateTimePoint(Convert.ToDateTime( "2024-01-04 09:08:00"), 5732),
new DateTimePoint(Convert.ToDateTime( "2024-01-05 09:08:00"), 5457),
new DateTimePoint(Convert.ToDateTime( "2024-01-06 09:08:00"), 2257),
new DateTimePoint(Convert.ToDateTime( "2024-01-07 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-8 09:08:00"), 517),
},
Fill = null,
Stroke = new SolidColorPaint(s_red, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_red, 2),
LineSmoothness = 0,
ScalesYAt = 1,
}
};
//x轴时间格式
public Axis[] XAxes { get; set; } =
{
new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("yyyy-MM-dd HH:mm"))
{
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);
private static readonly SKColor s_yellow = new SKColor(198, 167, 0);
public ICartesianAxis[] YAxes { get; set; } ={
new Axis //y在此轴上缩放
{
Name = Properties.Resources.Temperature +" ( °C )",
NameTextSize = 24,
NamePaint = new SolidColorPaint(s_blue),
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
Padding = new LiveChartsCore.Drawing.Padding(0, 0, 20, 0),
TextSize = 16,
LabelsPaint = new SolidColorPaint(s_blue),
TicksPaint = new SolidColorPaint(s_blue),
SubticksPaint = new SolidColorPaint(s_blue),
DrawTicksPath = true,
CrosshairSnapEnabled = true
},//温度轴
new Axis // the "hundreds" series will be scaled on this axis
{
Name = Properties.Resources.Flowmeter +" ( L )",
NameTextSize = 24,
NamePaint = new SolidColorPaint(s_red),
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
Padding = new LiveChartsCore.Drawing.Padding(20, 0, 0, 0),
TextSize = 16,
LabelsPaint = new SolidColorPaint(s_red),
TicksPaint = new SolidColorPaint(s_red),
SubticksPaint = new SolidColorPaint(s_red),
DrawTicksPath = true,
ShowSeparatorLines = false,
CrosshairSnapEnabled = true,
Position = LiveChartsCore.Measure.AxisPosition.End
}, //液位轴
};
public CurveDiagramViewModel()
{
}
}
}