在VariableHistoryView中增强图表显示
This commit is contained in:
@@ -108,21 +108,21 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable
|
|||||||
|
|
||||||
private void OnVariableValueChanged(object? sender, VariableValueChangedEventArgs e)
|
private void OnVariableValueChanged(object? sender, VariableValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Variable.Id != CurrentVariable.Id)
|
// if (e.Variable.Id != CurrentVariable.Id)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var variableHistory = new VariableHistoryDto()
|
// var variableHistory = new VariableHistoryDto()
|
||||||
{
|
// {
|
||||||
VariableId = CurrentVariable.Id,
|
// VariableId = CurrentVariable.Id,
|
||||||
Timestamp = DateTime.Now,
|
// Timestamp = DateTime.Now,
|
||||||
Value = e.Variable.DataValue
|
// Value = e.Variable.DataValue
|
||||||
};
|
// };
|
||||||
_variableHistoryList.Add(variableHistory);
|
// _variableHistoryList.Add(variableHistory);
|
||||||
|
//
|
||||||
// 更新图表数据
|
// // 更新图表数据
|
||||||
UpdateChartData();
|
// UpdateChartData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -256,11 +256,12 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable
|
|||||||
// 创建线性序列
|
// 创建线性序列
|
||||||
var series = new LineSeries<DateTimePoint>
|
var series = new LineSeries<DateTimePoint>
|
||||||
{
|
{
|
||||||
Name = "变量值",
|
Name = CurrentVariable?.Name ?? "变量值",
|
||||||
Values = values,
|
Values = values,
|
||||||
Fill = null,
|
Fill = null,
|
||||||
Stroke = new SolidColorPaint(new SKColor(41, 128, 185)) { StrokeThickness = 2 },
|
Stroke = new SolidColorPaint(new SKColor(41, 128, 185)) { StrokeThickness = 2 },
|
||||||
GeometrySize = 0 // 不显示数据点,只显示线条
|
GeometrySize = 6, // 显示数据点,圆点大小为6
|
||||||
|
LineSmoothness = 0 // 使用直线连接点,也可以设为其他值实现曲线
|
||||||
};
|
};
|
||||||
|
|
||||||
// 更新序列集合
|
// 更新序列集合
|
||||||
@@ -279,7 +280,8 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable
|
|||||||
{
|
{
|
||||||
new Axis
|
new Axis
|
||||||
{
|
{
|
||||||
Name = "值"
|
Name = CurrentVariable?.Name ?? "值",
|
||||||
|
MinLimit = 0 // 设置Y轴从0开始
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@
|
|||||||
SelectionMode="Single"
|
SelectionMode="Single"
|
||||||
Style="{StaticResource DataGridBaseStyle}">
|
Style="{StaticResource DataGridBaseStyle}">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Binding="{Binding Value}" Header="值" />
|
<DataGridTextColumn Binding="{Binding Value}" Header="{Binding DataContext.CurrentVariable.Name, RelativeSource={RelativeSource AncestorType=UserControl}, FallbackValue='值'}" />
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Timestamp, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
|
Binding="{Binding Timestamp, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
|
||||||
Header="时间戳"
|
Header="时间戳"
|
||||||
|
|||||||
Reference in New Issue
Block a user