Skip to content

feat: add Chart.js-powered data chart layouts + cohort retention heatmap - #48

Merged
gregmeyer merged 1 commit into
mainfrom
feat/chartjs-layouts
Apr 24, 2026
Merged

feat: add Chart.js-powered data chart layouts + cohort retention heatmap#48
gregmeyer merged 1 commit into
mainfrom
feat/chartjs-layouts

Conversation

@gregmeyer

Copy link
Copy Markdown
Owner

Summary

  • Adds 11 new data-chart layouts: line-chart, bar-chart, grouped-bar-chart, horizontal-bar-chart, stacked-bar-chart, grouped-stacked-bar-chart, stacked-area-chart, pie-chart, donut-chart, sankey-chart, and a Mixpanel-style cohort-chart retention heatmap.
  • Chart.js v4.4.7 + chartjs-chart-sankey v0.12.1 vendored under modern_graphics/assets/vendor/ so PNG export works offline with no network dependency.
  • export.py waits on window.__chartReady (set by Chart.js animation.onComplete) before capturing a screenshot.
  • CLI gains --labels, --series-json, --links-json, --cohorts-json, --nodes, --period-labels, --subtitle, --x-label, --y-label, --no-legend. JSON flags accept inline strings or @path/to/file.json.
  • MCP and suggest_layout automatically pick up the new layouts via the registry; generate_graphic's description is updated with per-layout input shapes.
  • README and docs/DIAGRAM_TYPES.md get galleries + CLI recipes. All 11 chart PNGs committed under examples/output/showcase/charts/.
  • 11 runnable examples/chart_*.py scripts, one per chart type.

Test plan

  • python3 examples/chart_bar.py through chart_sankey.py and chart_cohort.py — each produces HTML + PNG in examples/output/generated/
  • modern-graphics create --layout bar-chart --labels "A,B,C" --values "10,20,15" --output /tmp/bar.html
  • modern-graphics create --layout line-chart --labels "Q1,Q2,Q3,Q4" --series-json '[{"name":"2024","values":[10,14,18,22]}]' --output /tmp/line.html
  • modern-graphics create --layout sankey-chart --links-json '[{"from":"A","to":"B","value":10}]' --output /tmp/sankey.html
  • modern-graphics create --layout cohort-chart --cohorts-json '[{"date":"Jan 1","size":100,"values":[95,40,30]}]' --output /tmp/cohort.html
  • modern-graphics create --layout <chart> --png produces a valid PNG (validates __chartReady wait + Playwright integration)
  • @path/to/file.json loading works for the three JSON flags
  • list_layouts / suggest_layout (MCP) return all 11 new layouts
  • README + docs/DIAGRAM_TYPES.md render correctly on GitHub (images resolve from examples/output/showcase/charts/)

🤖 Generated with Claude Code

Adds 11 new layouts for data-driven graphics: line, bar, grouped bar,
horizontal bar, stacked bar, grouped stacked bar, stacked area, pie,
donut, sankey, and a Mixpanel-style cohort retention heatmap.

Chart.js v4 and chartjs-chart-sankey are vendored under
modern_graphics/assets/vendor so PNG export works offline. Playwright
waits on window.__chartReady (set in the animation.onComplete hook)
before screenshotting so canvases finish rendering.

CLI gains --labels, --series-json, --links-json, --cohorts-json,
--nodes, --period-labels, --subtitle, --x-label, --y-label, --no-legend.
JSON flags accept inline strings or @path/to/file.json. MCP and
suggest_layout auto-discover the new layouts via the registry.

README and docs/DIAGRAM_TYPES.md updated with galleries and CLI recipes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gregmeyer
gregmeyer merged commit 16f9132 into main Apr 24, 2026
2 checks passed
@gregmeyer
gregmeyer deleted the feat/chartjs-layouts branch April 24, 2026 17:21
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