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