Skip to content

Commit

Permalink
BarChart dataset model updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gvreddy04 committed Jun 22, 2024
1 parent 19dc548 commit 4ae4bcc
Show file tree
Hide file tree
Showing 5 changed files with 305 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
/// The bar chart allows a number of properties to be specified for each dataset.
/// These are used to set display properties for a specific dataset.
/// <see href="https://www.chartjs.org/docs/latest/charts/bar.html#dataset-properties" />
/// <seealso href="https://www.chartjs.org/docs/latest/charts/bar.html#general" />
/// </summary>
public class BarChartDataset : ChartDataset
{
#region Properties, Indexers

/// <summary>
/// The bar 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>
/// 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.
Expand All @@ -19,22 +29,41 @@ public class BarChartDataset : ChartDataset
public double BarPercentage { get; set; } = 0.9;

/// <summary>
/// Border thickness
/// 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 int? BarThickness { get; set; }
public double? BarThickness { get; set; }

/// <summary>
/// The bar border color.
/// </summary>
/// <remarks>
/// Default value is 'rgba(0, 0, 0, 0.1)'.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? BorderColor { get; set; }

/// <summary>
/// Border radius
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// Default value is 0.
/// </remarks>
public List<double>? BorderRadius { get; set; }

/// <summary>
/// Gets or sets the border width (in pixels).
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? BorderWidth { get; set; }

//BorderSkipped
//https://www.chartjs.org/docs/latest/api/interfaces/BarControllerDatasetOptions.html#borderskipped

Expand All @@ -60,14 +89,41 @@ public class BarChartDataset : ChartDataset
public bool Grouped { get; set; } = true;

/// <summary>
/// The bar border radius when hovered (in pixels).
/// The bar background color when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? HoverBackgroundColor { get; set; }

/// <summary>
/// The bar border color when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? HoverBorderColor { get; set; }

/// <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 bar border width when hovered (in pixels).
/// </summary>
/// <remarks>
/// Default value is 1.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? HoverBorderWidth { get; set; }

/// <summary>
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
/// </summary>
Expand Down Expand Up @@ -102,7 +158,7 @@ public class BarChartDataset : ChartDataset
//https://www.chartjs.org/docs/latest/configuration/elements.html#point-styles

/// <summary>
/// If true, null or undefined values will not be used for spacing calculations when determining bar size.
/// 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"/>.
Expand All @@ -116,7 +172,7 @@ public class BarChartDataset : ChartDataset
/// The ID of the x axis to plot this dataset on.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// Default value is first x axis.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? XAxisID { get; set; }
Expand All @@ -125,7 +181,7 @@ public class BarChartDataset : ChartDataset
/// The ID of the y axis to plot this dataset on.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// Default value is first y axis.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? YAxisID { get; set; }
Expand Down
61 changes: 5 additions & 56 deletions BlazorExpress.ChartJS/Models/ChartDataset/ChartDataset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,6 @@ public ChartDataset()

#region Properties, Indexers

/// <summary>
/// Get or sets the BackgroundColor.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? BackgroundColor { get; set; }

/// <summary>
/// Get or sets the BorderColor.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? BorderColor { get; set; }

/// <summary>
/// Width of the border, number for all sides, object to specify width for each side specifically.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? BorderWidth { get; set; }

/// <summary>
/// How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside
/// chartArea. 0 = clip at chartArea.
Expand All @@ -66,45 +39,18 @@ public ChartDataset()
public List<double>? Data { get; set; }

/// <summary>
/// Configures the visibility state of the dataset. Set it to true, to hide the dataset from the chart.
/// 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 bar background color when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? HoverBackgroundColor { get; set; }

/// <summary>
/// The bar border color when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? HoverBorderColor { get; set; }

/// <summary>
/// The bar 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>
/// The label for the dataset which appears in the legend and tooltips.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// Default value is <see cref="string.Empty" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Label { get; set; }
Expand All @@ -122,6 +68,9 @@ public ChartDataset()
/// </remarks>
public int Order { get; set; }

//Stack
//https://www.chartjs.org/docs/latest/general/data-structures.html#dataset-configuration

/// <summary>
/// Gets or sets the chart type.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,127 @@
namespace BlazorExpress.ChartJS;

/// <summary>
/// The doughnut/pie chart allows a number of properties to be specified for each dataset.
/// These are used to set display properties for a specific dataset.
/// <see href="https://www.chartjs.org/docs/latest/charts/doughnut.html#dataset-properties" />.
/// </summary>
public class DoughnutChartDataset : ChartDataset
{
#region Properties, Indexers

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public DoughnutChartDatasetDataLabels Datalabels { get; set; } = new();
/// <summary>
/// Get or sets the 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 for BorderAlign 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; } = new(1) { "center" };

/// <summary>
/// Get or sets the border color.
/// </summary>
/// <remarks>
/// Default value is 'rgba(0, 0, 0, 0.1)'.
/// </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>
public string? BorderJoinStyle { get; set; } // TODO: change this to enum

/// <summary>
/// It is applied to all corners of the arc (outerStart, outerEnd, innerStart, innerRight).
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
public List<double>? BorderRadius { get; set; }

/// <summary>
/// Arc border width (in pixels).
/// </summary>
/// <remarks>
/// Default value is 2.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public new 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>
public double? Circumference { get; set; }




[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DoughnutChartDatasetDataLabels Datalabels { get; set; } = new(); // TODO: add the reference link


/// <summary>
/// The bar/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>
/// The bar/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>
/// The bar border width when hovered (in pixels).
/// </summary>
/// <remarks>
/// Default value is 1.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? HoverBorderWidth { get; set; }

#endregion
}
Expand Down
Loading

0 comments on commit 4ae4bcc

Please sign in to comment.