#206
Animated proportions
A donut chart with Q1, Q2 and Q3 chips that switch which quarter of data the chart shows.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Animated proportions" pattern (@codeatlasdev/ui demo #206, charts/pie) in my app.
Call get_demo({ ids: ["#206"] }) first and keep its structure. It needs @codeatlasdev/[email protected] + echarts.
Use: Showing how a share breakdown shifts between periods with a selector.
Keep these library parts, with the props and tokens the demo uses:
- Card, Flex, Chip from "@codeatlasdev/ui"
- PieChart from "@codeatlasdev/ui/charts"
Behaviour to keep:
- `let selected = $state<Quarter>('Q1')` and `const data = $derived(qData[selected])`
- `{#each quarters as q}` renders `<Chip label={q} selected={selected === q}` with `variant="brand"` and `size="sm"`
- `onclick={() => (selected = q)}` changes the quarter
- `qData` has 4 items per quarter: Cloud, Enterprise, SaaS, Other
- `<PieChart {data} donut height="300px" />` inside `<Card full>`
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
How it is built
- `let selected = $state<Quarter>('Q1')` and `const data = $derived(qData[selected])`
- `{#each quarters as q}` renders `<Chip label={q} selected={selected === q}` with `variant="brand"` and `size="sm"`
- `onclick={() => (selected = q)}` changes the quarter
- `qData` has 4 items per quarter: Cloud, Enterprise, SaaS, Other
- `<PieChart {data} donut height="300px" />` inside `<Card full>`
Related
Loading source.