Back to Charts

Primitives

ChartTooltip

Shared chart tooltip content for consistent labels, markers, icons, units, hidden labels, and totals across every chart type.

Examples

Default

July 16, 2024 Running 380kcal Swimming 420kcal
<ChartTooltip
  label="July 16, 2024"
  rows={[
    {key: 'running', label: 'Running', value: '380', color: 'var(--uin-chart-1)'},
    {key: 'swimming', label: 'Swimming', value: '420', color: 'var(--uin-chart-2)'}
  ]}
/>

Line indicator

July 16, 2024 Running 380kcal Swimming 420kcal
<ChartTooltip
  label="July 16, 2024"
  indicator="line"
  rows={rows}
/>

Icons and total

Activities Running 380kcal Swimming 420kcal Total 800 kcal
<ChartTooltip
  label="Activities"
  indicator="none"
  rows={[
    {key: 'running', label: 'Running', value: '380', unit: 'kcal', icon: '⌁'},
    {key: 'swimming', label: 'Swimming', value: '420', unit: 'kcal', icon: '≈'}
  ]}
  total="800 kcal"
/>

Used by a chart

Tooltip - Line Indicator Tooltip rows can use line indicators. Running Swimming
Tooltip - Line IndicatorTooltip rows can use line indicators.02004006008001,000MonTueWedThuFriSat
Tooltip - Line Indicator
dayRunningSwimming
Mon450300
Tue380420
Wed510240
Thu220610
Fri560460
Sat410520
<BarChart
  title="Tooltip - Line Indicator"
  xKey="day"
  data={activity}
  stacked
  tooltipIndicator="line"
  series={[
    {key: 'running', label: 'Running'},
    {key: 'swimming', label: 'Swimming'}
  ]}
/>

Props

PropTypeDefaultDescription
labelstringTooltip heading, usually the active x/category value.
rowsChartTooltipRow[][]Rows with label, formatted value, color, icon, and unit metadata.
indicator'dot' | 'line' | 'none''dot'Visual marker rendered before row labels.
hideLabelbooleanfalseHide the heading while keeping the rows.
totalLabelstring'Total'Label for the optional total row.
totalstringOptional preformatted total value.

Install

CLI

npx @a3tai/mittsu add chart-tooltip --registry ./packages/charts/registry.json