Skip to content

Commit 901b225

Browse files
committed
Enhance LineChartDataset documentation and defaults
Updated the `LineChartDataset` class in `LineChartDataset.cs` to include more descriptive attributes for various properties. Key changes include: - Added detailed descriptions for properties like `CubicInterpolationMode`, `DrawActiveElementsOnTop`, and `Fill`. - Explicitly set default values for several properties to improve dataset initialization. - Enhanced comments for the `ShowLine` and `Stepped` properties to clarify their functionality and possible values. - Overall improvements to documentation and usability for better developer understanding. NOTE: This commit message is auto-generated using GitHub Copilot.
1 parent 6281780 commit 901b225

1 file changed

Lines changed: 74 additions & 65 deletions

File tree

BlazorExpress.ChartJS/Models/ChartDataset/LineChart/LineChartDataset.cs

Lines changed: 74 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace BlazorExpress.ChartJS;
1+
using System.Diagnostics.Metrics;
2+
using System.Reflection;
3+
4+
namespace BlazorExpress.ChartJS;
25

36
/// <summary>
47
/// A line chart is a way of plotting data points on a line.
@@ -214,7 +217,7 @@ public LineChartDataset FillToValue(double value)
214217
/// </summary>
215218
[AddedVersion("1.0.0")]
216219
[DefaultValue("default")]
217-
[Description("")]
220+
[Description("Supported values are 'default', and 'monotone'.")]
218221
public string CubicInterpolationMode { get; set; } = "default";
219222

220223
[AddedVersion("1.0.0")]
@@ -231,8 +234,8 @@ public LineChartDataset FillToValue(double value)
231234
/// </para>
232235
/// </summary>
233236
[AddedVersion("1.0.0")]
234-
[DefaultValue("")]
235-
[Description("")]
237+
[DefaultValue(null)]
238+
[Description("Draw the active points of a dataset over the other points of the dataset.")]
236239
[ParameterTypeName("List<bool>?")]
237240
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
238241
public List<bool>? DrawActiveElementsOnTop { get; set; }
@@ -245,7 +248,7 @@ public LineChartDataset FillToValue(double value)
245248
/// </summary>
246249
[AddedVersion("1.0.0")]
247250
[DefaultValue(false)]
248-
[Description("")]
251+
[Description("How to fill the area under the line.")]
249252
public object Fill { get; set; } = false;
250253

251254
/// <summary>
@@ -255,8 +258,8 @@ public LineChartDataset FillToValue(double value)
255258
/// </para>
256259
/// </summary>
257260
[AddedVersion("1.0.0")]
258-
[DefaultValue("")]
259-
[Description("")]
261+
[DefaultValue(null)]
262+
[Description("The line fill color when hovered.")]
260263
[ParameterTypeName("string?")]
261264
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
262265
public string? HoverBackgroundColor { get; set; }
@@ -268,8 +271,8 @@ public LineChartDataset FillToValue(double value)
268271
/// </para>
269272
/// </summary>
270273
[AddedVersion("1.0.0")]
271-
[DefaultValue("")]
272-
[Description("")]
274+
[DefaultValue(null)]
275+
[Description("Cap style of the line when hovered.")]
273276
[ParameterTypeName("string?")]
274277
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
275278
public string? HoverBorderCapStyle { get; set; }
@@ -281,21 +284,21 @@ public LineChartDataset FillToValue(double value)
281284
/// </para>
282285
/// </summary>
283286
[AddedVersion("1.0.0")]
284-
[DefaultValue("")]
285-
[Description("")]
287+
[DefaultValue(null)]
288+
[Description("The line color when hovered.")]
286289
[ParameterTypeName("string?")]
287290
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
288291
public string? HoverBorderColor { get; set; }
289292

