MudChart: Fix series coloring issue with more than 20 custom colors (#8099)#8117
Merged
henon merged 2 commits intoMudBlazor:devfrom Feb 6, 2024
alanmansour:fix/series-coloring
Merged
MudChart: Fix series coloring issue with more than 20 custom colors (#8099)#8117henon merged 2 commits intoMudBlazor:devfrom alanmansour:fix/series-coloring
henon merged 2 commits intoMudBlazor:devfrom
alanmansour:fix/series-coloring
Conversation
…n 20 custom colors (#8099)
Member
|
Hi. |
Contributor
|
Yes please check in the test case that the parent chart palette is used and that the argument exception is not thrown |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #8117 +/- ##
==========================================
+ Coverage 88.11% 88.12% +0.01%
==========================================
Files 394 394
Lines 11760 11760
Branches 2384 2384
==========================================
+ Hits 10362 10364 +2
Misses 871 871
+ Partials 527 525 -2 ☔ View full report in Codecov by Sentry. |
Contributor
Author
|
I added the bUnit tests that test the coloring on all charts. |
Contributor
|
Thanks @Alanocorleo |
biegehydra
pushed a commit
to biegehydra/MudBlazor
that referenced
this pull request
Apr 26, 2024
…Blazor#8099) (MudBlazor#8117) * Chart: Fix series coloring issue which restricted specifying more than 20 custom colors (MudBlazor#8099) * Chart: Add bUnit tests to check the coloring of the charts (MudBlazor#8099) --------- Co-authored-by: APXM <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In "MudBlazor/Components/Chart/Charts", the files "Bar.razor", "Donut.razor", "Line.razor", "Pie.razor", and "StackedBar.razor" were modified. The modification was basically changing the operation ChartOptions.ChartPalette.Count() to MudChartParent.ChartOptions.ChartPalette.Count(). MudChartParent allows Bar, Donut, Line, Pie, and StackedBar to access their parent MudChart's properties and methods. When accessing ChartPalette directly through ChartOptions class, then Count() operation will perform counting on the predefined array in "ChartOptions.cs":
string [] ChartPalette = { Colors.Blue.Accent3, Colors.Teal.Accent3, Colors.Amber.Accent3, Colors.Orange.Accent3, Colors.Red.Accent3, Colors.DeepPurple.Accent3, Colors.Green.Accent3, Colors.LightBlue.Accent3, Colors.Teal.Lighten1, Colors.Amber.Lighten1, Colors.Orange.Lighten1, Colors.Red.Lighten1, Colors.DeepPurple.Lighten1, Colors.Green.Lighten1, Colors.LightBlue.Lighten1, Colors.Amber.Darken2, Colors.Orange.Darken2, Colors.Red.Darken2, Colors.DeepPurple.Darken2, Colors.Grey.Darken2 };
The same modification was applied to "Legend.razor" in "MudBlazor/Components/Chart/Parts".
This PR therefore fixes #8099.
How Has This Been Tested?
The fix was tested visually by inspecting few local made examples when running MudBlazor.Docs.Server. The example from this link https://try.mudblazor.com/snippet/GkcyulGAUNIYVebt was also used.
Test example (A stacked bar chart was used with 21 series and 21 colors. The colors have a pattern. Every 3 series have the colors green, blue, and red):

Before (21st bar is green, though it should be red):
After (21st bar is red as expected)

Before (when specifying one color, while having 20 series)
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'
After (it succeeds mapping the color specified to all series)

Types of changes
Checklist:
dev).