Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/Components/Charts/Chart/Annotations/ChartAnnotations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel;
using Microsoft.AspNetCore.Components;
using Syncfusion.Blazor.Toolkit.Charts.Internal;

namespace Syncfusion.Blazor.Toolkit.Charts
{
Expand Down Expand Up @@ -38,9 +39,23 @@ public class ChartAnnotations : ChartSubComponent, ISubcomponentTracker
/// </value>
/// <remarks>
/// Use this property to provide an accessibility role for the <see cref="ChartAnnotations"/>.
/// The value, if non-empty, must be a valid WAI-ARIA role (for example
/// <c>"region"</c>, <c>"status"</c>, <c>"group"</c>). Invalid values are
/// rejected at component initialization to prevent invalid <c>role</c>
/// attributes from reaching the DOM.
/// </remarks>
[Parameter]
public string AccessibilityRole { get; set; } = string.Empty;
public string AccessibilityRole
{
get => _accessibilityRole;
set
{
DataVizCommonHelper.AriaRoleValidator.EnsureValidRole(value, nameof(AccessibilityRole));
_accessibilityRole = value;
}
}

private string _accessibilityRole = string.Empty;

/// <summary>
/// Gets or sets the accessibility keyboard navigation focus option for the <see cref="ChartAnnotations"/>.
Expand Down Expand Up @@ -253,4 +268,4 @@ public override void AddRenderer(IChartElementRenderer renderer)
}
#endregion
}
}
}
16 changes: 15 additions & 1 deletion src/Components/Charts/Chart/ChartArea/ChartSubTitleStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public class ChartSubTitleStyle : ChartDefaultFont
/// </value>
/// <remarks>
/// Use this property to provide an accessibility role for the chart subtitle.
/// The value, if non-empty, must be a valid WAI-ARIA role (for example
/// <c>"heading"</c>, <c>"region"</c>). Invalid values are rejected at
/// component initialization to prevent invalid <c>role</c> attributes from
/// reaching the DOM.
/// </remarks>
/// <example>
/// <code>
Expand All @@ -127,7 +131,17 @@ public class ChartSubTitleStyle : ChartDefaultFont
/// </code>
/// </example>
[Parameter]
public string AccessibilityRole { get; set; } = string.Empty;
public string AccessibilityRole
{
get => _accessibilityRole;
set
{
DataVizCommonHelper.AriaRoleValidator.EnsureValidRole(value, nameof(AccessibilityRole));
_accessibilityRole = value;
}
}

private string _accessibilityRole = string.Empty;

/// <summary>
/// Gets or sets the accessibility keyboard navigation focus option for the chart subtitle.
Expand Down
16 changes: 15 additions & 1 deletion src/Components/Charts/Chart/ChartArea/ChartTitleStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ public class ChartTitleStyle : ChartDefaultFont
/// </value>
/// <remarks>
/// Use this property to provide an accessibility role for the chart title.
/// The value, if non-empty, must be a valid WAI-ARIA role (for example
/// <c>"heading"</c>, <c>"region"</c>). Invalid values are rejected at
/// component initialization to prevent invalid <c>role</c> attributes from
/// reaching the DOM.
/// </remarks>
/// <example>
/// <code>
Expand All @@ -219,7 +223,17 @@ public class ChartTitleStyle : ChartDefaultFont
/// </code>
/// </example>
[Parameter]
public string AccessibilityRole { get; set; } = string.Empty;
public string AccessibilityRole
{
get => _accessibilityRole;
set
{
DataVizCommonHelper.AriaRoleValidator.EnsureValidRole(value, nameof(AccessibilityRole));
_accessibilityRole = value;
}
}

private string _accessibilityRole = string.Empty;

/// <summary>
/// Gets or sets the accessibility keyboard navigation focus option for the chart title.
Expand Down
20 changes: 17 additions & 3 deletions src/Components/Charts/Chart/Legend/LegendSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components;
using System.ComponentModel;
using Microsoft.AspNetCore.Components;
using Syncfusion.Blazor.Toolkit.Charts.Internal;
using System.ComponentModel;

