98 lines
2.7 KiB
Plaintext
98 lines
2.7 KiB
Plaintext
@using ApexCharts
|
|
@using Newtonsoft.Json
|
|
@using UI_SequentMicrosystems.Components
|
|
@using UI_SequentMicrosystems.Services
|
|
@using UI_SequentMicrosystems.Models
|
|
|
|
@inject RTD8TMService _RTD8TMService
|
|
|
|
@if (_RTD8TMService.GetActualData().Keys.Count > 0)
|
|
{
|
|
if (false)
|
|
{
|
|
<div>
|
|
<input type="text" class="form-control form-control-sm bg-black text-white no-border" placeholder="Json syntax with Chart Points" @onchange="((x) => ChartPointsAdd(x.Value.ToString()))">
|
|
</div>
|
|
}
|
|
|
|
<ApexChart TItem="RTD8TMPointModel"
|
|
Title="Temperature"
|
|
Options="chartOptions"
|
|
@ref="chart">
|
|
|
|
@foreach (byte stack in _RTD8TMService.GetActualData().Keys)
|
|
{
|
|
for (byte chanel = 0; chanel < 8; chanel++)
|
|
{
|
|
if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
|
|
{
|
|
//Console.WriteLine($"Chart Data: Stack: {stack} | Chanel: {chanel} | {JsonConvert.SerializeObject(_RTD8TMService.GetChartData(stack, chanel))}");
|
|
|
|
<ApexPointSeries TItem="RTD8TMPointModel"
|
|
Items="@_RTD8TMService.GetChartData(stack, chanel)"
|
|
Name="@(_RTD8TMService.GetChanelName(stack, chanel))"
|
|
SeriesType="SeriesType.Line"
|
|
XValue="@(e => e.Time.ToString("HH:mm:ss"))"
|
|
YValue="@(e => (decimal)e.Value)"
|
|
OrderBy="e=>e.X" />
|
|
|
|
}
|
|
}
|
|
}
|
|
</ApexChart>
|
|
}
|
|
|
|
|
|
@code {
|
|
private ApexChart<RTD8TMPointModel> chart;
|
|
private ApexChartOptions<RTD8TMPointModel> chartOptions;
|
|
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
_RTD8TMService.EventUpdateGraph += UpdateChart;
|
|
|
|
chartOptions = new ApexChartOptions<RTD8TMPointModel>
|
|
{
|
|
Theme = new Theme
|
|
{
|
|
Mode = Mode.Dark,
|
|
},
|
|
Legend = new Legend
|
|
{
|
|
Position = LegendPosition.Bottom,
|
|
FontSize = "15px",
|
|
HorizontalAlign = Align.Center
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
public async Task UpdateChart(object? o, bool b)
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
chart.UpdateSeriesAsync(false);
|
|
|
|
StateHasChanged();
|
|
|
|
});
|
|
}
|
|
|
|
public void ChartPointsAdd(string points)
|
|
{
|
|
_RTD8TMService.SetChartData(JsonConvert.DeserializeObject<SortedList<byte, List<List<RTD8TMPointModel>>>>(points));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|