Each recipe is a pattern you can paste and adapt. They use only @once-ui-system/core and @once-ui-system/core/data.
Charts fill their container, so a dashboard is a Grid of them. Give every chart in a row the same height so their plots line up, and let the grid collapse to one column on small screens.
A tile is a number, its change and the shape behind it: a Sparkline, not a full chart. Keep full charts for the questions a reader explores; tiles are for glancing.
Colour the change by what it means for the business, not by its sign: more refunds is up and bad.
The charts render on the server, so the page can query and pass the rows straight in. The first HTML holds the drawn chart, with no loading spinner and no client fetch.
Rows cross to the client as JSON, so send what the chart draws, not whole database records. Date values arrive as Dates; numbers stored as strings (Postgres numeric) need a Number() first. Keep function props out of server components: see Numbers and dates.
Draw the comparison as a quiet reference: last period in gray, this period in a colour.
| day | Last month | This month |
|---|---|---|
| 1 | 40 | 48 |
| 5 | 46 | 55 |
| 10 | 52 | 61 |
| 15 | 49 | 70 |
| 20 | 58 | 74 |
| 25 | 61 | |
| 30 | 64 |
Align the two periods by position (day 1, day 2…), not by date, so they share the axis. The current period stops where today is: leave its later values out instead of writing 0, and the line ends there.
A pie past five slices stops being readable. Keep the biggest and add up the rest:
| name | Sessions | Share |
|---|---|---|
| Search | 42.1K | 41.9% |
| Direct | 31.8K | 31.6% |
| Social | 12.4K | 12.3% |
| 8.3K | 8.3% | |
| Other | 5.9K | 5.9% |
gray marks "Other" as the leftovers, not a fifth source to compare.
LineBarChart draws its first series as a line and its second as bars, on one axis: the target as the line, the actuals as bars.
For a chart that updates every second, keep the x range fixed so the axis doesn't rescale on each sample. useStreamingViewport buffers the samples and pans the visible window; the live examples on LineChart show it with the animation tuned to glide, and turned off to snap.
LineChart and BarChart take the same props, so one set of props can draw either. A SegmentedControl picks which.
useDataTheme() reads the chart settings and setChartOptions changes them for every chart under the provider. A new mode is also remembered in the browser.