Skip to content

Commit d329eeb

Browse files
committed
Update Usings and ChartComponentBase with new references
- Added `BlazorExpress.Core` to `Usings.cs` and updated `System.ComponentModel` reference. - Changed company name in `BlazorExpress.ChartJS.csproj` and updated `PackageReference` for `Microsoft.AspNetCore.Components.Web` to version `8.0.17`. - Significant refactoring in `ChartComponentBase.cs`, including inheritance change, removal of several methods, and addition of new properties with XML documentation. - Updated `Usings.cs` to include `System.Drawing` and `System.Globalization`. NOTE: This commit message is auto-generated using GitHub Copilot.
1 parent f50d0c8 commit d329eeb

4 files changed

Lines changed: 67 additions & 153 deletions

File tree

BlazorExpress.ChartJS.Demo.RCL/Usings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
global using Microsoft.AspNetCore.Components;
55
global using Microsoft.Extensions.Configuration;
66
global using Microsoft.JSInterop;
7-
global using System.ComponentModel;
7+
global using System.ComponentModel;

BlazorExpress.ChartJS/BlazorExpress.ChartJS.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>Blazor, BlazorExpress, Charts, BlazorBarChart, BlazorDoughnutChart, BlazorLineChart, BlazorPieChart</PackageTags>
1515
<Description>An open-source, production-ready Blazor charts component library built on the Blazor and Chart.js JavaScript library.</Description>
1616
<Authors>Vikram Reddy</Authors>
17-
<!--<Company>your_company</Company>-->
17+
<Company>Blazor Express</Company>
1818
<Copyright>Copyright © 2025 Blazor Express</Copyright>
1919

2020
<TargetFramework>net8.0</TargetFramework>
@@ -32,7 +32,8 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.5" />
35+
<PackageReference Include="BlazorExpress.Core" Version="0.0.4" />
36+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.17" />
3637
</ItemGroup>
3738

3839
</Project>

BlazorExpress.ChartJS/ChartComponents/Core/ChartComponentBase.cs

Lines changed: 59 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
namespace BlazorExpress.ChartJS;
22

