WeldProcessRecordPage.razor
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@using DataAcquisition.DataAccess
@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<DataContext> dbContextFactory;
<AntDesign.Charts.Line Data="data" Config="config" />
@code {
[Parameter]
public Guid ProductionId { get; set; }
IEnumerable<object> data = new List<object>();
protected override void OnParametersSet()
{
using var context = dbContextFactory.CreateDbContext();
data = context.WeldProcessRecords.Where(x => x.ProductionId == ProductionId).OrderBy(x => x.CreateTime).ThenBy(x => x.Code).Select(x => new
{
x.CreateTime,
x.Name,
x.Value
}).AsEnumerable().Select(x =>
{
double.TryParse(x.Value, out var val);
var data = new
{
Time = x.CreateTime.ToString("HH:mm:ss"),
x.Name,
Value = Math.Round(val, 1)
};
return data;
}).ToList();
base.OnParametersSet();
}
LineConfig config = new LineConfig
{
Padding = "auto",
XField = "time",
YField = "value",
YAxis = new ValueAxis
{
Label = new BaseAxisLabel()
},
SeriesField = "name"
};
}