290293
/// <summary>
291-
/// Gets or sets the length and spacing of dashes when hovered.
294+
/// Length and spacing of dashes when hovered.
292295
/// <para>
293296
/// Default value is <see langword="null"/>.
294297
/// </para>
295298
/// </summary>
296299
[AddedVersion("1.0.0")]
297-
[DefaultValue("")]
298-
[Description("")]
300+
[DefaultValue(null)]
301+
[Description("Length and spacing of dashes when hovered.")]
299302
[ParameterTypeName("List<double>?")]
300303
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
301304
public List<double>? HoverBorderDash { get; set; }
@@ -307,33 +310,33 @@ public LineChartDataset FillToValue(double value)
307310
/// </para>
308311
/// </summary>
309312
[AddedVersion("1.0.0")]
310-
[DefaultValue("")]
311-
[Description("")]
313+
[DefaultValue(null)]
314+
[Description("Offset for line dashes when hovered.")]
312315
[ParameterTypeName("double?")]
313316
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
314317
public double? HoverBorderDashOffset { get; set; }
315318

316319
/// <summary>
317-
/// Line joint style.
320+
/// Line joint style when hovered.
318321
/// There are three possible values for this property: 'round', 'bevel', and 'miter'.
319322
/// <para>
320323
/// Default value is 'miter'.
321324
/// </para>
322325
/// </summary>
323326
[AddedVersion("1.0.0")]
324-
[DefaultValue("")]
325-
[Description("")]
327+
[DefaultValue("miter")]
328+
[Description("Line joint style. There are three possible values for this property: 'round', 'bevel', and 'miter'.")]
326329
public string HoverBorderJoinStyle { get; set; } = "miter";
327330

328331
/// <summary>
329-
/// The bar border width when hovered (in pixels) when hovered.
332+
/// The line width (in pixels) when hovered.
330333
/// <para>
331334
/// Default value is <see langword="null"/>.
332335
/// </para>
333336
/// </summary>
334337
[AddedVersion("1.0.0")]
335-
[DefaultValue("")]
336-
[Description("")]
338+
[DefaultValue(null)]
339+
[Description("The line width (in pixels) when hovered.")]
337340
[ParameterTypeName("double?")]
338341
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
339342
public double? HoverBorderWidth { get; set; }
@@ -345,11 +348,11 @@ public LineChartDataset FillToValue(double value)
345348
/// </para>
346349
/// </summary>
347350
[AddedVersion("1.0.0")]
348-
[DefaultValue("")]
349-
[Description("")]
351+
[DefaultValue("x")]
352+
[Description("The base axis of the dataset. 'x' for horizontal lines and 'y' for vertical lines.")]
350353
[ParameterTypeName("string?")]
351354
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
352-
public string? IndexAxis { get; set; }
355+
public string? IndexAxis { get; set; } = "x";
353356

