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..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))
@@ -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