namespace Syncfusion.Blazor.Toolkit.Charts
{
Expand Down Expand Up @@ -250,6 +250,10 @@ public string Height
/// </value>
/// <remarks>
/// Use this property to provide an accessibility role for the <see cref="ChartLegendSettings"/>.
/// The value, if non-empty, must be a valid WAI-ARIA role (for example
/// <c>"region"</c>, <c>"group"</c>, <c>"list"</c>). Invalid values are
/// rejected at component initialization to prevent invalid <c>role</c>
/// attributes from reaching the DOM.
/// </remarks>
/// <example>
/// <code>
Expand All @@ -265,7 +269,17 @@ public string Height
/// </code>
/// </example>
[Parameter]
public string AccessibilityRole { get; set; } = string.Empty;
public string AccessibilityRole
{
get => _accessibilityRole;
set
{
DataVizCommonHelper.AriaRoleValidator.EnsureValidRole(value, nameof(AccessibilityRole));
_accessibilityRole = value;
}
}

private string _accessibilityRole = string.Empty;

/// <summary>
/// Gets or sets the accessibility keyboard navigation focus option for the <see cref="ChartLegendSettings"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ internal void CustomizeGridRenderingOptions(string key)
foreach (PathOptions option in axisGridOptions)
{
option.Stroke = Axis?.MajorGridLines.Color ?? string.Empty;
option.StrokeWidth = Axis?.Renderer?.MajorGridLinesWidth ?? 0;
option.StrokeWidth = Axis?.MajorGridLines.Width ?? 0;
option.StrokeDashArray = Axis?.MajorGridLines.DashArray ?? string.Empty;
}
}
Expand All @@ -1829,7 +1829,7 @@ internal void CustomizeGridRenderingOptions(string key)
foreach (CircleOptions option in AxisRenderInfo.MajorGridCircleOptions)
{
option.Stroke = Axis?.MajorGridLines.Color ?? string.Empty;
option.StrokeWidth = Axis?.Renderer?.MajorGridLinesWidth ?? 0;
option.StrokeWidth = Axis?.MajorGridLines.Width ?? 0;
option.StrokeDashArray = Axis?.MajorGridLines.DashArray ?? string.Empty;
}
}
Expand Down
24 changes: 19 additions & 5 deletions src/Components/Charts/Chart/Series/ChartSeries.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Components;
using Syncfusion.Blazor.Toolkit.Charts.Internal;
using Syncfusion.Blazor.Toolkit.Data;
using Syncfusion.Blazor.Toolkit.Internal;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using Microsoft.AspNetCore.Components;
using Syncfusion.Blazor.Toolkit.Charts.Internal;
using Syncfusion.Blazor.Toolkit.Data;
using Syncfusion.Blazor.Toolkit.Internal;

