Chart
Lines, areas and bars without a chart library. One tooltip reads every series, arrow keys read it too, and several charts can follow one cursor.
| Day | Visitors |
|---|---|
| Oct 1 | 4,082 |
| Oct 2 | 4,432 |
| Oct 3 | 4,534 |
| Oct 4 | 4,584 |
| Oct 5 | 4,871 |
| Oct 6 | 3,156 |
| Oct 7 | 3,018 |
| Oct 8 | 4,764 |
| Oct 9 | 4,815 |
| Oct 10 | 4,921 |
| Oct 11 | 4,966 |
| Oct 12 | 5,273 |
| Oct 13 | 3,659 |
| Oct 14 | 3,258 |
| Oct 15 | 5,139 |
| Oct 16 | 5,186 |
| Oct 17 | 5,296 |
| Oct 18 | 5,725 |
| Oct 19 | 5,661 |
| Oct 20 | 3,926 |
| Oct 21 | 3,490 |
| Oct 22 | 5,502 |
| Oct 23 | 5,949 |
| Oct 24 | 5,658 |
| Oct 25 | 6,114 |
| Oct 26 | 6,036 |
| Oct 27 | 4,185 |
| Oct 28 | 3,985 |
| Oct 29 | 5,853 |
| Oct 30, so far | 2,210 |
Installation
npx shadcn@latest add @quireui/chartUsage
Pass the rows, the field that names each row, and the series to draw from them.
<Chart
label="Visitors by day"
data={[
{ day: "Oct 1", visitors: 4200 },
{ day: "Oct 2", visitors: 4410 },
// ...
]}
x="day"
type="area"
series={[{ key: "visitors", label: "Visitors" }]}
/>label names the chart for screen readers and the table. format takes the options of Intl.NumberFormat or your own function, and the axis switches to 12K and 1.2M on its own once the numbers get that big.
Lines, areas and bars
linefor a level that moves, like response time. Its scale fits the data, so small changes show.areafor a total and its shape, like visitors. It starts at zero, because an area is read by its size.barfor counts, like signups per week. Bars start at zero too, and the one under the pointer stays solid while the rest step back.
It is one component either way: every option below is a prop on Chart, off until you set it, so a plain chart stays plain.
Curves
curve sets how lines and areas run between points. linear joins them straight, and is the default. smooth curves through them without ever overshooting, so it cannot draw a peak or a dip the data does not have. step holds each value until the next, for things that change in jumps, like a price, a plan or a seat count.
| Day | Response time |
|---|---|
| Oct 1 | 182 ms |
| Oct 2 | 187 ms |
| Oct 3 | 190 ms |
| Oct 4 | 191 ms |
| Oct 5 | 189 ms |
| Oct 6 | 207 ms |
| Oct 7 | 178 ms |
| Oct 8 | 170 ms |
| Oct 9 | 163 ms |
| Oct 10 | 156 ms |
| Oct 11 | 152 ms |
| Oct 12 | 151 ms |
| Oct 13 | 174 ms |
| Oct 14 | 156 ms |
| Oct 15 | 161 ms |
| Oct 16 | 165 ms |
| Oct 17 | 168 ms |
| Oct 18 | 169 ms |
| Oct 19 | 166 ms |
| Oct 20 | 184 ms |
| Oct 21 | 155 ms |
| Oct 22 | 147 ms |
| Oct 23 | 139 ms |
| Oct 24 | 133 ms |
| Oct 25 | 130 ms |
| Oct 26 | 129 ms |
| Oct 27 | 153 ms |
| Oct 28 | 135 ms |
| Oct 29 | 139 ms |
| Oct 30 | 144 ms |
Several series
Each series takes the next chart colour in a fixed order, picked so neighbours stay apart for colour-blind readers and checked against both themes. The legend names them, and clicking a name hides that series. The others keep their colours, so nothing you were reading changes under you. The legend also offers the numbers as a table, which can be downloaded as CSV. table turns that on or off; it is on by default with more than one series.
| Day | Organic | Paid | Referral |
|---|---|---|---|
| Oct 1 | 2,123 | 898 | 490 |
| Oct 2 | 2,305 | 1,019 | 496 |
| Oct 3 | 2,358 | 1,088 | 472 |
| Oct 4 | 2,384 | 1,146 | 550 |
| Oct 5 | 2,533 | 1,072 | 546 |
| Oct 6 | 1,641 | 726 | 328 |
| Oct 7 | 1,569 | 724 | 362 |
| Oct 8 | 2,477 | 1,191 | 534 |
| Oct 9 | 2,504 | 1,059 | 501 |
| Oct 10 | 2,559 | 1,132 | 591 |
| Oct 11 | 2,582 | 1,192 | 556 |
| Oct 12 | 2,742 | 1,318 | 548 |
| Oct 13 | 1,903 | 805 | 439 |
| Oct 14 | 1,694 | 749 | 365 |
| Oct 15 | 2,672 | 1,233 | 534 |
| Oct 16 | 2,697 | 1,297 | 622 |
| Oct 17 | 2,754 | 1,165 | 593 |
| Oct 18 | 2,977 | 1,317 | 595 |
| Oct 19 | 2,944 | 1,359 | 679 |
| Oct 20 | 2,042 | 982 | 440 |
| Oct 21 | 1,815 | 768 | 363 |
| Oct 22 | 2,861 | 1,265 | 660 |
| Oct 23 | 3,093 | 1,428 | 666 |
| Oct 24 | 2,942 | 1,415 | 588 |
| Oct 25 | 3,179 | 1,345 | 734 |
| Oct 26 | 3,139 | 1,388 | 676 |
| Oct 27 | 2,176 | 1,004 | 435 |
| Oct 28 | 2,072 | 996 | 478 |
| Oct 29 | 3,044 | 1,288 | 656 |
| Oct 30 | 1,150 | 480 | 260 |
Bars side by side for comparing, stacked for a total and its parts. Stacked parts are split by a hairline of the surface, not an outline.
| Week | Free | Pro |
|---|---|---|
| Sep 8 | 180 | 64 |
| Sep 15 | 216 | 85 |
| Sep 22 | 252 | 82 |
| Sep 29 | 222 | 103 |
| Oct 6 | 258 | 100 |
| Oct 13 | 294 | 121 |
| Oct 20 | 264 | 118 |
| Oct 27 | 300 | 139 |
| Week | Free | Pro | Team |
|---|---|---|---|
| Sep 8 | 180 | 64 | 18 |
| Sep 15 | 216 | 85 | 21 |
| Sep 22 | 252 | 82 | 24 |
| Sep 29 | 222 | 103 | 27 |
| Oct 6 | 258 | 100 | 30 |
| Oct 13 | 294 | 121 | 33 |
| Oct 20 | 264 | 118 | 36 |
| Oct 27 | 300 | 139 | 39 |
The tooltip on a stack adds a total under the parts, so nobody has to add them up.
stacked="percent" stacks the parts as shares of the whole, each row adding up to 100%, for how a mix changes over time. The tooltip shows each part's value and its share.
| Day | Organic | Paid | Referral |
|---|---|---|---|
| Oct 1 | 2,123 | 898 | 490 |
| Oct 2 | 2,305 | 1,019 | 496 |
| Oct 3 | 2,358 | 1,088 | 472 |
| Oct 4 | 2,384 | 1,146 | 550 |
| Oct 5 | 2,533 | 1,072 | 546 |
| Oct 6 | 1,641 | 726 | 328 |
| Oct 7 | 1,569 | 724 | 362 |
| Oct 8 | 2,477 | 1,191 | 534 |
| Oct 9 | 2,504 | 1,059 | 501 |
| Oct 10 | 2,559 | 1,132 | 591 |
| Oct 11 | 2,582 | 1,192 | 556 |
| Oct 12 | 2,742 | 1,318 | 548 |
| Oct 13 | 1,903 | 805 | 439 |
| Oct 14 | 1,694 | 749 | 365 |
| Oct 15 | 2,672 | 1,233 | 534 |
| Oct 16 | 2,697 | 1,297 | 622 |
| Oct 17 | 2,754 | 1,165 | 593 |
| Oct 18 | 2,977 | 1,317 | 595 |
| Oct 19 | 2,944 | 1,359 | 679 |
| Oct 20 | 2,042 | 982 | 440 |
| Oct 21 | 1,815 | 768 | 363 |
| Oct 22 | 2,861 | 1,265 | 660 |
| Oct 23 | 3,093 | 1,428 | 666 |
| Oct 24 | 2,942 | 1,415 | 588 |
| Oct 25 | 3,179 | 1,345 | 734 |
| Oct 26 | 3,139 | 1,388 | 676 |
| Oct 27 | 2,176 | 1,004 | 435 |
| Oct 28 | 2,072 | 996 | 478 |
| Oct 29 | 3,044 | 1,288 | 656 |
Bars and a line together
A series can set its own type, so a line can run over bars, like daily signups with their weekly average. They share one scale; there is no second axis, because two scales on one plot let any two lines look related. If the line is a different unit, give it its own chart and sync their cursors.
| Day | Signups | 7-day average |
|---|---|---|
| Oct 1 | 127 | |
| Oct 2 | 153 | |
| Oct 3 | 151 | |
| Oct 4 | 148 | |
| Oct 5 | 151 | |
| Oct 6 | 109 | |
| Oct 7 | 101 | 134 |
| Oct 8 | 153 | 138 |
| Oct 9 | 149 | 137 |
| Oct 10 | 170 | 140 |
| Oct 11 | 166 | 143 |
| Oct 12 | 170 | 145 |
| Oct 13 | 113 | 146 |
| Oct 14 | 113 | 148 |
| Oct 15 | 172 | 150 |
| Oct 16 | 167 | 153 |
| Oct 17 | 164 | 152 |
| Oct 18 | 198 | 157 |
| Oct 19 | 189 | 159 |
| Oct 20 | 126 | 161 |
| Oct 21 | 108 | 161 |
| Oct 22 | 190 | 163 |
| Oct 23 | 199 | 168 |
| Oct 24 | 182 | 170 |
| Oct 25 | 190 | 169 |
| Oct 26 | 209 | 172 |
| Oct 27 | 140 | 174 |
| Oct 28 | 128 | 177 |
| Oct 29 | 181 | 176 |
| Oct 30, so far | 64 | 156 |
Stacks take negative values too: positive parts build up from zero and negative ones down, so profit and loss reads right. Here costs and refunds sit below the line, with the net drawn over them.
| Month | Revenue | Costs | Refunds | Net |
|---|---|---|---|---|
| Jan | $42,000 | -$31,000 | -$6,000 | $5,000 |
| Feb | $45,000 | -$32,000 | -$4,000 | $9,000 |
| Mar | $51,000 | -$35,000 | -$9,000 | $7,000 |
| Apr | $48,000 | -$38,000 | -$12,000 | -$2,000 |
| May | $56,000 | -$36,000 | -$5,000 | $15,000 |
| Jun | $61,000 | -$40,000 | -$7,000 | $14,000 |
The period before
previous on a series names a field with the same point in the period before. It is drawn dashed behind the series, and the tooltip shows both.
A period still running
partial says the last row is still being counted, like today. Its line turns dashed for the last step, or its bar fades, and it reads "Oct 30, so far", so a half-finished day does not look like a crash.
The scale
Bars and areas start at zero, and lines fit their data; zero changes that. min and max set the ends exactly, like 99% to 100% for uptime, where any dip matters, or 0 to 100 for a percentage. A value past an end you set is drawn at the edge.
| Day | Uptime |
|---|---|
| Oct 1 | 100.00% |
| Oct 2 | 99.99% |
| Oct 3 | 99.98% |
| Oct 4 | 100.00% |
| Oct 5 | 99.99% |
| Oct 6 | 100.00% |
| Oct 7 | 99.99% |
| Oct 8 | 99.98% |
| Oct 9 | 100.00% |
| Oct 10 | 99.99% |
| Oct 11 | 100.00% |
| Oct 12 | 99.42% |
| Oct 13 | 99.98% |
| Oct 14 | 100.00% |
| Oct 15 | 99.99% |
| Oct 16 | 100.00% |
| Oct 17 | 99.99% |
| Oct 18 | 99.98% |
| Oct 19 | 100.00% |
| Oct 20 | 99.99% |
| Oct 21 | 100.00% |
| Oct 22 | 99.99% |
| Oct 23 | 99.98% |
| Oct 24 | 99.81% |
| Oct 25 | 99.99% |
| Oct 26 | 100.00% |
| Oct 27 | 99.99% |
| Oct 28 | 99.98% |
| Oct 29 | 100.00% |
| Oct 30 | 99.99% |
Goals and limits
references draws a line across the plot for a goal or a limit, named at its end. With to, it is a band between two values, like an acceptable range for response time. The scale always makes room for them.
Notes on the timeline
notes marks events by a row's x: a deploy, a launch, an outage. A note is a thin line with its name beside it, or with to, a shaded span. Its name shows in the tooltip and is read out with the row, so a spike explains itself. Pass the same notes to every chart on a page and they line up across all of them.
| Day | Visitors |
|---|---|
| Oct 1 | 4,082 |
| Oct 2 | 4,432 |
| Oct 3 | 4,534 |
| Oct 4 | 4,584 |
| Oct 5 | 4,871 |
| Oct 6 | 3,156 |
| Oct 7 | 3,018 |
| Oct 8 | 4,764 |
| Oct 9 | 4,815 |
| Oct 10 | 4,921 |
| Oct 11 | 4,966 |
| Oct 12 | 5,273 |
| Oct 13 | 3,659 |
| Oct 14 | 3,258 |
| Oct 15 | 5,139 |
| Oct 16 | 5,186 |
| Oct 17 | 5,296 |
| Oct 18 | 5,725 |
| Oct 19 | 5,661 |
| Oct 20 | 3,926 |
| Oct 21 | 3,490 |
| Oct 22 | 5,502 |
| Oct 23 | 5,949 |
| Oct 24 | 5,658 |
| Oct 25 | 6,114 |
| Oct 26 | 6,036 |
| Oct 27 | 4,185 |
| Oct 28 | 3,985 |
| Oct 29 | 5,853 |
| Oct 30, so far | 2,210 |
<Chart
{...visitors}
references={[{ value: 5500, label: "Goal" }]}
notes={[
{ x: "Oct 9", label: "Launched on Hacker News" },
{ x: "Oct 20", to: "Oct 23", label: "Pricing test" },
]}
/>Choosing a range
With onRangeSelect, a drag across the plot chooses a range of rows and calls it with the first and last x. By keyboard, hold Shift with the arrow keys and press Enter. Hand it to a Date range picker and the whole page follows the range you drew. A click that stays put still picks a single row. On touch, a drag keeps reading the chart, so it never fights scrolling.
| Day | Signups |
|---|---|
| Oct 1 | 127 |
| Oct 2 | 153 |
| Oct 3 | 151 |
| Oct 4 | 148 |
| Oct 5 | 151 |
| Oct 6 | 109 |
| Oct 7 | 101 |
| Oct 8 | 153 |
| Oct 9 | 149 |
| Oct 10 | 170 |
| Oct 11 | 166 |
| Oct 12 | 170 |
| Oct 13 | 113 |
| Oct 14 | 113 |
| Oct 15 | 172 |
| Oct 16 | 167 |
| Oct 17 | 164 |
| Oct 18 | 198 |
| Oct 19 | 189 |
| Oct 20 | 126 |
| Oct 21 | 108 |
| Oct 22 | 190 |
| Oct 23 | 199 |
| Oct 24 | 182 |
| Oct 25 | 190 |
| Oct 26 | 209 |
| Oct 27 | 140 |
| Oct 28 | 128 |
| Oct 29 | 181 |
| Oct 30, so far | 64 |
One cursor for several charts
active is the row under the cursor, by its x, and onActiveChange reports it. Give several charts the same value and they all read the same day; the one you are pointing at shows the tooltip, the others show the line. Stat cards in a group match on the same names.
Point at either chart.
| Day | Visitors |
|---|---|
| Oct 1 | 4,082 |
| Oct 2 | 4,432 |
| Oct 3 | 4,534 |
| Oct 4 | 4,584 |
| Oct 5 | 4,871 |
| Oct 6 | 3,156 |
| Oct 7 | 3,018 |
| Oct 8 | 4,764 |
| Oct 9 | 4,815 |
| Oct 10 | 4,921 |
| Oct 11 | 4,966 |
| Oct 12 | 5,273 |
| Oct 13 | 3,659 |
| Oct 14 | 3,258 |
| Oct 15 | 5,139 |
| Oct 16 | 5,186 |
| Oct 17 | 5,296 |
| Oct 18 | 5,725 |
| Oct 19 | 5,661 |
| Oct 20 | 3,926 |
| Oct 21 | 3,490 |
| Oct 22 | 5,502 |
| Oct 23 | 5,949 |
| Oct 24 | 5,658 |
| Oct 25 | 6,114 |
| Oct 26 | 6,036 |
| Oct 27 | 4,185 |
| Oct 28 | 3,985 |
| Oct 29 | 5,853 |
| Oct 30, so far | 2,210 |
| Day | Signups |
|---|---|
| Oct 1 | 127 |
| Oct 2 | 153 |
| Oct 3 | 151 |
| Oct 4 | 148 |
| Oct 5 | 151 |
| Oct 6 | 109 |
| Oct 7 | 101 |
| Oct 8 | 153 |
| Oct 9 | 149 |
| Oct 10 | 170 |
| Oct 11 | 166 |
| Oct 12 | 170 |
| Oct 13 | 113 |
| Oct 14 | 113 |
| Oct 15 | 172 |
| Oct 16 | 167 |
| Oct 17 | 164 |
| Oct 18 | 198 |
| Oct 19 | 189 |
| Oct 20 | 126 |
| Oct 21 | 108 |
| Oct 22 | 190 |
| Oct 23 | 199 |
| Oct 24 | 182 |
| Oct 25 | 190 |
| Oct 26 | 209 |
| Oct 27 | 140 |
| Oct 28 | 128 |
| Oct 29 | 181 |
| Oct 30, so far | 64 |
onPick is called with a row's x on click or Enter, for pinning a day or opening it.
Loading and empty
While new rows load, a chart that already has some keeps them, dimmed, so nothing jumps. Without rows it holds its height with a placeholder. With no rows at all it says so.
| Week | Free |
|---|---|
| Sep 8 | 180 |
| Sep 15 | 216 |
| Sep 22 | 252 |
| Sep 29 | 222 |
| Oct 6 | 258 |
| Oct 13 | 294 |
| Oct 20 | 264 |
| Oct 27 | 300 |
| Day | Refunds |
|---|
Making it your own
Every part can go or change, without a second chart component to learn:
legend,axes(both,x,yornone) andgridturn the legend, the axis labels and the gridlines on or off.fillsets areas to fade toward the baseline, the default, or to one flat tint.tooltip={false}drops the tooltip; the row still reads out to screen readers. A function instead draws your own content in the tooltip's frame, given the row, every series' value, the total and any notes.- Each part has a
data-slotto style from your own CSS:chart-legend,chart-y-axis,chart-x-axis,chart-grid,chart-bar,chart-line,chart-area,chart-tooltip,chart-reference,chart-note.
A tooltip with the conversion rate worked out from two fields:
| Day | Visitors |
|---|---|
| Oct 1 | 4,082 |
| Oct 2 | 4,432 |
| Oct 3 | 4,534 |
| Oct 4 | 4,584 |
| Oct 5 | 4,871 |
| Oct 6 | 3,156 |
| Oct 7 | 3,018 |
| Oct 8 | 4,764 |
| Oct 9 | 4,815 |
| Oct 10 | 4,921 |
| Oct 11 | 4,966 |
| Oct 12 | 5,273 |
| Oct 13 | 3,659 |
| Oct 14 | 3,258 |
| Oct 15 | 5,139 |
| Oct 16 | 5,186 |
| Oct 17 | 5,296 |
| Oct 18 | 5,725 |
| Oct 19 | 5,661 |
| Oct 20 | 3,926 |
| Oct 21 | 3,490 |
| Oct 22 | 5,502 |
| Oct 23 | 5,949 |
| Oct 24 | 5,658 |
| Oct 25 | 6,114 |
| Oct 26 | 6,036 |
| Oct 27 | 4,185 |
| Oct 28 | 3,985 |
| Oct 29 | 5,853 |
| Oct 30, so far | 2,210 |
With no axes, grid or legend, a chart fits a small card:
Visitors
| day | Visitors |
|---|---|
| Oct 1 | 4,082 |
| Oct 2 | 4,432 |
| Oct 3 | 4,534 |
| Oct 4 | 4,584 |
| Oct 5 | 4,871 |
| Oct 6 | 3,156 |
| Oct 7 | 3,018 |
| Oct 8 | 4,764 |
| Oct 9 | 4,815 |
| Oct 10 | 4,921 |
| Oct 11 | 4,966 |
| Oct 12 | 5,273 |
| Oct 13 | 3,659 |
| Oct 14 | 3,258 |
| Oct 15 | 5,139 |
| Oct 16 | 5,186 |
| Oct 17 | 5,296 |
| Oct 18 | 5,725 |
| Oct 19 | 5,661 |
| Oct 20 | 3,926 |
| Oct 21 | 3,490 |
| Oct 22 | 5,502 |
| Oct 23 | 5,949 |
| Oct 24 | 5,658 |
| Oct 25 | 6,114 |
| Oct 26 | 6,036 |
| Oct 27 | 4,185 |
| Oct 28 | 3,985 |
| Oct 29 | 5,853 |
| Oct 30 | 2,210 |
Signups
| day | Signups |
|---|---|
| Oct 1 | 127 |
| Oct 2 | 153 |
| Oct 3 | 151 |
| Oct 4 | 148 |
| Oct 5 | 151 |
| Oct 6 | 109 |
| Oct 7 | 101 |
| Oct 8 | 153 |
| Oct 9 | 149 |
| Oct 10 | 170 |
| Oct 11 | 166 |
| Oct 12 | 170 |
| Oct 13 | 113 |
| Oct 14 | 113 |
| Oct 15 | 172 |
| Oct 16 | 167 |
| Oct 17 | 164 |
| Oct 18 | 198 |
| Oct 19 | 189 |
| Oct 20 | 126 |
| Oct 21 | 108 |
| Oct 22 | 190 |
| Oct 23 | 199 |
| Oct 24 | 182 |
| Oct 25 | 190 |
| Oct 26 | 209 |
| Oct 27 | 140 |
| Oct 28 | 128 |
| Oct 29 | 181 |
| Oct 30 | 64 |
Colours
The series colours are tokens in the foundation, --qui-chart-1 to --qui-chart-8, with steps for each theme. Override them there for your brand, or give one series its own color. Stay at eight or fewer; past that, fold the smallest into "Other".
Accessibility
The plot is a slider over the rows. Screen readers hear its name, then every series at the row you move to and any note on it, like "Oct 9: Visitors 4,612. Launched on Hacker News". The numbers are also in a table read with it, and with more than one series the legend can show that table on screen. Every series is named in the legend, so none is told apart by colour alone.
| Key | Action |
|---|---|
| ← / →, ↓ / ↑ | Previous or next row |
| PageDown / PageUp | Back or forward a tenth |
| Home / End | First or last row |
| Shift + ← / → | With onRangeSelect: grows a range from where the cursor was |
| Enter | Chooses the range, or calls onPick with the row |
| Esc | Drops the range, then leaves the row |
Motion
When the chart first scrolls into view, its bars grow up from the baseline a few milliseconds apart and its lines rise into place, all within a quarter of a second; a chart already on screen when the page loads stays put. When new data arrives with the same rows, bars and lines glide to the new numbers while the scale stays still; try the month switch at the top. Hiding a series in the legend glides too: its bars narrow and sink away while the rest slide together and the scale settles, and a line fades out. Pointing at a legend name eases the other series back. The crosshair and the tooltip follow the pointer and the keys without easing, so a value is never on its way; the tooltip and the cursor dots only fade in once. From the keyboard nothing waits, and with reduced motion only the fades remain. animate={false} turns the arrival and the gliding off.
Chart or something else?
- One figure with its trend: a Stat card, whose sparkline reads the same way.
- How much of a limit is used: a Meter.
API reference
Chart
Lines, areas or bars, drawn without a chart library. Point at it, or arrow along it, and one tooltip reads every series at that row. The numbers are also a table, for screen readers and on request.
Prop
Type
Also takes every <figure> attribute. Style it with [data-slot="chart"].