first commit -push
This commit is contained in:
122
RobotNet.WebApp/Dashboard/Components/TaktTimeLineChart.razor
Normal file
122
RobotNet.WebApp/Dashboard/Components/TaktTimeLineChart.razor
Normal file
@@ -0,0 +1,122 @@
|
||||
@using RobotNet.Script.Shares.Dashboard
|
||||
@using RobotNet.WebApp.Charts.Components
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
@using RobotNet.WebApp.Charts.Models.Common
|
||||
@using RobotNet.WebApp.Charts.Models.Common.Dataset
|
||||
@using RobotNet.WebApp.Charts.Models.LineChart
|
||||
@using RobotNet.WebApp.Charts.Enums
|
||||
|
||||
<div class="paper">
|
||||
<LineChart @ref="ChartRef" Width="100" WidthUnit="Unit.Percentage" Height="100" HeightUnit="Unit.Percentage" Style="height: 30vh; width: 50vw" />
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private LineChart ChartRef = default!;
|
||||
private LineChartOptions ChartOptions = default!;
|
||||
private ChartData ChartData = default!;
|
||||
|
||||
private TaktTimeMissionDto[] DataParam = [];
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
var minDataset = new LineChartDataset() { Label = "Min", BackgroundColor = [ChartColors.ColorList[0]], BorderColor = [ChartColors.ColorList[0]], Data = [..DataParam.Select(d => d.Min)]};
|
||||
var AverageDataset = new LineChartDataset() { Label = "Average", BackgroundColor = [ChartColors.ColorList[1]], BorderColor = [ChartColors.ColorList[1]], Data = [.. DataParam.Select(d => d.Average)] };
|
||||
var maxDataset = new LineChartDataset() { Label = "Max", BackgroundColor = [ChartColors.ColorList[2]], BorderColor = [ChartColors.ColorList[2]], Data = [.. DataParam.Select(d => d.Max)] };
|
||||
ChartData = new ChartData { Labels = [.. DataParam.Select(d => d.Label)], Datasets = [minDataset, AverageDataset, maxDataset] };
|
||||
|
||||
ChartOptions = new()
|
||||
{
|
||||
Responsive = true,
|
||||
Interaction = new() { Mode = InteractionMode.Index, Intersect = false },
|
||||
Scales = new()
|
||||
{
|
||||
X = new()
|
||||
{
|
||||
Title = new()
|
||||
{
|
||||
Text = "Day",
|
||||
Display = true,
|
||||
Color = "#d6d6db",
|
||||
},
|
||||
Grid = new()
|
||||
{
|
||||
Display = false,
|
||||
},
|
||||
Ticks = new()
|
||||
{
|
||||
Color = "#d6d6db"
|
||||
}
|
||||
},
|
||||
Y = new()
|
||||
{
|
||||
Title = new()
|
||||
{
|
||||
Text = "Minute",
|
||||
Display = true,
|
||||
Color = "#d6d6db",
|
||||
},
|
||||
Grid = new()
|
||||
{
|
||||
Display = false,
|
||||
},
|
||||
Ticks = new()
|
||||
{
|
||||
Color = "#d6d6db"
|
||||
}
|
||||
},
|
||||
},
|
||||
Plugins = new()
|
||||
{
|
||||
Datalabels = new()
|
||||
{
|
||||
Display = false,
|
||||
},
|
||||
Legend = new()
|
||||
{
|
||||
Display = true,
|
||||
Labels = new()
|
||||
{
|
||||
Color = "#d6d6db",
|
||||
Font = new()
|
||||
{
|
||||
Family = "Roboto",
|
||||
Weight = "normal",
|
||||
Size = 15,
|
||||
},
|
||||
}
|
||||
},
|
||||
Title = new()
|
||||
{
|
||||
FullSize = false,
|
||||
Color = "#d6d6db",
|
||||
Text = "AMR Takt Time",
|
||||
Font = new()
|
||||
{
|
||||
Family = "Roboto",
|
||||
Size = 20,
|
||||
Weight = "normal",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
await ChartRef.InitializeAsync(chartData: ChartData, chartOptions: ChartOptions);
|
||||
}
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
public async Task UpdateData(TaktTimeMissionDto[] dataParam)
|
||||
{
|
||||
var minDataset = new LineChartDataset() { Label = "Min", BackgroundColor = [ChartColors.ColorList[0]], BorderColor = [ChartColors.ColorList[0]], Data = [.. dataParam.Select(d => d.Min)] };
|
||||
var AverageDataset = new LineChartDataset() { Label = "Average", BackgroundColor = [ChartColors.ColorList[1]], BorderColor = [ChartColors.ColorList[1]], Data = [.. dataParam.Select(d => d.Average)] };
|
||||
var maxDataset = new LineChartDataset() { Label = "Max", BackgroundColor = [ChartColors.ColorList[2]], BorderColor = [ChartColors.ColorList[2]], Data = [.. dataParam.Select(d => d.Max)] };
|
||||
ChartData = new ChartData { Labels = [.. dataParam.Select(d => d.Label)], Datasets = [minDataset, AverageDataset, maxDataset] };
|
||||
|
||||
await ChartRef.UpdateValuesAsync(ChartData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user