namespace Syncfusion.Blazor.Toolkit.Charts
{
Expand Down Expand Up @@ -328,6 +328,10 @@ public double Width
/// <value>A string that defines the accessibility role for the <see cref="ChartSeries"/>.</value>
/// <remarks>
/// Use this property to specify the accessibility role for the <see cref="ChartSeries"/> root element.
/// The value, if non-empty, must be a valid WAI-ARIA role (for example
/// <c>"region"</c>, <c>"img"</c>, <c>"list"</c>). Invalid values are
/// rejected at component initialization to prevent invalid <c>role</c>
/// attributes from reaching the DOM.
/// </remarks>
/// <example>
/// <code>
Expand All @@ -340,7 +344,17 @@ public double Width
/// </code>
/// </example>
[Parameter]
public string AccessibilityRole { get; set; } = string.Empty;
public string AccessibilityRole
{
get => _accessibilityRole;
set
{
DataVizCommonHelper.AriaRoleValidator.EnsureValidRole(value, nameof(AccessibilityRole));
_accessibilityRole = value;
}
}

private string _accessibilityRole = string.Empty;

/// <summary>
/// Gets or sets a value indicating whether the series root can receive keyboard focus.
Expand Down
20 changes: 18 additions & 2 deletions src/Components/Charts/Chart/Series/Trendline/ChartTrendline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ public TrendlineTypes Type
/// <summary>
/// Gets or sets the ARIA role for the trendline.
/// </summary>
/// <value>A string representing the ARIA role. Default is empty.</value>
/// <value> A string representing the ARIA role. Default is empty.</value>
/// <remarks>
/// The value, if non-empty, must be a valid WAI-ARIA role (for example
/// <c>"region"</c>, <c>"group"</c>). Invalid values are rejected at
/// component initialization to prevent invalid <c>role</c> attributes from
/// reaching the DOM.
/// </remarks>
/// <example>
/// <code>
/// <![CDATA[
Expand All @@ -274,7 +280,17 @@ public TrendlineTypes Type
/// </code>
/// </example>
[Parameter]
public string AccessibilityRole { get; set; } = string.Empty;
public string AccessibilityRole
{
get => _accessibilityRole;
set
{
DataVizCommonHelper.AriaRoleValidator.EnsureValidRole(value, nameof(AccessibilityRole));
_accessibilityRole = value;
}
}

private string _accessibilityRole = string.Empty;

/// <summary>
/// Gets or sets whether the trendline is focusable via keyboard navigation.
Expand Down
12 changes: 9 additions & 3 deletions src/Components/Charts/Chart/SfChart.razor.LifeCycle.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.JSInterop;
using Syncfusion.Blazor.Toolkit.Charts.Internal;
using System.Collections.Specialized;
using System.Collections.Specialized;
using System.ComponentModel;
using Microsoft.JSInterop;
using Syncfusion.Blazor.Toolkit.Charts.Internal;

namespace Syncfusion.Blazor.Toolkit.Charts
{
Expand Down Expand Up @@ -304,6 +304,12 @@ protected override async ValueTask DisposeAsyncCore()
_chartJsModule = null;
_chartJsInProcessModule = null;
}

// Clear instance-level font measurement caches to prevent memory retention
// after the chart is disposed. This ensures per-circuit/per-chart isolation.
_fontSizeCache?.Clear();
_requestedFontKeys?.Clear();

await base.DisposeAsyncCore().ConfigureAwait(true);
}

Expand Down
22 changes: 18 additions & 4 deletions src/Components/Charts/Chart/SfChart.razor.Members.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Components;
using Syncfusion.Blazor.Toolkit.Internal;
using System.Collections.Specialized;
using System.ComponentModel;
using Microsoft.AspNetCore.Components;
using Syncfusion.Blazor.Toolkit.Charts.Internal;
using System.Collections.Specialized;
using Syncfusion.Blazor.Toolkit.Internal;

