You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "bmampaey (via GitHub)" <gi...@apache.org> on 2026/07/09 13:50:39 UTC
[I] [Bug] stackStrategy: 'all' short-circuits and corrupts stack sum with null [echarts]
bmampaey opened a new issue, #21685:
URL: https://github.com/apache/echarts/issues/21685
### Version
6.1.0
### Link to Minimal Reproduction
https://codepen.io/Benjamin-Mampaey/pen/GgrQPGO
### Steps to Reproduce
On the [waterfall example](https://echarts.apache.org/examples/en/editor.html?c=bar-waterfall2), change the stackStrategy to 'all' on the Expenses series (and eventually on the others too) instead of the default stackStrategy: 'samesign'
### Current Behavior
Bars from the Expenses series disappear when the value of the Incomes series is null (i.e. '-')
### Expected Behavior
The stacking should exclude null values from the series Incomes, so that the sum does not become null, and the following series can be stacked.
### Environment
```markdown
- OS:
- Browser:
- Framework:
```
### Any additional comments?
In file src/processor/dataStack.ts :
// Considering positive stack, negative stack and empty data
if (
stackStrategy === 'all' // single stack group
|| (stackStrategy === 'positive' && val > 0)
|| (stackStrategy === 'negative' && val < 0)
|| (stackStrategy === 'samesign' && sum >= 0 && val > 0) // All positive stack
|| (stackStrategy === 'samesign' && sum <= 0 && val < 0) // All negative stack
) {
// The sum has to be very small to be affected by the
// floating arithmetic problem. An incorrect result will probably
// cause axis min/max to be filtered incorrectly.
sum = addSafe(sum, val);
stackedOver = val;
break;
}
if val is null, and stackStrategy === 'all' , when `sum = addSafe(sum, val);` is executed, sum becomes null
if val is null, and stackStrategy === 'samesign', because `&& val > 0` evaluates to False, `sum = addSafe(sum, val);` is not executed
There should be a safegard that val is not null
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] stackStrategy: 'all' short-circuits and corrupts stack sum with null [echarts]
Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart closed issue #21685: [Bug] stackStrategy: 'all' short-circuits and corrupts stack sum with null
URL: https://github.com/apache/echarts/issues/21685
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] stackStrategy: 'all' short-circuits and corrupts stack sum with null [echarts]
Posted by "aloktomarr (via GitHub)" <gi...@apache.org>.
aloktomarr commented on issue #21685:
URL: https://github.com/apache/echarts/issues/21685#issuecomment-5004077332
Can I pick this issue?
I checked the cause :-
In [calculateStack]() (`src/processor/dataStack.ts`), the [stackStrategy === 'all']() branch matches unconditionally,
so when a lower series' value is `null`/`'-'` (stored as [NaN]()),
[sum = addSafe(sum, NaN)]() becomes [NaN]() and the loop `break`s.
the upper series' bar disappears. The positive/negative/samesign strategies avoid this because their [val > 0]() / [val < 0]() checks reject [NaN](); `all` had no such guard.
Fix : -
guard the all branch with !isNaN(val) so null values are excluded from the stack (matching the other strategies) instead of corrupting the sum. Added a unit test.
Raising a PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] stackStrategy: 'all' short-circuits and corrupts stack sum with null [echarts]
Posted by "helgasoft (via GitHub)" <gi...@apache.org>.
helgasoft commented on issue #21685:
URL: https://github.com/apache/echarts/issues/21685#issuecomment-4928868314
> There should be a safegard that val is not null
Yes, makes sense.
The easy workaround is not to have nulls in the first place and use 0(zero) instead of '-' - [Demo](https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=tVRNj9owEL3zK6aXDQgK-QAWwrJVteqhl1WlrdQD4mDAQFQnjmxnF1Tx3zvjJA6gpeqhzcEf4-eZN28mFmzFBczhVwtA7-VbDEYVvIe7rVQpM4arGNp53oH5owUBKG4KlUGe91-ZKDjM5-DDJ_A8iJ1xhshT6zRrydwkMqsCmMQIHlduDD-YGLwfDENsmRDwtGfKeHSRwhsphUlyh1bJbkdcPHZItEcIAFp-k0lmSZY4RB5zjOHpPdvIN3JXObzIaFtka0usnTPFUt1x1wU3YJiiBOhLtjVkESzh7g7cpsr-A6bvffQaB8iAKUzYAWtXJ-BC81u4sMFVc6UzoTAuTv2MpRy64D2s1ODRwxUZNVcJ18_VEdagPnCFKF1aEQTf8WyDYtnd4TMK6BQudVtjPXZSHSuJN8wwbIBGr0ulRKIN5rBw5FFjaNNJguZghtMDzrTods81oov9vND7tvcsXy3npHNDAcJWeXTanTqV4zvkbcquhUplYlhYyFV_rJiqUkSgYeufaPsuDROX1hejSJAjNZ44O0sEz7B965_Ftorh6Ys5Nh1O30qqDVdPUkjqXXSWaSw43nWuANbvnNZK1Cie5numm4RvBvy7kH8M2hTAhS_bYOH3YOrjEITDEY6jiNbR_diNoyDAcTyZ4jgZkWU4JWQ4DZf1r3hRDWppZPE1W8uUO4L_pEb2abtKwLKPiHw0jXqAG5sBUbyf9CCcIOXSiP_0EgYDmulhLMQGVhz88_fkKocvh5xnmteP03_MomRIzH0kHYyG9Z5MAWofjbEMoR9VmuO4xMf4Nw&enc=deflate).
<img width="716" height="411" alt="Image" src="https://github.com/user-attachments/assets/a8075f0d-8dd4-476a-b1b2-1556132401bd" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org