first commit -push
This commit is contained in:
7
RobotNet.WebApp/Charts/Components/BarChart.razor
Normal file
7
RobotNet.WebApp/Charts/Components/BarChart.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div style="@ContainerStyle" class="d-flex justify-content-center align-items-center">
|
||||
<canvas @ref="@Element" id="@Id" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
115
RobotNet.WebApp/Charts/Components/BarChart.razor.cs
Normal file
115
RobotNet.WebApp/Charts/Components/BarChart.razor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.BarChart;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class BarChart : RobotNetChart
|
||||
{
|
||||
public BarChart()
|
||||
{
|
||||
chartType = ChartType.Bar;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<BarChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (BarChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<BarChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (BarChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<BarChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is BarChartDataset barChartDataset && barChartDataset.Label == dataLabel)
|
||||
if (data is BarChartDatasetData barChartDatasetData)
|
||||
{
|
||||
if (barChartDatasetData.Data is double dataValue) barChartDataset.Data?.Add(dataValue);
|
||||
barChartDataset.BackgroundColor?.Add(barChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is BarChartDataset barChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is BarChartDatasetData barChartDatasetData && barChartDatasetData.DatasetLabel == barChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is BarChartDatasetData barChartDatasetData)
|
||||
{
|
||||
if (barChartDatasetData.Data is double dataValue) barChartDataset.Data?.Add(dataValue);
|
||||
barChartDataset.BackgroundColor?.Add(barChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (BarChartDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is BarChartDataset barChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(barChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, barChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Components/BubbleChart.razor
Normal file
7
RobotNet.WebApp/Charts/Components/BubbleChart.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div style="@ContainerStyle">
|
||||
<canvas @ref="@Element" id="@Id" width="@Width" height="@Height" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
115
RobotNet.WebApp/Charts/Components/BubbleChart.razor.cs
Normal file
115
RobotNet.WebApp/Charts/Components/BubbleChart.razor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.BubbleChart;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class BubbleChart : RobotNetChart
|
||||
{
|
||||
public BubbleChart()
|
||||
{
|
||||
chartType = ChartType.Bubble;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<BubbleChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (BubbleChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<BubbleChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (BubbleChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<BubbleChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is BubbleChartDataset bubbleChartDataset && bubbleChartDataset.Label == dataLabel)
|
||||
if (data is BubbleChartDatasetData bubbleChartDatasetData)
|
||||
{
|
||||
if (bubbleChartDatasetData.Data is BubblePoint dataValue) bubbleChartDataset.Data?.Add(dataValue);
|
||||
bubbleChartDataset.BackgroundColor?.Add(bubbleChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is BubbleChartDataset bubbleChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is BubbleChartDatasetData bubbleChartDatasetData && bubbleChartDatasetData.DatasetLabel == bubbleChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is BubbleChartDatasetData bubbleChartDatasetData)
|
||||
{
|
||||
if (bubbleChartDatasetData.Data is BubblePoint dataValue) bubbleChartDataset.Data?.Add(dataValue);
|
||||
bubbleChartDataset.BackgroundColor?.Add(bubbleChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (BubbleChartDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is BubbleChartDataset bubbleChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(bubbleChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, bubbleChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div style="@ContainerStyle">
|
||||
<canvas @ref="@Element" id="@Id" width="@Width" height="@Height" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
115
RobotNet.WebApp/Charts/Components/ComboBarLineChart.razor.cs
Normal file
115
RobotNet.WebApp/Charts/Components/ComboBarLineChart.razor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.ComboBarLineChart;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class ComboBarLineChart : RobotNetChart
|
||||
{
|
||||
public ComboBarLineChart()
|
||||
{
|
||||
chartType = ChartType.Bar;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<ComboBarLineDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (ComboBarLineOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<ComboBarLineDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (ComboBarLineOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<ComboBarLineDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is ComboBarLineDataset comboBarLineChartDataset && comboBarLineChartDataset.Label == dataLabel)
|
||||
if (data is ComboBarLineDatasetData comboBarLineChartDatasetData)
|
||||
{
|
||||
if (comboBarLineChartDatasetData.Data is double dataValue) comboBarLineChartDataset.Data?.Add(dataValue);
|
||||
comboBarLineChartDataset.BackgroundColor?.Add(comboBarLineChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is ComboBarLineDataset comboBarLineChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is ComboBarLineDatasetData comboBarLineChartDatasetData && comboBarLineChartDatasetData.DatasetLabel == comboBarLineChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is ComboBarLineDatasetData comboBarLineChartDatasetData)
|
||||
{
|
||||
if (comboBarLineChartDatasetData.Data is double dataValue) comboBarLineChartDataset.Data?.Add(dataValue);
|
||||
comboBarLineChartDataset.BackgroundColor?.Add(comboBarLineChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (ComboBarLineDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is ComboBarLineDataset comboBarLineChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(comboBarLineChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, comboBarLineChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Components/LineChart.razor
Normal file
7
RobotNet.WebApp/Charts/Components/LineChart.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div class="d-flex justify-content-center align-items-center" style="@ContainerStyle">
|
||||
<canvas @ref="@Element" id="@Id" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
115
RobotNet.WebApp/Charts/Components/LineChart.razor.cs
Normal file
115
RobotNet.WebApp/Charts/Components/LineChart.razor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using RobotNet.WebApp.Charts.Models.LineChart;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class LineChart : RobotNetChart
|
||||
{
|
||||
public LineChart()
|
||||
{
|
||||
chartType = ChartType.Line;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<LineChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (LineChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<LineChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (LineChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<LineChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is LineChartDataset lineChartDataset && lineChartDataset.Label == dataLabel)
|
||||
if (data is LineChartDatasetData lineChartDatasetData)
|
||||
{
|
||||
if (lineChartDatasetData.Data is double dataValue) lineChartDataset.Data?.Add(dataValue);
|
||||
lineChartDataset.BackgroundColor?.Add(lineChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is LineChartDataset lineChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is LineChartDatasetData lineChartDatasetData && lineChartDatasetData.DatasetLabel == lineChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is LineChartDatasetData lineChartDatasetData)
|
||||
{
|
||||
if (lineChartDatasetData.Data is double dataValue) lineChartDataset.Data?.Add(dataValue);
|
||||
lineChartDataset.BackgroundColor?.Add(lineChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (LineChartDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is LineChartDataset lineChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(lineChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, lineChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Components/PieChart.razor
Normal file
7
RobotNet.WebApp/Charts/Components/PieChart.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div class="d-flex justify-content-center" style="@ContainerStyle">
|
||||
<canvas @ref="@Element" id="@Id" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
118
RobotNet.WebApp/Charts/Components/PieChart.razor.cs
Normal file
118
RobotNet.WebApp/Charts/Components/PieChart.razor.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using RobotNet.WebApp.Charts.Models.PieChart;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class PieChart : RobotNetChart
|
||||
{
|
||||
[Parameter]
|
||||
public bool IsDoughnutChart { get; set; } = false;
|
||||
public PieChart()
|
||||
{
|
||||
chartType = IsDoughnutChart ? ChartType.Doughnut : ChartType.Pie;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<PieChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (PieChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<PieChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (PieChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<PieChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is PieChartDataset pieChartDataset && pieChartDataset.Label == dataLabel)
|
||||
if (data is PieChartDatasetData pieChartDatasetData)
|
||||
{
|
||||
if (pieChartDatasetData.Data is double dataValue) pieChartDataset.Data?.Add(dataValue);
|
||||
pieChartDataset.BackgroundColor?.Add(pieChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is PieChartDataset pieChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is PieChartDatasetData pieChartDatasetData && pieChartDatasetData.DatasetLabel == pieChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is PieChartDatasetData pieChartDatasetData)
|
||||
{
|
||||
if (pieChartDatasetData.Data is double dataValue) pieChartDataset.Data?.Add(dataValue);
|
||||
pieChartDataset.BackgroundColor?.Add(pieChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (PieChartDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is PieChartDataset pieChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(pieChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, pieChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Components/PolarAreaChart.razor
Normal file
7
RobotNet.WebApp/Charts/Components/PolarAreaChart.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div style="@ContainerStyle">
|
||||
<canvas @ref="@Element" id="@Id" width="@Width" height="@Height" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
115
RobotNet.WebApp/Charts/Components/PolarAreaChart.razor.cs
Normal file
115
RobotNet.WebApp/Charts/Components/PolarAreaChart.razor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using RobotNet.WebApp.Charts.Models.PolarAreaChart;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class PolarAreaChart : RobotNetChart
|
||||
{
|
||||
public PolarAreaChart()
|
||||
{
|
||||
chartType = ChartType.PolarArea;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<PolarAreaChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (PolarAreaChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<PolarAreaChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (PolarAreaChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<PolarAreaChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is PolarAreaChartDataset polarAreaChartDataset && polarAreaChartDataset.Label == dataLabel)
|
||||
if (data is PolarAreaChartDatasetData polarAreaChartDatasetData)
|
||||
{
|
||||
if (polarAreaChartDatasetData.Data is double dataValue) polarAreaChartDataset.Data?.Add(dataValue);
|
||||
polarAreaChartDataset.BackgroundColor?.Add(polarAreaChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is PolarAreaChartDataset polarAreaChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is PolarAreaChartDatasetData polarAreaChartDatasetData && polarAreaChartDatasetData.DatasetLabel == polarAreaChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is PolarAreaChartDatasetData polarAreaChartDatasetData)
|
||||
{
|
||||
if (polarAreaChartDatasetData.Data is double dataValue) polarAreaChartDataset.Data?.Add(dataValue);
|
||||
polarAreaChartDataset.BackgroundColor?.Add(polarAreaChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (PolarAreaChartDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is PolarAreaChartDataset polarAreaChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(polarAreaChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, polarAreaChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Components/RadarChart.razor
Normal file
7
RobotNet.WebApp/Charts/Components/RadarChart.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div style="@ContainerStyle">
|
||||
<canvas @ref="@Element" id="@Id" width="@Width" height="@Height" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
115
RobotNet.WebApp/Charts/Components/RadarChart.razor.cs
Normal file
115
RobotNet.WebApp/Charts/Components/RadarChart.razor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using RobotNet.WebApp.Charts.Models.RadarChart;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class RadarChart : RobotNetChart
|
||||
{
|
||||
public RadarChart()
|
||||
{
|
||||
chartType = ChartType.Radar;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<RadarChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (RadarChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<RadarChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (RadarChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<RadarChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is RadarChartDataset radarChartDataset && radarChartDataset.Label == dataLabel)
|
||||
if (data is RadarChartDatasetData radarChartDatasetData)
|
||||
{
|
||||
if (radarChartDatasetData.Data is double dataValue) radarChartDataset.Data?.Add(dataValue);
|
||||
radarChartDataset.BackgroundColor?.Add(radarChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is RadarChartDataset radarChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is RadarChartDatasetData radarChartDatasetData && radarChartDatasetData.DatasetLabel == radarChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is RadarChartDatasetData radarChartDatasetData)
|
||||
{
|
||||
if (radarChartDatasetData.Data is double dataValue) radarChartDataset.Data?.Add(dataValue);
|
||||
radarChartDataset.BackgroundColor?.Add(radarChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (RadarChartDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is RadarChartDataset radarChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(radarChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, radarChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Components/ScatterChart.razor
Normal file
7
RobotNet.WebApp/Charts/Components/ScatterChart.razor
Normal file
@@ -0,0 +1,7 @@
|
||||
@using RobotNet.WebApp.Charts.Core
|
||||
|
||||
@inherits RobotNetChart
|
||||
|
||||
<div style="@ContainerStyle">
|
||||
<canvas @ref="@Element" id="@Id" width="@Width" height="@Height" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes"></canvas>
|
||||
</div>
|
||||
115
RobotNet.WebApp/Charts/Components/ScatterChart.razor.cs
Normal file
115
RobotNet.WebApp/Charts/Components/ScatterChart.razor.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Microsoft.JSInterop;
|
||||
using RobotNet.WebApp.Charts.Core;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using RobotNet.WebApp.Charts.Models.ScatterChart;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Components;
|
||||
|
||||
public partial class ScatterChart : RobotNetChart
|
||||
{
|
||||
public ScatterChart()
|
||||
{
|
||||
chartType = ChartType.Scatter;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<ScatterChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.initialize", Id, chartType, data, (ScatterChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ChartData chartData, IChartOptions chartOptions)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<ScatterChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.update", Id, data, (ScatterChartOptions)chartOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateValuesAsync(ChartData chartData)
|
||||
{
|
||||
if (chartData is not null && chartData.Datasets is not null && chartData.Datasets.Count != 0)
|
||||
{
|
||||
var datasets = chartData.Datasets.OfType<ScatterChartDataset>();
|
||||
var data = new { chartData.Labels, Datasets = datasets };
|
||||
await JSRuntime.InvokeVoidAsync("window.blazorChart.updateData", Id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IChartDatasetData data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is ScatterChartDataset scatterChartDataset && scatterChartDataset.Label == dataLabel)
|
||||
if (data is ScatterChartDatasetData scatterChartDatasetData)
|
||||
{
|
||||
if (scatterChartDatasetData.Data is ScatterChartDataPoint dataValue) scatterChartDataset.Data?.Add(dataValue);
|
||||
scatterChartDataset.BackgroundColor?.Add(scatterChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetData", Id, dataLabel, data);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDataAsync(ChartData chartData, string dataLabel, IReadOnlyCollection<IChartDatasetData> data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Labels);
|
||||
ArgumentNullException.ThrowIfNull(dataLabel);
|
||||
ArgumentNullException.ThrowIfNull(data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataLabel))
|
||||
throw new Exception($"{nameof(dataLabel)} cannot be empty.");
|
||||
|
||||
if (data.Count == 0)
|
||||
throw new Exception($"{nameof(data)} cannot be empty.");
|
||||
|
||||
if (chartData.Datasets.Count != data.Count)
|
||||
throw new InvalidDataException("The chart dataset count and the new data points count do not match.");
|
||||
|
||||
if (chartData.Labels.Contains(dataLabel))
|
||||
throw new Exception($"{dataLabel} already exists.");
|
||||
|
||||
chartData.Labels.Add(dataLabel);
|
||||
|
||||
foreach (var dataset in chartData.Datasets)
|
||||
if (dataset is ScatterChartDataset scatterChartDataset)
|
||||
{
|
||||
var chartDatasetData = data.FirstOrDefault(x => x is ScatterChartDatasetData scatterChartDatasetData && scatterChartDatasetData.DatasetLabel == scatterChartDataset.Label);
|
||||
|
||||
if (chartDatasetData is ScatterChartDatasetData scatterChartDatasetData)
|
||||
{
|
||||
if (scatterChartDatasetData.Data is ScatterChartDataPoint dataValue) scatterChartDataset.Data?.Add(dataValue);
|
||||
scatterChartDataset.BackgroundColor?.Add(scatterChartDatasetData.BackgroundColor!);
|
||||
}
|
||||
}
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDatasetsData", Id, dataLabel, data?.Select(x => (ScatterChartDatasetData)x));
|
||||
return chartData;
|
||||
}
|
||||
|
||||
public async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(chartData);
|
||||
ArgumentNullException.ThrowIfNull(chartData.Datasets);
|
||||
ArgumentNullException.ThrowIfNull(chartDataset);
|
||||
|
||||
if (chartDataset is ScatterChartDataset scatterChartDataset)
|
||||
{
|
||||
chartData.Datasets.Add(scatterChartDataset);
|
||||
await JSRuntime.InvokeVoidAsync($"window.blazorChart.addDataset", Id, scatterChartDataset);
|
||||
}
|
||||
|
||||
return chartData;
|
||||
}
|
||||
}
|
||||
149
RobotNet.WebApp/Charts/Core/BlazorComponentBase.cs
Normal file
149
RobotNet.WebApp/Charts/Core/BlazorComponentBase.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Core;
|
||||
|
||||
public abstract class BlazorComponentBase : ComponentBase, IDisposable, IAsyncDisposable
|
||||
{
|
||||
private bool isAsyncDisposed;
|
||||
|
||||
private bool isDisposed;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
IsRenderComplete = true;
|
||||
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Id ??= Guid.NewGuid().ToString();
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
public static string BuildClassNames(params (string? cssClass, bool when)[] cssClassList)
|
||||
{
|
||||
var list = new HashSet<string>();
|
||||
|
||||
if (cssClassList is not null && cssClassList.Length != 0)
|
||||
foreach (var (cssClass, when) in cssClassList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(cssClass) && when)
|
||||
list.Add(cssClass);
|
||||
}
|
||||
|
||||
if (list.Count != 0)
|
||||
return string.Join(" ", list);
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string BuildClassNames(string? userDefinedCssClass, params (string? cssClass, bool when)[] cssClassList)
|
||||
{
|
||||
var list = new HashSet<string>();
|
||||
|
||||
if (cssClassList is not null && cssClassList.Length != 0)
|
||||
foreach (var (cssClass, when) in cssClassList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(cssClass) && when)
|
||||
list.Add(cssClass);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(userDefinedCssClass))
|
||||
list.Add(userDefinedCssClass.Trim());
|
||||
|
||||
if (list.Count != 0)
|
||||
return string.Join(" ", list);
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string BuildStyleNames(string? userDefinedCssStyle, params (string? cssStyle, bool when)[] cssStyleList)
|
||||
{
|
||||
var list = new HashSet<string>();
|
||||
|
||||
if (cssStyleList is not null && cssStyleList.Length != 0)
|
||||
foreach (var (cssStyle, when) in cssStyleList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(cssStyle) && when)
|
||||
list.Add(cssStyle);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(userDefinedCssStyle))
|
||||
list.Add(userDefinedCssStyle.Trim());
|
||||
|
||||
if (list.Count != 0)
|
||||
return string.Join(';', list);
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await DisposeAsyncCore(true).ConfigureAwait(false);
|
||||
|
||||
Dispose(false);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!isDisposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// cleanup
|
||||
}
|
||||
|
||||
isDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual ValueTask DisposeAsyncCore(bool disposing)
|
||||
{
|
||||
if (!isAsyncDisposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// cleanup
|
||||
}
|
||||
|
||||
isAsyncDisposed = true;
|
||||
}
|
||||
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object> AdditionalAttributes { get; set; } = default!;
|
||||
|
||||
[Parameter] public string? Class { get; set; }
|
||||
|
||||
protected virtual string? ClassNames => Class;
|
||||
|
||||
public ElementReference Element { get; set; }
|
||||
|
||||
[Parameter] public string? Id { get; set; }
|
||||
|
||||
protected bool IsRenderComplete { get; private set; }
|
||||
|
||||
[Inject] protected IJSRuntime JSRuntime { get; set; } = default!;
|
||||
|
||||
[Parameter] public string? Style { get; set; }
|
||||
|
||||
protected virtual string? StyleNames => Style;
|
||||
|
||||
~BlazorComponentBase()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
22
RobotNet.WebApp/Charts/Core/ChartColors.cs
Normal file
22
RobotNet.WebApp/Charts/Core/ChartColors.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace RobotNet.WebApp.Charts.Core;
|
||||
|
||||
public static class ChartColors
|
||||
{
|
||||
public static readonly System.Drawing.Color RedRGB = System.Drawing.Color.FromArgb(255, 0, 0);
|
||||
public static readonly System.Drawing.Color YellowRGB = System.Drawing.Color.FromArgb(230, 162, 60);
|
||||
public static readonly System.Drawing.Color GreenRGB = System.Drawing.Color.FromArgb(0, 204, 0);
|
||||
public static readonly System.Drawing.Color OrangeRGB = System.Drawing.Color.FromArgb(255, 102, 0);
|
||||
public static readonly System.Drawing.Color GrayRGB = System.Drawing.Color.FromArgb(147, 147, 147);
|
||||
|
||||
public static readonly string RedStr = "#ff0000";
|
||||
public static readonly string YellowStr = "#e6a23c";
|
||||
public static readonly string GreenStr = "#00cc00";
|
||||
public static readonly string OrangeStr = "#ff6600";
|
||||
public static readonly string GrayStr = "#939393";
|
||||
public static readonly string BlueSkyStr = "#29a3ff";
|
||||
public static readonly string BlueStr = "#223771";
|
||||
public static readonly string Robot01Str = "#6300bd";
|
||||
public static readonly string Robot02Str = "#8a2e47";
|
||||
|
||||
public static readonly List<string> ColorList = [Robot01Str, Robot02Str, BlueSkyStr, GrayStr, OrangeStr];
|
||||
}
|
||||
80
RobotNet.WebApp/Charts/Core/RobotNetChart.cs
Normal file
80
RobotNet.WebApp/Charts/Core/RobotNetChart.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Globalization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Core;
|
||||
|
||||
public class RobotNetChart : BlazorComponentBase, IDisposable, IAsyncDisposable
|
||||
{
|
||||
internal ChartType chartType;
|
||||
|
||||
/// <inheritdoc />
|
||||
public new virtual void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public new virtual async ValueTask DisposeAsync()
|
||||
{
|
||||
await DisposeAsyncCore(true);
|
||||
Dispose(false);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private string GetChartContainerSizeAsStyle()
|
||||
{
|
||||
var style = "";
|
||||
|
||||
if (Width > 0)
|
||||
style += $"width:{Width.Value.ToString(CultureInfo.InvariantCulture)}{WidthUnit.ToCssString()};";
|
||||
|
||||
if (Height > 0)
|
||||
style += $"height:{Height.Value.ToString(CultureInfo.InvariantCulture)}{HeightUnit.ToCssString()};";
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
internal string ContainerStyle => GetChartContainerSizeAsStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets chart container height.
|
||||
/// The default unit of measure is <see cref="Unit.Px" />.
|
||||
/// To change the unit of measure see <see cref="HeightUnit" />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is null.
|
||||
/// </remarks>
|
||||
[Parameter]
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets chart container height unit of measure.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see cref="Unit.Px" />.
|
||||
/// </remarks>
|
||||
[Parameter]
|
||||
public Unit HeightUnit { get; set; } = Unit.Px;
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets chart container width.
|
||||
/// The default unit of measure is <see cref="Unit.Px" />.
|
||||
/// To change the unit of measure see <see cref="WidthUnit" />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is null.
|
||||
/// </remarks>
|
||||
[Parameter]
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets chart container width unit of measure.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see cref="Unit.Px" />.
|
||||
/// </remarks>
|
||||
[Parameter]
|
||||
public Unit WidthUnit { get; set; } = Unit.Px;
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/AxisDirection.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/AxisDirection.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<AxisDirection>))]
|
||||
public enum AxisDirection
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
XY
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Enums/BorderAlign.cs
Normal file
7
RobotNet.WebApp/Charts/Enums/BorderAlign.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
public enum BorderAlign
|
||||
{
|
||||
Center,
|
||||
Inner
|
||||
}
|
||||
12
RobotNet.WebApp/Charts/Enums/BorderJoinStyle.cs
Normal file
12
RobotNet.WebApp/Charts/Enums/BorderJoinStyle.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<BorderJoinStyle>))]
|
||||
public enum BorderJoinStyle
|
||||
{
|
||||
Round,
|
||||
Bevel,
|
||||
Miter
|
||||
}
|
||||
17
RobotNet.WebApp/Charts/Enums/BorderSkipped.cs
Normal file
17
RobotNet.WebApp/Charts/Enums/BorderSkipped.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<BorderSkipped>))]
|
||||
public enum BorderSkipped
|
||||
{
|
||||
Start,
|
||||
End,
|
||||
Middle,
|
||||
Bottom,
|
||||
Left,
|
||||
Top,
|
||||
Right,
|
||||
False,
|
||||
True
|
||||
}
|
||||
13
RobotNet.WebApp/Charts/Enums/ChartAxesType.cs
Normal file
13
RobotNet.WebApp/Charts/Enums/ChartAxesType.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<ChartAxesType>))]
|
||||
public enum ChartAxesType
|
||||
{
|
||||
Linear,
|
||||
Logarithmic,
|
||||
Category,
|
||||
Time,
|
||||
Timeseries,
|
||||
}
|
||||
17
RobotNet.WebApp/Charts/Enums/ChartType.cs
Normal file
17
RobotNet.WebApp/Charts/Enums/ChartType.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(CamelCaseEnumConverter<ChartType>))]
|
||||
public enum ChartType
|
||||
{
|
||||
Line,
|
||||
Bar,
|
||||
Pie,
|
||||
Doughnut,
|
||||
PolarArea,
|
||||
Radar,
|
||||
Scatter,
|
||||
Bubble
|
||||
}
|
||||
|
||||
16
RobotNet.WebApp/Charts/Enums/DataLabelsAlignment.cs
Normal file
16
RobotNet.WebApp/Charts/Enums/DataLabelsAlignment.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<DataLabelsAlignment>))]
|
||||
public enum DataLabelsAlignment
|
||||
{
|
||||
Center,
|
||||
Start,
|
||||
End,
|
||||
Right,
|
||||
Bottom,
|
||||
Left,
|
||||
Top,
|
||||
None
|
||||
}
|
||||
12
RobotNet.WebApp/Charts/Enums/DataLabelsAnchoring.cs
Normal file
12
RobotNet.WebApp/Charts/Enums/DataLabelsAnchoring.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<DataLabelsAnchoring>))]
|
||||
public enum DataLabelsAnchoring
|
||||
{
|
||||
Center,
|
||||
Start,
|
||||
End,
|
||||
None,
|
||||
}
|
||||
10
RobotNet.WebApp/Charts/Enums/DatasetType.cs
Normal file
10
RobotNet.WebApp/Charts/Enums/DatasetType.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<DatasetType>))]
|
||||
public enum DatasetType
|
||||
{
|
||||
Bar,
|
||||
Line,
|
||||
}
|
||||
40
RobotNet.WebApp/Charts/Enums/Easing.cs
Normal file
40
RobotNet.WebApp/Charts/Enums/Easing.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<Easing>))]
|
||||
public enum Easing
|
||||
{
|
||||
Linear,
|
||||
EaseInQuad,
|
||||
EaseOutQuad,
|
||||
EaseInOutQuad,
|
||||
EaseInCubic,
|
||||
EaseOutCubic,
|
||||
EaseInOutCubic,
|
||||
EaseInQuart,
|
||||
EaseOutQuart,
|
||||
EaseInOutQuart,
|
||||
EaseInQuint,
|
||||
EaseOutQuint,
|
||||
EaseInOutQuint,
|
||||
EaseInSine,
|
||||
EaseOutSine,
|
||||
EaseInOutSine,
|
||||
EaseInExpo,
|
||||
EaseOutExpo,
|
||||
EaseInOutExpo,
|
||||
EaseInCirc,
|
||||
EaseOutCirc,
|
||||
EaseInOutCirc,
|
||||
EaseInElastic,
|
||||
EaseOutElastic,
|
||||
EaseInOutElastic,
|
||||
EaseInBack,
|
||||
EaseOutBack,
|
||||
EaseInOutBack,
|
||||
EaseInBounce,
|
||||
EaseOutBounce,
|
||||
EaseInOutBounce,
|
||||
}
|
||||
38
RobotNet.WebApp/Charts/Enums/EnumExtensions.cs
Normal file
38
RobotNet.WebApp/Charts/Enums/EnumExtensions.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
|
||||
public static string? ToChartDatasetDataLabelAlignmentString(this DataLabelsAlignment alignment) =>
|
||||
alignment switch
|
||||
{
|
||||
DataLabelsAlignment.Start => "start",
|
||||
DataLabelsAlignment.Center or DataLabelsAlignment.None => "center", // default
|
||||
DataLabelsAlignment.End => "end",
|
||||
_ => null
|
||||
};
|
||||
|
||||
public static string? ToChartDatasetDataLabelAnchorString(this DataLabelsAnchoring anchor) =>
|
||||
anchor switch
|
||||
{
|
||||
DataLabelsAnchoring.Start => "start",
|
||||
DataLabelsAnchoring.Center or DataLabelsAnchoring.None => "center", // default
|
||||
DataLabelsAnchoring.End => "end",
|
||||
_ => null
|
||||
};
|
||||
|
||||
public static string ToCssString(this Unit unit) =>
|
||||
unit switch
|
||||
{
|
||||
Unit.Em => "em",
|
||||
Unit.Percentage => "%",
|
||||
Unit.Pt => "pt",
|
||||
Unit.Px => "px",
|
||||
Unit.Rem => "rem",
|
||||
Unit.Vh => "vh",
|
||||
Unit.VMax => "vmax",
|
||||
Unit.VMin => "vmin",
|
||||
Unit.Vw => "vw",
|
||||
_ => string.Empty
|
||||
};
|
||||
}
|
||||
10
RobotNet.WebApp/Charts/Enums/IndexAxis.cs
Normal file
10
RobotNet.WebApp/Charts/Enums/IndexAxis.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<IndexAxis>))]
|
||||
public enum IndexAxis
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
}
|
||||
37
RobotNet.WebApp/Charts/Enums/InteractionMode.cs
Normal file
37
RobotNet.WebApp/Charts/Enums/InteractionMode.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<InteractionMode>))]
|
||||
public enum InteractionMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Finds items in the same dataset.
|
||||
/// </summary>
|
||||
Dataset,
|
||||
|
||||
/// <summary>
|
||||
/// Finds item at the same index.
|
||||
/// </summary>
|
||||
Index,
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items that are at the nearest distance to the point.
|
||||
/// </summary>
|
||||
Nearest,
|
||||
|
||||
/// <summary>
|
||||
/// Finds all of the items that intersect the point
|
||||
/// </summary>
|
||||
Point,
|
||||
|
||||
/// <summary>
|
||||
/// Returns all items that would intersect based on the X coordinate of the position only. Would be useful for a vertical cursor implementation. Note that this only applies to cartesian charts.
|
||||
/// </summary>
|
||||
X,
|
||||
|
||||
/// <summary>
|
||||
/// Returns all items that would intersect based on the Y coordinate of the position. This would be useful for a horizontal cursor implementation. Note that this only applies to cartesian charts.
|
||||
/// </summary>
|
||||
Y
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/LegendAlignment.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/LegendAlignment.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<LegendAlignment>))]
|
||||
public enum LegendAlignment
|
||||
{
|
||||
Start,
|
||||
Center,
|
||||
End
|
||||
}
|
||||
16
RobotNet.WebApp/Charts/Enums/LegendPosition.cs
Normal file
16
RobotNet.WebApp/Charts/Enums/LegendPosition.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<LegendPosition>))]
|
||||
public enum LegendPosition
|
||||
{
|
||||
Top,
|
||||
Left,
|
||||
Bottom,
|
||||
Right,
|
||||
/// <summary>
|
||||
/// Using the 'chartArea' option the legend position is at the moment not configurable, it will always be on the left side of the chart in the middle.
|
||||
/// </summary>
|
||||
ChartArea,
|
||||
}
|
||||
52
RobotNet.WebApp/Charts/Enums/LowerCaseEnumConverter.cs
Normal file
52
RobotNet.WebApp/Charts/Enums/LowerCaseEnumConverter.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
public class LowerCaseEnumConverter<T> : JsonConverter<T> where T : struct, Enum
|
||||
{
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var value = reader.GetString();
|
||||
if (Enum.TryParse(value, true, out T result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
throw new JsonException($"Unable to convert \"{value}\" to enum {typeof(T)}.");
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString().ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
public class CamelCaseEnumConverter<T> : JsonConverter<T> where T : struct, Enum
|
||||
{
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
string value = reader.GetString() ?? throw new JsonException();
|
||||
foreach (T enumValue in Enum.GetValues<T>())
|
||||
{
|
||||
if (string.Equals(CamelCaseEnumConverter<T>.ToCamelCase(enumValue.ToString()), value, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return enumValue;
|
||||
}
|
||||
}
|
||||
throw new JsonException($"Unable to convert \"{value}\" to {typeof(T)}.");
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||
{
|
||||
string enumString = CamelCaseEnumConverter<T>.ToCamelCase(value.ToString());
|
||||
writer.WriteStringValue(enumString);
|
||||
}
|
||||
|
||||
private static string ToCamelCase(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input) || char.IsLower(input[0]))
|
||||
return input;
|
||||
|
||||
return char.ToLower(input[0]) + input[1..];
|
||||
}
|
||||
}
|
||||
18
RobotNet.WebApp/Charts/Enums/PointStyle.cs
Normal file
18
RobotNet.WebApp/Charts/Enums/PointStyle.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<PointStyle>))]
|
||||
public enum PointStyle
|
||||
{
|
||||
Circle,
|
||||
Cross,
|
||||
CrossRot,
|
||||
Dash,
|
||||
Line,
|
||||
Rect,
|
||||
RectRounded,
|
||||
RectRot,
|
||||
Star,
|
||||
Triangle,
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/TicksAlignment.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/TicksAlignment.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TicksAlignment>))]
|
||||
public enum TicksAlignment
|
||||
{
|
||||
Center,
|
||||
Start,
|
||||
End
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/TitleAlignment.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/TitleAlignment.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TitleAlignment>))]
|
||||
public enum TitleAlignment
|
||||
{
|
||||
Start,
|
||||
Center,
|
||||
End
|
||||
}
|
||||
12
RobotNet.WebApp/Charts/Enums/TitlePosition.cs
Normal file
12
RobotNet.WebApp/Charts/Enums/TitlePosition.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TitlePosition>))]
|
||||
public enum TitlePosition
|
||||
{
|
||||
Top,
|
||||
Left,
|
||||
Bottom,
|
||||
Right,
|
||||
}
|
||||
19
RobotNet.WebApp/Charts/Enums/TooltipAlignment.cs
Normal file
19
RobotNet.WebApp/Charts/Enums/TooltipAlignment.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipXAlignment>))]
|
||||
public enum TooltipXAlignment
|
||||
{
|
||||
Left,
|
||||
Center,
|
||||
Right,
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipYAlignment>))]
|
||||
public enum TooltipYAlignment
|
||||
{
|
||||
Top,
|
||||
Center,
|
||||
Bottom,
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/TooltipPosition.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/TooltipPosition.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipPosition>))]
|
||||
public enum TooltipPosition
|
||||
{
|
||||
Average,
|
||||
Nearest
|
||||
}
|
||||
57
RobotNet.WebApp/Charts/Enums/Unit.cs
Normal file
57
RobotNet.WebApp/Charts/Enums/Unit.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<Unit>))]
|
||||
public enum Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// No unit.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Ems.
|
||||
/// </summary>
|
||||
Em,
|
||||
|
||||
/// <summary>
|
||||
/// Percent.
|
||||
/// </summary>
|
||||
Percentage,
|
||||
|
||||
/// <summary>
|
||||
/// Points.
|
||||
/// </summary>
|
||||
Pt,
|
||||
|
||||
/// <summary>
|
||||
/// Pixels.
|
||||
/// </summary>
|
||||
Px,
|
||||
|
||||
/// <summary>
|
||||
/// Root ems.
|
||||
/// </summary>
|
||||
Rem,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport height.
|
||||
/// </summary>
|
||||
Vh,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport maximum height.
|
||||
/// </summary>
|
||||
VMax,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport minimum height.
|
||||
/// </summary>
|
||||
VMin,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport width.
|
||||
/// </summary>
|
||||
Vw
|
||||
}
|
||||
86
RobotNet.WebApp/Charts/Models/BarChart/Axes/ChartAxes.cs
Normal file
86
RobotNet.WebApp/Charts/Models/BarChart/Axes/ChartAxes.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
|
||||
public class ChartAxes
|
||||
{
|
||||
/// <summary>
|
||||
/// If true, scale will include 0 if it is not already included.
|
||||
/// </summary>
|
||||
public bool BeginAtZero { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Define options for the border that run perpendicular to the axis.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxesBorder? Border { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the grid configuration.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxesGrid? Grid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User defined maximum number for the scale, overrides maximum value from data.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Max { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User defined minimum number for the scale, overrides minimum value from data.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Min { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Should the data be stacked.
|
||||
/// By default data is not stacked.
|
||||
/// If the stacked option of the value scale (y-axis on horizontal chart) is true, positive and negative values are stacked
|
||||
/// separately.
|
||||
/// </summary>
|
||||
public bool Stacked { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adjustment used when calculating the maximum data value.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? SuggestedMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adjustment used when calculating the minimum data value.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? SuggestedMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tick configuration.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxesTicks? Ticks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title configuration.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxesTitle? Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the index scale type. />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxesType? Type { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// The weight used to sort the axis. Higher weights are further away from the chart area.
|
||||
/// </summary>
|
||||
public int? Weight { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public TitlePosition? Position { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
|
||||
public class ChartAxesBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// The color of the border line.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Length and spacing of dashes on grid lines
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<int>? Dash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Offset for line dashes.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? DashOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, draw a border at the edge between the axis and the chart area.
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the border line.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// z-index of the border layer. Values <= 0 are drawn under datasets, > 0 on top.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? Z { get; set; }
|
||||
}
|
||||
82
RobotNet.WebApp/Charts/Models/BarChart/Axes/ChartAxesGrid.cs
Normal file
82
RobotNet.WebApp/Charts/Models/BarChart/Axes/ChartAxesGrid.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
|
||||
public class ChartAxesGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, gridlines are circular (on radar and polar area charts only).
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? Circular { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Color of the grid axis lines. Here one can write a CSS method or even a JavaScript method for a dynamic color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If false, do not display grid lines for this axis.
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, draw lines on the chart area inside the axis lines. This is useful when there are multiple
|
||||
/// axes and you need to control which grid lines are drawn.
|
||||
/// </summary>
|
||||
public bool DrawOnChartArea { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, draw lines beside the ticks in the axis area beside the chart.
|
||||
/// </summary>
|
||||
public bool DrawTicks { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Stroke width of grid lines.
|
||||
/// </summary>
|
||||
public int LineWidth { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, grid lines will be shifted to be between labels. This is set to true for a bar chart by
|
||||
/// default.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? Offset { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Length and spacing of the tick mark line.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<int>? TickBorderDash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Offset for the line dash of the tick mark.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? TickBorderDashOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Color of the tick line. If unset, defaults to the grid line color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? TickColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Length in pixels that the grid lines will draw into the axis area.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? TickLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Width of the tick mark in pixels.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? TickWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// z-index of the gridline layer. Values <= 0 are drawn under datasets, > 0 on top.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? Z { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
|
||||
public class ChartAxesTicks
|
||||
{
|
||||
[JsonPropertyName("align")]
|
||||
public TicksAlignment Alignment { get; set; } = TicksAlignment.Center;
|
||||
|
||||
/// <summary>
|
||||
/// Color of label backdrops
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BackdropColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Padding of label backdrop
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BackdropPadding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Color of ticks
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, show tick labels.
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// defines options for the major tick marks that are generated by the axis.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxesTicksMajor? Major { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the offset of the tick labels from the axis
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, draw a background behind the tick labels.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? ShowLabelBackdrop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The color of the stroke around the text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? TextStrokeColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stroke width around the text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? TextStrokeWidth { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
|
||||
public class ChartAxesTicksMajor
|
||||
{
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, major ticks are generated. A major tick will affect auto skipping and major will be defined
|
||||
/// on ticks in the scriptable options context.
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; } = false;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
|
||||
public class ChartAxesTitle
|
||||
{
|
||||
/// <summary>
|
||||
/// Alignment of the title.
|
||||
/// Options are: 'start', 'center', and 'end'
|
||||
/// </summary>
|
||||
[JsonPropertyName("align")]
|
||||
public TitleAlignment Alignment { get; set; } = TitleAlignment.Center;
|
||||
|
||||
/// <summary>
|
||||
/// Color of text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; } = "black";
|
||||
|
||||
/// <summary>
|
||||
/// Is the title shown?
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
public ChartFont? Font { get; set; } = new();
|
||||
|
||||
public bool FullSize { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position of the title.
|
||||
/// </summary>
|
||||
public TitlePosition Position { get; set; } = TitlePosition.Top;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of pixels to add above and below the title text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Text { get; set; }
|
||||
}
|
||||
118
RobotNet.WebApp/Charts/Models/BarChart/BarChartDataset.cs
Normal file
118
RobotNet.WebApp/Charts/Models/BarChart/BarChartDataset.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart;
|
||||
|
||||
public class BarChartDataset : ChartDataset<double>
|
||||
{
|
||||
/// <summary>
|
||||
/// Percent (0-1) of the available width each bar should be within the category width.
|
||||
/// 1.0 will take the whole category width and put the bars right next to each other.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.9.
|
||||
/// </remarks>
|
||||
public double BarPercentage { get; set; } = 0.9;
|
||||
|
||||
/// <summary>
|
||||
/// It is applied to the width of each bar, in pixels.
|
||||
/// When this is enforced, barPercentage and categoryPercentage are ignored.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? BarThickness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This setting is used to avoid drawing the bar stroke at the base of the fill, or disable the border radius.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public BorderSkipped? BorderSkipped { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Percent (0-1) of the available width each category should be within the sample width.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.8.
|
||||
/// </remarks>
|
||||
public double CategoryPercentage { get; set; } = 0.8;
|
||||
|
||||
/// <summary>
|
||||
/// Should the bars be grouped on index axis.
|
||||
/// When <see langword="true" />, all the datasets at same index value will be placed next to each other centering on that
|
||||
/// index value.
|
||||
/// When <see langword="false" />, each bar is placed on its actual index-axis value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="true" />.
|
||||
/// </remarks>
|
||||
public bool Grouped { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The bar border radius when hovered (in pixels).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? HoverBorderRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
|
||||
/// Supported values are 'x' and 'y'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public IndexAxis? IndexAxis { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set this to ensure that bars are not sized thicker than this.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? MaxBarThickness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set this to ensure that bars have a minimum length in pixels.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? MinBarLength { get; set; }
|
||||
|
||||
public PointStyle PointStyle { get; set; } = PointStyle.Circle;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, null or undefined values will not be used for spacing calculations when determining bar
|
||||
/// size.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="false" />.
|
||||
/// </remarks>
|
||||
public bool SkipNull { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the x axis to plot this dataset on.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is first x axis.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? XAxisID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the y axis to plot this dataset on.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is first y axis.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? YAxisID { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart;
|
||||
|
||||
public class BarChartDatasetData(string? datasetLabel, object data, string? backgroundColor) : ChartDatasetData(datasetLabel, data, backgroundColor)
|
||||
{
|
||||
}
|
||||
21
RobotNet.WebApp/Charts/Models/BarChart/BarChartOptions.cs
Normal file
21
RobotNet.WebApp/Charts/Models/BarChart/BarChartOptions.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart;
|
||||
|
||||
public class BarChartOptions : ChartOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
|
||||
/// Supported values are 'x' and 'y'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null"/>.
|
||||
/// </remarks>
|
||||
public IndexAxis IndexAxis { get; set; } = IndexAxis.X;
|
||||
|
||||
public BarChartPlugins Plugins { get; set; } = new();
|
||||
|
||||
public BarScales Scales { get; set; } = new();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart;
|
||||
|
||||
public class BarChartPlugins : ChartPlugins
|
||||
{
|
||||
}
|
||||
13
RobotNet.WebApp/Charts/Models/BarChart/BarScales.cs
Normal file
13
RobotNet.WebApp/Charts/Models/BarChart/BarScales.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BarChart;
|
||||
|
||||
public class BarScales
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxes? X { get; set; } = new();
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxes? Y { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BubbleChart;
|
||||
|
||||
public class BubbleChartDataset : ChartDataset<BubblePoint>
|
||||
{
|
||||
public bool DrawActiveElementsOnTop { get; set; } = true;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? HoverRadius { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? HitRadius { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? Radius { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BubbleChart;
|
||||
|
||||
public class BubbleChartDatasetData(string? datasetLabel, BubblePoint data, string? backgroundColor) : ChartDatasetData(datasetLabel, data, backgroundColor)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.BarChart;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BubbleChart;
|
||||
|
||||
public class BubbleChartOptions : ChartOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
|
||||
/// Supported values are 'x' and 'y'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null"/>.
|
||||
/// </remarks>
|
||||
public IndexAxis IndexAxis { get; set; } = IndexAxis.X;
|
||||
|
||||
public BubbleChartPlugins Plugins { get; set; } = new();
|
||||
|
||||
public BarScales Scales { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BubbleChart;
|
||||
|
||||
public class BubbleChartPlugins : ChartPlugins
|
||||
{
|
||||
}
|
||||
26
RobotNet.WebApp/Charts/Models/BubbleChart/BubblePoint.cs
Normal file
26
RobotNet.WebApp/Charts/Models/BubbleChart/BubblePoint.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.BubbleChart;
|
||||
|
||||
public class BubblePoint(double x, double y, double r)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the X-value of this <see cref="BubblePoint"/>.
|
||||
/// </summary>
|
||||
public double X { get; } = x;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Y-value of this <see cref="BubblePoint"/>.
|
||||
/// </summary>
|
||||
public double Y { get; } = y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the radius of this <see cref="BubblePoint"/> in pixels. Will be serialized as 'r'.
|
||||
/// <para>
|
||||
/// Important: this property is not scaled by the chart,
|
||||
/// it is the raw radius in pixels of the bubble that is drawn on the canvas.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[JsonPropertyName("r")]
|
||||
public double Radius { get; } = r;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.ComboBarLineChart;
|
||||
|
||||
public class ComboBarLineDataset : ChartDataset<double>
|
||||
{
|
||||
/// <summary>
|
||||
/// Percent (0-1) of the available width each bar should be within the category width.
|
||||
/// 1.0 will take the whole category width and put the bars right next to each other.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.9.
|
||||
/// </remarks>
|
||||
public double BarPercentage { get; set; } = 0.9;
|
||||
|
||||
/// <summary>
|
||||
/// It is applied to the width of each bar, in pixels.
|
||||
/// When this is enforced, barPercentage and categoryPercentage are ignored.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? BarThickness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This setting is used to avoid drawing the bar stroke at the base of the fill, or disable the border radius.
|
||||
/// </summary>
|
||||
public BorderSkipped BorderSkipped { get; set; } = BorderSkipped.Start;
|
||||
|
||||
/// <summary>
|
||||
/// Percent (0-1) of the available width each category should be within the sample width.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.8.
|
||||
/// </remarks>
|
||||
public double CategoryPercentage { get; set; } = 0.8;
|
||||
|
||||
/// <summary>
|
||||
/// Should the bars be grouped on index axis.
|
||||
/// When <see langword="true" />, all the datasets at same index value will be placed next to each other centering on that
|
||||
/// index value.
|
||||
/// When <see langword="false" />, each bar is placed on its actual index-axis value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="true" />.
|
||||
/// </remarks>
|
||||
public bool Grouped { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The bar border radius when hovered (in pixels).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? HoverBorderRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
|
||||
/// Supported values are 'x' and 'y'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
public IndexAxis IndexAxis { get; set; } = IndexAxis.X;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to ensure that bars are not sized thicker than this.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? MaxBarThickness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set this to ensure that bars have a minimum length in pixels.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? MinBarLength { get; set; }
|
||||
|
||||
public PointStyle PointStyle { get; set; } = PointStyle.Circle;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, null or undefined values will not be used for spacing calculations when determining bar
|
||||
/// size.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="false" />.
|
||||
/// </remarks>
|
||||
public bool SkipNull { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the x axis to plot this dataset on.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is first x axis.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? XAxisID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the y axis to plot this dataset on.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is first y axis.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? YAxisID { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.ComboBarLineChart;
|
||||
|
||||
public class ComboBarLineDatasetData(string? datasetLabel, object data, string? backgroundColor) : ChartDatasetData(datasetLabel, data, backgroundColor)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.BarChart;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.ComboBarLineChart;
|
||||
|
||||
public class ComboBarLineOptions : ChartOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
|
||||
/// Supported values are 'x' and 'y'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null"/>.
|
||||
/// </remarks>
|
||||
public IndexAxis IndexAxis { get; set; } = IndexAxis.X;
|
||||
|
||||
public BarChartPlugins Plugins { get; set; } = new();
|
||||
|
||||
public ComboBarLineScales Scales { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.ComboBarLineChart;
|
||||
|
||||
public class ComboBarLinePlugins : ChartPlugins
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using RobotNet.WebApp.Charts.Models.BarChart.Axes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.ComboBarLineChart;
|
||||
|
||||
public class ComboBarLineScales
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxes? X { get; set; } = new();
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxes? Y { get; set; } = new();
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAxes? Y1 { get; set; }
|
||||
}
|
||||
19
RobotNet.WebApp/Charts/Models/Common/ArcAnimation.cs
Normal file
19
RobotNet.WebApp/Charts/Models/Common/ArcAnimation.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
/// <summary>
|
||||
/// The animation-subconfig of the options for a radial chart.
|
||||
/// </summary>
|
||||
public class ArcAnimation : ChartAnimation
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the chart will
|
||||
/// load in with a rotation animation or not.
|
||||
/// </summary>
|
||||
public bool? AnimateRotate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the chart will
|
||||
/// load in with a scaling animation (from the center outwards) or not.
|
||||
/// </summary>
|
||||
public bool? AnimateScale { get; set; }
|
||||
}
|
||||
28
RobotNet.WebApp/Charts/Models/Common/ChartAnimation.cs
Normal file
28
RobotNet.WebApp/Charts/Models/Common/ChartAnimation.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public class ChartAnimation
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the number of milliseconds an animation takes.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public long? Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Delay before starting the animations.
|
||||
/// </summary>
|
||||
public int Delay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If set to true, the animations loop endlessly.
|
||||
/// </summary>
|
||||
public bool Loop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the easing function to use.
|
||||
/// </summary>
|
||||
public Easing Easing { get; set; }
|
||||
}
|
||||
36
RobotNet.WebApp/Charts/Models/Common/ChartFont.cs
Normal file
36
RobotNet.WebApp/Charts/Models/Common/ChartFont.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public class ChartFont
|
||||
{
|
||||
/// <summary>
|
||||
/// Default font family for all text, follows CSS font-family options.
|
||||
/// 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Family { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Height of an individual line of text
|
||||
/// </summary>
|
||||
public double LineHeight { get; set; } = 1.2;
|
||||
|
||||
/// <summary>
|
||||
/// Default font size (in px) for text. Does not apply to radialLinear scale point labels.
|
||||
/// </summary>
|
||||
public int Size { get; set; } = 12;
|
||||
|
||||
/// <summary>
|
||||
/// Default font style. Does not apply to tooltip title or footer. Does not apply to chart title.
|
||||
/// Follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit).
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Style { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default font weight (boldness).
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Weight { get; set; } = "bold";
|
||||
}
|
||||
17
RobotNet.WebApp/Charts/Models/Common/ChartLayout.cs
Normal file
17
RobotNet.WebApp/Charts/Models/Common/ChartLayout.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public class ChartLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// The padding to add inside the chart
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Apply automatic padding so visible elements are completely drawn.
|
||||
/// </summary>
|
||||
public bool AutoPadding { get; set; } = true;
|
||||
}
|
||||
67
RobotNet.WebApp/Charts/Models/Common/ChartOptions.cs
Normal file
67
RobotNet.WebApp/Charts/Models/Common/ChartOptions.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Elements;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public class ChartOptions : IChartOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the locale.
|
||||
/// By default, the chart is using the default locale of the platform which is running on.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Locale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to maintain the original canvas aspect ratio (width / height) when resizing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="true" />.
|
||||
/// </remarks>
|
||||
public bool MaintainAspectRatio { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the chart canvas should be resized when its container is.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="false" />.
|
||||
/// </remarks>
|
||||
public bool Responsive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the canvas aspect ratio (i.e. width / height, a value of 1 representing a square canvas).
|
||||
/// <para>Note that this option is ignored if the height is explicitly defined either as attribute (of the canvas) or via the style.</para>
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? AspectRatio { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the duration in milliseconds it takes to animate to new size after a resize event.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? ResponsiveAnimationDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the animation-configuration for this chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartAnimation? Animation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the layout options for this chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartLayout? Layout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Interaction configuration for this chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public Interaction? Interaction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the elements options for this chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartElements? Elements { get; set; }
|
||||
}
|
||||
24
RobotNet.WebApp/Charts/Models/Common/ChartPadding.cs
Normal file
24
RobotNet.WebApp/Charts/Models/Common/ChartPadding.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public class ChartPadding
|
||||
{
|
||||
public ChartPadding() { }
|
||||
public ChartPadding(int padding)
|
||||
{
|
||||
Left = padding;
|
||||
Right = padding;
|
||||
Top = padding;
|
||||
Bottom = padding;
|
||||
}
|
||||
public ChartPadding(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Right = top;
|
||||
Top = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
public int Left { get; set; }
|
||||
public int Right { get; set; }
|
||||
public int Top { get; set; }
|
||||
public int Bottom { get; set; }
|
||||
}
|
||||
12
RobotNet.WebApp/Charts/Models/Common/Dataset/ChartData.cs
Normal file
12
RobotNet.WebApp/Charts/Models/Common/Dataset/ChartData.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
public class ChartData
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<IChartDataset>? Datasets { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? Labels { get; set; }
|
||||
}
|
||||
256
RobotNet.WebApp/Charts/Models/Common/Dataset/ChartDataset.cs
Normal file
256
RobotNet.WebApp/Charts/Models/Common/Dataset/ChartDataset.cs
Normal file
@@ -0,0 +1,256 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
public class ChartDataset<TData> : IChartDataset
|
||||
{
|
||||
public ChartDataset()
|
||||
{
|
||||
Oid = Guid.NewGuid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside
|
||||
/// chartArea. 0 = clip at chartArea.
|
||||
/// Clipping can also be configured per side: clip: {left: 5, top: false, right: -2, bottom: 0}
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Clip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the Data.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<TData>? Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Configures the visibility state of the dataset. Set it to <see langword="true" />, to hide the dataset from the chart.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="false" />.
|
||||
/// </remarks>
|
||||
public bool Hidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The label for the dataset which appears in the legend and tooltips.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see cref="string.Empty" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get unique object id.
|
||||
/// </summary>
|
||||
public Guid Oid { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The drawing order of dataset. Also affects order for stacking, tooltip and legend.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the chart type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc background color.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'rgba(0, 0, 0, 0.1)'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Supported values are 'center' and 'inner'.
|
||||
/// When 'center' is set, the borders of arcs next to each other will overlap.
|
||||
/// When 'inner' is set, it is guaranteed that all borders will not overlap.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'center'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? BorderAlign { get; set; } // TODO: change this to enum
|
||||
|
||||
/// <summary>
|
||||
/// Arc border color.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is '#fff'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? BorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border length and spacing of dashes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? BorderDash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border offset for line dashes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.0.
|
||||
/// </remarks>
|
||||
public double BorderDashOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border join style.
|
||||
/// Supported values are 'round', 'bevel', 'miter'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? BorderJoinStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// It is applied to all corners of the arc (outerStart, outerEnd, innerStart, innerRight).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? BorderRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border width (in pixels).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 2.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? BorderWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Per-dataset override for the sweep that the arcs cover.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Circumference { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartDatasetDataLabels? Datalabels { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc background color when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? HoverBackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border color when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? HoverBorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border length and spacing of dashes when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? HoverBorderDash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border offset for line dashes when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? HoverBorderDashOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc border join style when hovered.
|
||||
/// Supported values are 'round', 'bevel', 'miter'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? HoverBorderJoinStyle { get; set; } // TODO: change this to enum
|
||||
|
||||
/// <summary>
|
||||
/// Arc border width when hovered (in pixels).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? HoverBorderWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc offset when hovered (in pixels).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? HoverOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc offset (in pixels).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Per-dataset override for the starting angle to draw arcs from.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Rotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fixed arc offset (in pixels). Similar to <see cref="Offset" /> but applies to all arcs.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
public double Spacing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The relative thickness of the dataset.
|
||||
/// Providing a value for weight will cause the pie or doughnut dataset to be drawn
|
||||
/// with a thickness relative to the sum of all the dataset weight values.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 1.
|
||||
/// </remarks>
|
||||
public double Weight { get; set; } = 1;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
public class ChartDatasetData(string? datasetLabel, object data, string? backgroundColor) : IChartDatasetData
|
||||
{
|
||||
public string? DatasetLabel { get; init; } = datasetLabel;
|
||||
|
||||
public object Data { get; init; } = data;
|
||||
|
||||
public string? BackgroundColor { get; init; } = backgroundColor;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
public class ChartDatasetDataLabels
|
||||
{
|
||||
public DataLabelsAlignment Align { get; set; } = DataLabelsAlignment.Center;
|
||||
public DataLabelsAnchoring Anchor { get; set; } = DataLabelsAnchoring.Center;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BackgroundColor { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartFont? Font { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; } = new(6);
|
||||
}
|
||||
55
RobotNet.WebApp/Charts/Models/Common/Elements/Arc.cs
Normal file
55
RobotNet.WebApp/Charts/Models/Common/Elements/Arc.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
|
||||
|
||||
public class Arc
|
||||
{
|
||||
/// <summary>
|
||||
/// Arc angle to cover.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc fill color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc stroke alignment.
|
||||
/// </summary>
|
||||
public BorderAlign BorderAlign { get; set; } = BorderAlign.Center;
|
||||
|
||||
/// <summary>
|
||||
/// Arc stroke color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc line dash
|
||||
/// </summary>
|
||||
public int[]? BorderDash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc line dash offset
|
||||
/// </summary>
|
||||
public double BorderDashOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Line join style.
|
||||
/// </summary>
|
||||
public BorderJoinStyle? BorderJoinStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arc stroke width.
|
||||
/// </summary>
|
||||
public int BorderWidth { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// By default the Arc is curved. If circular: false the Arc will be flat
|
||||
/// </summary>
|
||||
public bool Circular { get; set; } = true;
|
||||
}
|
||||
46
RobotNet.WebApp/Charts/Models/Common/Elements/Bar.cs
Normal file
46
RobotNet.WebApp/Charts/Models/Common/Elements/Bar.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
|
||||
|
||||
public class Bar
|
||||
{
|
||||
/// <summary>
|
||||
/// Bar fill color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bar stroke width.
|
||||
/// </summary>
|
||||
public int BorderWidth { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Bar stroke color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Skipped (excluded) border.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public BorderSkipped? BorderSkipped { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The bar border radius (in pixels).
|
||||
/// </summary>
|
||||
public int BorderRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of pixels to inflate the bar rectangle(s) when drawing.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? InflateAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Style of the point for legend.
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public PointStyle? PointStyle { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
|
||||
|
||||
public class ChartElements
|
||||
{
|
||||
/// <summary>
|
||||
/// Arcs are used in the polar area, doughnut and pie charts.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public Arc? Arc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bar elements are used to represent the bars in a bar chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public Bar? Bar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Line elements are used to represent the line in a line chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public Line? Line { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Point elements are used to represent the points in a line, radar or bubble chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public Point? Point { get; set; }
|
||||
}
|
||||
71
RobotNet.WebApp/Charts/Models/Common/Elements/Line.cs
Normal file
71
RobotNet.WebApp/Charts/Models/Common/Elements/Line.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
|
||||
|
||||
public class Line
|
||||
{
|
||||
/// <summary>
|
||||
/// Bézier curve tension (0 for no Bézier curves).
|
||||
/// </summary>
|
||||
public int Tension { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Line fill color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Line stroke width.
|
||||
/// </summary>
|
||||
public int BorderWidth { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Line stroke color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Line cap style.
|
||||
/// </summary>
|
||||
public string BorderCapStyle { get; set; } = "butt";
|
||||
|
||||
/// <summary>
|
||||
/// Line dash.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int[]? BorderDash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Line dash offset.
|
||||
/// </summary>
|
||||
public double BorderDashOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Line join style.
|
||||
/// </summary>
|
||||
public BorderJoinStyle BorderJoinStyle { get; set; } = BorderJoinStyle.Miter;
|
||||
|
||||
/// <summary>
|
||||
/// if true to keep Bézier control inside the chart, false for no restriction.
|
||||
/// </summary>
|
||||
public bool CapBezierPoints { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Interpolation mode to apply.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? CubicInterpolationMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How to fill the area under the line.
|
||||
/// </summary>
|
||||
public bool Fill { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// if true to show the line as a stepped line (tension will be ignored).
|
||||
/// </summary>
|
||||
public bool Stepped { get; set; }
|
||||
}
|
||||
54
RobotNet.WebApp/Charts/Models/Common/Elements/Point.cs
Normal file
54
RobotNet.WebApp/Charts/Models/Common/Elements/Point.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
|
||||
|
||||
public class Point
|
||||
{
|
||||
/// <summary>
|
||||
/// Point radius.
|
||||
/// </summary>
|
||||
public double Radius { get; set; } = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Point style.
|
||||
/// </summary>
|
||||
public PointStyle PointStyle { get; set; } = PointStyle.Circle;
|
||||
|
||||
/// <summary>
|
||||
/// Point rotation (in degrees).
|
||||
/// </summary>
|
||||
public double Rotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Point fill color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Point stroke width.
|
||||
/// </summary>
|
||||
public int BorderWidth { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Point stroke color.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Extra radius added to point radius for hit detection.
|
||||
/// </summary>
|
||||
public double HitRadius { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Point radius when hovered.
|
||||
/// </summary>
|
||||
public int HhoverRadius { get; set; } = 4;
|
||||
|
||||
/// <summary>
|
||||
/// Stroke width when hovered.
|
||||
/// </summary>
|
||||
public int HoverBorderWidth { get; set; } = 1;
|
||||
}
|
||||
5
RobotNet.WebApp/Charts/Models/Common/IChartDataset.cs
Normal file
5
RobotNet.WebApp/Charts/Models/Common/IChartDataset.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public interface IChartDataset
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public interface IChartDatasetData
|
||||
{
|
||||
}
|
||||
5
RobotNet.WebApp/Charts/Models/Common/IChartOptions.cs
Normal file
5
RobotNet.WebApp/Charts/Models/Common/IChartOptions.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public interface IChartOptions
|
||||
{
|
||||
}
|
||||
67
RobotNet.WebApp/Charts/Models/Common/Interaction.cs
Normal file
67
RobotNet.WebApp/Charts/Models/Common/Interaction.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
public class Interaction
|
||||
{
|
||||
private InteractionMode mode;
|
||||
|
||||
public Interaction() => Mode = InteractionMode.Nearest;
|
||||
|
||||
private void SetMode(InteractionMode interactionMode) =>
|
||||
ChartInteractionMode = interactionMode switch
|
||||
{
|
||||
InteractionMode.Dataset => "dataset",
|
||||
InteractionMode.Index => "index",
|
||||
InteractionMode.Nearest => "nearest",
|
||||
InteractionMode.Point => "point",
|
||||
InteractionMode.X => "x",
|
||||
InteractionMode.Y => "y",
|
||||
_ => ""
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets which elements appear in the interaction.
|
||||
/// </summary>
|
||||
[JsonPropertyName("mode")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? ChartInteractionMode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// if <see langword="true" />, the interaction mode only applies when the mouse position intersects an item on the chart.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="true" />.
|
||||
/// </remarks>
|
||||
public bool Intersect { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Sets which elements appear in the tooltip. See Interaction Modes for details.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public InteractionMode Mode
|
||||
{
|
||||
get => mode;
|
||||
set
|
||||
{
|
||||
mode = value;
|
||||
SetMode(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets which directions are used in calculating distances.
|
||||
/// Defaults to <see cref="AxisDirection.X"/> for <see cref="Mode"/> == <see cref="InteractionMode.Index"/>
|
||||
/// and <see cref="AxisDirection.XY"/> for <see cref="Mode"/> == <see cref="InteractionMode.Dataset"/> or <see cref="InteractionMode.Nearest"/>.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public AxisDirection? Axis { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// if true, the invisible points that are outside of the chart area will also be included when evaluating interactions.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? IncludeInvisible { get; set; }
|
||||
}
|
||||
35
RobotNet.WebApp/Charts/Models/Common/Plugins/ChartPlugins.cs
Normal file
35
RobotNet.WebApp/Charts/Models/Common/Plugins/ChartPlugins.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPlugins
|
||||
{
|
||||
/// <summary>
|
||||
/// The chart legend displays data about the datasets that are appearing on the chart.
|
||||
/// </summary>
|
||||
public ChartPluginsLegend Legend { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// The chart title defines text to draw at the top of the chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPluginsTitle? Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Tooltip for the element.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPluginsTooltip? Tooltip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// DataLabels for the element.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPluginsDataLabels? Datalabels { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Subtitle for the element.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPluginsSubtitle? Subtitle { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPluginsDataLabels
|
||||
{
|
||||
public DataLabelsAlignment Align { get; set; } = DataLabelsAlignment.Center;
|
||||
public DataLabelsAnchoring Anchor { get; set; } = DataLabelsAnchoring.Center;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BackgroundColor { get; set; }
|
||||
public string BorderColor { get; set; } = "white";
|
||||
public double BorderRadius { get; set; } = 25;
|
||||
public double BorderWidth { get; set; } = 2;
|
||||
public bool Clamp { get; set; } = false;
|
||||
public bool Clip { get; set; } = false;
|
||||
public string Color { get; set; } = "white";
|
||||
public bool Display { get; set; } = true;
|
||||
public ChartFont Font { get; set; } = new();
|
||||
public int Offset { get; set; } = 4;
|
||||
public double Opacity { get; set; } = 1;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
public int Rotation { get; set; }
|
||||
|
||||
public DataLabelsAlignment TextAlign { get; set; } = DataLabelsAlignment.Center;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? TextStrokeColor { get; set; }
|
||||
public int TextStrokeWidth { get; set; }
|
||||
public int TextShadowBlur { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? TextShadowColor { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPluginsLegend
|
||||
{
|
||||
/// <summary>
|
||||
/// Alignment of the legend. Default values is 'center'. Other possible values 'start' and 'end'.
|
||||
/// </summary>
|
||||
public LegendAlignment Align { get; set; } = LegendAlignment.Center;
|
||||
|
||||
/// <summary>
|
||||
/// Is the legend shown? Default value is 'true'.
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, Marks that this box should take the full width/height of the canvas (moving other boxes). This is unlikely to need to be changed in day-to-day use.
|
||||
/// </summary>
|
||||
public bool FullSize { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Label settings for the legend.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPluginsLegendLabels? Labels { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum height of the legend, in pixels.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? MaxHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum width of the legend, in pixels.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? MaxWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Position of the legend. Default value is 'top'. Other possible value is 'bottom'.
|
||||
/// </summary>
|
||||
public LegendPosition Position { get; set; } = LegendPosition.Top;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, the Legend will show datasets in reverse order.
|
||||
/// </summary>
|
||||
public bool Reverse { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, for rendering of the legends will go from right to left.
|
||||
/// </summary>
|
||||
public bool Rtl { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This will force the text direction 'rtl' or 'ltr' on the canvas for rendering the legend, regardless of the css specified on the canvas
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? TextDirection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Title object
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPluginsLegendTitle? Title { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPluginsLegendLabels
|
||||
{
|
||||
/// <summary>
|
||||
/// Width of coloured box.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BoxWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Height of the coloured box
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BoxHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Override the borderRadius to use.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BorderRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Color of label and the strikethrough.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartFont? Font { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Padding between rows of colored boxes.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? Padding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If specified, this style of point is used for the legend. Only used if <see cref="UsePointStyle"/>> is true.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public PointStyle? PointStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If <see cref="UsePointStyle"/> is <see langword="true" />, the width of the point style used for the legend.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? PointStyleWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Label borderRadius will match corresponding <see cref="BorderRadius"/>.
|
||||
/// </summary>
|
||||
public bool UseBorderRadius { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true"/>, Label style will match corresponding point style (size is based on pointStyleWidth or the minimum value between <see cref="BoxWidth"/> and <see cref="Font"/> -> Size).
|
||||
/// </summary>
|
||||
public bool UsePointStyle { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal alignment of the label text
|
||||
/// </summary>
|
||||
public LegendAlignment TextAlign { get; set; } = LegendAlignment.Center;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPluginsLegendTitle
|
||||
{
|
||||
/// <summary>
|
||||
/// Color of the legend. Default value is 'black'.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the legend title displayed.
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Padding around the title.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The string title
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Text { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Font Legend Title
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartFont? Font { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPluginsSubtitle
|
||||
{
|
||||
/// <summary>
|
||||
/// Alignment of the title.
|
||||
/// Options are: 'start', 'center', and 'end'
|
||||
/// </summary>
|
||||
public TitleAlignment Align { get; set; } = TitleAlignment.Center;
|
||||
/// <summary>
|
||||
/// Color of text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the title shown?
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartFont? Font { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Text { get; set; }
|
||||
|
||||
public bool FullSize { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position of the title.
|
||||
/// </summary>
|
||||
public TitlePosition Position { get; set; } = TitlePosition.Top;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of pixels to add above and below the title text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPluginsTitle
|
||||
{
|
||||
/// <summary>
|
||||
/// Alignment of the title.
|
||||
/// Options are: 'start', 'center', and 'end'
|
||||
/// </summary>
|
||||
public TitleAlignment Align { get; set; } = TitleAlignment.Center;
|
||||
/// <summary>
|
||||
/// Color of text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the title shown?
|
||||
/// </summary>
|
||||
public bool Display { get; set; } = true;
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartFont? Font { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Text { get; set; }
|
||||
|
||||
public bool FullSize { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position of the title.
|
||||
/// </summary>
|
||||
public TitlePosition Position { get; set; } = TitlePosition.Top;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of pixels to add above and below the title text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
public class ChartPluginsTooltip
|
||||
{
|
||||
/// <summary>
|
||||
/// Background color of the tooltip.
|
||||
/// </summary>
|
||||
public string BackgroundColor { get; set; } = "rgba(0, 0, 0, 0.8)";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets which elements appear in the tooltip.
|
||||
/// </summary>
|
||||
public InteractionMode Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value indicating if the hover mode only applies when the mouse position intersects an item on the chart.
|
||||
/// </summary>
|
||||
public bool? Intersect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The mode for positioning the tooltip.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public TooltipPosition? Position { get; set; } = TooltipPosition.Average;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal alignment of the body text lines. left/right/center.
|
||||
/// </summary>
|
||||
public TooltipXAlignment BodyAlign { get; set; } = TooltipXAlignment.Left;
|
||||
|
||||
/// <summary>
|
||||
/// Color of body text.
|
||||
/// </summary>
|
||||
public string BodyColor { get; set; } = "#fff";
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartFont? BodyFont { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Spacing to add to top and bottom of each tooltip item.
|
||||
/// </summary>
|
||||
public int BodySpacing { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Padding for Tooltips
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public ChartPadding? Padding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Extra distance to move the end of the tooltip arrow away from the tooltip point.
|
||||
/// </summary>
|
||||
public int CaretPadding { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Size, in px, of the tooltip arrow.
|
||||
/// </summary>
|
||||
public int CaretSize { get; set; } = 5;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, color boxes are shown in the tooltip.
|
||||
/// </summary>
|
||||
public bool DisplayColors { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Are on-canvas tooltips enabled?
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal alignment of the footer text lines. left/right/center.
|
||||
/// </summary>
|
||||
public TooltipXAlignment FooterAlign { get; set; } = TooltipXAlignment.Left;
|
||||
|
||||
/// <summary>
|
||||
/// Color of footer text.
|
||||
/// </summary>
|
||||
public string FooterColor { get; set; } = "#fff";
|
||||
|
||||
public ChartFont FooterFont { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Margin to add before drawing the footer.
|
||||
/// </summary>
|
||||
public int FooterMarginTop { get; set; } = 6;
|
||||
|
||||
/// <summary>
|
||||
/// Spacing to add to top and bottom of each footer line.
|
||||
/// </summary>
|
||||
public int FooterSpacing { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal alignment of the title text lines. left/right/center.
|
||||
/// </summary>
|
||||
public TooltipXAlignment TitleAlign { get; set; } = TooltipXAlignment.Left;
|
||||
|
||||
/// <summary>
|
||||
/// Color of title text.
|
||||
/// </summary>
|
||||
public string TitleColor { get; set; } = "#fff";
|
||||
|
||||
public ChartFont TitleFont { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Margin to add on bottom of title section.
|
||||
/// </summary>
|
||||
public int TitleMarginBottom { get; set; } = 6;
|
||||
|
||||
/// <summary>
|
||||
/// Spacing to add to top and bottom of each title line.
|
||||
/// </summary>
|
||||
public int TitleSpacing { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Position of the tooltip caret in the X direction. left/center/right.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public TooltipXAlignment? XAlign { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Position of the tooltip caret in the Y direction. top/center/bottom.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public TooltipYAlignment? YAlign { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Width of the color box if displayColors is true.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BoxWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Height of the color box if displayColors is true.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BoxHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Padding between the color box and the text.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BoxPadding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Size of the border.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? BorderWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Color of the border.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? BorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Use the corresponding point style (from dataset options) instead of color boxes, ex: star, triangle etc. (size is based on the minimum value between boxWidth and boxHeight).
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? UsePointStyle { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// true for rendering the tooltip from right to left.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? Rtl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This will force the text direction 'rtl' or 'ltr' on the canvas for rendering the tooltips, regardless of the css specified on the canvas
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? TextDirection { get; set; }
|
||||
}
|
||||
216
RobotNet.WebApp/Charts/Models/LineChart/LineChartDataset.cs
Normal file
216
RobotNet.WebApp/Charts/Models/LineChart/LineChartDataset.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.LineChart;
|
||||
|
||||
public class LineChartDataset : ChartDataset<double>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Cap style of the line.
|
||||
/// Supported values are 'butt', 'round', and 'square'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'butt'.
|
||||
/// </remarks>
|
||||
public string BorderCapStyle { get; set; } = "butt";
|
||||
|
||||
/// <summary>
|
||||
/// Draw the active points of a dataset over the other points of the dataset.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<bool>? DrawActiveElementsOnTop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How to fill the area under the line.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="false" />.
|
||||
/// </remarks>
|
||||
public object Fill { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Cap style of the line when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? HoverBorderCapStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The base axis of the dataset. 'x' for horizontal lines and 'y' for vertical lines.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'x'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public IndexAxis? IndexAxis { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The fill color for points.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'rgba(0, 0, 0, 0.1)'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? PointBackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The border color for points.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'rgba(0, 0, 0, 0.1)'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? PointBorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The width of the point border in pixels.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 1.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? PointBorderWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The pixel size of the non-displayed point that reacts to mouse events.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 1.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? PointHitRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Point background color when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? PointHoverBackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Point border color when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? PointHoverBorderColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Border width of point when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 1.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? PointHoverBorderWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The radius of the point when hovered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 4.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? PointHoverRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The radius of the point shape. If set to 0, the point is not rendered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 3.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? PointRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The rotation of the point in degrees.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<double>? PointRotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Style of the point.
|
||||
/// Supported values are 'circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', and
|
||||
/// 'triangle' to style.
|
||||
/// the point.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'circle'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<string>? PointStyle { get; set; }
|
||||
|
||||
//segment
|
||||
//https://www.chartjs.org/docs/latest/charts/line.html#segment
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="false" />, the lines between points are not drawn.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="true" />.
|
||||
/// </remarks>
|
||||
public bool ShowLine { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If <see langword="true" />, lines will be drawn between points with no or null data.
|
||||
/// If <see langword="false" />, points with null data will create a break in the line.
|
||||
/// Can also be a number specifying the maximum gap length to span.
|
||||
/// The unit of the value depends on the scale used.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null" />.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public bool? SpanGaps { get; set; }
|
||||
|
||||
//stack
|
||||
//https://www.chartjs.org/docs/latest/charts/line.html#general
|
||||
|
||||
/// <summary>
|
||||
/// true to show the line as a stepped line (tension will be ignored).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="false" />.
|
||||
/// </remarks>
|
||||
public bool Stepped { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bezier curve tension of the line. Set to 0 to draw straight lines.
|
||||
/// This option is ignored if monotone cubic interpolation is used.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 0.
|
||||
/// </remarks>
|
||||
public double Tension { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the x axis to plot this dataset on.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'first x axis'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? XAxisID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the y axis to plot this dataset on.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is 'first y axis'.
|
||||
/// </remarks>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? YAxisID { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.LineChart;
|
||||
|
||||
public class LineChartDatasetData(string? datasetLabel, object data, string? backgroundColor) : ChartDatasetData(datasetLabel, data, backgroundColor)
|
||||
{
|
||||
}
|
||||
21
RobotNet.WebApp/Charts/Models/LineChart/LineChartOptions.cs
Normal file
21
RobotNet.WebApp/Charts/Models/LineChart/LineChartOptions.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using RobotNet.WebApp.Charts.Enums;
|
||||
using RobotNet.WebApp.Charts.Models.BarChart;
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.LineChart;
|
||||
|
||||
public class LineChartOptions : ChartOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
|
||||
/// Supported values are 'x' and 'y'.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is <see langword="null"/>.
|
||||
/// </remarks>
|
||||
public IndexAxis IndexAxis { get; set; } = IndexAxis.X;
|
||||
|
||||
public LineChartPlugins Plugins { get; set; } = new();
|
||||
|
||||
public BarScales Scales { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.LineChart;
|
||||
|
||||
public class LineChartPlugins : ChartPlugins
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.PieChart;
|
||||
|
||||
public class PieChartDataset : ChartDataset<double>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.PieChart;
|
||||
|
||||
public class PieChartDatasetData(string? datasetLabel, double data, string? backgroundColor) : ChartDatasetData(datasetLabel, data, backgroundColor)
|
||||
{
|
||||
}
|
||||
40
RobotNet.WebApp/Charts/Models/PieChart/PieChartOptions.cs
Normal file
40
RobotNet.WebApp/Charts/Models/PieChart/PieChartOptions.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.PieChart;
|
||||
|
||||
public class PieChartOptions : ChartOptions
|
||||
{
|
||||
public PieChartPlugins Plugins { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the percentage of the chart that is cut out of the middle.
|
||||
/// <para>Default for Pie is 0, Default for Doughnut is 50. This will be filled in by Chart.js unless you specify a non-null value.</para>
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Cutout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the animation-configuration for this chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public new ArcAnimation? Animation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the starting angle to draw arcs from.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Rotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The outer radius of the chart.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Radius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sweep to allow arcs to cover.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public double? Circumference { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Plugins;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.PieChart;
|
||||
|
||||
public class PieChartPlugins : ChartPlugins
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.PolarAreaChart;
|
||||
|
||||
public class PolarAreaChartDataset : ChartDataset<double>
|
||||
{
|
||||
public bool Circular { get; set; } = true;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using RobotNet.WebApp.Charts.Models.Common.Dataset;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Models.PolarAreaChart;
|
||||
|
||||
public class PolarAreaChartDatasetData(string? datasetLabel, double data, string? backgroundColor) : ChartDatasetData(datasetLabel, data, backgroundColor)
|
||||
{
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user