namespace Syncfusion.Blazor.Toolkit.Charts
{
Expand Down Expand Up @@ -178,6 +178,10 @@ internal class ChartDataState
/// </value>
/// <remarks>
/// Use this property to provide an accessibility role for the <see cref="SfChart">Chart</see> component.
/// The value, if non-empty, must be a valid WAI-ARIA role (for example
/// <c>"region"</c>, <c>"figure"</c>, <c>"img"</c>). Invalid values are
/// rejected at component initialization to prevent invalid <c>role</c>
/// attributes from reaching the DOM.
/// </remarks>
/// <example>
/// <code>
Expand All @@ -189,7 +193,17 @@ internal class ChartDataState
/// </code>
/// </example>
[Parameter]
public string AccessibilityRole { get; set; } = string.Empty;
public string AccessibilityRole
{
get => _accessibilityRole;
set
{
DataVizCommonHelper.AriaRoleValidator.EnsureValidRole(value, nameof(AccessibilityRole));
_accessibilityRole = value;
}
}

private string _accessibilityRole = string.Empty;

/// <summary>
/// Gets or sets the accessibility keyboard navigation focus option for the <see cref="SfChart">Chart</see> component.
Expand Down
42 changes: 17 additions & 25 deletions src/Components/Charts/Chart/SfChart.razor.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.JSInterop;
using Syncfusion.Blazor.Toolkit.Charts.Internal;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Reflection;
using System.ComponentModel;
using Syncfusion.Blazor.Toolkit.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.Extensions.Localization;
using System.Runtime.CompilerServices;
using Microsoft.JSInterop;
using Syncfusion.Blazor.Toolkit.Charts.Internal;
using Syncfusion.Blazor.Toolkit.Data;

[assembly: InternalsVisibleTo("Syncfusion.Blazor.Toolkit.BUnitTest")]
namespace Syncfusion.Blazor.Toolkit.Charts
Expand Down Expand Up @@ -178,6 +179,9 @@ internal class JsInteropState
internal List<IChartEventBorder> _seriesBorders = [];
internal List<IAxis> _axes = [];
internal List<PatternOptions> _highLightPatternCollection = [];
// Instance-level font measurement caches
internal ConcurrentDictionary<string, Size> _fontSizeCache = new();
internal ConcurrentDictionary<string, byte> _requestedFontKeys = new();
internal ChartAnnotations _annotations = new();
internal DomRect _elementOffset = new();
/*To store the SVGElement's dimensions value.*/
Expand Down Expand Up @@ -1244,9 +1248,9 @@ private async Task GetOtherLanguageCharSizeAsync(bool _updateDataSource)
/// <param name="text">The text to analyze.</param>
/// <param name="font">The font options for the text.</param>
/// <param name="distinctKeys">The collection to populate with distinct character keys.</param>
private static void GetDistinctCharacter(string text, ChartFontOptions font, List<string> distinctKeys)
private void GetDistinctCharacter(string text, ChartFontOptions font, List<string> distinctKeys)
{
ChartHelper.GetDistinctCharacter(text, font, distinctKeys);
ChartHelper.GetDistinctCharacter(text, font, distinctKeys, this);
}

/// <summary>
Expand All @@ -1271,7 +1275,7 @@ private async Task LoadCharacterDictionaryAsync(List<string> distinctKeys)
Dictionary<string, SymbolLocation> charSizeList = JsonSerializer.Deserialize<Dictionary<string, SymbolLocation>>(result) ?? null!;
foreach (KeyValuePair<string, SymbolLocation> charSize in charSizeList)
{
_ = ChartHelper.SizePerCharacter.TryAdd(charSize.Key, new Size { Width = charSize.Value.X, Height = charSize.Value.Y });
_ = _fontSizeCache.TryAdd(charSize.Key, new Size { Width = charSize.Value.X, Height = charSize.Value.Y });
}
}

Expand Down Expand Up @@ -1832,10 +1836,9 @@ internal async Task GetCharSizeListAsync(List<string> fontKeys)
List<string> uniqueKeys = [];
foreach (string fontKey in fontKeys)
{
if (!ChartHelper.ChartFontKeys.Contains(fontKey))
if (_requestedFontKeys.TryAdd(fontKey, 0))
{
uniqueKeys.Add(fontKey);
ChartHelper.ChartFontKeys.Add(fontKey);
}
}

Expand All @@ -1855,7 +1858,7 @@ internal async Task GetCharSizeListAsync(List<string> fontKeys)
int i = 33, j = 0;
foreach (string width in result_2)
{
_ = ChartHelper.SizePerCharacter.TryAdd(Convert.ToChar(i) + Constants.Underscore + uniqueKeys[j], new Size { Width = Convert.ToInt16(width, null), Height = 133 });
_ = _fontSizeCache.TryAdd(Convert.ToChar(i) + Constants.Underscore + uniqueKeys[j], new Size { Width = Convert.ToInt16(width, null), Height = 133 });
i++;
if (i > 590)
{
Expand Down Expand Up @@ -2590,17 +2593,6 @@ protected override void OnParametersSet()
PushSubcomponent();
}

/// <summary>
/// Performs cleanup operations when the component is being disposed.
/// </summary>
/// <exclude />
[EditorBrowsable(EditorBrowsableState.Never)]
[Browsable(false)]
protected override ValueTask DisposeAsyncCore()
{
return base.DisposeAsyncCore();
}

#endregion

#region Protected Methods
Expand Down
Loading