354357
/// <summary>
355358
/// The fill color for points.
@@ -358,8 +361,8 @@ public LineChartDataset FillToValue(double value)
358361
/// </para>
359362
/// </summary>
360363
[AddedVersion("1.0.0")]
361-
[DefaultValue("")]
362-
[Description("")]
364+
[DefaultValue("rgba(0, 0, 0, 0.1)")]
365+
[Description("The fill color for points.")]
363366
[ParameterTypeName("List<string>?")]
364367
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
365368
public List<string>? PointBackgroundColor { get; set; }
@@ -371,8 +374,8 @@ public LineChartDataset FillToValue(double value)
371374
/// </para>
372375
/// </summary>
373376
[AddedVersion("1.0.0")]
374-
[DefaultValue("")]
375-
[Description("")]
377+
[DefaultValue("rgba(0, 0, 0, 0.1)")]
378+
[Description("The border color for points.")]
376379
[ParameterTypeName("List<string>?")]
377380
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
378381
public List<string>? PointBorderColor { get; set; }
@@ -384,8 +387,8 @@ public LineChartDataset FillToValue(double value)
384387
/// </para>
385388
/// </summary>
386389
[AddedVersion("1.0.0")]
387-
[DefaultValue("")]
388-
[Description("")]
390+
[DefaultValue(1)]
391+
[Description("The width of the point border in pixels.")]
389392
[ParameterTypeName("List<double>?")]
390393
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
391394
public List<double>? PointBorderWidth { get; set; }
@@ -397,8 +400,8 @@ public LineChartDataset FillToValue(double value)
397400
/// </para>
398401
/// </summary>
399402
[AddedVersion("1.0.0")]
400-
[DefaultValue("")]
401-
[Description("")]
403+
[DefaultValue(1)]
404+
[Description("The pixel size of the non-displayed point that reacts to mouse events.")]
402405
[ParameterTypeName("List<double>?")]
403406
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
404407
public List<double>? PointHitRadius { get; set; }
@@ -410,8 +413,8 @@ public LineChartDataset FillToValue(double value)
410413
/// </para>
411414
/// </summary>
412415
[AddedVersion("1.0.0")]
413-
[DefaultValue("")]
414-
[Description("")]
416+
[DefaultValue(null)]
417+
[Description("Point background color when hovered.")]
415418
[ParameterTypeName("List<string>?")]
416419
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
417420
public List<string>? PointHoverBackgroundColor { get; set; }
@@ -423,8 +426,8 @@ public LineChartDataset FillToValue(double value)
423426
/// </para>
424427
/// </summary>
425428
[AddedVersion("1.0.0")]
426-
[DefaultValue("")]
427-
[Description("")]
429+
[DefaultValue(null)]
430+
[Description("Point border color when hovered.")]
428431
[ParameterTypeName("List<string>?")]
429432
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
430433
public List<string>? PointHoverBorderColor { get; set; }
@@ -436,8 +439,8 @@ public LineChartDataset FillToValue(double value)
436439
/// </para>
437440
/// </summary>
438441
[AddedVersion("1.0.0")]
439-
[DefaultValue("")]
440-
[Description("")]
442+
[DefaultValue(1)]
443+
[Description("Border width of point when hovered.")]
441444
[ParameterTypeName("List<double>?")]
442445
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
443446
public List<double>? PointHoverBorderWidth { get; set; }
@@ -449,8 +452,8 @@ public LineChartDataset FillToValue(double value)
449452
/// </para>
450453
/// </summary>
451454
[AddedVersion("1.0.0")]
452-
[DefaultValue("")]
453-
[Description("")]
455+
[DefaultValue(4)]
456+
[Description("The radius of the point when hovered.")]
454457
[ParameterTypeName("List<double>?")]
455458
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
456459
public List<double>? PointHoverRadius { get; set; }
@@ -462,8 +465,8 @@ public LineChartDataset FillToValue(double value)
462465
/// </para>
463466
/// </summary>
464467
[AddedVersion("1.0.0")]
465-
[DefaultValue("")]
466-
[Description("")]
468+
[DefaultValue(3)]
469+
[Description("The radius of the point shape. If set to 0, the point is not rendered.")]
467470
[ParameterTypeName("List<double>?")]
468471
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
469472
public List<double>? PointRadius { get; set; }
@@ -475,23 +478,23 @@ public LineChartDataset FillToValue(double value)
475478
/// </para>
476479
/// </summary>
477480
[AddedVersion("1.0.0")]
478-
[DefaultValue("")]
479-
[Description("")]
481+
[DefaultValue(0)]
482+
[Description("The rotation of the point in degrees.")]
480483
[ParameterTypeName("List<double>?")]
481484
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
482485
public List<double>? PointRotation { get; set; }
483486

484487
/// <summary>
485488
/// Style of the point.
486-
/// Supported values are 'circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', and 'triangle' to style.
487-
/// the point.
489+
/// Supported values are 'circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', and 'triangle'.
488490
/// <para>
489491
/// Default value is 'circle'.
490492
/// </para>
493+
/// <see href="https://www.chartjs.org/docs/latest/configuration/elements.html#point-styles" />
491494
/// </summary>
492495
[AddedVersion("1.0.0")]
493-
[DefaultValue("")]
494-
[Description("")]
496+
[DefaultValue("circle")]
497+
[Description("Style of the point. Supported values are 'circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', and 'triangle'.")]
495498
[ParameterTypeName("List<string>?")]
496499
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
497500
public List<string>? PointStyle { get; set; }
@@ -500,15 +503,14 @@ public LineChartDataset FillToValue(double value)
500503
//https://www.chartjs.org/docs/latest/charts/line.html#segment
501504