3-
public abstract class ChartComponentBase : ComponentBase, IDisposable, IAsyncDisposable
3+
/// <summary>
4+
/// Base class for Chart components.
5+
/// <para>
6+
/// <see href="https://www.chartjs.org/docs/latest/" />
7+
/// </para>
8+
/// </summary>
9+
public abstract class ChartComponentBase : BlazorExpressComponentCore, IDisposable, IAsyncDisposable
410
{
511
#region Fields and Constants
612

@@ -14,73 +20,6 @@ public abstract class ChartComponentBase : ComponentBase, IDisposable, IAsyncDis
1420

1521
#region Methods
1622

17-
/// <inheritdoc />
18-
protected override async Task OnAfterRenderAsync(bool firstRender)
19-
{
20-
IsRenderComplete = true;
21-
22-
await base.OnAfterRenderAsync(firstRender);
23-
}
24-
25-
/// <inheritdoc />
26-
protected override void OnInitialized()
27-
{
28-
Id ??= IdUtility.GetNextId();
29-
30-
base.OnInitialized();
31-
}
32-
33-
public static string BuildClassNames(params (string? cssClass, bool when)[] cssClassList)
34-
{
35-
var list = new HashSet<string>();
36-
37-
if (cssClassList is not null && cssClassList.Any())
38-
foreach (var (cssClass, when) in cssClassList)
39-
if (!string.IsNullOrWhiteSpace(cssClass) && when)
40-
list.Add(cssClass);
41-
42-
if (list.Any())
43-
return string.Join(" ", list);
44-
45-
return string.Empty;
46-
}
47-
48-
public static string BuildClassNames(string? userDefinedCssClass, params (string? cssClass, bool when)[] cssClassList)
49-
{
50-
var list = new HashSet<string>();
51-
52-
if (cssClassList is not null && cssClassList.Any())
53-
foreach (var (cssClass, when) in cssClassList)
54-
if (!string.IsNullOrWhiteSpace(cssClass) && when)
55-
list.Add(cssClass);
56-
57-
if (!string.IsNullOrWhiteSpace(userDefinedCssClass))
58-
list.Add(userDefinedCssClass.Trim());
59-
60-
if (list.Any())
61-
return string.Join(" ", list);
62-
63-
return string.Empty;
64-
}
65-
66-
public static string BuildStyleNames(string? userDefinedCssStyle, params (string? cssStyle, bool when)[] cssStyleList)
67-
{
68-
var list = new HashSet<string>();
69-
70-
if (cssStyleList is not null && cssStyleList.Any())
71-
foreach (var (cssStyle, when) in cssStyleList)
72-
if (!string.IsNullOrWhiteSpace(cssStyle) && when)
73-
list.Add(cssStyle);
74-
75-
if (!string.IsNullOrWhiteSpace(userDefinedCssStyle))
76-
list.Add(userDefinedCssStyle.Trim());
77-
78-
if (list.Any())
79-
return string.Join(';', list);
80-
81-
return string.Empty;
82-
}
83-
8423
//public async Task Stop() { }
8524

8625
//public async Task ToBase64Image() { }
@@ -93,25 +32,6 @@ public static string BuildStyleNames(string? userDefinedCssStyle, params (string
9332

9433
public virtual async Task<ChartData> AddDatasetAsync(ChartData chartData, IChartDataset chartDataset, IChartOptions chartOptions) => await Task.FromResult(chartData);
9534

96-
/// <inheritdoc />
97-
/// <seealso href="https://learn.microsoft.com/en-us/dotnet/api/system.idisposable?view=net-6.0" />
98-
public void Dispose()
99-
{
100-
Dispose(true);
101-
GC.SuppressFinalize(this);
102-
}
103-
104-
/// <inheritdoc />
105-
/// <seealso
106-
/// href="https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-disposeasync#implement-both-dispose-and-async-dispose-patterns" />
107-
public async ValueTask DisposeAsync()
108-
{
109-
await DisposeAsyncCore(true).ConfigureAwait(false);
110-
111-
Dispose(false);
112-
GC.SuppressFinalize(this);
113-
}
114-
11535
//public async Task Clear() { }
11636

11737
/// <summary>
@@ -161,34 +81,6 @@ public virtual async Task UpdateAsync(ChartData chartData, IChartOptions chartOp
16181
await JSRuntime.InvokeVoidAsync(ChartInterop.Update, Id, GetChartType(), _data, chartOptions);
16282
}
16383

164-
protected virtual void Dispose(bool disposing)
165-
{
166-
if (!isDisposed)
167-
{
168-
if (disposing)
169-
{
170-
// cleanup
171-
}
172-
173-
isDisposed = true;
174-
}
175-
}
176-
177-
protected virtual ValueTask DisposeAsyncCore(bool disposing)
178-
{
179-
if (!isAsyncDisposed)
180-
{
181-
if (disposing)
182-
{
183-
// cleanup
184-
}
185-
186-
isAsyncDisposed = true;
187-
}
188-
189-
return ValueTask.CompletedTask;
190-
}
191-
19284
protected string GetChartType() =>
19385
_chartType switch
19486
{
@@ -242,74 +134,93 @@ private object GetChartDataObject(ChartData chartData)
242134

243135
#region Properties, Indexers
244136

245-
[Parameter(CaptureUnmatchedValues = true)]
246-
public Dictionary<string, object> AdditionalAttributes { get; set; } = default!;
247-
248-
[Parameter] public string? Class { get; set; }
249-
250-
protected virtual string? ClassNames => Class;
251-
137+
/// <summary>
138+
/// Gets or sets the CSS class name for the container element.
139+
/// <para>
140+
/// Default value is <see langword="null" />.
141+
/// </para>
142+
/// </summary>
143+
[AddedVersion("1.0.0")]
144+
[DefaultValue(null)]
145+
[Description("Gets or sets the CSS class name for the container element.")]
252146
[Parameter]
253147
public string? ContainerClass { get; set; }
254148

149+
/// <summary>
150+
/// Gets or sets the CSS style string applied to the container element.
151+
/// <para>
152+
/// Default value is <see langword="null" />.
153+
/// </para>
154+
/// </summary>
155+
[AddedVersion("1.0.0")]
156+
[DefaultValue(null)]
157+
[Description("Gets or sets the CSS style string applied to the container element.")]
255158
[Parameter]
256159
public string? ContainerStyle { get; set; }
257160

258-
public ElementReference Element { get; set; }
259-
260161
/// <summary>
261162
/// Gets or sets chart container height.
262163
/// The default unit of measure is <see cref="Unit.Px" />.
263164
/// To change the unit of measure see <see cref="HeightUnit" />.
165+
/// <para>
166+
/// Default value is <see langword="null" />.
167+
/// </para>
264168
/// </summary>
265-
/// <remarks>
266-
/// Default value is null.
267-
/// </remarks>
169+
[AddedVersion("1.0.0")]
170+
[DefaultValue(null)]
171+
[Description("Gets or sets chart container height.")]
268172
[Parameter]
269173
public int? Height { get; set; }
270174

271175
/// <summary>
272176
/// Gets or sets chart container height unit of measure.
273-
/// </summary>
274-
/// <remarks>
177+
/// <para>
275178
/// Default value is <see cref="Unit.Px" />.
276-
/// </remarks>
179+
/// </para>
180+
/// </summary>
181+
[AddedVersion("1.0.0")]
182+
[DefaultValue(Unit.Px)]
183+
[Description("Gets or sets chart container height unit of measure.")]
277184
[Parameter]
278185
public Unit HeightUnit { get; set; } = Unit.Px;
279186

280-
[Parameter]
281-
public string? Id { get; set; }
282-
187+
/// <summary>
188+
/// Gets or sets a value indicating whether the container is fluid.
189+
/// <para>
190+
/// Default value is <see langword="false" />.
191+
/// </para>
192+
/// </summary>
193+
[AddedVersion("1.0.0")]
194+
[DefaultValue(false)]
195+
[Description("Gets or sets a value indicating whether the container is fluid.")]
283196
[Parameter]
284197
public bool IsContainerFluid { get; set; }
285198

286199
protected bool IsRenderComplete { get; private set; }
287200

288-
[Inject]
289-
protected IJSRuntime JSRuntime { get; set; } = default!;
290-
291-
[Parameter]
292-
public string? Style { get; set; }
293-
294-
protected virtual string? StyleNames => Style;
295-
296201
/// <summary>
297-
/// Get or sets chart container width.
202+
/// Gets or sets chart container width.
298203
/// The default unit of measure is <see cref="Unit.Px" />.
299204
/// To change the unit of measure see <see cref="WidthUnit" />.
205+
/// <para>
206+
/// Default value is <see langword="null" />.
207+
/// </para>
300208
/// </summary>
301-
/// <remarks>
302-
/// Default value is null.
303-
/// </remarks>
209+
[AddedVersion("1.0.0")]
210+
[DefaultValue(null)]
211+
[Description("Gets or sets chart container width.")]
304212
[Parameter]
305213
public int? Width { get; set; }
306214

307215
/// <summary>
308216
/// Gets or sets chart container width unit of measure.
309-
/// </summary>
310-
/// <remarks>
217+
/// <para>
311218
/// Default value is <see cref="Unit.Px" />.
312-
/// </remarks>
219+
/// </para>
220+
/// </summary>
221+
[AddedVersion("1.0.0")]
222+
[DefaultValue(Unit.Px)]
223+
[Description("Gets or sets chart container width unit of measure.")]
313224
[Parameter]
314225
public Unit WidthUnit { get; set; } = Unit.Px;
315226

BlazorExpress.ChartJS/Usings.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
global using Microsoft.AspNetCore.Components;
1+
global using BlazorExpress.Core;
2+
global using Microsoft.AspNetCore.Components;
23
global using Microsoft.JSInterop;
4+
global using System.ComponentModel;
35
global using System.Drawing;
46
global using System.Globalization;
5-
global using System.Text.Json.Serialization;
7+
global using System.Text.Json.Serialization;

0 commit comments

Comments
 (0)