Skip to content

Commit 35383ee

Browse files
author
Mischa Spelt
committed
Charts: Made ChartDataset.Data generic so derived classes don't have to shadow it
1 parent cbf1b52 commit 35383ee

File tree

8 files changed

+1671
-1734
lines changed

8 files changed

+1671
-1734
lines changed

blazorbootstrap/Models/Charts/ChartDataset/BarChart/BarChartDataset.cs

Lines changed: 181 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -6,197 +6,188 @@
66
/// <see href="https://www.chartjs.org/docs/latest/charts/bar.html#dataset-properties" />
77
/// <seealso href="https://www.chartjs.org/docs/latest/charts/bar.html#general" />
88
/// </summary>
9-
public class BarChartDataset : ChartDataset
9+
public class BarChartDataset : ChartDataset<double?>
1010
{
11-
#region Properties, Indexers
12-
13-
/// <summary>
14-
/// The bar background color.
15-
/// </summary>
16-
/// <remarks>
17-
/// Default value is 'rgba(0, 0, 0, 0.1)'.
18-
/// </remarks>
19-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
20-
public List<string>? BackgroundColor { get; set; }
21-
22-
/// <summary>
23-
/// Percent (0-1) of the available width each bar should be within the category width.
24-
/// 1.0 will take the whole category width and put the bars right next to each other.
25-
/// </summary>
26-
/// <remarks>
27-
/// Default value is 0.9.
28-
/// </remarks>
29-
public double BarPercentage { get; set; } = 0.9;
30-
31-
/// <summary>
32-
/// It is applied to the width of each bar, in pixels.
33-
/// When this is enforced, barPercentage and categoryPercentage are ignored.
34-
/// </summary>
35-
/// <remarks>
36-
/// Default value is <see langword="null"/>.
37-
/// </remarks>
38-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
39-
public double? BarThickness { get; set; }
40-
41-
/// <summary>
42-
/// The bar border color.
43-
/// </summary>
44-
/// <remarks>
45-
/// Default value is 'rgba(0, 0, 0, 0.1)'.
46-
/// </remarks>
47-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
48-
public List<string>? BorderColor { get; set; }
49-
50-
/// <summary>
51-
/// Border radius
52-
/// </summary>
53-
/// <remarks>
54-
/// Default value is 0.
55-
/// </remarks>
56-
public List<double>? BorderRadius { get; set; }
57-
58-
/// <summary>
59-
/// Gets or sets the border width (in pixels).
60-
/// </summary>
61-
/// <remarks>
62-
/// Default value is 0.
63-
/// </remarks>
64-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
65-
public List<double>? BorderWidth { get; set; }
66-
67-
//BorderSkipped
68-
//https://www.chartjs.org/docs/latest/api/interfaces/BarControllerDatasetOptions.html#borderskipped
69-
70-
/// <summary>
71-
/// Percent (0-1) of the available width each category should be within the sample width.
72-
/// </summary>
73-
/// <remarks>
74-
/// Default value is 0.8.
75-
/// </remarks>
76-
public double CategoryPercentage { get; set; } = 0.8;
77-
78-
/// <summary>
79-
/// Get or sets the Data.
80-
/// </summary>
81-
/// <remarks>
82-
/// Default value is <see langword="null"/>.
83-
/// </remarks>
84-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
85-
public new List<double?>? Data { get; set; }
86-
87-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
88-
public BarChartDatasetDataLabels Datalabels { get; set; } = new(); // TODO: add the reference link
89-
90-
/// <summary>
91-
/// Should the bars be grouped on index axis.
92-
/// When <see langword="true"/>, all the datasets at same index value will be placed next to each other centering on that index value.
93-
/// When <see langword="false"/>, each bar is placed on its actual index-axis value.
94-
/// </summary>
95-
/// <remarks>
96-
/// Default value is <see langword="true"/>.
97-
/// </remarks>
98-
public bool Grouped { get; set; } = true;
99-
100-
/// <summary>
101-
/// The bar background color when hovered.
102-
/// </summary>
103-
/// <remarks>
104-
/// Default value is <see langword="null"/>.
105-
/// </remarks>
106-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
107-
public List<string>? HoverBackgroundColor { get; set; }
108-
109-
/// <summary>
110-
/// The bar border color when hovered.
111-
/// </summary>
112-
/// <remarks>
113-
/// Default value is <see langword="null"/>.
114-
/// </remarks>
115-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
116-
public List<string>? HoverBorderColor { get; set; }
117-
118-
/// <summary>
119-
/// The bar border radius when hovered (in pixels).
120-
/// </summary>
121-
/// <remarks>
122-
/// Default value is 0.
123-
/// </remarks>
124-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
125-
public List<double>? HoverBorderRadius { get; set; }
126-
127-
/// <summary>
128-
/// The bar border width when hovered (in pixels).
129-
/// </summary>
130-
/// <remarks>
131-
/// Default value is 1.
132-
/// </remarks>
133-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
134-
public List<double>? HoverBorderWidth { get; set; }
135-
136-
/// <summary>
137-
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
138-
/// Supported values are 'x' and 'y'.
139-
/// </summary>
140-
/// <remarks>
141-
/// Default value is <see langword="null"/>.
142-
/// </remarks>
143-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
144-
public string? IndexAxis { get; set; }
145-
146-
//InflateAmount
147-
//https://www.chartjs.org/docs/latest/charts/bar.html#inflateamount
148-
149-
/// <summary>
150-
/// Set this to ensure that bars are not sized thicker than this.
151-
/// </summary>
152-
/// <remarks>
153-
/// Default value is <see langword="null"/>.
154-
/// </remarks>
155-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
156-
public double? MaxBarThickness { get; set; }
157-
158-
/// <summary>
159-
/// Set this to ensure that bars have a minimum length in pixels.
160-
/// </summary>
161-
/// <remarks>
162-
/// Default value is <see langword="null"/>.
163-
/// </remarks>
164-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
165-
public double? MinBarLength { get; set; }
166-
167-
//PointStyle
168-
//https://www.chartjs.org/docs/latest/configuration/elements.html#point-styles
169-
170-
/// <summary>
171-
/// If <see langword="true"/>, null or undefined values will not be used for spacing calculations when determining bar size.
172-
/// </summary>
173-
/// <remarks>
174-
/// Default value is <see langword="false"/>.
175-
/// </remarks>
176-
public bool SkipNull { get; set; }
177-
178-
//Stack
179-
//https://www.chartjs.org/docs/latest/charts/bar.html#general
180-
181-
/// <summary>
182-
/// The ID of the x axis to plot this dataset on.
183-
/// </summary>
184-
/// <remarks>
185-
/// Default value is first x axis.
186-
/// </remarks>
187-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
188-
public string? XAxisID { get; set; }
189-
190-
/// <summary>
191-
/// The ID of the y axis to plot this dataset on.
192-
/// </summary>
193-
/// <remarks>
194-
/// Default value is first y axis.
195-
/// </remarks>
196-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
197-
public string? YAxisID { get; set; }
198-
199-
#endregion
11+
#region Properties, Indexers
12+
13+
/// <summary>
14+
/// The bar background color.
15+
/// </summary>
16+
/// <remarks>
17+
/// Default value is 'rgba(0, 0, 0, 0.1)'.
18+
/// </remarks>
19+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
20+
public List<string>? BackgroundColor { get; set; }
21+
22+
/// <summary>
23+
/// Percent (0-1) of the available width each bar should be within the category width.
24+
/// 1.0 will take the whole category width and put the bars right next to each other.
25+
/// </summary>
26+
/// <remarks>
27+
/// Default value is 0.9.
28+
/// </remarks>
29+
public double BarPercentage { get; set; } = 0.9;
30+
31+
/// <summary>
32+
/// It is applied to the width of each bar, in pixels.
33+
/// When this is enforced, barPercentage and categoryPercentage are ignored.
34+
/// </summary>
35+
/// <remarks>
36+
/// Default value is <see langword="null"/>.
37+
/// </remarks>
38+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
39+
public double? BarThickness { get; set; }
40+
41+
/// <summary>
42+
/// The bar border color.
43+
/// </summary>
44+
/// <remarks>
45+
/// Default value is 'rgba(0, 0, 0, 0.1)'.
46+
/// </remarks>
47+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
48+
public List<string>? BorderColor { get; set; }
49+
50+
/// <summary>
51+
/// Border radius
52+
/// </summary>
53+
/// <remarks>
54+
/// Default value is 0.
55+
/// </remarks>
56+
public List<double>? BorderRadius { get; set; }
57+
58+
/// <summary>
59+
/// Gets or sets the border width (in pixels).
60+
/// </summary>
61+
/// <remarks>
62+
/// Default value is 0.
63+
/// </remarks>
64+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
65+
public List<double>? BorderWidth { get; set; }
66+
67+
//BorderSkipped
68+
//https://www.chartjs.org/docs/latest/api/interfaces/BarControllerDatasetOptions.html#borderskipped
69+
70+
/// <summary>
71+
/// Percent (0-1) of the available width each category should be within the sample width.
72+
/// </summary>
73+
/// <remarks>
74+
/// Default value is 0.8.
75+
/// </remarks>
76+
public double CategoryPercentage { get; set; } = 0.8;
77+
78+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
79+
public BarChartDatasetDataLabels Datalabels { get; set; } = new(); // TODO: add the reference link
80+
81+
/// <summary>
82+
/// Should the bars be grouped on index axis.
83+
/// When <see langword="true"/>, all the datasets at same index value will be placed next to each other centering on that index value.
84+
/// When <see langword="false"/>, each bar is placed on its actual index-axis value.
85+
/// </summary>
86+
/// <remarks>
87+
/// Default value is <see langword="true"/>.
88+
/// </remarks>
89+
public bool Grouped { get; set; } = true;
90+
91+
/// <summary>
92+
/// The bar background color when hovered.
93+
/// </summary>
94+
/// <remarks>
95+
/// Default value is <see langword="null"/>.
96+
/// </remarks>
97+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
98+
public List<string>? HoverBackgroundColor { get; set; }
99+
100+
/// <summary>
101+
/// The bar border color when hovered.
102+
/// </summary>
103+
/// <remarks>
104+
/// Default value is <see langword="null"/>.
105+
/// </remarks>
106+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
107+
public List<string>? HoverBorderColor { get; set; }
108+
109+
/// <summary>
110+
/// The bar border radius when hovered (in pixels).
111+
/// </summary>
112+
/// <remarks>
113+
/// Default value is 0.
114+
/// </remarks>
115+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
116+
public List<double>? HoverBorderRadius { get; set; }
117+
118+
/// <summary>
119+
/// The bar border width when hovered (in pixels).
120+
/// </summary>
121+
/// <remarks>
122+
/// Default value is 1.
123+
/// </remarks>
124+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
125+
public List<double>? HoverBorderWidth { get; set; }
126+
127+
/// <summary>
128+
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
129+
/// Supported values are 'x' and 'y'.
130+
/// </summary>
131+
/// <remarks>
132+
/// Default value is <see langword="null"/>.
133+
/// </remarks>
134+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
135+
public string? IndexAxis { get; set; }
136+
137+
//InflateAmount
138+
//https://www.chartjs.org/docs/latest/charts/bar.html#inflateamount
139+
140+
/// <summary>
141+
/// Set this to ensure that bars are not sized thicker than this.
142+
/// </summary>
143+
/// <remarks>
144+
/// Default value is <see langword="null"/>.
145+
/// </remarks>
146+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
147+
public double? MaxBarThickness { get; set; }
148+
149+
/// <summary>
150+
/// Set this to ensure that bars have a minimum length in pixels.
151+
/// </summary>
152+
/// <remarks>
153+
/// Default value is <see langword="null"/>.
154+
/// </remarks>
155+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
156+
public double? MinBarLength { get; set; }
157+
158+
//PointStyle
159+
//https://www.chartjs.org/docs/latest/configuration/elements.html#point-styles
160+
161+
/// <summary>
162+
/// If <see langword="true"/>, null or undefined values will not be used for spacing calculations when determining bar size.
163+
/// </summary>
164+
/// <remarks>
165+
/// Default value is <see langword="false"/>.
166+
/// </remarks>
167+
public bool SkipNull { get; set; }
168+
169+
//Stack
170+
//https://www.chartjs.org/docs/latest/charts/bar.html#general
171+
172+
/// <summary>
173+
/// The ID of the x axis to plot this dataset on.
174+
/// </summary>
175+
/// <remarks>
176+
/// Default value is first x axis.
177+
/// </remarks>
178+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
179+
public string? XAxisID { get; set; }
180+
181+
/// <summary>
182+
/// The ID of the y axis to plot this dataset on.
183+
/// </summary>
184+
/// <remarks>
185+
/// Default value is first y axis.
186+
/// </remarks>
187+
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
188+
public string? YAxisID { get; set; }
189+
190+
#endregion
200191
}
201192

202193
public class BarChartDatasetDataLabels : ChartDatasetDataLabels

0 commit comments

Comments
 (0)