Skip to content
Merged
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
6 changes: 4 additions & 2 deletions maui/src/Charts/Series/BoxAndWhiskerSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ internal override void GenerateSegments(SeriesView seriesView)

if (yList.Length > 0)
{
// The quartile, whisker, and min/max calculations below all rely on ascending values.
Array.Sort(yList);
average = yList.Average();
}
Expand Down Expand Up @@ -1086,8 +1087,9 @@ internal override void GenerateSegments(SeriesView seriesView)
}
else
{
minimum = yList.Min();
maximum = yList.Max();
// yList was sorted above and is not modified afterwards, so first/last entries are the min/max.
minimum = yList[0];
maximum = yList[^1];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mentioned as ylist already sorted, ensure it are we sorted the points at all flow.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can you check this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked it: GenerateSegments() sorts yList with Array.Sort(yList) before the quartile/whisker/min-max path, and the array is not modified afterwards. I pushed f889217 to make that invariant explicit in the code comments next to the sort and direct index access.

}

double actualMinimum = minimum;
Expand Down