SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

chartTooltip

Bridges a Chart.Bar, Chart.Line, Chart.Area, or Chart.Pie root to its sibling Chart.Tooltip surface.

tsx
import { chartTooltip } from "@sdxc/ui/app";

Usage

Adds pointer- and focus-tracked tooltip coordination to a Chart.Bar, Chart.Line, Chart.Area, or Chart.Pie root, resolving the active point and its group into the sibling Chart.Tooltip's rows, position, and events.

Signature

typescript
chartTooltip(): MixinDescriptor<HTMLElement>

Returns a mixin descriptor for a chart root's mix prop.

Examples

tsx
<div mix={[css({ position: "relative" })]}>
  <Chart.Bar data={points} mix={chartTooltip()} />
  <Chart.Tooltip>
    <Chart.Tooltip.Row>
      <Chart.Tooltip.Label />
      <Chart.Tooltip.Value />
    </Chart.Tooltip.Row>
  </Chart.Tooltip>
</div>

The events, constants and types its module publishes, each imported from @sdxc/ui/app too.

Event

ChartTooltipChangeEvent

Dispatched on a chart root by chartTooltip every time the active point set changes, carrying every active point's label and value so a consumer can drive a live-region announcement or cross-highlight a legend.

typescript
new ChartTooltipChangeEvent(points: readonly ChartTooltipPoint[])
PropertyTypeDefaultRequiredDescription
pointsreadonly readonly ChartTooltipPoint[]—YesEvery currently active point's label and value, in document order, or an empty array when nothing is active.
Constant

CHART_POINT_ATTRIBUTE

Attribute every plottable point a chart root renders carries: a bar's <rect>, a line or area's vertex marker, or a pie's wedge <path>. chartTooltip() reads it to build its pointer-tracked candidate set.

typescript
const CHART_POINT_ATTRIBUTE = "data-chart-point"
Constant

CHART_POINT_LABEL_ATTRIBUTE

Attribute a point carries its already-localized label on — the category, series name, or slice name a chart renders it under. chartTooltip() copies it unchanged into the matching row's CHART_TOOLTIP_LABEL_ATTRIBUTE.

typescript
const CHART_POINT_LABEL_ATTRIBUTE = "data-chart-label"
Constant

CHART_POINT_VALUE_ATTRIBUTE

Attribute a point carries its already-formatted value on, rendered through the consumer's own Intl formatting. chartTooltip() copies it unchanged into the matching row's CHART_TOOLTIP_VALUE_ATTRIBUTE slot.

typescript
const CHART_POINT_VALUE_ATTRIBUTE = "data-chart-value"
Constant

CHART_POINT_GROUP_ATTRIBUTE

Attribute an ancestor of a cluster of related points carries — every series' point for one category in a grouped bar chart. Every point beneath the nearest such ancestor populates the tooltip together, one row each.

typescript
const CHART_POINT_GROUP_ATTRIBUTE = "data-chart-group"
Constant

CHART_TOOLTIP_ATTRIBUTE

Attribute Chart.Tooltip's own root element carries. chartTooltip() finds it among its host's parent element's descendants — the sibling relationship a chart root and its Chart.Tooltip render in.

typescript
const CHART_TOOLTIP_ATTRIBUTE = "data-chart-tooltip"
Constant

CHART_TOOLTIP_ROW_ATTRIBUTE

Attribute every pre-rendered row inside Chart.Tooltip carries, one per series it could ever need to show, in document order. chartTooltip() fills as many as the active point set holds and hides the rest.

typescript
const CHART_TOOLTIP_ROW_ATTRIBUTE = "data-chart-tooltip-row"
Constant

CHART_TOOLTIP_LABEL_ATTRIBUTE

Attribute the element inside a Chart.Tooltip row that receives the active point's CHART_POINT_LABEL_ATTRIBUTE text carries.

typescript
const CHART_TOOLTIP_LABEL_ATTRIBUTE = "data-chart-tooltip-label"
Constant

CHART_TOOLTIP_VALUE_ATTRIBUTE

Attribute the element inside a Chart.Tooltip row that receives the active point's CHART_POINT_VALUE_ATTRIBUTE text carries.

typescript
const CHART_TOOLTIP_VALUE_ATTRIBUTE = "data-chart-tooltip-value"
Constant

CHART_TOOLTIP_X_PROPERTY

CSS custom property chartTooltip() writes on Chart.Tooltip's host with the active point's horizontal pixel offset, relative to the chart root's own parent element, for its own styling to read back via var().

typescript
const CHART_TOOLTIP_X_PROPERTY = "--ui-chart-tooltip-x"
Constant

CHART_TOOLTIP_Y_PROPERTY

CSS custom property chartTooltip() writes on Chart.Tooltip's host with the active point's vertical pixel offset, relative to the chart root's own parent element, read back the same way as CHART_TOOLTIP_X_PROPERTY.

typescript
const CHART_TOOLTIP_Y_PROPERTY = "--ui-chart-tooltip-y"
Interface

ChartTooltipPoint

One point's already-localized label and value text, read off CHART_POINT_LABEL_ATTRIBUTE and CHART_POINT_VALUE_ATTRIBUTE, as carried by ChartTooltipChangeEvent.

MemberTypeDefaultRequiredDescription
labelreadonly string—YesThe point's label, copied from CHART_POINT_LABEL_ATTRIBUTE unchanged.
valuereadonly string—YesThe point's value, copied from CHART_POINT_VALUE_ATTRIBUTE unchanged.
@sdxc/ui

Can’t find it? Contact us