Skip to content

fix(sort): apply sort to 1-axis charts#175

Merged
fahimfaisaal merged 1 commit into
mainfrom
fix/1-axis-chart-sort
Jun 30, 2026
Merged

fix(sort): apply sort to 1-axis charts#175
fahimfaisaal merged 1 commit into
mainfrom
fix/1-axis-chart-sort

Conversation

@fahimfaisaal

Copy link
Copy Markdown
Member

Summary

Fixes sort not affecting 1-axis charts when using --sort asc / --sort desc (e.g. vizb bar examples/csv/sales.csv -o index.html --sort asc). The sort toggle worked in the UI but bar order did not change.

Root cause

1-axis charts were often routed through the mixedTuples path because Dashboard.vue had a legacy override that forced preserveRows=true for solo --select embeds (axes.length === 1 && axes[0].key === 'x'), even when Go set preserveRows: false for auto-grouped data.

That path skipped sortSeriesByTotal (which only runs when series.length > 0) and rendered tuples as-is.

Changes

  • Remove legacy preserveRows override in Dashboard.vue — honor only activeDataSet.preserveRows === true
  • Add mixed-tuple sorting in finalize.ts for preserveRows charts without series
  • Add regression tests for preserveRows 1D asc/desc sort in transform.test.ts
  • Rebuild embed (pkg/template/vizb-ui.gen.go)

Test plan

  • cd ui && pnpm test — 416 tests pass
  • Pre-commit hooks (format, go-test, ui-gen-check) pass
  • Manual: regenerate index.html with --sort asc and confirm asc/desc toggle reorders bars

Remove legacy preserveRows override that forced category-scatter path
for solo --select embeds. Add mixed-tuple sorting in finalize for
preserveRows charts without series.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fahimfaisaal
fahimfaisaal merged commit 070e58e into main Jun 30, 2026
13 checks passed
@fahimfaisaal
fahimfaisaal deleted the fix/1-axis-chart-sort branch June 30, 2026 10:06
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.

2 participants