suiss/ui · Chart
Tooltip Chart Label Formatter
A gradient area chart whose tooltip heading shows a longer date than the axis ticks.
Tooltip Chart Label Formatter is an open-source chart from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.
Two weeks of active energy as a gradient area, where the axis shows only day numbers but the tooltip heading spells out the weekday. Use a label formatter when the axis needs short labels and the tooltip has room for the full context.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies:
-
Copy the source into
components/charts/tooltip-chart-label-formatter.tsx:
- Update the import paths to match your project.
Usage
Pass a labelFormatter to ChartTooltipContent and build the heading from the hovered record, which arrives in its second argument. Adjust the date format there, for example to add the year when your range spans more than one year.
Notes
The demo format shows the weekday, month and day, so ranges that cross a month boundary stay clear. It leaves out the year.