Skip to content

Commit 45180f5

Browse files
authored
Code cleanup + 1.1.0 updates (#16)
* Update Bubble Chart support and clean up code - Removed unused `linkGroups` field in `MainLayout`. - Commented out several links in `MainLayoutBaseFooter`. - Updated documentation references from `BarChart` to `BubbleChart`. - Changed icon for "Bubble Chart" in `DemoPageLinkUtil`. - Bumped version to `1.1.0` in `appsettings.json` and project file. - Updated properties in `BubbleChartDataset` for version `1.1.0`. - Cleaned up `BubbleChartOptions` class definition. NOTE: This commit message is auto-generated using GitHub Copilot. * Refactor chart components and improve error handling - Removed `isAsyncDisposed` and `isDisposed` fields in `ChartComponentBase.cs` to simplify disposal logic. - Added null check for `chartData?.Datasets` in `LineChartDataset.cs` to enhance error handling. - Initialized `ChartInteractionMode` to `string.Empty` in `ChartOptions.cs` to prevent null reference issues. NOTE: This commit message is auto-generated using GitHub Copilot.
1 parent a7ee26c commit 45180f5

11 files changed

Lines changed: 38 additions & 113 deletions

File tree

BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayout.razor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ public partial class MainLayout : MainLayoutBase
55
#region Fields and Constants
66

77
private bool isSidebarVisible = false;
8-
//private HashSet<LinkGroup> linkGroups = new();
98
private Menu menuRef = default!;
109

1110
#endregion

BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayoutBaseFooter.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
<li><a href="/">Home</a></li>
3333
<li><a href="@DemoRouteConstants.Docs_Getting_Started_Introduction">Docs</a></li>
3434
<li><a href="@DemoRouteConstants.Demos_BarChart">Demos</a></li>
35-
<li><a href="/">Blog</a></li>
35+
@* <li><a href="/">Blog</a></li> *@
3636
<li><a href="@GithubUrl" target="_blank">GitHub</a></li>
3737
</ul>
3838
</div>
3939
<div class="column">
4040
<p class="is-size-5">Guides</p>
4141
<ul class="menu-list">
4242
<li><a href="@DemoRouteConstants.Docs_Getting_Started_Introduction">Getting started</a></li>
43-
<li><a href="/">Install NuGet package</a></li>
44-
<li><a href="/">Starter templates</a></li>
43+
@* <li><a href="/">Install NuGet package</a></li> *@
44+
@* <li><a href="/">Starter templates</a></li> *@
4545
</ul>
4646
</div>
4747
<div class="column">

BlazorExpress.ChartJS.Demo.RCL/Pages/Docs/BubbleChart/BubbleChart_Doc_01_Documentation.razor

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@
1111

1212
<Image Src="@DemoImageSrcConstants.BarChart" class="img-fluid" alt="Blazor Bar Chart - API Documentation" />
1313

14-
<DemoLink Href="@DemoRouteConstants.Demos_BarChart" />
14+
<DemoLink Href="@DemoRouteConstants.Demos_BubbleChart" />
1515

1616
<Section Class="p-0" Size="HeadingSize.H4" Name="Parameters" PageUrl="@pageUrl" Link="parameters">
17-
<DocxTable TItem="BarChart" DocType="DocType.Parameters" />
17+
<DocxTable TItem="BubbleChart" DocType="DocType.Parameters" />
1818
</Section>
1919

2020
<Section Class="p-0" Size="HeadingSize.H4" Name="Methods" PageUrl="@pageUrl" Link="methods">
21-
<DocxTable TItem="BarChart" DocType="DocType.Methods" />
21+
<DocxTable TItem="BubbleChart" DocType="DocType.Methods" />
2222
</Section>
2323

2424
<Section Class="p-0" Size="HeadingSize.H4" Name="ChartData Properties" PageUrl="@pageUrl" Link="chart-data-properties">
2525
<DocxTable TItem="ChartData" DocType="DocType.Properties" />
2626
</Section>
2727

28-
<Section Class="p-0" Size="HeadingSize.H4" Name="BarChartDataset Properties" PageUrl="@pageUrl" Link="barchart-dataset-properties">
29-
<DocxTable TItem="BarChartDataset" DocType="DocType.Properties" />
28+
<Section Class="p-0" Size="HeadingSize.H4" Name="BubbleChartDataset Properties" PageUrl="@pageUrl" Link="bubblechart-dataset-properties">
29+
<DocxTable TItem="BubbleChartDataset" DocType="DocType.Properties" />
3030
</Section>
3131

32-
<Section Class="p-0" Size="HeadingSize.H4" Name="BarChartDatasetData Properties" PageUrl="@pageUrl" Link="barchart-dataset-data-properties">
33-
<DocxTable TItem="BarChartDatasetData" DocType="DocType.Properties" />
32+
<Section Class="p-0" Size="HeadingSize.H4" Name="BubbleChartDatasetData Properties" PageUrl="@pageUrl" Link="bubblechart-dataset-data-properties">
33+
<DocxTable TItem="BubbleChartDatasetData" DocType="DocType.Properties" />
3434
</Section>
3535

36-
<Section Class="p-0" Size="HeadingSize.H4" Name="BarChartDatasetDataLabels Properties" PageUrl="@pageUrl" Link="barchart-dataset-data-labels-properties">
37-
<DocxTable TItem="BarChartDatasetDataLabels" DocType="DocType.Properties" />
36+
<Section Class="p-0" Size="HeadingSize.H4" Name="BubbleChartDatasetDataLabels Properties" PageUrl="@pageUrl" Link="bubblechart-dataset-data-labels-properties">
37+
<DocxTable TItem="BubbleChartDatasetDataLabels" DocType="DocType.Properties" />
3838
</Section>
3939

40-
<Section Class="p-0" Size="HeadingSize.H4" Name="BarChartOptions Properties" PageUrl="@pageUrl" Link="barchart-options-properties">
41-
<DocxTable TItem="BarChartOptions" DocType="DocType.Properties" />
40+
<Section Class="p-0" Size="HeadingSize.H4" Name="BubbleChartOptions Properties" PageUrl="@pageUrl" Link="bubblechart-options-properties">
41+
<DocxTable TItem="BubbleChartOptions" DocType="DocType.Properties" />
4242
</Section>
4343

4444
@code {

BlazorExpress.ChartJS.Demo.RCL/Utils/DemoPageLinkUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static HashSet<PageLink> GetDemosLinks()
1414
links.Add(new PageLink { Id = index, IconName = BootstrapIconName.BarChartFill, Href = DemoRouteConstants.Demos_BarChart, Text = "Bar Chart", Categories = new() { DemoPageLinkCategory.All, DemoPageLinkCategory.Charts }, Status = PageLinkStatus.None, IsActive = true });
1515

1616
index += 1;
17-
links.Add(new PageLink { Id = index, IconName = BootstrapIconName.Diagram3Fill, Href = DemoRouteConstants.Demos_BubbleChart, Text = "Bubble Chart", Categories = new() { DemoPageLinkCategory.All, DemoPageLinkCategory.Charts }, Status = PageLinkStatus.New, IsActive = true });
17+
links.Add(new PageLink { Id = index, IconName = BootstrapIconName.ThreeDotsVertical, Href = DemoRouteConstants.Demos_BubbleChart, Text = "Bubble Chart", Categories = new() { DemoPageLinkCategory.All, DemoPageLinkCategory.Charts }, Status = PageLinkStatus.New, IsActive = true });
1818

1919
index += 1;
2020
links.Add(new PageLink { Id = index, IconName = BootstrapIconName.CircleFill, Href = DemoRouteConstants.Demos_DoughnutChart, Text = "Doughnut Chart", Categories = new() { DemoPageLinkCategory.All, DemoPageLinkCategory.Charts }, Status = PageLinkStatus.None, IsActive = true });

BlazorExpress.ChartJS.Demo.WebAssembly/wwwroot/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"version": "1.0.0",
2+
"version": "1.1.0",
33
"release": {
4-
"short_description": "Bar, Doughnut, Line and Pie chart components!!!"
4+
"short_description": "Introduces Bubble Chart support and various enhancements."
55
},
66
"NugetPackageName": "BlazorExpress.ChartJS",
77
"NugetPackageDisplayName": "BlazorExpress ChartJS",

BlazorExpress.ChartJS/BlazorExpress.ChartJS.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44

55
<PackageId>BlazorExpress.ChartJS</PackageId>
6-
<Version>1.0.0</Version>
7-
<PackageVersion>1.0.0</PackageVersion>
6+
<Version>1.1.0</Version>
7+
<PackageVersion>1.1.0</PackageVersion>
88

99
<PackageIcon>logo.png</PackageIcon>
1010
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>

BlazorExpress.ChartJS/ChartComponents/Core/ChartComponentBase.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ public abstract class ChartComponentBase : BlazorExpressComponentCore, IDisposab
1212

1313
internal ChartType _chartType;
1414

15-
private bool isAsyncDisposed;
16-
17-
private bool isDisposed;
18-
1915
#endregion
2016

2117
#region Methods

BlazorExpress.ChartJS/Models/ChartDataset/BubbleChart/BubbleChartDataset.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
1818
/// Default value is 'rgba(0, 0, 0, 0.1)'.
1919
/// </para>
2020
/// </summary>
21-
[AddedVersion("1.0.0")]
21+
[AddedVersion("1.1.0")]
2222
[DefaultValue("rgba(0, 0, 0, 0.1)")]
2323
[Description("The line fill color.")]
2424
[ParameterTypeName("List<string>?")]
@@ -31,7 +31,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
3131
/// Default value is 'rgba(0, 0, 0, 0.1)'.
3232
/// </para>
3333
/// </summary>
34-
[AddedVersion("1.0.0")]
34+
[AddedVersion("1.1.0")]
3535
[DefaultValue("rgba(0, 0, 0, 0.1)")]
3636
[Description("The line color.")]
3737
[ParameterTypeName("List<string>?")]
@@ -44,7 +44,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
4444
/// Default value is 3.
4545
/// </para>
4646
/// </summary>
47-
[AddedVersion("1.0.0")]
47+
[AddedVersion("1.1.0")]
4848
[DefaultValue(3)]
4949
[Description("The line width (in pixels).")]
5050
public double BorderWidth { get; set; } = 3;
@@ -60,7 +60,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
6060
/// </para>
6161
/// <see href="https://chartjs-plugin-datalabels.netlify.app/guide/getting-started.html#configuration" />
6262
/// </summary>
63-
[AddedVersion("1.0.0")]
63+
[AddedVersion("1.1.0")]
6464
[DefaultValue("new()")]
6565
[Description("Gets or sets the data labels configuration for the bubble chart dataset. Use this property to customize the display of data labels, such as their position, formatting, and visibility, for the dataset in the bubble chart.")]
6666
[ParameterTypeName(nameof(BubbleChartDatasetDataLabels))]
@@ -73,7 +73,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
7373
/// Default value is <see langword="true"/>.
7474
/// </para>
7575
/// </summary>
76-
[AddedVersion("1.0.0")]
76+
[AddedVersion("1.1.0")]
7777
[DefaultValue(true)]
7878
[Description("Draw the active points of a dataset over the other points of the dataset.")]
7979
[ParameterTypeName("List<bool>?")]
@@ -86,7 +86,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
8686
/// Default value is <see langword="null"/>.
8787
/// </para>
8888
/// </summary>
89-
[AddedVersion("1.0.0")]
89+
[AddedVersion("1.1.0")]
9090
[DefaultValue(null)]
9191
[Description("The line fill color when hovered.")]
9292
[ParameterTypeName("List<string>?")]
@@ -99,7 +99,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
9999
/// Default value is <see langword="null"/>.
100100
/// </para>
101101
/// </summary>
102-
[AddedVersion("1.0.0")]
102+
[AddedVersion("1.1.0")]
103103
[DefaultValue(null)]
104104
[Description("The line color when hovered.")]
105105
[ParameterTypeName("List<string>?")]
@@ -112,7 +112,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
112112
/// Default value is 1.
113113
/// </para>
114114
/// </summary>
115-
[AddedVersion("1.0.0")]
115+
[AddedVersion("1.1.0")]
116116
[DefaultValue(1)]
117117
[Description("The line width (in pixels) when hovered.")]
118118
[ParameterTypeName("List<double>?")]
@@ -125,7 +125,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
125125
/// Default value is 1.
126126
/// </para>
127127
/// </summary>
128-
[AddedVersion("1.0.0")]
128+
[AddedVersion("1.1.0")]
129129
[DefaultValue(1)]
130130
[Description("The pixel size of the non-displayed point that reacts to mouse events.")]
131131
[ParameterTypeName("List<double>?")]
@@ -138,7 +138,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
138138
/// Default value is 4.
139139
/// </para>
140140
/// </summary>
141-
[AddedVersion("1.0.0")]
141+
[AddedVersion("1.1.0")]
142142
[DefaultValue(4)]
143143
[Description("The pixel size of the non-displayed point that reacts to mouse events.")]
144144
[ParameterTypeName("List<double>?")]
@@ -154,7 +154,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
154154
/// Default value is 3.
155155
/// </para>
156156
/// </summary>
157-
[AddedVersion("1.0.0")]
157+
[AddedVersion("1.1.0")]
158158
[DefaultValue(3)]
159159
[Description("The radius of the point shape. If set to 0, the point is not rendered.")]
160160
[ParameterTypeName("List<double>?")]
@@ -167,7 +167,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
167167
/// Default value is 0.
168168
/// </para>
169169
/// </summary>
170-
[AddedVersion("1.0.0")]
170+
[AddedVersion("1.1.0")]
171171
[DefaultValue(0)]
172172
[Description("The rotation of the point in degrees.")]
173173
[ParameterTypeName("List<double>?")]
@@ -182,7 +182,7 @@ public class BubbleChartDataset : ChartDataset<BubbleChartDataPoint>
182182
/// </para>
183183
/// <see href="https://www.chartjs.org/docs/latest/configuration/elements.html#point-styles" />
184184
/// </summary>
185-
[AddedVersion("1.0.0")]
185+
[AddedVersion("1.1.0")]
186186
[DefaultValue("circle")]
187187
[Description("Style of the point. Supported values are 'circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', and 'triangle'.")]
188188
[ParameterTypeName("List<string>?")]

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public LineChartDataset FillToDataset(ChartData chartData, IChartDataset dataset
4848

4949
if (relativeIndex)
5050
{
51-
var myIndex = relativeIndex ? chartData.Datasets.IndexOf(this) : 0;
51+
if (chartData?.Datasets == null)
52+
throw new ArgumentException("The chart data or its datasets collection is null.");
53+
54+
var myIndex = chartData.Datasets.IndexOf(this);
5255

5356
if (myIndex < 0)
5457
throw new ArgumentException("The dataset is not in the chart data.");
Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,3 @@
11
namespace BlazorExpress.ChartJS;
22

3-
public class BubbleChartOptions : ChartOptions
4-
{
5-
#region Properties, Indexers
6-
7-
//hover -> mode, intersect
8-
//maintainAspectRatio
9-
//plugins -> title -> display, text
10-
/*
11-
/// <summary>
12-
/// The base axis of the dataset. 'x' for horizontal lines and 'y' for vertical lines.
13-
/// </summary>
14-
/// <remarks>
15-
/// Default value is <see langword="null"/>.
16-
/// </remarks>
17-
[AddedVersion("1.0.0")]
18-
[DefaultValue(null)]
19-
[Description("The base axis of the dataset. 'x' for horizontal lines and 'y' for vertical lines.")]
20-
[ParameterTypeName("string?")]
21-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
22-
public string? IndexAxis { get; set; }
23-
24-
/// <summary>
25-
/// Gets or sets the interaction options for the chart.
26-
/// By default, these options apply to both the hover and tooltip interactions.
27-
/// <para>
28-
/// Default value is a new instance of <see cref="Interaction"/>.
29-
/// </para>
30-
/// <see href="https://www.chartjs.org/docs/latest/configuration/interactions.html#interactions" />
31-
/// </summary>
32-
[AddedVersion("1.0.0")]
33-
[DefaultValue("new()")]
34-
[Description("Gets or sets the interaction options for the chart.")]
35-
public Interaction Interaction { get; set; } = new();
36-
37-
/// <summary>
38-
/// Gets or sets the layout configuration for the chart.
39-
/// <para>
40-
/// Default value is a new instance of <see cref="ChartLayout"/>.
41-
/// </para>
42-
/// <see href="https://www.chartjs.org/docs/latest/configuration/layout.html#layout" />
43-
/// </summary>
44-
[AddedVersion("1.0.0")]
45-
[DefaultValue("new()")]
46-
[Description("Gets or sets the layout configuration for the chart.")]
47-
[ParameterTypeName(nameof(ChartLayout))]
48-
public ChartLayout Layout { get; set; } = new();
49-
50-
/// <summary>
51-
/// Gets or sets the collection of plugins associated with the line chart.
52-
/// <para>
53-
/// Default value is a new instance of <see cref="LineChartPlugins"/>.
54-
/// </para>
55-
/// </summary>
56-
[AddedVersion("1.0.0")]
57-
[DefaultValue("new()")]
58-
[Description("Gets or sets the collection of plugins associated with the line chart.")]
59-
[ParameterTypeName(nameof(LineChartPlugins))]
60-
public LineChartPlugins Plugins { get; set; } = new();
61-
62-
/// <summary>
63-
/// Gets or sets the collection of scales used for measurement or calibration.
64-
/// <para>
65-
/// Default value is a new instance of <see cref="Scales"/>.
66-
/// </para>
67-
/// </summary>
68-
[AddedVersion("1.0.0")]
69-
[DefaultValue("new()")]
70-
[Description("Gets or sets the collection of scales used for measurement or calibration.")]
71-
public Scales Scales { get; set; } = new();
72-
*/
73-
#endregion
74-
75-
//tooltips -> mode, intersect
76-
}
3+
public class BubbleChartOptions : ChartOptions { }

0 commit comments

Comments
 (0)