feat(stack): add order value for per-bucket stacking#568
Conversation
Implement Observable Plot-compatible stack order 'value' via per-bucket signed-value sorting and manual cumulative stacking. Supports offset none only; crossover, facet, stackX, negative, and unit tests included.
Coerce stack magnitudes with unary + like d3, use Map for group keys, sort null/NaN last with stable index ties, and allow diverging offset as a no-op alias on the value-order path.
✅ Deploy Preview for svelteplot ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93d215395f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| out.push( | ||
| ...stackBucketByValue(itemsToStack, byDim, byLow, byHigh, options.reverse) |
There was a problem hiding this comment.
Respect offset none for negative value-order stacks
When order: 'value' is used with the default or explicit offset: 'none' and a stack bucket contains negative values, this call does not pass the accepted offset into the manual stacker, so offset: 'none' follows the helper's separate positive/negative accumulators and produces the same coordinates as offset: 'diverging'. That flips/places negative segments as diverging stacks (for example -100 becomes [y1=-100, y2=0] rather than the cumulative none-offset [0, -100]), so mixed-sign value-ordered stacks no longer honor the selected offset.
Useful? React with 👍 / 👎.
Narrow STACK_ORDER index type for svelte-check. Use single cumulative baseline (d3 stackOffsetNone) instead of py/ny split when offset is none.
Summary
stack.order: 'value'(Observable Plot parity): sorts rows within each stack group by signed magnitudeoffset: 'none'/'diverging'only (other offsets throw)stack.tsTests
Crossover, reverse, stackX, facets, negatives, unit stacking, numeric strings, missing values
Docs
StackOrderupdatedvaluein order list + first interactive select (not streamgraph select — wiggle offset incompatible)