# Chart tooltip

Source: https://ecosphere.dev/docs/charts/chart-tooltip (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

A card that opens beside the column or point under the pointer or keyboard focus and lists everything at that position.

`import { EcoChartTooltip } from "vue-ecosphere"`

## Open on a column

Hover or focus any column: the others dim to 45% and the card lists every family, top segment first. It is aria-hidden; the hit area's label says everything. Escape closes it without moving focus.

Vue (vue-ecosphere):

```vue
<!-- Every chart opens its own card on hover and focus; Escape closes it. -->
<EcoBarChart
  :labels="year"
  :titles="yearTitles"
  :series="revenue"
  :value-format="(v) => '$' + v.toLocaleString('en-US')"
  :height="270"
  title="Revenue by product family"
/>
```

React (react-ecosphere):

```tsx
// Every chart opens its own card on hover and focus; Escape closes it.
<EcoBarChart
  labels={year}
  titles={yearTitles}
  series={revenue}
  valueFormat={(v) => "$" + v.toLocaleString("en-US")}
  height={270}
  title="Revenue by product family"
/>
```

## The card on its own

Keys use the chart's own marks: swatches for bars and areas, line keys for lines. No total when the figures do not add up to one amount.

Vue (vue-ecosphere):

```vue
<EcoChartTooltip inline title="October 2026" total="$74,900" unit="total" :rows="[
  { label: 'Support', value: '$11,600', slot: 3 },
  { label: 'Services', value: '$22,100', slot: 2 },
  { label: 'Hardware', value: '$41,200', slot: 1 },
]" />
<EcoChartTooltip inline title="Week of 12 October" total="1,284" unit="requests" :rows="lineRows /* key: 'key' */" />
<EcoChartTooltip inline title="December 2025" :rows="signedRows" />
<EcoChartTooltip inline title="From 1 November 2023" total="$11.60" unit="per unit"
  :rows="[{ label: 'Change', value: '−$0.50 (−4.1%)' }]" note="Held until 1 July 2024" />
<EcoChartTooltip inline title="September 2026" total="—"
  note="Nothing recorded for this month. Figures post after the month closes." />

<!-- In your own chart: inside chart__fig, after the svg -->
<EcoChartTooltip :open="active !== null" :anchor="{ x, y, half }" v-bind="card" @close="active = null" />
```

React (react-ecosphere):

```tsx
<EcoChartTooltip inline title="October 2026" total="$74,900" unit="total" rows={[
  { label: "Support", value: "$11,600", slot: 3 },
  { label: "Services", value: "$22,100", slot: 2 },
  { label: "Hardware", value: "$41,200", slot: 1 },
]} />
<EcoChartTooltip inline title="Week of 12 October" total="1,284" unit="requests" rows={lineRows /* key: "key" */} />
<EcoChartTooltip inline title="December 2025" rows={signedRows} />
<EcoChartTooltip inline title="From 1 November 2023" total="$11.60" unit="per unit"
  rows={[{ label: "Change", value: "−$0.50 (−4.1%)" }]} note="Held until 1 July 2024" />
<EcoChartTooltip inline title="September 2026" total="—"
  note="Nothing recorded for this month. Figures post after the month closes." />

// In your own chart: inside chart__fig, after the svg
<EcoChartTooltip open={active !== null} anchor={{ x, y, half }} {...card} onClose={() => setActive(null)} />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | — | The period: “October 2026”, “Version 3”. |
| `total / unit` | `string` | — | The headline figure and its unit. Leave out when the rows do not add up; “—” for a gap. |
| `rows` | `ChartTooltipRow[]` | — | One per series, in the order the marks sit on screen (top segment first). A row without slot is a plain figure. |
| `note` | `string` | — | One line of context: “Held until 1 July 2024”. |
| `open` | `boolean` | false | Removes hidden. |
| `anchor` | `{ x, y, half? }` | — | The mark in px relative to chart__fig: 8px right of it, else left, clamped to the frame. |
| `inline` | `boolean` | false | Render in flow, for documentation and static cards. |
| `@close` | `()` | — | Escape was pressed while the card was open. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | — | The period: “October 2026”, “Version 3”. |
| `total / unit` | `string` | — | The headline figure and its unit. Leave out when the rows do not add up; “—” for a gap. |
| `rows` | `ChartTooltipRow[]` | — | One per series, in the order the marks sit on screen (top segment first). A row without slot is a plain figure. |
| `note` | `string` | — | One line of context: “Held until 1 July 2024”. |
| `open` | `boolean` | false | Removes hidden. |
| `anchor` | `{ x, y, half? }` | — | The mark in px relative to chart__fig: 8px right of it, else left, clamped to the frame. |
| `inline` | `boolean` | false | Render in flow, for documentation and static cards. |
| `onClose` | `()` | — | Escape was pressed while the card was open. |
