From a6d4de2f0ea74cc6147aaeeca78c9fd421beee75 Mon Sep 17 00:00:00 2001 From: Vikram Reddy Date: Sat, 9 Aug 2025 22:29:12 +0530 Subject: [PATCH 1/2] 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. --- .../Layout/MainLayout.razor.cs | 1 - .../Layout/MainLayoutBaseFooter.razor | 6 +- .../BubbleChart_Doc_01_Documentation.razor | 22 +++--- .../Utils/DemoPageLinkUtil.cs | 2 +- .../wwwroot/appsettings.json | 4 +- .../BlazorExpress.ChartJS.csproj | 4 +- .../BubbleChart/BubbleChartDataset.cs | 26 +++---- .../Models/ChartOptions/BubbleChartOptions.cs | 75 +------------------ 8 files changed, 33 insertions(+), 107 deletions(-) diff --git a/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayout.razor.cs b/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayout.razor.cs index fc8bd82d..a4a30773 100644 --- a/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayout.razor.cs +++ b/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayout.razor.cs @@ -5,7 +5,6 @@ public partial class MainLayout : MainLayoutBase #region Fields and Constants private bool isSidebarVisible = false; - //private HashSet linkGroups = new(); private Menu menuRef = default!; #endregion diff --git a/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayoutBaseFooter.razor b/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayoutBaseFooter.razor index d706ada0..03b020f5 100644 --- a/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayoutBaseFooter.razor +++ b/BlazorExpress.ChartJS.Demo.RCL/Layout/MainLayoutBaseFooter.razor @@ -32,7 +32,7 @@
  • Home
  • Docs
  • Demos
  • -
  • Blog
  • + @*
  • Blog
  • *@
  • GitHub
  • @@ -40,8 +40,8 @@

    Guides

    diff --git a/BlazorExpress.ChartJS.Demo.RCL/Pages/Docs/BubbleChart/BubbleChart_Doc_01_Documentation.razor b/BlazorExpress.ChartJS.Demo.RCL/Pages/Docs/BubbleChart/BubbleChart_Doc_01_Documentation.razor index b2f76549..9a56fa8a 100644 --- a/BlazorExpress.ChartJS.Demo.RCL/Pages/Docs/BubbleChart/BubbleChart_Doc_01_Documentation.razor +++ b/BlazorExpress.ChartJS.Demo.RCL/Pages/Docs/BubbleChart/BubbleChart_Doc_01_Documentation.razor @@ -11,34 +11,34 @@ Blazor Bar Chart - API Documentation - +
    - +
    - +
    -
    - +
    +
    -
    - +
    +
    -
    - +
    +
    -
    - +
    +
    @code { diff --git a/BlazorExpress.ChartJS.Demo.RCL/Utils/DemoPageLinkUtil.cs b/BlazorExpress.ChartJS.Demo.RCL/Utils/DemoPageLinkUtil.cs index 07c775f2..c4d883d1 100644 --- a/BlazorExpress.ChartJS.Demo.RCL/Utils/DemoPageLinkUtil.cs +++ b/BlazorExpress.ChartJS.Demo.RCL/Utils/DemoPageLinkUtil.cs @@ -14,7 +14,7 @@ public static HashSet GetDemosLinks() 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 }); index += 1; - 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 }); + 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 }); index += 1; 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 }); diff --git a/BlazorExpress.ChartJS.Demo.WebAssembly/wwwroot/appsettings.json b/BlazorExpress.ChartJS.Demo.WebAssembly/wwwroot/appsettings.json index 060cce91..edb67bfe 100644 --- a/BlazorExpress.ChartJS.Demo.WebAssembly/wwwroot/appsettings.json +++ b/BlazorExpress.ChartJS.Demo.WebAssembly/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { - "version": "1.0.0", + "version": "1.1.0", "release": { - "short_description": "Bar, Doughnut, Line and Pie chart components!!!" + "short_description": "Introduces Bubble Chart support and various enhancements." }, "NugetPackageName": "BlazorExpress.ChartJS", "NugetPackageDisplayName": "BlazorExpress ChartJS", diff --git a/BlazorExpress.ChartJS/BlazorExpress.ChartJS.csproj b/BlazorExpress.ChartJS/BlazorExpress.ChartJS.csproj index 1d316b48..9584f7b0 100644 --- a/BlazorExpress.ChartJS/BlazorExpress.ChartJS.csproj +++ b/BlazorExpress.ChartJS/BlazorExpress.ChartJS.csproj @@ -3,8 +3,8 @@ BlazorExpress.ChartJS - 1.0.0 - 1.0.0 + 1.1.0 + 1.1.0 logo.png Apache-2.0 diff --git a/BlazorExpress.ChartJS/Models/ChartDataset/BubbleChart/BubbleChartDataset.cs b/BlazorExpress.ChartJS/Models/ChartDataset/BubbleChart/BubbleChartDataset.cs index 2cf02ad5..3a1e6ae1 100644 --- a/BlazorExpress.ChartJS/Models/ChartDataset/BubbleChart/BubbleChartDataset.cs +++ b/BlazorExpress.ChartJS/Models/ChartDataset/BubbleChart/BubbleChartDataset.cs @@ -18,7 +18,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 'rgba(0, 0, 0, 0.1)'. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue("rgba(0, 0, 0, 0.1)")] [Description("The line fill color.")] [ParameterTypeName("List?")] @@ -31,7 +31,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 'rgba(0, 0, 0, 0.1)'. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue("rgba(0, 0, 0, 0.1)")] [Description("The line color.")] [ParameterTypeName("List?")] @@ -44,7 +44,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 3. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(3)] [Description("The line width (in pixels).")] public double BorderWidth { get; set; } = 3; @@ -60,7 +60,7 @@ public class BubbleChartDataset : ChartDataset /// /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue("new()")] [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.")] [ParameterTypeName(nameof(BubbleChartDatasetDataLabels))] @@ -73,7 +73,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is . /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(true)] [Description("Draw the active points of a dataset over the other points of the dataset.")] [ParameterTypeName("List?")] @@ -86,7 +86,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is . /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(null)] [Description("The line fill color when hovered.")] [ParameterTypeName("List?")] @@ -99,7 +99,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is . /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(null)] [Description("The line color when hovered.")] [ParameterTypeName("List?")] @@ -112,7 +112,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 1. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(1)] [Description("The line width (in pixels) when hovered.")] [ParameterTypeName("List?")] @@ -125,7 +125,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 1. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(1)] [Description("The pixel size of the non-displayed point that reacts to mouse events.")] [ParameterTypeName("List?")] @@ -138,7 +138,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 4. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(4)] [Description("The pixel size of the non-displayed point that reacts to mouse events.")] [ParameterTypeName("List?")] @@ -154,7 +154,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 3. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(3)] [Description("The radius of the point shape. If set to 0, the point is not rendered.")] [ParameterTypeName("List?")] @@ -167,7 +167,7 @@ public class BubbleChartDataset : ChartDataset /// Default value is 0. /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue(0)] [Description("The rotation of the point in degrees.")] [ParameterTypeName("List?")] @@ -182,7 +182,7 @@ public class BubbleChartDataset : ChartDataset /// /// /// - [AddedVersion("1.0.0")] + [AddedVersion("1.1.0")] [DefaultValue("circle")] [Description("Style of the point. Supported values are 'circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', and 'triangle'.")] [ParameterTypeName("List?")] diff --git a/BlazorExpress.ChartJS/Models/ChartOptions/BubbleChartOptions.cs b/BlazorExpress.ChartJS/Models/ChartOptions/BubbleChartOptions.cs index a4a99211..feab0c20 100644 --- a/BlazorExpress.ChartJS/Models/ChartOptions/BubbleChartOptions.cs +++ b/BlazorExpress.ChartJS/Models/ChartOptions/BubbleChartOptions.cs @@ -1,76 +1,3 @@ namespace BlazorExpress.ChartJS; -public class BubbleChartOptions : ChartOptions -{ - #region Properties, Indexers - - //hover -> mode, intersect - //maintainAspectRatio - //plugins -> title -> display, text - /* - /// - /// The base axis of the dataset. 'x' for horizontal lines and 'y' for vertical lines. - /// - /// - /// Default value is . - /// - [AddedVersion("1.0.0")] - [DefaultValue(null)] - [Description("The base axis of the dataset. 'x' for horizontal lines and 'y' for vertical lines.")] - [ParameterTypeName("string?")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string? IndexAxis { get; set; } - - /// - /// Gets or sets the interaction options for the chart. - /// By default, these options apply to both the hover and tooltip interactions. - /// - /// Default value is a new instance of . - /// - /// - /// - [AddedVersion("1.0.0")] - [DefaultValue("new()")] - [Description("Gets or sets the interaction options for the chart.")] - public Interaction Interaction { get; set; } = new(); - - /// - /// Gets or sets the layout configuration for the chart. - /// - /// Default value is a new instance of . - /// - /// - /// - [AddedVersion("1.0.0")] - [DefaultValue("new()")] - [Description("Gets or sets the layout configuration for the chart.")] - [ParameterTypeName(nameof(ChartLayout))] - public ChartLayout Layout { get; set; } = new(); - - /// - /// Gets or sets the collection of plugins associated with the line chart. - /// - /// Default value is a new instance of . - /// - /// - [AddedVersion("1.0.0")] - [DefaultValue("new()")] - [Description("Gets or sets the collection of plugins associated with the line chart.")] - [ParameterTypeName(nameof(LineChartPlugins))] - public LineChartPlugins Plugins { get; set; } = new(); - - /// - /// Gets or sets the collection of scales used for measurement or calibration. - /// - /// Default value is a new instance of . - /// - /// - [AddedVersion("1.0.0")] - [DefaultValue("new()")] - [Description("Gets or sets the collection of scales used for measurement or calibration.")] - public Scales Scales { get; set; } = new(); - */ - #endregion - - //tooltips -> mode, intersect -} +public class BubbleChartOptions : ChartOptions { } From d58317e40021327a6330da7c4819afdda1fd7037 Mon Sep 17 00:00:00 2001 From: Vikram Reddy Date: Sat, 9 Aug 2025 22:42:54 +0530 Subject: [PATCH 2/2] 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. --- .../ChartComponents/Core/ChartComponentBase.cs | 4 ---- .../Models/ChartDataset/LineChart/LineChartDataset.cs | 5 ++++- BlazorExpress.ChartJS/Models/ChartOptions/ChartOptions.cs | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/BlazorExpress.ChartJS/ChartComponents/Core/ChartComponentBase.cs b/BlazorExpress.ChartJS/ChartComponents/Core/ChartComponentBase.cs index 9c4ae2d7..ff37ca5c 100644 --- a/BlazorExpress.ChartJS/ChartComponents/Core/ChartComponentBase.cs +++ b/BlazorExpress.ChartJS/ChartComponents/Core/ChartComponentBase.cs @@ -12,10 +12,6 @@ public abstract class ChartComponentBase : BlazorExpressComponentCore, IDisposab internal ChartType _chartType; - private bool isAsyncDisposed; - - private bool isDisposed; - #endregion #region Methods diff --git a/BlazorExpress.ChartJS/Models/ChartDataset/LineChart/LineChartDataset.cs b/BlazorExpress.ChartJS/Models/ChartDataset/LineChart/LineChartDataset.cs index 6686fa32..a4ca63f3 100644 --- a/BlazorExpress.ChartJS/Models/ChartDataset/LineChart/LineChartDataset.cs +++ b/BlazorExpress.ChartJS/Models/ChartDataset/LineChart/LineChartDataset.cs @@ -48,7 +48,10 @@ public LineChartDataset FillToDataset(ChartData chartData, IChartDataset dataset if (relativeIndex) { - var myIndex = relativeIndex ? chartData.Datasets.IndexOf(this) : 0; + if (chartData?.Datasets == null) + throw new ArgumentException("The chart data or its datasets collection is null."); + + var myIndex = chartData.Datasets.IndexOf(this); if (myIndex < 0) throw new ArgumentException("The dataset is not in the chart data."); diff --git a/BlazorExpress.ChartJS/Models/ChartOptions/ChartOptions.cs b/BlazorExpress.ChartJS/Models/ChartOptions/ChartOptions.cs index 8a2366b1..1be256d3 100644 --- a/BlazorExpress.ChartJS/Models/ChartOptions/ChartOptions.cs +++ b/BlazorExpress.ChartJS/Models/ChartOptions/ChartOptions.cs @@ -150,7 +150,7 @@ private void SetMode(InteractionMode interactionMode) => /// Sets which elements appear in the interaction. /// [JsonPropertyName("mode")] - public string ChartInteractionMode { get; private set; } + public string ChartInteractionMode { get; private set; } = string.Empty; /// /// if , the interaction mode only applies when the mouse position intersects an item on the chart.