|
1 | | -using System.Collections.ObjectModel; |
| 1 | +using System.Collections.ObjectModel; |
2 | 2 |
|
3 | 3 | namespace Syncfusion.Maui.Toolkit.Charts |
4 | 4 | { |
@@ -103,8 +103,23 @@ internal void CalculateSbsPosition() |
103 | 103 | { |
104 | 104 | if (!stackingSeries.IsSbsValueCalculated && _seriesGroup != null) |
105 | 105 | { |
106 | | - var stackingSeriesType = stackingSeries.GetType(); |
107 | | - string groupID = _seriesGroup.FirstOrDefault(x => x.Value.Any(s => s.GroupingLabel == stackingSeries.GroupingLabel && s.GetType() == stackingSeriesType)).Key; |
| 106 | + string? groupID = null; |
| 107 | + foreach (var group in _seriesGroup) |
| 108 | + { |
| 109 | + foreach (var s in group.Value) |
| 110 | + { |
| 111 | + if (s.GroupingLabel == stackingSeries.GroupingLabel && s.GetType() == stackingSeries.GetType()) |
| 112 | + { |
| 113 | + groupID = group.Key; |
| 114 | + break; |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + if (groupID != null) |
| 119 | + { |
| 120 | + break; |
| 121 | + } |
| 122 | + } |
108 | 123 | StackingSeriesBase stackingSeriesBase; |
109 | 124 | int size = SideBySideSeriesPosition.Count > 0 && groupingKeys.Count > 0 && groupingKeys.TryGetValue(groupID, out var groupValue) |
110 | 125 | ? SideBySideSeriesPosition[groupValue].Count : 0; |
@@ -354,15 +369,23 @@ internal void InvalidateMinWidth() |
354 | 369 |
|
355 | 370 | internal void ResetSBSSegments() |
356 | 371 | { |
357 | | - var sideBySideSeries = VisibleSeries?.Where(series => series.IsSideBySide).ToList(); |
358 | | - |
359 | | - if (sideBySideSeries != null && sideBySideSeries.Count > 0) |
| 372 | + if (VisibleSeries == null) |
360 | 373 | { |
361 | | - SideBySideSeriesPosition = null; |
| 374 | + return; |
| 375 | + } |
362 | 376 |
|
363 | | - foreach (var chartSeries in sideBySideSeries) |
| 377 | + bool hasSbsSeries = false; |
| 378 | + foreach (var series in VisibleSeries) |
| 379 | + { |
| 380 | + if (series.IsSideBySide) |
364 | 381 | { |
365 | | - chartSeries.SegmentsCreated = false; |
| 382 | + if (!hasSbsSeries) |
| 383 | + { |
| 384 | + SideBySideSeriesPosition = null; |
| 385 | + hasSbsSeries = true; |
| 386 | + } |
| 387 | + |
| 388 | + series.SegmentsCreated = false; |
366 | 389 | } |
367 | 390 | } |
368 | 391 | } |
@@ -407,7 +430,22 @@ static double GetSBSMaxWidth(List<CartesianSeries> seriesGroup) |
407 | 430 | internal void UpdateStackingSeries() |
408 | 431 | { |
409 | 432 | //if visible series count is 0 or not contain any stacking series then return. |
410 | | - if (VisibleSeries == null || VisibleSeries.Count == 0 || !VisibleSeries.Any(series => series is StackingSeriesBase && !series.SegmentsCreated)) |
| 433 | + if (VisibleSeries == null || VisibleSeries.Count == 0) |
| 434 | + { |
| 435 | + return; |
| 436 | + } |
| 437 | + |
| 438 | + bool hasStackingToCreate = false; |
| 439 | + foreach (var series in VisibleSeries) |
| 440 | + { |
| 441 | + if (series is StackingSeriesBase && !series.SegmentsCreated) |
| 442 | + { |
| 443 | + hasStackingToCreate = true; |
| 444 | + break; |
| 445 | + } |
| 446 | + } |
| 447 | + |
| 448 | + if (!hasStackingToCreate) |
411 | 449 | { |
412 | 450 | return; |
413 | 451 | } |
|
0 commit comments