502505
/// <summary>
503-
/// If <see langword="false" />, the lines between points are not drawn.
506+
/// If <see langword="false" />, the line is not drawn for this dataset.
504507
/// <para>
505508
/// Default value is <see langword="true"/>.
506509
/// </para>
507510
/// </summary>
508511
[AddedVersion("1.0.0")]
509-
[DefaultValue("")]
510-
[Description("")]
511-
//[ParameterTypeName("")]
512+
[DefaultValue(true)]
513+
[Description("If false, the line is not drawn for this dataset.")]
512514
public bool ShowLine { get; set; } = true;
513515

514516
/// <summary>
@@ -521,8 +523,8 @@ public LineChartDataset FillToValue(double value)
521523
/// </para>
522524
/// </summary>
523525
[AddedVersion("1.0.0")]
524-
[DefaultValue("")]
525-
[Description("")]
526+
[DefaultValue(null)]
527+
[Description("If true, lines will be drawn between points with no or null data. If 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.")]
526528
[ParameterTypeName("bool?")]
527529
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
528530
public bool? SpanGaps { get; set; }
@@ -531,15 +533,22 @@ public LineChartDataset FillToValue(double value)
531533
//https://www.chartjs.org/docs/latest/charts/line.html#general
532534

533535
/// <summary>
534-
/// true to show the line as a stepped line (tension will be ignored).
536+
/// If the stepped value is set to anything other than <see langword="false"/>, tension will be ignored.
537+
/// The following values are supported for stepped.
538+
/// - false: No Step Interpolation(default)
539+
/// - true: Step-before Interpolation(eq. 'before')
540+
/// - 'before': Step-before Interpolation
541+
/// - 'after': Step-after Interpolation
542+
/// - 'middle': Step-middle Interpolation
535543
/// <para>
536544
/// Default value is <see langword="false"/>.
537545
/// </para>
546+
/// <see href="https://www.chartjs.org/docs/latest/charts/line.html#stepped" />
538547
/// </summary>
539548
[AddedVersion("1.0.0")]
540-
[DefaultValue("")]
541-
[Description("")]
542-
public bool Stepped { get; set; }
549+
[DefaultValue(false)]
550+
[Description("If the stepped value is set to anything other than false, tension will be ignored. <br /> <div>The following values are supported for stepped. <ol class=\"pl-4\"><li><b>false</b>: No Step Interpolation(default)</li><li><b>true</b>: Step-before Interpolation(eq. 'before')</li><li><b>'before'</b>: Step-before Interpolation</li><li><b>'after'</b>: Step-after Interpolation</li><li><b>'middle'</b>: Step-middle Interpolation</ol></div>")]
551+
public object Stepped { get; set; } = false;
543552

544553
/// <summary>
545554
/// Bezier curve tension of the line. Set to 0 to draw straight lines.
@@ -549,8 +558,8 @@ public LineChartDataset FillToValue(double value)
549558
/// </para>
550559
/// </summary>
551560
[AddedVersion("1.0.0")]
552-
[DefaultValue("")]
553-
[Description("")]
561+
[DefaultValue(0)]
562+
[Description("Bezier curve tension of the line. Set to 0 to draw straightlines. This option is ignored if monotone cubic interpolation is used.")]
554563
public double Tension { get; set; }
555564

556565
/// <summary>
@@ -560,8 +569,8 @@ public LineChartDataset FillToValue(double value)
560569
/// </para>
561570
/// </summary>
562571
[AddedVersion("1.0.0")]
563-
[DefaultValue("")]
564-
[Description("")]
572+
[DefaultValue("Default value is 'first x axis'.")]
573+
[Description("The ID of the x-axis to plot this dataset on. Default value is 'first x axis'.")]
565574
[ParameterTypeName("string?")]
566575
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
567576
public string? XAxisID { get; set; }
@@ -573,8 +582,8 @@ public LineChartDataset FillToValue(double value)
573582
/// </para>
574583
/// </summary>
575584
[AddedVersion("1.0.0")]
576-
[DefaultValue("")]
577-
[Description("")]
585+
[DefaultValue("Default value is 'first y axis'.")]
586+
[Description("The ID of the y-axis to plot this dataset on. Default value is 'first y axis'.")]
578587
[ParameterTypeName("string?")]
579588
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
580589
public string? YAxisID { get; set; }

0 commit comments

Comments
 (0)