Skip to content

feat(bar): add --horizontal flag for 2D grouped bar charts#190

Merged
fahimfaisaal merged 14 commits into
mainfrom
fahimfaisaal/feat-horizontal-2d-bar-charts-grouped-mode
Jul 6, 2026
Merged

feat(bar): add --horizontal flag for 2D grouped bar charts#190
fahimfaisaal merged 14 commits into
mainfrom
fahimfaisaal/feat-horizontal-2d-bar-charts-grouped-mode

Conversation

@fahimfaisaal

@fahimfaisaal fahimfaisaal commented Jul 5, 2026

Copy link
Copy Markdown
Member

Related Issue

Resolve #189

Summary

  • Adds horizontal layout for 2D grouped bar charts (categories on Y axis, values on X axis, bars grow right).
  • Exposes the feature through CLI --horizontal, --chart bar:horizontal, the UI settings panel, and ?bar.h=true deep links.
  • Horizontal mode is layout-only — it flips ECharts axis geometry without remapping data or labels (distinct from --swap).
  • Keeps horizontal bars unavailable for 3D bar charts, mixed mode, value mode, and non-bar chart types.

Changes

  • Added bar-only --horizontal CLI flag and horizontal config field in Go (HorizontalFlag, Bar.Horizontal).
  • Added --chart bar:horizontal support via the chart flag registry.
  • Added Horizontal bars UI toggle for 2D bar charts; hidden when rendering 3D or in mixed/value transform modes.
  • Added createHorizontalAxisConfig, createHorizontalDataZoomConfig, and right-positioned bar labels for horizontal orientation.
  • Branched useBarChartOptions for horizontal grouped mode: legend at bottom center, category Y-axis (inverse: true), value X-axis, Y-axis dataZoom slider.
  • Added bar.h URL deep-link in useUrlRouter.
  • Left 3D bar rendering (useBar3DChartOptions) unchanged.
  • Added backend and UI tests for flag registration, config materialisation, field visibility, store updates, axis/legend options, and URL routing.
  • Updated bar chart docs (charts/bar.mdx, commands/charts.mdx, commands/root.mdx).
  • Regenerated the embedded UI bundle in pkg/template/vizb-ui.gen.go.

Test Result

Testing Steps

  • Ran full Go test suite:
go test ./...
  • Ran targeted UI tests:
cd ui
corepack pnpm test \
  src/composables/charts/useBarChartOptions.test.ts \
  src/composables/useUrlRouter.test.ts \
  src/composables/settings/fieldRegistry.test.ts \
  src/components/SettingsPanel.test.ts
  • Smoke-tested --horizontal CLI output:
go run . bar examples/csv/sales.csv -g region,category -p x,y --horizontal --show-labels -o out.html
  • Verified generated HTML contains baked config:
grep -o '"horizontal":true' out.html
  • Smoke-tested root --chart override:
go run . examples/csv/sales.csv -g region,category -p x,y -c bar --chart bar:horizontal -o dashboard.html
  • Verified CLI flag exposure:
go run . bar --help | grep horizontal
go run . line --help | grep horizontal

Expected: --horizontal appears under bar --help only.

horizontal-bar-preview.webm

@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 546bc38 into main Jul 6, 2026
13 checks passed
@fahimfaisaal
fahimfaisaal deleted the fahimfaisaal/feat-horizontal-2d-bar-charts-grouped-mode branch July 6, 2026 04:14
@fahimfaisaal fahimfaisaal added enhancement New feature or request ui ui-related tasks cli Command line interface related tasks labels Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Command line interface related tasks enhancement New feature or request ui ui-related tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat]: Horizontal 2D bar charts (grouped mode)

2 participants