RobotNet/RobotNet.WebApp/Charts/Models/Common/Dataset/ChartDataset.cs
2025-10-15 15:15:53 +07:00

257 lines
8.1 KiB
C#

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;
}