Skip to content

feat: support custom arrays for sorting order#9840

Draft
joelostblom wants to merge 5 commits into
mainfrom
feat/order-by-array
Draft

feat: support custom arrays for sorting order#9840
joelostblom wants to merge 5 commits into
mainfrom
feat/order-by-array

Conversation

@joelostblom

Copy link
Copy Markdown
Contributor

PR Description

WIP

Checklist

  • This PR is atomic (i.e., it fixes one issue at a time).
  • The title is a concise semantic commit message (e.g. "fix: correctly handle undefined properties").
  • npm test runs successfully
  • For new features:
    • Has unit tests.
    • Has documentation under site/docs/ + examples.

Tips:

joelostblom and others added 5 commits April 22, 2026 17:40
Allow  field definitions to use explicit sort arrays,\nmatching behavior that already exists for other sortable field channels.\nThis closes a long-standing inconsistency where custom order lists worked\nfor scale channels but not for mark ordering or stack ordering.\n\nImplement sort-array handling for order fields by generating derived\n formula fields during data parsing and by compiling\norder comparators to use those derived indexes. For multi-field order,\ninclude the order position in the derived field name so different sort\narrays can coexist without collisions.\n\nAlso update order encoding normalization so array-valued order channel\ndefinitions are retained instead of being dropped. Add targeted compile\ntests for calculate, mark sort, and stack sort paths to verify both\nsingle and multi-order array behavior.
When color or fill uses an explicit sort array, stacked and grouped order\nalignment should follow that array the same way it follows an explicit\nscale domain array. This keeps sort behavior consistent across discrete\nordering inputs and matches user expectations for stack ordering.\n\nIf an explicit order field is present and targets the same field as color,\nwe now inherit the color sort array when order.sort is unspecified instead\nof leaving order at its default. This allows specs that declare order for\nstack semantics to still respect color sort arrays.\n\nThis change also deduplicates stack-by field names when color and order\nreference the same field, and adds regression tests covering grouped\nbars, stacked bars, and inherited stack sort compilation.
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.

1 participant