From 84fbe325929d356334db7baa1739ef1d37ae59ef Mon Sep 17 00:00:00 2001 From: YokeshSF4393 Date: Tue, 8 Sep 2026 14:14:18 +0530 Subject: [PATCH 1/3] 1052437: Fixed the warnings in the Toolkit Charts. --- .../AxisRenderer/ChartAxisRenderer.cs | 2 +- .../Chart/Renderer/ChartElementRenderer.cs | 2 +- .../Chart/Renderer/ChartLegendRenderer.cs | 2 +- .../BaseRenderers/ChartSeriesRenderer.cs | 14 ++--- .../BaseRenderers/ColumnBase.cs | 14 ++--- .../SeriesRenderers/BaseRenderers/LineBase.cs | 4 +- .../BaseRenderers/MultiColoredBase.cs | 4 +- .../BaseRenderers/SeriesContainer.cs | 52 +++++++++++-------- .../BaseRenderers/SplineBase.cs | 6 +-- .../GradientRenderer/ChartGradientRenderer.cs | 18 +++---- .../BubbleSeriesRenderer.cs | 2 +- .../ColumnSeriesRenderer.cs | 4 +- .../ChartStriplineRenderer.cs | 2 +- .../UserInteractions/Selection/Selection.cs | 49 ++++++++++++----- .../Charts/Chart/Series/ChartSeries.cs | 8 +-- .../Chart/Series/DataLabel/ChartDataLabel.cs | 2 +- .../Charts/Chart/SfChart.razor.JsInterop.cs | 4 +- src/Components/Charts/Chart/SfChart.razor.cs | 26 ++++++---- .../Crosshair/Models/ChartCrosshairLine.cs | 2 +- .../Common/BaseTooltip/TooltipData.razor.cs | 2 +- .../Charts/Common/CommonLegend/LegendBase.cs | 5 +- 21 files changed, 130 insertions(+), 94 deletions(-) diff --git a/src/Components/Charts/Chart/Renderer/AxisRenderer/ChartAxisRenderer.cs b/src/Components/Charts/Chart/Renderer/AxisRenderer/ChartAxisRenderer.cs index 5fa93c6..be79bef 100644 --- a/src/Components/Charts/Chart/Renderer/AxisRenderer/ChartAxisRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/AxisRenderer/ChartAxisRenderer.cs @@ -1127,7 +1127,7 @@ private static bool IsRectType(string type) /// The series whose Y range is applied. private void YAxisRange(ChartSeries series) { - FindMinMax(series.Renderer.YMin, series.Renderer.YMax); + FindMinMax(series.Renderer?.YMin ?? 0, series.Renderer?.YMax ?? 0); } /// diff --git a/src/Components/Charts/Chart/Renderer/ChartElementRenderer.cs b/src/Components/Charts/Chart/Renderer/ChartElementRenderer.cs index 08e0c3f..04ccbd3 100644 --- a/src/Components/Charts/Chart/Renderer/ChartElementRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/ChartElementRenderer.cs @@ -261,7 +261,7 @@ public virtual void AddRenderer(IChartElementRenderer renderer) /// The renderer instance to remove. public void RemoveRenderer(IChartElementRenderer renderer) { - if (Renderers.Contains(renderer)) + if (renderer != null && Renderers.Contains(renderer)) { ContainerPrerender = false; RendererShouldRender = true; diff --git a/src/Components/Charts/Chart/Renderer/ChartLegendRenderer.cs b/src/Components/Charts/Chart/Renderer/ChartLegendRenderer.cs index 67b9054..95977dc 100644 --- a/src/Components/Charts/Chart/Renderer/ChartLegendRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/ChartLegendRenderer.cs @@ -1284,7 +1284,7 @@ internal void Click(ChartInternalMouseEventArgs eventArgs, bool isMouseMove = fa /// internal void RefreshSeriesPosition() { - Owner?._seriesContainer?.Renderers.ForEach(renderer => (renderer as ChartSeriesRenderer ?? null!).Position = (((renderer as ChartSeriesRenderer ?? null!).Series?.Visible ?? false) && (!(renderer as ChartSeriesRenderer ?? null!).Series?.Renderer.IsStackingSeries() ?? false)) ? double.NaN : (renderer as ChartSeriesRenderer ?? null!).Position); + Owner?._seriesContainer?.Renderers.ForEach(renderer => (renderer as ChartSeriesRenderer ?? null!).Position = (((renderer as ChartSeriesRenderer ?? null!).Series?.Visible ?? false) && (!(renderer as ChartSeriesRenderer ?? null!).Series?.Renderer?.IsStackingSeries() ?? false)) ? double.NaN : (renderer as ChartSeriesRenderer ?? null!).Position); } /// diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ChartSeriesRenderer.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ChartSeriesRenderer.cs index 68cb42d..bbb274d 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ChartSeriesRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ChartSeriesRenderer.cs @@ -607,7 +607,7 @@ protected virtual void RenderSeries() RendererShouldRender = true; FindClipRect(); - if (Series?.Renderer.Container is not null && !Series.Renderer.Container.IsTrendLine) + if (Series?.Renderer?.Container is not null && !Series.Renderer.Container.IsTrendLine) { GetSeriesFocusIndex(); } @@ -1448,7 +1448,7 @@ internal virtual double GetStackingStartValue(int pointIndex, int seriesIndex) { return Series is not null && !Series.Visible && Series._isLegendClicked && seriesIndex >= 0 && seriesIndex < Owner?._visibleSeriesRenderers.Count && Owner._visibleSeriesRenderers[seriesIndex].StackedValues is not null && pointIndex < Owner._visibleSeriesRenderers[seriesIndex].StackedValues?.StartValues?.Count && pointIndex < Owner._visibleSeriesRenderers[seriesIndex].StackedValues?.EndValues?.Count - ? Index > 0 ? Owner._visibleSeriesRenderers[seriesIndex].StackedValues?.EndValues[pointIndex] ?? 0 : Series.Renderer.StackedValues?.StartValues[pointIndex] ?? 0 + ? Index > 0 ? Owner._visibleSeriesRenderers[seriesIndex].StackedValues?.EndValues[pointIndex] ?? 0 : Series.Renderer?.StackedValues?.StartValues[pointIndex] ?? 0 : 0; } @@ -1873,7 +1873,7 @@ internal Rect GetSeriesClipRect() Height = ClipRect?.Height ?? 0 }; - double plotOffset = Series?.Renderer.XAxisRenderer.Axis is not null ? Series.Renderer.XAxisRenderer.Axis.PlotOffset : 0; + double plotOffset = Series?.Renderer?.XAxisRenderer.Axis is not null ? Series.Renderer.XAxisRenderer.Axis.PlotOffset : 0; double halfPlotOffset = plotOffset != 0 ? -(plotOffset / 2) : 0; if (Owner is not null && Owner._requireInvertedAxis) @@ -1920,7 +1920,7 @@ internal void PerformInitialAnimation(List animationInfo) animationInfo.Add(new InitialAnimationInfo { Type = animationType, ElementId = options.Id, ClipPathId = ClipRectId(), Duration = duration, Delay = delay, IsInvertedAxis = Owner?._requireInvertedAxis ?? false }); int animationInfoIndex = animationInfo.Count - 1; int count = Category() == SeriesCategories.Indicator ? 0 : 1; - List visiblePoints = ChartHelper.GetVisiblePoints(Series?.Renderer.Points ?? null!); + List visiblePoints = ChartHelper.GetVisiblePoints(Series?.Renderer?.Points ?? null!); foreach (Point point in visiblePoints) { if (point.SymbolLocations.Count == 0) @@ -2088,7 +2088,7 @@ internal virtual string CalCulateAccessibilityText(Point point) /// specified, returns a DateTime object; otherwise, returns the original value. internal virtual object GetPointXValue(object pointX, string dateFormat) { - return Series?.Renderer.Container is not null && Series.Renderer.Container.IsTrendLine && !string.IsNullOrEmpty(dateFormat) ? DateTime.Parse(Intl.GetDateFormat(ChartHelper.GetDate(Convert.ToDouble(pointX, Culture)), string.Empty), CultureInfo.CurrentCulture) : pointX; + return Series?.Renderer?.Container is not null && Series.Renderer.Container.IsTrendLine && !string.IsNullOrEmpty(dateFormat) ? DateTime.Parse(Intl.GetDateFormat(ChartHelper.GetDate(Convert.ToDouble(pointX, Culture)), string.Empty), CultureInfo.CurrentCulture) : pointX; } /// @@ -2100,7 +2100,7 @@ internal virtual object GetPointXValue(object pointX, string dateFormat) /// series and its data points. internal string GetSeriesDescriptionFormatText(List points) { - return Series is not null && Series.AccessibilityDescription is not null ? Series.AccessibilityDescription : Series?.Name + (Series?.Renderer.Container is not null && Series.Renderer.Container.IsTrendLine ? ",Trendline " : ",") + Series?.Type + " series with " + points.Count + " data points"; + return Series is not null && Series.AccessibilityDescription is not null ? Series.AccessibilityDescription : Series?.Name + (Series?.Renderer?.Container is not null && Series.Renderer.Container.IsTrendLine ? ",Trendline " : ",") + Series?.Type + " series with " + points.Count + " data points"; } /// @@ -2256,7 +2256,7 @@ internal virtual void GetChartData(Point point) { try { - _ = ChartData?.Append(JsonSerializer.Serialize(Series?.Renderer.ChartPoints?[point.Index], _jsonOptions)); + _ = ChartData?.Append(JsonSerializer.Serialize(Series?.Renderer?.ChartPoints?[point.Index], _jsonOptions)); _ = ChartData?.Append(','); } catch (Exception exception) diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ColumnBase.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ColumnBase.cs index e39e1ba..45df677 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ColumnBase.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/ColumnBase.cs @@ -298,7 +298,7 @@ private DoubleRange UpdateSeriesGroupDoubleRange(DoubleRange doubleRange, double /// Calculated representing the start and end offsets. protected DoubleRange GetSideBySideInfo() { - if (Series?.Container is not null && Series.Container.EnableSideBySidePlacement && (Series.Renderer.Position == 0 || double.IsNaN(Series.Renderer.Position))) + if (Series?.Container is not null && Series.Container.EnableSideBySidePlacement && (Series.Renderer?.Position == 0 || double.IsNaN(Series.Renderer?.Position ?? 0))) { GetSideBySidePositions(); } @@ -308,7 +308,7 @@ protected DoubleRange GetSideBySideInfo() return new DoubleRange(0, 0); } - double rectCount = Series?.Container is not null && !Series.Container.EnableSideBySidePlacement ? 1 : Series?.Renderer.RectCount ?? 0; + double rectCount = Series?.Container is not null && !Series.Container.EnableSideBySidePlacement ? 1 : Series?.Renderer?.RectCount ?? 0; if (Owner is not null && XAxisRenderer is null) { @@ -317,7 +317,7 @@ protected DoubleRange GetSideBySideInfo() double minimumPointDelta = ChartHelper.GetMinPointsDelta(XAxisRenderer?.Axis ?? null!, Series?.Container?._seriesContainer?.Renderers.Cast().ToList() ?? null!); double width = GetColumnWidth(minimumPointDelta); - double location = ((Series?.Container is not null && !Series.Container.EnableSideBySidePlacement ? 0 : Series?.Renderer.Position ?? 0) / rectCount) - 0.5; + double location = ((Series?.Container is not null && !Series.Container.EnableSideBySidePlacement ? 0 : Series?.Renderer?.Position ?? 0) / rectCount) - 0.5; DoubleRange doubleRange = new(location, location + (1 / rectCount)); if (!(double.IsNaN(doubleRange.Start) || double.IsNaN(doubleRange.End))) @@ -523,16 +523,16 @@ internal Rect GetColumnWidthInPixelRect(Rect rectangle) { double columnWidth = Series.ColumnWidthInPixel; bool isTransposed = Owner?.IsTransposed ?? false; - double halfColumnWidthAdjustment = columnWidth / 2 * (double.IsNaN(Series.Renderer.RectCount) ? 0 : Series.Renderer.RectCount); - double positionAdjustment = columnWidth * (double.IsNaN(Series.Renderer.Position) ? 0 : Series.Renderer.Position); + double halfColumnWidthAdjustment = columnWidth / 2 * (double.IsNaN(Series.Renderer?.RectCount ?? 0) ? 0 : Series.Renderer?.RectCount ?? 0); + double positionAdjustment = columnWidth * (double.IsNaN(Series.Renderer?.Position ?? 0) ? 0 : Series.Renderer?.Position ?? 0); return Series.Type switch { ChartSeriesType.Bar or ChartSeriesType.StackingBar or ChartSeriesType.StackingBar100 => isTransposed ? new Rect(rectangle.X - (halfColumnWidthAdjustment - positionAdjustment), rectangle.Y, columnWidth, rectangle.Height) - : new Rect(rectangle.X, rectangle.Y - (halfColumnWidthAdjustment - (columnWidth * ((double.IsNaN(Series.Renderer.RectCount) ? 0 : Series.Renderer.RectCount) - (double.IsNaN(Series.Renderer.Position) ? 0 : Series.Renderer.Position) - 1))), rectangle.Width, columnWidth), + : new Rect(rectangle.X, rectangle.Y - (halfColumnWidthAdjustment - (columnWidth * ((double.IsNaN(Series.Renderer?.RectCount ?? 0) ? 0 : Series.Renderer.RectCount) - (double.IsNaN(Series.Renderer.Position) ? 0 : Series.Renderer.Position) - 1))), rectangle.Width, columnWidth), ChartSeriesType.Column or ChartSeriesType.StackingColumn or ChartSeriesType.StackingColumn100 => isTransposed - ? new Rect(rectangle.X, rectangle.Y - (halfColumnWidthAdjustment - (columnWidth * ((double.IsNaN(Series.Renderer.RectCount) ? 0 : Series.Renderer.RectCount) - (double.IsNaN(Series.Renderer.Position) ? 0 : Series.Renderer.Position) - 1))), rectangle.Width, columnWidth) + ? new Rect(rectangle.X, rectangle.Y - (halfColumnWidthAdjustment - (columnWidth * ((double.IsNaN(Series.Renderer?.RectCount ?? 0) ? 0 : Series.Renderer.RectCount) - (double.IsNaN(Series.Renderer.Position) ? 0 : Series.Renderer.Position) - 1))), rectangle.Width, columnWidth) : new Rect(rectangle.X - (halfColumnWidthAdjustment - positionAdjustment), rectangle.Y, columnWidth, rectangle.Height), ChartSeriesType.Line => new Rect(), ChartSeriesType.Area => new Rect(), diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/LineBase.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/LineBase.cs index cafa52e..656a246 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/LineBase.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/LineBase.cs @@ -197,9 +197,9 @@ protected virtual void StorePointLocation(Point point, ChartSeries series, bool (Owner is not null && Owner._zoomingModule is not null && Owner._zoomingModule.IsZoomed)) { point?.SymbolLocations.Add(location); - series.Renderer.ChartPoints?[point?.Index ?? 0]?.SymbolLocations.Add(new IChartInternalLocation(Math.Round(location.X, 2), Math.Round(location.Y, 2))); + series.Renderer?.ChartPoints?[point?.Index ?? 0]?.SymbolLocations.Add(new IChartInternalLocation(Math.Round(location.X, 2), Math.Round(location.Y, 2))); point?.Regions.Add(new Rect(point.SymbolLocations[0].X - markerWidth, point.SymbolLocations[0].Y - markerHeight, 2 * markerWidth, 2 * markerHeight)); - series.Renderer.ChartPoints?[point?.Index ?? 0]?.Regions.Add(new IRect(Math.Round(point?.SymbolLocations[0].X ?? 0, 2) - markerWidth, Math.Round(point?.SymbolLocations[0].Y ?? 0, 2) - markerHeight, 2 * markerWidth, 2 * markerHeight)); + series.Renderer?.ChartPoints?[point?.Index ?? 0]?.Regions.Add(new IRect(Math.Round(point?.SymbolLocations[0].X ?? 0, 2) - markerWidth, Math.Round(point?.SymbolLocations[0].Y ?? 0, 2) - markerHeight, 2 * markerWidth, 2 * markerHeight)); } } diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs index 9e95a6c..86ec52c 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs @@ -240,7 +240,7 @@ internal bool SetPointColor(Point currentPoint, Point previous, ChartSeries seri { if (compareValue <= GetAxisValue(segments[i].Value, isXSegment ? XAxisRenderer.Axis ?? null! : YAxisRenderer.Axis ?? null!) || segments[i].Value is null) { - if (series.Renderer.ChartPoints is not null) + if (series.Renderer?.ChartPoints is not null) { currentPoint.Interior = series.Renderer.ChartPoints[currentPoint.Index].Interior = segments[i].Color; } @@ -292,7 +292,7 @@ internal void ApplySegmentAxis(RenderTreeBuilder builder, ChartSeries series, Li GetAxisValue(segment.Value, axis), index, series?.SegmentAxis == Segment.X, - series?.Renderer.Index ?? 0 + series?.Renderer?.Index ?? 0 ); if (!string.IsNullOrEmpty(clipPath)) diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SeriesContainer.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SeriesContainer.cs index def1817..9e4968b 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SeriesContainer.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SeriesContainer.cs @@ -158,11 +158,11 @@ private static void FindPercentageOfStacking(List stackingSeries, L return; } - if (item.Renderer.Points is not null) + if (item.Renderer?.Points is not null) { foreach (Point point in ChartHelper.GetVisiblePoints(item.Renderer.Points)) { - if (item.Renderer.ChartPoints is not null) + if (item.Renderer?.ChartPoints is not null) { point.Percentage = item.Renderer.ChartPoints[point.Index].Percentage = Convert.ToDouble(Math.Abs(Convert.ToDouble(point.Y, null) / values[point.Index] * 100).ToString("N2", null), null); } @@ -187,13 +187,14 @@ private static void CalculateStackingValues(List seriesCollection, { if (series.SeriesType is not null && series.SeriesType.Contains("Stacking", StringComparison.InvariantCulture)) { - series.Renderer.StackedPointValues = []; + if (series.Renderer is not null) + series.Renderer.StackedPointValues = []; string stackingGroup = GetStackingGroup(series); EnsureStackingDictionaries(lastPositive, lastNegative, stackingGroup); stackingSeries.Add(series); - List visiblePoints = ChartHelper.GetVisiblePoints(series.Renderer.Points ?? null!); + List visiblePoints = ChartHelper.GetVisiblePoints(series.Renderer?.Points ?? null!); ProcessSeriesStacking(series, isStacking100, lastPositive, lastNegative, frequencies, stackedValues, visiblePoints); } @@ -236,7 +237,7 @@ private static void ProcessSeriesStacking(ChartSeries series, bool isStacking100 for (int j = 0, pointsLength = visiblePoints.Count; j < pointsLength; j++) { double lastValue, - y_Value = !string.IsNullOrEmpty(series.Container?._sorting.SortKey) ? series.Renderer.Points?[j].YValue ?? 0 : double.IsNaN(series.Renderer.YData[j]) ? 0 : series.Renderer.YData[j], + y_Value = !string.IsNullOrEmpty(series.Container?._sorting.SortKey) ? series.Renderer?.Points?[j].YValue ?? 0 : double.IsNaN(series.Renderer?.YData[j] ?? 0) ? 0 : series.Renderer?.YData[j] ?? 0, pos = visiblePoints[j].XValue; if (!lastPositive[stackingGroup].TryGetValue(pos, out double _)) { @@ -252,7 +253,7 @@ private static void ProcessSeriesStacking(ChartSeries series, bool isStacking100 { y_Value = y_Value / frequencies[stackingGroup][pos] * 100; y_Value = !double.IsNaN(y_Value) ? y_Value : 0; - if (series.Renderer.ChartPoints is not null) + if (series.Renderer?.ChartPoints is not null) { visiblePoints[j].Percentage = series.Renderer.ChartPoints[j].Percentage = Convert.ToDouble(y_Value.ToString("N2", null), null); } @@ -287,25 +288,29 @@ private static void ProcessSeriesStacking(ChartSeries series, bool isStacking100 endValues[j] = 100; } } - - series.Renderer.StackedValues = new StackValues(startValues, endValues); - series.Renderer.StackedPointValues = lastPositive[stackingGroup]; - + if (series.Renderer != null) + { + series.Renderer.StackedValues = new StackValues(startValues, endValues); + series.Renderer.StackedPointValues = lastPositive[stackingGroup]; + } double startMin = startValues.Count > 0 ? startValues.Min() : 0; double startMax = startValues.Count > 0 ? startValues.Max() : 0; double endMin = endValues.Count > 0 ? endValues.Min() : 0; double endMax = endValues.Count > 0 ? endValues.Max() : 0; - series.Renderer.YMin = startMin; - series.Renderer.YMax = endMax; - if (series.Renderer.YMin > endMin) + if (series.Renderer != null) { - series.Renderer.YMin = isStacking100 ? -100 : endMin; - } + series.Renderer.YMin = startMin; + series.Renderer.YMax = endMax; + if (series.Renderer.YMin > endMin) + { + series.Renderer.YMin = isStacking100 ? -100 : endMin; + } - if (series.Renderer.YMax < startMax) - { - series.Renderer.YMax = 0; + if (series.Renderer.YMax < startMax) + { + series.Renderer.YMax = 0; + } } } @@ -317,8 +322,9 @@ private static Dictionary> FindFrequencies(Li Dictionary> frequencies = []; foreach (ChartSeries series in seriesCollection) { - series.Renderer.YAxisRenderer.IsStack100 = series.SeriesType is not null && series.SeriesType.Contains("100", StringComparison.InvariantCulture); - List visiblePoints = ChartHelper.GetVisiblePoints(series.Renderer.Points ?? null!); + if (series.Renderer != null) + series.Renderer.YAxisRenderer.IsStack100 = series.SeriesType is not null && series.SeriesType.Contains("100", StringComparison.InvariantCulture); + List visiblePoints = ChartHelper.GetVisiblePoints(series.Renderer?.Points ?? null!); if (series.SeriesType is not null && series.SeriesType.Contains("Stacking", StringComparison.InvariantCulture)) { string stackingGroup = GetStackingGroup(series); @@ -608,7 +614,7 @@ protected override void OnElementRemoved(IChartElement element) { if (element is not null) { - RemoveRenderer((element as ChartSeries ?? null!).Renderer); + RemoveRenderer((element as ChartSeries ?? null!).Renderer ?? null!); if (Owner is not null && !Owner.ChartDisposed()) { _ = InvokeAsync(StateHasChanged); @@ -698,7 +704,7 @@ protected override void BuildRenderers(RenderTreeBuilder builder) { element.NeedRendererRemove = false; element.UpdateDataSource = false; - RemoveRenderer(element.Renderer); + RemoveRenderer(element.Renderer ?? null!); } CreateSeriesElements(builder, element); @@ -906,7 +912,7 @@ internal void UpdateStackingValues() string type; foreach (ChartSeriesRenderer renderer in Renderers.Cast()) { - if (renderer.Series is not null && renderer.Series.Visible) + if (renderer.Series is not null && renderer.Series.Renderer is not null && renderer.Series.Visible) { renderer.Series.Renderer.RectCount = renderer.Series.Renderer.Position = 0; } diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SplineBase.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SplineBase.cs index fd17805..50c0ddb 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SplineBase.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/SplineBase.cs @@ -71,12 +71,12 @@ private void CreateDrawPoints(List points, ref bool isNegativePoint) if (data.Index != 0) { int previous = GetPreviousIndex(points, data.Index - 1, Series ?? null!); - ControlPoints pointValue = GetControlPoints(points[previous], data, _splinePoints[previous], _splinePoints[data.Index], Series ?? null!); + ControlPoints pointValue = GetControlPoints(points[previous], data, _splinePoints[previous], _splinePoints[data.Index], Series ?? null!) ?? null!; if (pointValue is not null) { DrawPoints.Add(pointValue); } - if (data.YValue != 0 && !double.IsNaN(data.YValue) && pointValue?.ControlPoint1.Y != 0 && !double.IsNaN(pointValue.ControlPoint1.Y) && pointValue.ControlPoint2.Y != 0 && !double.IsNaN(pointValue.ControlPoint2.Y) && Series is not null && (Series.Renderer.YMax - Series.Renderer.YMin) > 1) + if (data.YValue != 0 && !double.IsNaN(data.YValue) && pointValue?.ControlPoint1.Y != 0 && !double.IsNaN(pointValue?.ControlPoint1.Y ?? 0) && pointValue?.ControlPoint2.Y != 0 && !double.IsNaN(pointValue?.ControlPoint2.Y ?? 0) && Series is not null && ((Series.Renderer?.YMax ?? 0) - (Series.Renderer?.YMin ?? 0)) > 1) { bool maxValue = Math.Abs(Series.Renderer.YMin - Math.Floor(Series.Renderer.YMin)) > double.Epsilon; Series.Renderer.YMin = maxValue ? Series.Renderer.YMin : Math.Floor(Math.Min(Math.Min(Series.Renderer.YMin, data.YValue), Math.Min(pointValue.ControlPoint1.Y, pointValue.ControlPoint2.Y))); @@ -99,7 +99,7 @@ private static void ComputeMonotonicCoefficients(List points, ChartSeries for (int i = 0; i < count - 1; i++) { - series.Renderer.GetSplineTypePoints(points, i, SplineType.Monotonic, isLow); + series.Renderer?.GetSplineTypePoints(points, i, SplineType.Monotonic, isLow); dx[i] = !double.IsNaN(points[i + 1].XValue - points[i].XValue) ? points[i + 1].XValue - points[i].XValue : 0; dy[i] = !double.IsNaN(points[i + 1].YValue - points[i].YValue) ? points[i + 1].YValue - points[i].YValue : 0; slope[i] = dy[i] / dx[i]; diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/GradientRenderer/ChartGradientRenderer.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/GradientRenderer/ChartGradientRenderer.cs index e42f0d1..cc24bb7 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/GradientRenderer/ChartGradientRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/GradientRenderer/ChartGradientRenderer.cs @@ -146,36 +146,36 @@ private void RenderAllGradients(RenderTreeBuilder builder) ChartLinearGradient? seriesLinear = Series?.LinearGradient; if (seriesLinear?.RendererType is not null) { - RenderLinearGradient(builder, seriesLinear, SvgRenderer); + RenderLinearGradient(builder, seriesLinear, SvgRenderer ?? null!); } ChartRadialGradient? seriesRadial = Series?.RadialGradient; if (seriesRadial?.RendererType is not null) { - RenderRadialGradient(builder, seriesRadial, SvgRenderer); + RenderRadialGradient(builder, seriesRadial, SvgRenderer ?? null!); } ChartLinearGradient? trendlineLinear = Trendline?.LinearGradient; if (trendlineLinear?.RendererType is not null) { - RenderLinearGradient(builder, trendlineLinear, SvgRenderer); + RenderLinearGradient(builder, trendlineLinear, SvgRenderer ?? null!); } ChartRadialGradient? trendlineRadial = Trendline?.RadialGradient; if (trendlineRadial?.RendererType is not null) { - RenderRadialGradient(builder, trendlineRadial, SvgRenderer, null); + RenderRadialGradient(builder, trendlineRadial, SvgRenderer ?? null!, null); } - if (ChartHelper.NeedsLegendHorizontalLineGradient(Series)) + if (ChartHelper.NeedsLegendHorizontalLineGradient(Series ?? null!)) { if (seriesLinear?.RendererType is not null) { - RenderLinearGradient(builder, seriesLinear, SvgRenderer, $"{Series.Type}Legend"); + RenderLinearGradient(builder, seriesLinear, SvgRenderer ?? null!, $"{Series?.Type}Legend"); } if (seriesRadial?.RendererType is not null) { - RenderRadialGradient(builder, seriesRadial, SvgRenderer, $"{Series.Type}Legend"); + RenderRadialGradient(builder, seriesRadial, SvgRenderer ?? null!, $"{Series?.Type}Legend"); } } @@ -185,12 +185,12 @@ private void RenderAllGradients(RenderTreeBuilder builder) if (trendlineLinear?.RendererType is not null) { - RenderLinearGradient(builder, trendlineLinear, SvgRenderer, suffix); + RenderLinearGradient(builder, trendlineLinear, SvgRenderer ?? null!, suffix); } if (trendlineRadial?.RendererType is not null) { - RenderRadialGradient(builder, trendlineRadial, SvgRenderer, suffix); + RenderRadialGradient(builder, trendlineRadial, SvgRenderer ?? null!, suffix); } } } diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/BubbleSeriesRenderer.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/BubbleSeriesRenderer.cs index 108f20e..3426971 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/BubbleSeriesRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/BubbleSeriesRenderer.cs @@ -364,7 +364,7 @@ private void ExtractAndProcessDynamicPointData(DynamicObject dynamicObject, Type { X = chartPoint.X = ReflectionExtension.GetValueFromDynamicObject(dynamicObject, xName) ?? 0, Y = chartPoint.Y = ReflectionExtension.GetValueFromDynamicObject(dynamicObject, yName) ?? 0, - Size = chartPoint.Size = !string.IsNullOrEmpty(size) ? ReflectionExtension.GetValueFromDynamicObject(dynamicObject, size) : null!, + Size = chartPoint.Size = !string.IsNullOrEmpty(size) ? ReflectionExtension.GetValueFromDynamicObject(dynamicObject, size) ?? null! : null!, Interior = chartPoint.Interior = ChartHelper.GetDynamicStringValue(dynamicObject ?? null!, pointColor), Text = chartPoint.Text = ChartHelper.GetDynamicStringValue(dynamicObject ?? null!, GetTextMapping()), Tooltip = chartPoint.Tooltip = ChartHelper.GetDynamicStringValue(dynamicObject ?? null!, Series?.TooltipMappingName ?? null!) diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/ColumnSeriesRenderer.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/ColumnSeriesRenderer.cs index cc7f4b3..d931a03 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/ColumnSeriesRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/SeriesTypeRenderers/ColumnSeriesRenderer.cs @@ -19,9 +19,9 @@ public class ColumnSeriesRenderer : ColumnBaseRenderer private void CalculateColumnPathOption() { DoubleRange sideBySideInfo = GetSideBySideInfo(); - string pointId = Series?.Container?.ID + "_Series_" + Index + "_Point_", id; + string pointId = Series?.Container?.ID + "_Series_" + Index + "_Point_"; double origin = Math.Max(YAxisRenderer?.VisibleRange.Start ?? 0, 0); - + string visibility = ShouldAnimate() ? "hidden" : "visible"; int pointsCount = Points?.Count ?? 0; diff --git a/src/Components/Charts/Chart/Renderer/StriplineRenderer/ChartStriplineRenderer.cs b/src/Components/Charts/Chart/Renderer/StriplineRenderer/ChartStriplineRenderer.cs index 76fc6af..4a1a57c 100644 --- a/src/Components/Charts/Chart/Renderer/StriplineRenderer/ChartStriplineRenderer.cs +++ b/src/Components/Charts/Chart/Renderer/StriplineRenderer/ChartStriplineRenderer.cs @@ -281,7 +281,7 @@ private void CreatePixelStriplinePath(bool isUpdateDirection, string id) { Id = id, Direction = direction, - StrokeDashArray = Stripline.DashArray, + StrokeDashArray = Stripline.DashArray ?? null!, StrokeWidth = Stripline.Size != 0 ? Stripline.Size : 1, Stroke = Stripline.Color, Opacity = Stripline.Opacity diff --git a/src/Components/Charts/Chart/Renderer/UserInteractions/Selection/Selection.cs b/src/Components/Charts/Chart/Renderer/UserInteractions/Selection/Selection.cs index 0e385ec..904f930 100644 --- a/src/Components/Charts/Chart/Renderer/UserInteractions/Selection/Selection.cs +++ b/src/Components/Charts/Chart/Renderer/UserInteractions/Selection/Selection.cs @@ -1,4 +1,5 @@ using System.Runtime.InteropServices; +using Microsoft.JSInterop; namespace Syncfusion.Blazor.Toolkit.Charts.Internal { @@ -135,9 +136,13 @@ private async Task SelectDataIndexAsync() } await SfBaseComponent.InvokeVoidAsync(_chartInstance._chartJsModule, _chartInstance._chartJsInProcessModule, Constants.SelectDataIndex, [.. new object[] { _chartInstance._dataId, SelectedDataIndexes.Concat(_chartInstance.SelectedDataIndexes).ToList() }]).ConfigureAwait(true); } - catch (Exception exception) + catch (JSException ex) { - Console.Error.WriteLine(exception); + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; + } + catch (ObjectDisposedException ex) + { + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; } } @@ -311,9 +316,13 @@ protected async Task SelectionChartAsync(ChartSelectedDataIndex index) } await SfBaseComponent.InvokeVoidAsync(_chartInstance._chartJsModule, _chartInstance._chartJsInProcessModule, "selectionChart", [.. new object[] { _chartInstance._dataId, index }]).ConfigureAwait(true); } - catch (Exception exception) + catch (JSException ex) + { + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; + } + catch (ObjectDisposedException ex) { - Console.Error.WriteLine(exception); + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; } } @@ -330,9 +339,13 @@ protected async Task BlurEffectAsync() } await SfBaseComponent.InvokeVoidAsync(_chartInstance._chartJsModule, _chartInstance._chartJsInProcessModule, "invokeBlurEffect", [.. new object[] { _chartInstance._dataId }]).ConfigureAwait(true); } - catch (Exception exception) + catch (JSException ex) + { + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; + } + catch (ObjectDisposedException ex) { - Console.Error.WriteLine(exception); + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; } } #endregion @@ -375,9 +388,13 @@ internal async Task RedrawSelectionAsync() } await SfBaseComponent.InvokeVoidAsync(_chartInstance._chartJsModule, _chartInstance._chartJsInProcessModule, "redrawSelection", [.. new object[] { _chartInstance._dataId }]).ConfigureAwait(true); } - catch (Exception exception) + catch (JSException ex) { - Console.Error.WriteLine(exception); + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; + } + catch (ObjectDisposedException ex) + { + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; } } @@ -394,9 +411,13 @@ internal async Task RemoveSelectionStylesAsync() } await SfBaseComponent.InvokeVoidAsync(_chartInstance._chartJsModule, _chartInstance._chartJsInProcessModule, "removeSelectionStyles", [.. new object[] { _chartInstance._dataId }]).ConfigureAwait(true); } - catch (Exception exception) + catch (JSException ex) + { + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; + } + catch (ObjectDisposedException ex) { - Console.Error.WriteLine(exception); + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; } } @@ -413,9 +434,13 @@ internal async Task RemoveSelectedElementsAsync() } await SfBaseComponent.InvokeVoidAsync(_chartInstance._chartJsModule, _chartInstance._chartJsInProcessModule, "invokeRemoveSelectedElements", [.. new object[] { _chartInstance._dataId }]).ConfigureAwait(true); } - catch (Exception exception) + catch (JSException ex) + { + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; + } + catch (ObjectDisposedException ex) { - Console.Error.WriteLine(exception); + await Console.Error.WriteLineAsync(ex.ToString()).ConfigureAwait(true); ; } } diff --git a/src/Components/Charts/Chart/Series/ChartSeries.cs b/src/Components/Charts/Chart/Series/ChartSeries.cs index 7588549..f989c31 100644 --- a/src/Components/Charts/Chart/Series/ChartSeries.cs +++ b/src/Components/Charts/Chart/Series/ChartSeries.cs @@ -137,7 +137,7 @@ public ChartSeriesType Type if (Container._legendRenderer is not null) { Container._legendRenderer.RendererShouldRender = Visible; - Container._legendRenderer.UpdateLegendShape(Renderer); + Container._legendRenderer.UpdateLegendShape(Renderer ?? null!); Container._legendRenderer.ProcessRenderQueue(); } } @@ -648,7 +648,7 @@ public string Name { Container._legendRenderer.RendererShouldRender = Visible; - Container._legendRenderer.UpdateLegendShape(Renderer); + Container._legendRenderer.UpdateLegendShape(Renderer ?? null!); Container._legendRenderer.ProcessRenderQueue(); } } @@ -1196,7 +1196,7 @@ public LegendShape LegendShape if (Container?._legendRenderer is not null) { Container._legendRenderer.RendererShouldRender = Visible; - Container._legendRenderer.UpdateLegendShape(Renderer); + Container._legendRenderer.UpdateLegendShape(Renderer ?? null!); Container._legendRenderer.ProcessRenderQueue(); } } @@ -2193,7 +2193,7 @@ private async Task RefreshSeriesAsync() Container?._svgRenderer?.RefreshElementList(); Renderer.IsSeriesRender = false; - _ = SetDataManager((DataSource is not null) ? DataSource : Container?.DataSource); + _ = SetDataManager((DataSource is not null) ? DataSource : Container?.DataSource ?? null!); Container?._seriesContainer?.AddToRenderQueue(Renderer); UpdateDataSource = true; diff --git a/src/Components/Charts/Chart/Series/DataLabel/ChartDataLabel.cs b/src/Components/Charts/Chart/Series/DataLabel/ChartDataLabel.cs index cbb195f..fe339d9 100644 --- a/src/Components/Charts/Chart/Series/DataLabel/ChartDataLabel.cs +++ b/src/Components/Charts/Chart/Series/DataLabel/ChartDataLabel.cs @@ -563,7 +563,7 @@ internal void ComponentDispose() { _marker = null; _renderer = null; - ChildContent = null; + ChildContent = null!; _margin?.ComponentDispose(); _margin = null; _border?.ComponentDispose(); diff --git a/src/Components/Charts/Chart/SfChart.razor.JsInterop.cs b/src/Components/Charts/Chart/SfChart.razor.JsInterop.cs index f514d68..1af0696 100644 --- a/src/Components/Charts/Chart/SfChart.razor.JsInterop.cs +++ b/src/Components/Charts/Chart/SfChart.razor.JsInterop.cs @@ -489,7 +489,7 @@ private void MultiLevelLabelClick(string labelIndex, int axisIndex) int textElement = int.TryParse(labelIndex.AsSpan(7), out int element) ? element : 0; ChartAxis axis = (_axisContainer?.Renderers[axisIndex] as ChartAxisRenderer ?? null!).Axis ?? null!; List categories = axis.MultiLevelLabels[int.TryParse(labelIndex.AsSpan(0, 1), out int index) ? index : 0].Categories; - MultiLevelLabelClickEventArgs multilevelclickArgs = new("OnMultiLevelLabelClick", false, categories[textElement].Text, axis, categories[textElement].CustomAttributes, categories[textElement].End, int.TryParse(labelIndex.AsSpan(0, 1), out int length) ? length : 0, categories[textElement].Start); + MultiLevelLabelClickEventArgs multilevelclickArgs = new("OnMultiLevelLabelClick", false, categories[textElement].Text, axis, categories[textElement].CustomAttributes, categories[textElement].End ?? null!, int.TryParse(labelIndex.AsSpan(0, 1), out int length) ? length : 0, categories[textElement].Start ?? null!); OnMultiLevelLabelClick.Invoke(multilevelclickArgs); } @@ -944,7 +944,7 @@ public void ZoomingComplete(ZoomingEventArgs zoomingEventArgs, IZoomingStates zo _zoomingModule._wheelEndEventArgs = zoomingEventArgs; } } - InvokeZoomingEvents(zoomingEventArgs); + InvokeZoomingEvents(zoomingEventArgs ?? null!); if ((_onZoomStartArgs is not null && !_onZoomStartArgs.Cancel) || (_onZoomingArgs is not null && !_onZoomingArgs.Cancel)) { diff --git a/src/Components/Charts/Chart/SfChart.razor.cs b/src/Components/Charts/Chart/SfChart.razor.cs index 4f8d94b..c66fb7a 100644 --- a/src/Components/Charts/Chart/SfChart.razor.cs +++ b/src/Components/Charts/Chart/SfChart.razor.cs @@ -778,9 +778,16 @@ private async Task GetElementOffsetAsync(string getElementBounds) _skipRendering = true; } } - catch (Exception ex) + catch (JSException ex) { - Console.Error.WriteLine($"Error getting element offset: {ex.Message}"); + await Console.Error.WriteLineAsync($"Error getting element offset: {ex.Message}") + .ConfigureAwait(true); + _skipRendering = true; + } + catch (ObjectDisposedException ex) + { + await Console.Error.WriteLineAsync($"Error getting element offset: {ex.Message}") + .ConfigureAwait(true); _skipRendering = true; } } @@ -1123,25 +1130,24 @@ private bool IsRendererDisposed() try { - FieldInfo field = GetType().BaseType?.BaseType?.BaseType?.BaseType?.BaseType?.GetField(RENDERHANDLE, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); + FieldInfo field = GetType().BaseType?.BaseType?.BaseType?.BaseType?.BaseType?.GetField(RENDERHANDLE, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static) ?? null!; if (field == null) return false; - object renderHandlerObj = field.GetValue(this); + object renderHandlerObj = field.GetValue(this) ?? null!; if (renderHandlerObj == null) return false; RenderHandle renderHandler = (RenderHandle)renderHandlerObj; - FieldInfo rendererInfo = renderHandler.GetType().GetField(RENDERER, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); + FieldInfo rendererInfo = renderHandler.GetType().GetField(RENDERER, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static) ?? null!; if (rendererInfo == null) return false; - object renderer = rendererInfo.GetValue(renderHandler); + object renderer = rendererInfo.GetValue(renderHandler) ?? null!; if (renderer == null) return false; - FieldInfo disposedInfo = renderer.GetType().BaseType?.GetField(DISPOSED, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); + FieldInfo disposedInfo = renderer.GetType().BaseType?.GetField(DISPOSED, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static) ?? null!; return disposedInfo is not null && (bool)(disposedInfo.GetValue(renderer) ?? false); } - catch + catch (Exception ex) when (ex is TargetException or TargetInvocationException or FieldAccessException or InvalidOperationException) { - // In test environments (like BUnit), reflection might not work as expected return false; } } @@ -1461,7 +1467,7 @@ internal void GetChartPoints() _seriesMarkers.Add(new IMarkerSettingModel { Visible = marker.Visible && _shouldRenderMarker, - Border = new IChartEventBorder() { Color = marker.Border.Color, Width = marker.Border.Width }, + Border = new IChartEventBorder() { Color = marker.Border.Color ?? null!, Width = marker.Border.Width }, Fill = marker.Fill, Height = marker.Height, Width = marker.Width, diff --git a/src/Components/Charts/Chart/UserInteractions/Crosshair/Models/ChartCrosshairLine.cs b/src/Components/Charts/Chart/UserInteractions/Crosshair/Models/ChartCrosshairLine.cs index 005d202..4a1611d 100644 --- a/src/Components/Charts/Chart/UserInteractions/Crosshair/Models/ChartCrosshairLine.cs +++ b/src/Components/Charts/Chart/UserInteractions/Crosshair/Models/ChartCrosshairLine.cs @@ -41,7 +41,7 @@ public class ChartCrosshairLine : ChartDefaultBorder [Parameter] public override string Color { - get => _color ?? base.Color; + get => _color ?? base.Color ?? string.Empty; set { if (_color != value) diff --git a/src/Components/Charts/Common/BaseTooltip/TooltipData.razor.cs b/src/Components/Charts/Common/BaseTooltip/TooltipData.razor.cs index 6c7e635..425bed6 100644 --- a/src/Components/Charts/Common/BaseTooltip/TooltipData.razor.cs +++ b/src/Components/Charts/Common/BaseTooltip/TooltipData.razor.cs @@ -180,7 +180,7 @@ internal void GetTemplateOptions(SfChart chart) } } - GivenContent = chart._tooltip.Template ?? (_ => builder => { }); + GivenContent = chart._tooltip.Template; } /// diff --git a/src/Components/Charts/Common/CommonLegend/LegendBase.cs b/src/Components/Charts/Common/CommonLegend/LegendBase.cs index e048ff0..13eba10 100644 --- a/src/Components/Charts/Common/CommonLegend/LegendBase.cs +++ b/src/Components/Charts/Common/CommonLegend/LegendBase.cs @@ -495,7 +495,7 @@ private string ResolveLegendTextX(LegendOption legendOption, double textWidth) private void CreateLegendElements(RenderTreeBuilder builder, SvgRendering svgRenderer, ChartDefaultBorder legendBorder) { string clipPath = LegendID + "_clipPath"; - RectOptions Option = new RectOptions(LegendID + "_element", LegendBounds.X, LegendBounds.Y, LegendBounds.Width, LegendBounds.Height, legendBorder.Width, legendBorder.Color, Legend?.Background ?? string.Empty, 0, 0, Legend?.Opacity ?? 1, string.Empty, "pointer-events: none; cursor: " + (Legend is not null && Legend.ToggleVisibility ? "default" : "pointer")); + RectOptions Option = new RectOptions(LegendID + "_element", LegendBounds.X, LegendBounds.Y, LegendBounds.Width, LegendBounds.Height, legendBorder.Width, legendBorder.Color ?? null!, Legend?.Background ?? string.Empty, 0, 0, Legend?.Opacity ?? 1, string.Empty, "pointer-events: none; cursor: " + (Legend is not null && Legend.ToggleVisibility ? "default" : "pointer")); svgRenderer.RenderRect(builder, Option); svgRenderer.OpenClipPath(builder, svgRenderer.Seq++, clipPath); Option.Id = clipPath + "_rect"; @@ -526,7 +526,7 @@ private void CreateLegendElements(RenderTreeBuilder builder, SvgRendering svgRen private string ResolveLegendMarkerFill(LegendOption legendOption, string defaultFill) { ChartSeries? series = Owner?._visibleSeriesRenderers?.ElementAtOrDefault((int)legendOption.SeriesIndex)?.Series; - if (ChartHelper.NeedsLegendHorizontalLineGradient(series)) + if (ChartHelper.NeedsLegendHorizontalLineGradient(series ?? null!)) { return Owner?._visibleSeriesRenderers?.ElementAtOrDefault((int)legendOption.SeriesIndex)?.Interior ?? defaultFill; } @@ -585,7 +585,6 @@ private void GetPosition(Size availableSize, string _baseControl, string seriesT /// Computed start point for legend items. private ChartEventLocation SetupStartAndPagingMetrics(int firstLegend, out double textPadding, out string pointerValue) { - int count = 0; double x_Align = 0; if (!string.IsNullOrEmpty(Legend?.Width) && MaxRowWidth < LegendBounds.Width && !IsVertical) From 0488e4d27167d658dd68e5b172f5684a2d435689 Mon Sep 17 00:00:00 2001 From: YokeshSF4393 Date: Wed, 9 Sep 2026 11:18:32 +0530 Subject: [PATCH 2/3] 1052437: Fixed playwright failure due to timeout. --- .../Charts/ChartAxes/axis-label-template.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Syncfusion.Blazor.Playwright.Test/Blazor.Toolkit.playwright.Test/Charts/ChartAxes/axis-label-template.spec.ts b/tests/Syncfusion.Blazor.Playwright.Test/Blazor.Toolkit.playwright.Test/Charts/ChartAxes/axis-label-template.spec.ts index 58fcca5..bb5fe8e 100644 --- a/tests/Syncfusion.Blazor.Playwright.Test/Blazor.Toolkit.playwright.Test/Charts/ChartAxes/axis-label-template.spec.ts +++ b/tests/Syncfusion.Blazor.Playwright.Test/Blazor.Toolkit.playwright.Test/Charts/ChartAxes/axis-label-template.spec.ts @@ -22,6 +22,7 @@ test.describe('Chart Axes – Axis Label Template', () => { test('X-axis label template with images renders', async ({ page }) => { // The sample uses custom label templates with country flags const images = page.locator('img[alt*="flag"]'); + await expect(images.first()).toBeVisible(); const count = await images.count(); expect(count).toBeGreaterThan(0); }); @@ -52,6 +53,7 @@ test.describe('Chart Axes – Axis Label Template', () => { test('Y-axis has numeric labels', async ({ page }) => { const yAxisLabels = page.locator('svg text').filter({ hasText: /\d+/ }); + await expect(yAxisLabels.first()).toBeVisible(); const count = await yAxisLabels.count(); expect(count).toBeGreaterThan(0); }); @@ -75,6 +77,7 @@ test.describe('Chart Axes – Axis Label Template', () => { test('All country flags load without error', async ({ page }) => { const images = page.locator('img[alt*="flag"]'); + await expect(images.first()).toBeVisible(); const count = await images.count(); expect(count).toBeGreaterThanOrEqual(6); // At least 6 countries }); From eecb22ddf07a1fc6b0110eff92e68580824264fc Mon Sep 17 00:00:00 2001 From: YokeshSF4393 Date: Wed, 9 Sep 2026 12:50:15 +0530 Subject: [PATCH 3/3] 1052437: Fixed vulnerability issue in toolkit and updated xml comments. --- .../BaseRenderers/MultiColoredBase.cs | 18 +++++++++--------- src/Syncfusion.Blazor.Toolkit.csproj | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs index 86ec52c..1ddf55e 100644 --- a/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs +++ b/src/Components/Charts/Chart/Renderer/SeriesRenderers/BaseRenderers/MultiColoredBase.cs @@ -26,6 +26,7 @@ internal class MultiColoredBaseSeriesRenderer : AreaBaseSeriesRenderer /// End axis value for clipping. /// Segment index (used for clip id). /// Whether the segment axis is X. + /// Index of the series owning the segment. /// CSS url() clip-path reference string or null when not applicable. private string CreateClipRect(RenderTreeBuilder builder, double startValue, double endValue, int index, bool isX, int seriesIndex) { @@ -209,15 +210,6 @@ internal List SortSegments(ChartSeries series, IList return segments; } - /// - /// Sets the fill/stroke color for the current point using the segment list or point color mapping. - /// - /// Point being colored. - /// Previous point for comparison when using point color mapping. - /// Series metadata. - /// Whether segmentation occurs on the X axis. - /// List of configured segments. - /// True when color changed compared to the previous point (used for boundary detection). /// /// Sets the fill/stroke color for the current point using the segment list or point color mapping. /// @@ -230,7 +222,15 @@ public override string SetPointColor(Point point, string color) } + /// + /// Sets the fill/stroke color for a point and reports whether it differs from the previous point. /// + /// Point being colored. + /// Previous point for comparison. + /// Series metadata. + /// Whether segmentation occurs on the X axis. + /// Configured axis segments. + /// when the point color differs from the previous point. internal bool SetPointColor(Point currentPoint, Point previous, ChartSeries series, bool isXSegment, List segments) { if (string.IsNullOrEmpty(series.PointColorMapping)) diff --git a/src/Syncfusion.Blazor.Toolkit.csproj b/src/Syncfusion.Blazor.Toolkit.csproj index 9bdc1bd..6207e08 100644 --- a/src/Syncfusion.Blazor.Toolkit.csproj +++ b/src/Syncfusion.Blazor.Toolkit.csproj @@ -89,7 +89,7 @@ - +