ChartTooltip
The box that follows the pointer or the focus over a chart: the position, then every series with its colour and value. It flips sides past the middle so it never leaves the chart.
import { ChartTooltip } from '@sypnia/ui/react'
On this page
Over a bar chart
Hover a bar, or press Tab until one is focused.
Deploys
Per day
- Finished
- Failed
View as table
| Finished | Failed | |
|---|---|---|
| Mon | 6 | 1 |
| Tue | 9 | 0 |
| Wed | 4 | 2 |
| Thu | 11 | 1 |
| Fri | 7 | 0 |
Code
import { BarChart } from '@sypnia/ui/react';
// Hover a bar or reach it with Tab: the tooltip lists every series with its colour and value.
export default function Hover() {
return <BarChart title="Deploys" subtitle="Per day" x={['Mon', 'Tue', 'Wed', 'Thu', 'Fri']}
series={[{ id: 'ok', label: 'Finished', data: [6, 9, 4, 11, 7] }, { id: 'fail', label: 'Failed', data: [1, 0, 2, 1, 0] }]} />;
} When to use it
Use it when
- Charts you draw yourself; the library's charts show it already.
Do not use it when
- Information found only in the tooltip: the table view must have it too.
For everyone
- It opens on keyboard focus as well as on hover.
- Every value is also in the table view.
Props
| ChartTooltip | Type | Default |
|---|---|---|
atrequired | number | |
rowsrequired | { i: number; label: string; value: string; }[] | |
widthrequired | number | |
xrequired | ReactNode | |
y | number | 8 |