Branch: ai/sugar-charts-shared
Depends on: step-02 (candy-buffer)
Blocks: β
Migrate sugar-charts (LineChart, BarChart, Sparkline, etc.) onto candy-buffer for cell-grid rendering. Charts are the canonical use case for cell-level diffing (live dashboards re-rendering on tick) β building on candy-buffer enables step-26/27 buffer-diff wins for charts later.
Reference: Β§369.5 (consolidate buffer rendering), Β§387.5 (string-composition reinvention).
sugar-charts/composer.jsonβ addsugarcraft/candy-bufferviapath-repo-closure.sugar-charts/src/LineChart/LineChart.phpβ render via candy-buffer.sugar-charts/src/BarChart/BarChart.phpβ render via candy-buffer.sugar-charts/src/Sparkline.php(or wherever sparkline lives) β render via candy-buffer.- Other chart types as applicable.
- Tests get byte-snapshot pinning before/after.
- All existing sugar-charts tests pass; byte-snapshot tests show no diff for any existing fixture.
- Each chart type's
render()builds a Buffer internally; existing public string-return API preserved. - β₯95 % coverage maintained.
-
git statusclean on master.
- path-repo closure: add candy-buffer to sugar-charts.
- Per chart type: refactor
render()to build a Buffer, then call Buffer's toAnsi() (or string-render fallback β note in updates if Buffer::toAnsi isn't fully implemented yet). - Wide-char awareness: charts that include labels in CJK / emoji should respect cell width through candy-buffer's Cell width field.
- Run phpunit + check-path-repos.
- For each chart type: byte-snapshot test of existing fixtures unchanged.
- Add one wide-char label test (e.g., BarChart with
'ε€1', 'ε€2'labels) and pin the expected byte output. - Coverage report per chart class.
sugar-charts/README.md:## Shared foundationsmentioning candy-buffer.sugar-charts/CALIBER_LEARNINGS.md: "All chart renderers build a Buffer first. Don't re-implement string padding β use candy-buffer."
- PR title:
sugar-charts: render through candy-buffer - PR body:
## Summary - sugar-charts chart renderers (LineChart, BarChart, Sparkline, ...) build a Buffer instead of string-padding. - Sets up sugar-charts for the step-27 buffer-diff wiring (live-dashboard SSH-bandwidth wins). - Wide-char label rendering correct via Buffer's width-aware Cells. - Byte snapshots confirm no regression on existing fixtures. ## Test plan - [x] vendor/bin/phpunit in sugar-charts (β₯95% coverage, byte-snapshots green) - [x] php tools/check-path-repos.php Refs: docs/repo_map_step_17.md, docs/repo_map_update.md Β§369.5, Β§387.5 - Commit subject:
sugar-charts: render via candy-buffer.