Skip to content

feat(bar/line): add --stack for 2d charts#194

Merged
fahimfaisaal merged 9 commits into
goptics:mainfrom
hfl0506:feat/add-stack-for-2d-charts
Jul 9, 2026
Merged

feat(bar/line): add --stack for 2d charts#194
fahimfaisaal merged 9 commits into
goptics:mainfrom
hfl0506:feat/add-stack-for-2d-charts

Conversation

@hfl0506

@hfl0506 hfl0506 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Related Issues


Summary

  • Added opt-in --stack support for 2D grouped bar and line charts.
  • bar --stack renders stacked bars.
  • line --stack renders stacked area lines.
  • Default behavior remains grouped side-by-side / normal lines.
  • Stack is skipped for z data and log scale.

Changes

  • Added StackFlag in Go chart flags.

  • Added stack JSON config to BarConfig and LineConfig.

  • Registered --stack on bar and line commands.

  • Added rule checks:

    • requires x,y
    • excludes z
    • skips when scale=log
  • Added stack?: boolean to UI chart config types.

  • Threaded stack through active chart shape, chart options, and ChartCard.

  • Updated bar renderer to emit stack: 'total'.

  • Updated line renderer to emit stack: 'total' and areaStyle: {}.

  • Added StackControl.vue and Settings panel toggle.

  • Updated settings registry and tests for stack visibility.

  • Updated docs with stacked bar and stacked area examples.

  • Regenerated pkg/template/vizb-ui.gen.go.

  • Resolved merge conflicts with upstream horizontal bar and smooth line
    features preserved.


Test Result

Ran validations below

task build:ui
task build:cli

cd ui
pnpm test
pnpm typecheck
pnpm format:check

Case 1 (Bar)

./bin/vizb bar examples/csv/sales.csv \
    -g region,category \
    -p x,y \
    --stack \
    -o /tmp/vizb-stacked-bar.html
Screenshot 2026-07-05 at 10 50 56 PM Screenshot 2026-07-05 at 10 51 38 PM

Case 2 (Line)

./bin/vizb line examples/csv/sales.csv \
    -g region,category \
    -p x,y \
    --stack \
    -o /tmp/vizb-stacked-line.html
Screenshot 2026-07-05 at 10 52 51 PM Screenshot 2026-07-05 at 10 52 57 PM

Case 3 (log scale + stack, should warning and ignore stack)

./bin/vizb bar examples/csv/sales.csv -g region,category -p x,y --stack
  --scale log -o /tmp/log.html
Screenshot 2026-07-05 at 10 55 58 PM

@codecov-commenter

codecov-commenter commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hfl0506 hfl0506 changed the title Feat/add stack for 2d charts feat(bar/line): add --stack for 2d charts Jul 6, 2026
@hfl0506
hfl0506 marked this pull request as ready for review July 6, 2026 06:10
@hfl0506

hfl0506 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @fahimfaisaal Can I get you review this PR when you have a moment ? thank you

@fahimfaisaal

Copy link
Copy Markdown
Member

@hfl0506 i will, currently AFK

@fahimfaisaal

Copy link
Copy Markdown
Member

@hfl0506 how show labels works with stack bar/line charts?

@hfl0506

hfl0506 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @fahimfaisaal here's the show label examples for both case of bar/line below. Thanks
please let me know if it needs to change.
Screenshot 2026-07-07 at 8 03 22 PM
Screenshot 2026-07-07 at 8 03 59 PM

@fahimfaisaal

fahimfaisaal commented Jul 8, 2026

Copy link
Copy Markdown
Member

Hi @hfl0506 can we add these stack SS at chart docs?

Also, can we disable the scale component in the UI when stack is enabled?

@hfl0506

hfl0506 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @fahimfaisaal I pushed change according to what you mention like below. Please take a look when you have a moment. Thank you

Case 1

./bin/vizb bar examples/csv/sales.csv -g region,category -p x,y
  --stack -o /tmp/vizb-stack.html
Screenshot 2026-07-08 at 10 10 14 PM Screenshot 2026-07-08 at 10 10 31 PM

Case 2

./bin/vizb line examples/csv/sales.csv -g region,category -p
  x,y --stack -o /tmp/vizb-stack-line.html
Screenshot 2026-07-08 at 10 11 09 PM Screenshot 2026-07-08 at 10 11 23 PM

@fahimfaisaal

Copy link
Copy Markdown
Member

@hfl0506 Nice, Well Done

@fahimfaisaal
fahimfaisaal merged commit 45920aa into goptics:main Jul 9, 2026
13 checks passed
@fahimfaisaal fahimfaisaal linked an issue Jul 9, 2026 that may be closed by this pull request
15 tasks
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.

[feat]: Add --stack for 2D grouped bar/line charts

3 participants