Skip to content

Gang929 fix stacked area series negative#2086

Merged
beto-rodriguez merged 10 commits intodevfrom
gang929-fix-StackedAreaSeries-Negative
Feb 8, 2026
Merged

Gang929 fix stacked area series negative#2086
beto-rodriguez merged 10 commits intodevfrom
gang929-fix-StackedAreaSeries-Negative

Conversation

@beto-rodriguez
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 8, 2026 17:19
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 8, 2026

Thanks for your contribution!

The build and test process is starting. This may take a while.
You can find more details below as the process continues or at the actions tab.


All packages have been packed successfully! 📦✅
You can download the NuGet packages for this build here.

The packages will be available for 30 days, you can either use them directly, or wait for this PR to be merged to have them published to NuGet.org.


Tests will start now, you can monitor their progress below or at the actions tab.

Test Results Summary (Passed) ✅ 🥳

0 skipped.
0 failed.
987 passed! ✅

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the stacking accumulation logic in Stacker.StackPoint to address incorrect behavior for negative values in stacked area-like series.

Changes:

  • Updates how StackedValue.End/NegativeEnd are incremented during stacking.
  • Updates how per-index positive/negative totals are accumulated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 127 to +143
currentStack.End += value;
currentStack.NegativeEnd += value;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;

return positiveTotal;
}
else
{
currentStack.End += value;
currentStack.NegativeEnd += value;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

In the value >= 0 branch, the code now also adds the positive value to currentStack.NegativeEnd and _totals[index].Negative. That mixes the positive and negative stacks/totals; it will shift NegativeEnd upward and make NegativeTotal positive, which breaks later negative stacking (next series uses previousActiveStack.NegativeEnd) and can produce incorrect StackedValue.Share / bounds.

Suggested change
currentStack.End += value;
currentStack.NegativeEnd += value;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;
return positiveTotal;
}
else
{
currentStack.End += value;
currentStack.NegativeEnd += value;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
// positive values contribute only to the positive stack and positive totals
currentStack.End += value;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
return positiveTotal;
}
else
{
// negative values contribute only to the negative stack and negative totals
currentStack.NegativeEnd += value;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;

Copilot uses AI. Check for mistakes.
Comment on lines 127 to +143
currentStack.End += value;
currentStack.NegativeEnd += value;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;

return positiveTotal;
}
else
{
currentStack.End += value;
currentStack.NegativeEnd += value;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

In the value < 0 branch, the code now also adds the negative value to currentStack.End and _totals[index].Positive. That contaminates the positive stack baseline (previousActiveStack.End is used as the next series' positiveStart) and can make Total incorrect/negative, affecting stacked rendering and axis bounds.

Suggested change
currentStack.End += value;
currentStack.NegativeEnd += value;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;
return positiveTotal;
}
else
{
currentStack.End += value;
currentStack.NegativeEnd += value;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
// positive values contribute only to the positive stack and total
currentStack.End += value;
var positiveTotal = _totals[index].Positive + value;
_totals[index].Positive = positiveTotal;
return positiveTotal;
}
else
{
// negative values contribute only to the negative stack and total
currentStack.NegativeEnd += value;
var negativeTotal = _totals[index].Negative + value;
_totals[index].Negative = negativeTotal;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 8, 2026

@beto-rodriguez I've opened a new pull request, #2087, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 5 commits February 8, 2026 17:33
Co-authored-by: beto-rodriguez <10853349+beto-rodriguez@users.noreply.github.com>
Co-authored-by: beto-rodriguez <10853349+beto-rodriguez@users.noreply.github.com>
…selection

Co-authored-by: beto-rodriguez <10853349+beto-rodriguez@users.noreply.github.com>
Co-authored-by: beto-rodriguez <10853349+beto-rodriguez@users.noreply.github.com>
Add regression tests for mixed positive/negative stacked values and enable workflow on all branches
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 8, 2026

Thanks for your contribution!

The build and test process is starting. This may take a while.
You can find more details below as the process continues or at the actions tab.


All packages have been packed successfully! 📦✅
You can download the NuGet packages for this build here.

The packages will be available for 30 days, you can either use them directly, or wait for this PR to be merged to have them published to NuGet.org.


Tests will start now, you can monitor their progress below or at the actions tab.

Test Results Summary (Passed) ✅ 🥳

0 skipped.
0 failed.
1233 passed! ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants