Heatmap chart
Rows binned into cells by two keys, aggregated, and coloured by a sequential, diverging or stepped scale: a currency matrix, pair × tenor, hour × weekday, or a calendar of days. Drawn by ECharts, with a colour key that counts, marks and filters.
c2-heatmap-chart
A heatmap drawn by ECharts: rows binned into cells by two keys, aggregated, and coloured by a sequential, diverging or stepped scale. A calendar is one way to derive the keys, from a date; any two fields — currency × currency, pair × tenor, hour × weekday — are others.
<c2-heatmap-chart x-field="tenor" x-order="tenor" y-field="pair" value-field="vol" unit="%"
data='[{ "pair": "EURUSD", "tenor": "1M", "vol": 7.1 }, { "pair": "EURUSD", "tenor": "1W", "vol": 7.4 }]'>
</c2-heatmap-chart>
layout="grid"(the default) has a column perx-fieldvalue and a row pery-fieldvalue.x-binandy-binderive a key from a date instead (x-bin="hour"y-bin="weekday"reads one timestamp twice), andx-order/y-orderorder the axes: by data, naturally, by maturity (tenor), by total, or as an explicit list.group-fieldbands the rows,diagonal="hide"blanks a matrix's x = y cells andmarginalsadds total bars.layout="calendar"takesdate-fieldand draws a column per week and a row per weekday, labelled by month;weekdays="mon-fri"drops weekends, as trading days do. Days inrangewithout rows are drawn empty.layout="calendar-month"draws one month grid per month, with day numbers when there is room.
Rows that share a cell are combined by aggregate. The colour scale is the one c2-map-chart uses: scale,
domain, thresholds and scale-colors work the same way.
The legend is the colour key. By default (legend-detail="histogram") it counts the cells in each band, names
both ends (scale-poles), marks the hovered cell's value, and filters the cells: hover a band to preview it, click
to keep it, drag across a continuous scale for a range. legend-detail="simple" keeps the bar and its ticks only.
legend places the key above, below, or beside the plot (start, end), where it stands upright; legend="none" hides it.
Each line of text in the key can be hidden through its --c2-chart__scale-key-…--display variable, and
--c2-chart__axis-label--display: none leaves only the cells.
scale-filter holds the kept range and can be set by the application.
The plot is one tab stop: the arrow keys move from cell to cell, Enter fires cell-click and Escape leaves.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
layout | HeatmapLayout | grid | Where the cells go: two category axes, a column per week, or a grid per month. |
y-field | string | — | Row field holding the row key of layout="grid". The column key is x-field. |
value-field | string | — | Row field holding the value cells are coloured by. Without it, aggregate="count" counts rows. |
value-label | string | — | Names the value in the tooltip and the colour key. Defaults to the humanized value-field. |
unit | string | — | Text appended to every formatted value, such as % or bp. |
date-field | string | — | Row field holding the date of the calendar layouts. |
x-bin | HeatmapBin | '' | — | Derives the column key from a date in x-field: hour, weekday, day, week, month, quarter or year. |
y-bin | HeatmapBin | '' | — | Derives the row key from a date in y-field, as x-bin does the column key. |
x-order | HeatmapOrder | undefined | — | Column order: data (first appearance), natural or natural-desc, tenor (ON, TN, 1W … 30Y), value-asc, value-desc, or a JSON
list of keys, which also adds listed columns without rows. Defaults to natural for a binned key, data otherwise. |
y-order | HeatmapOrder | undefined | — | Row order, as x-order; x mirrors the columns, for a matrix. |
aggregate | HeatmapAggregate | sum | How the rows sharing a cell combine: sum, mean, count, min, max, first or last. |
group-field | string | — | Row field that bands the rows into labelled groups (region, desk, asset class). layout="grid" only. |
group-order | HeatmapOrder | undefined | — | Group order, as x-order. |
diagonal | 'show' | 'hide' | show | hide blanks the cells whose column and row keys are equal, as a currency cross matrix does. |
marginals | 'none' | 'top' | 'end' | 'both' | none | Bars with each column's total along the top, each row's along the end, or both. |
cell-labels | 'none' | 'auto' | 'always' | auto | Which values are written in the cells: auto where they fit, always, or none. |
range | string | — | The calendar span: a year (2026), months (2026-08/2026-10) or days (2025-10-20/2026-10-19). Days in it without
rows are drawn empty. Defaults to the data's first and last day. |
weekdays | HeatmapWeekdays | all | mon-fri drops Saturday and Sunday from the calendar layouts. |
week-start | HeatmapWeekStart | monday | The first day of the calendar's weeks. |
time-zone | HeatmapTimeZone | local | The time zone a timestamp's day and hour are read in. A plain YYYY-MM-DD date is that day in either. |
scale | 'sequential' | 'diverging' | sequential | sequential shades from light to dark; diverging runs two hues out from a neutral midpoint. |
domain | number[] | undefined | — | The values the scale's ends sit at: [min, max], or [min, mid, max] for a diverging scale. Defaults to the data's extent, symmetric around 0 when diverging. |
thresholds | number[] | undefined | — | Class breaks, such as [-50, -10, 10, 50], which turn the scale into stepped classes. A value equal to a break is in the upper class. |
scale-colors | string[] | undefined | — | One colour per class of a stepped scale, overriding the ramp. |
scale-poles | string[] | undefined | — | What the two ends of the scale mean, written under the colour key: ["loss", "gain"]. |
legend-detail | 'histogram' | 'simple' | histogram | histogram adds the distribution bars and the readout to the colour key; simple keeps the bar and its ticks. |
legend-interaction | 'filter' | 'preview' | 'none' | filter | What the colour key does: filter previews a band on hover and keeps it on click, preview only previews, none nothing. |
scale-filter | HeatmapScaleRange | null | undefined | — | The kept range, [from, to) in values with null for an open end; cells outside it are dimmed. |
renderer | 'canvas' | 'svg' | canvas | Which ECharts renderer to use. SVG prints and scales crisply; canvas is faster with many marks. |
data | ChartInput | undefined | — | The data to plot. Row objects, a bare number[], columnar [xs, ys…], or an already-normalised
frame. Compared by identity: replace the array, or bump revision after mutating it in place. |
revision | number | 0 | Bump after mutating data in place. The cheap escape hatch for a large buffer you own. |
series | ChartSeriesConfig[] | undefined | — | Series definitions, as an alternative to c2-chart-series children. Children win when both are set. |
x-field | string | — | Row field holding the x value; may be a dotted path. Defaults to the row index. |
label-field | string | — | Row field holding each row's label: the slice names of a pie, the category axis of a bar chart, and the x tick
labels of a line, area or sparkline chart (label-field="month", or "year" to print 2021 rather than 2,021). |
x-type | 'time' | 'linear' | 'category' | linear | How x values are interpreted, which decides the axis and the tooltip format. |
legend | 'none' | 'top' | 'bottom' | 'start' | 'end' | bottom | Where the legend sits, or none to hide it. Shown by default: a chart with more than one series is
unreadable without one, and a single-series chart simply renders a one-entry legend. |
legend-action | 'toggle' | 'highlight' | highlight | What clicking a legend entry does. highlight (the default) emphasises the series and dims the others, and a
second click clears the highlight, just as a click on the series in the plot does; toggle hides or shows the
series instead. A linked c2-chart-legend follows the same mode. |
highlighted | string | null | null | Key of the series drawn emphasised, the others dimmed: the series field, or a pie's slice label, or an overlap
chart's set key. Set by a legend click in highlight mode, and settable from the application in either mode. |
tooltip | 'none' | 'item' | 'axis' | axis | Whether the tooltip follows the whole x position or only the hovered datum. |
animation | 'none' | 'auto' | auto | Whether the chart animates its initial draw. ECharts uses its native shape animation and uPlot uses a
lightweight plot reveal; subsequent data updates stay immediate so a live source does not animate
every tick. Named animation rather than animate because HTMLElement.animate() is a method every
element already has, and shadowing it breaks the Web Animations API on the host. |
locale | string | undefined | — | BCP 47 locale for the axis and tooltip formatting. Defaults to the browser locale. |
loading | boolean | false | Shows the loading state instead of the plot. |
error | string | — | Shows an error message instead of the plot. |
empty-message | string | No data | Replaces the built-in "no data" text. |
max-points | number | 0 | Caps how many points a streaming chart keeps; older points fall off the front. 0 keeps everything. |
lazy-render | boolean | false | Defers loading the engine until the host first scrolls into view. |
annotations | ChartAnnotation[] | undefined | — | Markers at an x value and shaded x ranges, drawn over the plot of a cartesian chart (line, area, bar, sparkline,
scatter, bubble, candlestick) and placed by the engine's own x scale, so they follow the axes, a resize and a
zoom. x/x2 are x values: what x-field holds (epoch milliseconds on a time chart), else the row index. Each
marker is a button, reachable with Tab and named by its label and x, that fires annotation-click. The
other charts (pie, gauge, radar, pyramid, butterfly, heatmap, overlap, chord, map) ignore it. |
Slots
| Name | Description |
|---|---|
default | The series definitions: c2-chart-series elements. They render nothing themselves. |
legend | Replaces the built-in legend. The built-in one is still what legend positions. |
tooltip | Replaces the built-in tooltip body. The hovered point is available through the renderTooltip property when a function is easier than markup. |
actions | Controls pinned to the top-right of the plot area, for a range picker or an export button. |
empty | Replaces the built-in "no data" message. |
loading | Replaces the built-in message shown while loading is set. |
error | Replaces the built-in message shown when error is set. |
Events
| Name | Type | Description |
|---|---|---|
cell-hover | CustomEvent<HeatmapCellDetail | null> | Fired as the pointer or the keyboard focus moves onto a cell, and with a null detail when it leaves. Does not bubble. |
cell-click | CustomEvent<HeatmapCellDetail> | Fired when a cell is clicked, or chosen with Enter. detail.rows are the rows behind it. Does not bubble. |
scale-filter-change | CustomEvent<HeatmapScaleFilterChangeEventDetail> | Fired when the reader keeps or clears a range from the colour key. detail.range is [from, to) (an open end is null), or null once cleared. Does not bubble. |
tooltip-change | CustomEvent<ChartTooltipContext | null> | Fired with the complete tooltip model as the pointer moves, and with null when it leaves. Used by c2-chart-tooltip. |
series-toggle | CustomEvent<ChartSeriesToggleEventDetail> | Fired when a series is hidden or shown, from the legend with legend-action="toggle" or through setSeriesVisible. Does not bubble. |
series-highlight | CustomEvent<ChartSeriesHighlightEventDetail> | Fired when the reader highlights a series, from the legend or by clicking it in the plot, or clears the highlight. detail.key names it, or is null. Does not bubble. |
legend-change | CustomEvent<ChartLegendChangeEventDetail> | Fired when legend entries or visibility change. Used by c2-chart-legend. |
chart-ready | CustomEvent<{ engine: string }> | Fired after the engine has loaded and drawn for the first time. The host also matches :state(ready) from then on, which is what a test should wait on. |
chart-error | CustomEvent<{ error: unknown }> | Fired when the engine fails to load or to draw. detail.error is the underlying failure. |
range-change | CustomEvent<ChartRangeEventDetail> | Fired after the user zooms or brushes. detail.min and detail.max are the new x bounds. Does not bubble. |
point-hover | CustomEvent<ChartPointEventDetail | null> | Fired as the pointer moves between data points, and with a null detail when it leaves the plot. Does not bubble. |
annotation-click | CustomEvent<ChartAnnotationEventDetail> | Fired when an annotation's marker is clicked, or activated from the keyboard. detail.annotation is the entry and detail.index its position in annotations. Does not bubble. |
point-click | CustomEvent<ChartPointEventDetail> | Fired when a datum is clicked; the chart then highlights the clicked series (a second click on it clears the highlight). Cancelable: preventDefault() keeps the highlight as it is. Does not bubble: several components fire point events, so a listener belongs on the element itself. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
scale-key | The colour key in the built-in legend. |
scale-band | One band of a stepped colour key, a button when the key filters. |
frame | The outer flex column holding the legend and the plot area. |
plot-area | The positioned box the engine draws into. |
plot | The engine's container element. Carries no Lit bindings, so the canvas survives every update. |
overlay | The non-interactive layer above the canvas that holds the tooltip and the actions. |
tooltip | Component-owned bubble containing the tooltip slot and its generated fallback content. |
actions | The container for the actions slot. |
annotations | The layer holding the annotations, above the plot and below the tooltip. |
annotation | One annotation: the box from x to x2, or a zero-width box at x. |
annotation-range | The shaded fill of a range annotation. |
annotation-line | The rule drawn at an annotation's x. |
annotation-marker | The focusable button at the top of an annotation's rule. |
state | Shared message layer containing the empty, loading, or error slot and its fallback state. |
legend | Component-owned container wrapping the legend slot and generated legend fallback. |
legend-item | One legend entry, a toggle button. |
legend-marker | The colour swatch inside a legend entry. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-chart--width | length | 100% | Width of the host. The plot is absolutely positioned and has no intrinsic width, so a chart used as a flex item would otherwise collapse to its legend. |
--c2-chart--height | pixel | 320px | Height of the host. A canvas has no intrinsic size, so this is what gives the chart a box. |
--c2-chart--background | color | #ffffff | Background of the chart surface. |
--c2-chart--color | color | #18181b | Primary text colour. |
--c2-chart--font-family | font-family | inherit | Font family used for the chart chrome and the labels the engine draws. |
--c2-chart--font-size | font-size | 12px | Base font size. |
--c2-chart--padding | padding | 12px | Padding around the whole chart. |
--c2-chart--border-top | border | 1px solid #e4e4e7 | Top border. |
--c2-chart--border-right | border | 1px solid #e4e4e7 | Right border. |
--c2-chart--border-bottom | border | 1px solid #e4e4e7 | Bottom border. |
--c2-chart--border-left | border | 1px solid #e4e4e7 | Left border. |
--c2-chart--border-top-left-radius | border-radius | 8px | Top-left corner radius. |
--c2-chart--border-top-right-radius | border-radius | 8px | Top-right corner radius. |
--c2-chart--border-bottom-left-radius | border-radius | 8px | Bottom-left corner radius. |
--c2-chart--border-bottom-right-radius | border-radius | 8px | Bottom-right corner radius. |
--c2-chart__cell--gap | pixel | 2px | Space between two cells. |
--c2-chart__cell--border-radius | pixel | 2px | Corner radius of a cell. |
--c2-chart__cell--max-size | pixel | 24px | Largest side of a calendar cell, and half the largest width of a month grid's cell, so a short span is not drawn with huge squares. |
--c2-chart__cell__empty--background-color | color | #f4f4f5 | Fill of a cell without data: a day in the range with no rows, a pair with no quote. |
--c2-chart__cell__hover--border-color | color | #18181b | Outline of the hovered cell. |
--c2-chart__cell__focus--border-color | color | #0265dc | Outline of the cell the keyboard focus is on. |
--c2-chart__cell__dimmed--opacity | opacity | 0.15 | Opacity of the cells outside the range previewed or kept from the colour key. |
--c2-chart__cell-label--color | color | #18181b | Colour of a cell's value on a light cell. |
--c2-chart__cell-label--font-size | font-size | 11px | Font size of the values written in the cells and of a month grid's day numbers. |
--c2-chart__cell-label__inverse--color | color | #ffffff | Colour of a cell's value on a dark cell. |
--c2-chart__group--gap | pixel | 12px | Space between two row groups. |
--c2-chart__marginal--size | pixel | 40px | Depth of the band the marginal total bars are drawn in. |
--c2-chart__marginal--color | color | #a1a1aa | Colour of the marginal total bars. |
--c2-chart__scale-start--color | color | #dce8fb | Low end of a sequential scale. |
--c2-chart__scale-end--color | color | #0a3b8c | High end of a sequential scale, and positive end of a diverging one. |
--c2-chart__scale-negative--color | color | #c2410c | Negative end of a diverging scale. |
--c2-chart__scale-mid--color | color | #e4e4e7 | Neutral midpoint of a diverging scale. |
--c2-chart__axis-label--display | string | block | none draws the cells alone: no row, column, group or month labels, and no room kept for them. |
--c2-chart__scale-key-title--display | string | inline | none hides the colour key's title. |
--c2-chart__scale-key-readout--display | string | inline | none hides the line under the key's title: the count, the range, the total and the hovered cell's value. |
--c2-chart__scale-key-total--display | string | inline | none hides the total in the readout, for values that do not add up to anything meaningful. |
--c2-chart__scale-key-hint--display | string | inline | none hides the line saying how to preview and keep a band. It is always hidden beside the plot. |
--c2-chart__scale-key-poles--display | string | flex | none hides the names of the scale's two ends. |
--c2-chart__scale-key--width | length | 280px | Width of the colour key. |
--c2-chart__scale-key--height | length | 200px | Length of the colour key when it stands beside the plot (legend="start" or "end"), where it runs from bottom to top. |
--c2-chart__scale-key-histogram--height | pixel | 28px | Height of the distribution bars above the colour key, and their width beside a vertical key. |
--c2-chart__scale-key-histogram--color | color | #a1a1aa | Colour of the distribution bars. |
--c2-chart__scale-key-marker--color | color | #18181b | Colour of the hovered value's marker and of the kept range's outline on the colour key. |
--c2-chart__plot__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | Focus ring of the plot when it is reached with the keyboard. |
--c2-chart__series-1--color | color | #0265dc | Colour of the first series. |
--c2-chart__series-2--color | color | #ea580c | Colour of the second series. |
--c2-chart__series-3--color | color | #0f766e | Colour of the third series. |
--c2-chart__series-4--color | color | #db2777 | Colour of the fourth series. |
--c2-chart__series-5--color | color | #a16207 | Colour of the fifth series. |
--c2-chart__series-6--color | color | #7c3aed | Colour of the sixth series. |
--c2-chart__series-7--color | color | #0891b2 | Colour of the seventh series. |
--c2-chart__series-8--color | color | #52525b | Colour of the eighth series. Series beyond the eighth reuse the palette from the start. |
--c2-chart__axis--color | color | #71717a | Colour of the axis lines and tick labels. |
--c2-chart__axis--font-size | font-size | 12px | Font size of the tick labels. |
--c2-chart__grid--color | color | #e4e4e7 | Colour of the grid lines. |
--c2-chart__crosshair--color | color | #a1a1aa | Colour of the cursor crosshair. |
--c2-chart__crosshair--width | pixel | 1px | Width of the cursor crosshair. |
--c2-chart__surface--color | color | #ffffff | Surface colour handed to the engine, for marker borders and label backdrops. |
--c2-chart__muted--color | color | #71717a | Secondary text colour. |
--c2-chart__positive--color | color | #16a34a | Colour for a rising value, used by the candlestick chart and as the sparkline's positive tone. |
--c2-chart__negative--color | color | #dc2626 | Colour for a falling value, used by the candlestick chart and as the sparkline's negative tone. |
--c2-chart__legend--gap | pixel | 12px | Gap between legend entries. |
--c2-chart__legend--padding | padding | 8px 0 0 | Padding around the legend. |
--c2-chart__legend--color | color | #71717a | Legend text colour. |
--c2-chart__legend--font-size | font-size | 12px | Legend font size. |
--c2-chart__legend__disabled--opacity | opacity | 0.38 | Opacity of the legend entries that are not highlighted while one is, or, with legend-action="toggle", of an entry whose series is hidden. |
--c2-chart__legend-marker--size | pixel | 10px | Size of the legend colour swatch. |
--c2-chart__legend-marker--border-radius | border-radius | 999px | Corner radius of the legend colour swatch. |
--c2-chart__tooltip--background-color | color | #18181b | Tooltip background. |
--c2-chart__tooltip--color | color | #fafafa | Tooltip text colour. |
--c2-chart__tooltip--font-size | font-size | 12px | Tooltip font size. |
--c2-chart__tooltip--padding | padding | 8px 10px | Tooltip padding. |
--c2-chart__tooltip--border-radius | border-radius | 6px | Tooltip corner radius. |
--c2-chart__tooltip--box-shadow | box-shadow | 0 8px 24px rgba(24, 24, 27, 0.08) | Tooltip shadow. |
--c2-chart__tooltip--gap | pixel | 6px | Gap between tooltip rows. |
--c2-chart__annotation--color | color | #71717a | Colour of a neutral annotation (the default tone). |
--c2-chart__annotation__info--color | color | #0265dc | Colour of an info annotation. |
--c2-chart__annotation__success--color | color | #16a34a | Colour of a success annotation. |
--c2-chart__annotation__warning--color | color | #d97706 | Colour of a warning annotation. |
--c2-chart__annotation__danger--color | color | #dc2626 | Colour of a danger annotation. |
--c2-chart__annotation-range--opacity | opacity | 0.12 | Opacity of the shaded fill of a range annotation. |
--c2-chart__annotation-line--border-width | pixel | 1px | Width of an annotation's rule. |
--c2-chart__annotation-line--border-style | border-style | dashed | Style of an annotation's rule. |
--c2-chart__annotation-marker--size | pixel | 10px | Diameter of an annotation's marker. |
--c2-chart__annotation-marker--border-color | color | #ffffff | Ring drawn around a marker, so it stands out from the bars or lines behind it. |
--c2-chart__annotation-marker__focus--outline | outline | 2px solid #0265dc | Focus ring of a marker. |
--c2-chart__state--color | color | #71717a | Colour of the empty, loading and error text. |
--c2-chart__state--font-size | font-size | 14px | Font size of the empty, loading and error text. |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under heatmap-chart, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
noData | No data | — |
needsAxes | A heatmap grid needs x-field and y-field. | — |
needsDate | A calendar heatmap needs date-field. | — |
clearFilter | Clear filter | — |
cells | {0} cells | {0} count |
days | {0} days | {0} count |
ofTotal | {0} of {1} | {0} count {1} total |
range | {0} to {1} | {0} from {1} to |
below | below {0} | {0} value |
andAbove | {0} and above | {0} value |
total | total {0} | {0} value |
pastScale | some values past the scale | — |
inBand | {0} in this band | {0} count |
hintStepped | Hover a band to preview it, click to keep it | — |
hintContinuous | Hover to preview a band, click to keep it, drag for a range | — |
scaleLabel | {0} colour scale. Arrow keys pick a band, Enter keeps it, Escape clears. | {0} title |
bandLabel | {0}, {1} | {0} range {1} count |
roleDescription | heatmap | — |
rows | {0} rows | {0} count |
totalFor | Total for {0} | {0} name |
row | Row | — |
column | Column | — |
date | Date | — |
value | Value | — |
cellAnnouncement | {0}: {1} | {0} name {1} value |
c2-chart-legend
A legend linked to a chart by id. Place it anywhere in the document to control the legend's layout independently from the chart.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
for | string | — | Id of the chart this element presents. |
Slots
| Name | Description |
|---|---|
(default) | Replaces the generated legend. Use renderLegend or renderLegendItem for data-driven custom content. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
item | One interactive legend entry. |
marker | The colour swatch inside an entry. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-chart__legend--gap | pixel | 12px | Gap between legend entries. |
--c2-chart__legend--padding | padding | 0 | Padding around the legend. |
--c2-chart__legend--color | color | #71717a | Legend text colour. |
--c2-chart__legend--font-size | font-size | 12px | Legend font size. |
--c2-chart__legend__disabled--opacity | opacity | 0.38 | Opacity of a disabled entry. |
--c2-chart__legend-marker--size | pixel | 10px | Size of the colour swatch. |
--c2-chart__legend-marker--border-radius | border-radius | 999px | Radius of the colour swatch. |
c2-chart-tooltip
A tooltip linked to a chart by id. It can float beside the hovered point or render inline wherever it is placed in the document.
It is shown only while its chart has a hovered point, and says so through the custom state :state(open) rather
than by toggling hidden on itself: the host keeps exactly the attributes it was authored with, so a
server-rendered tooltip matches the hydrated one. An authored hidden still hides it.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
position | 'floating' | 'inline' | floating | Whether the tooltip follows the hovered point or occupies its authored HTML position. |
placement | 'top' | 'bottom' | 'start' | 'end' | top | Preferred side of the hovered point when position="floating". Flips at viewport edges. |
for | string | — | Id of the chart this element presents. |
Slots
| Name | Description |
|---|---|
(default) | Replaces the generated tooltip body. Use renderTooltip for data-driven custom content. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
bubble | The tooltip surface. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-chart__tooltip--background-color | color | #18181b | Tooltip background. |
--c2-chart__tooltip--color | color | #fafafa | Tooltip text colour. |
--c2-chart__tooltip--font-size | font-size | 12px | Tooltip font size. |
--c2-chart__tooltip--padding | padding | 8px 10px | Tooltip padding. |
--c2-chart__tooltip--border-radius | border-radius | 6px | Tooltip corner radius. |
--c2-chart__tooltip--box-shadow | box-shadow | 0 8px 24px rgba(24, 24, 27, 0.08) | Tooltip shadow. |
--c2-chart__tooltip--gap | pixel | 6px | Gap between tooltip rows. |
--c2-chart__legend-marker--size | pixel | 10px | Size of the colour swatch in a tooltip row. |
--c2-chart__legend-marker--border-radius | border-radius | 999px | Corner radius of a tooltip row's colour swatch. |