WeldProcessRecordPage.razor 1.03 KB
@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).Select(x => new
        {
            Time = x.CreateTime,
            x.Name,
            x.Value
        }).ToList();
        base.OnParametersSet();
    }

    LineConfig config = new LineConfig
        {
            Padding = "auto",
            XField = "Time",
            YField = "Value",
            YAxis = new ValueAxis
            {
                Label = new BaseAxisLabel()
            },
            Legend = new Legend
            {
                Position = "right-top"
            },
            SeriesField = "Name"
        };
}