@astryxdesign/charts 0.6.2-canary.eec3a19 → 0.6.2-canary.fc74d7e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,8 +39,8 @@ export interface ChartTooltipProps {
39
39
  * Composable grouped tooltip for Chart.
40
40
  *
41
41
  * Subscribes to the chart's pointer event stream and only re-renders when the
42
- * hovered data index changes (not on every pointer move). Card position is
43
- * updated imperatively via a ref to keep pointer-move cost ~free.
42
+ * hovered data index changes (not on every pointer move). Card coordinates retain
43
+ * their previous state when the resolved point and browser geometry are unchanged.
44
44
  */
45
45
  export declare function ChartTooltip({ series, render, hoverIndicator, showHoverDots, placement, }: ChartTooltipProps): import("react").JSX.Element;
46
46
  //# sourceMappingURL=ChartTooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../src/ChartTooltip.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAaf,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAC,SAAS,EAAoB,MAAM,SAAS,CAAC;AAG1D,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC9B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,SAAS,CAAC;IAC5E;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AA2DD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,MAAW,EACX,MAAM,EACN,cAAqB,EACrB,aAAoB,EACpB,SAAkB,GACnB,EAAE,iBAAiB,+BA4QnB"}
1
+ {"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../src/ChartTooltip.tsx"],"names":[],"mappings":"AA8BA,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAYf,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAC,SAAS,EAAoB,MAAM,SAAS,CAAC;AAG1D,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC9B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,SAAS,CAAC;IAC5E;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAwDD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,MAAW,EACX,MAAM,EACN,cAAqB,EACrB,aAAoB,EACpB,SAAkB,GACnB,EAAE,iBAAiB,+BAqUnB"}
@@ -17,7 +17,11 @@
17
17
  *
18
18
  * // Composable — drop into the chart's children for full control
19
19
  * <Chart>
20
- * <ChartTooltip hoverIndicator={false} placement="top" />
20
+ * <ChartTooltip
21
+ * series={series}
22
+ * hoverIndicator={false}
23
+ * placement="top"
24
+ * />
21
25
  * </Chart>
22
26
  * ```
23
27
  */
@@ -29,13 +33,25 @@ import { createPortal } from 'react-dom';
29
33
  import * as stylex from '@stylexjs/stylex';
30
34
  import '@astryxdesign/core/theme/tokens.stylex';
31
35
  import { colorVars, radiusVars, shadowVars, spacingVars } from '@astryxdesign/core/theme/tokens.stylex';
32
- import { Text } from '@astryxdesign/core';
33
- import { VStack, HStack } from '@astryxdesign/core';
36
+ import { HStack, Text, useLayer, VStack } from '@astryxdesign/core';
34
37
  import { useChart } from "./ChartContext.js";
35
38
  import { ChartSwatch, swatchVariantForType } from "./ChartSwatch.js";
36
39
  import { deriveTooltipSeriesValues, shouldRenderHoverDot } from "./tooltip.js";
37
40
  import { isBandScale, xPixel } from "./utils.js";
38
41
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
42
+ const styles = {
43
+ card: {
44
+ kWkggS: "x1prclbq",
45
+ kaIpWk: "x1hviunn",
46
+ k8WAf4: "xce4md1",
47
+ kg3NbH: "xrrkdod",
48
+ kGVxlE: "x14hfi27",
49
+ kfzvcC: "x47corl",
50
+ khDVqt: "xuxw1ft",
51
+ $$css: true
52
+ }
53
+ };
54
+
39
55
  /** Default tooltip body — used when `render` is not provided. */
40
56
  const DefaultTooltipContent = /*#__PURE__*/memo(function DefaultTooltipContent({
41
57
  xValue,
@@ -75,8 +91,8 @@ const DefaultTooltipContent = /*#__PURE__*/memo(function DefaultTooltipContent({
75
91
  * Composable grouped tooltip for Chart.
76
92
  *
77
93
  * Subscribes to the chart's pointer event stream and only re-renders when the
78
- * hovered data index changes (not on every pointer move). Card position is
79
- * updated imperatively via a ref to keep pointer-move cost ~free.
94
+ * hovered data index changes (not on every pointer move). Card coordinates retain
95
+ * their previous state when the resolved point and browser geometry are unchanged.
80
96
  */
81
97
  export function ChartTooltip({
82
98
  series = [],
@@ -97,20 +113,44 @@ export function ChartTooltip({
97
113
  height
98
114
  } = useChart();
99
115
  const [hoveredIndex, setHoveredIndex] = useState(null);
116
+ const [cardPosition, setCardPosition] = useState({
117
+ x: 0,
118
+ y: 0
119
+ });
120
+ const [portalTarget, setPortalTarget] = useState(null);
100
121
  const cardRef = useRef(null);
122
+ const lastPointerEventRef = useRef(null);
123
+ const {
124
+ hide: hideLayer,
125
+ isOpen: isLayerOpen,
126
+ render: renderLayer,
127
+ show: showLayer
128
+ } = useLayer({
129
+ mode: 'fixed'
130
+ });
101
131
  // Whether the card is currently suppressed (no content, or a custom `render`
102
- // opted out by returning null). positionCard reads this so a same-index
103
- // pointer move — which repositions the card without a React commit — can't
104
- // re-reveal a card the visibility effect below has hidden.
105
- const cardHiddenRef = useRef(false);
132
+ // opted out by returning null). Start closed; once present content opens the
133
+ // Layer, a content-bearing index change keeps it open while React swaps the
134
+ // content. positionCard also reads this so a same-index pointer move cannot
135
+ // re-reveal a suppressed card before the visibility effect confirms content.
136
+ const cardHiddenRef = useRef(true);
137
+
138
+ // The Layer host must remain in the chart's nearest HTML subtree so nested
139
+ // Theme and MediaTheme scopes keep applying. The portal crosses only the SVG
140
+ // boundary; browser top-layer promotion remains Layer's responsibility.
141
+ useEffect(() => {
142
+ const nextTarget = svgRef.current?.parentElement ?? null;
143
+ setPortalTarget(current => current === nextTarget ? current : nextTarget);
144
+ }, [svgRef, width]);
106
145
 
107
146
  // Stable Set of resolved series keys — used by deriveTooltipSeriesValues.
108
147
  // Recomputed only when the resolved map identity changes (per layout pass).
109
148
  const resolvedKeys = useMemo(() => new Set(resolved.keys()), [resolved]);
110
149
 
111
150
  // ─── Card positioning ──────────────────────────────────────────────────
112
- // Imperative — the card is portaled, and we don't want pointer-move to
113
- // trigger React renders.
151
+ // Layer owns top-layer promotion. Pointer moves update coordinates only when
152
+ // the hovered point or browser geometry changes, so moves within one point do
153
+ // not force a React commit.
114
154
  const positionCard = useCallback(e => {
115
155
  const card = cardRef.current;
116
156
  const svg = svgRef.current;
@@ -118,14 +158,19 @@ export function ChartTooltip({
118
158
  return;
119
159
  }
120
160
  if (!svg || !e.nearest || cardHiddenRef.current) {
121
- card.style.display = 'none';
161
+ hideLayer();
162
+ return;
163
+ }
164
+ showLayer();
165
+ const layerHost = card.parentElement;
166
+ if (!layerHost) {
122
167
  return;
123
168
  }
124
169
  const svgRect = svg.getBoundingClientRect();
125
170
  const screenX = svgRect.left + margin.left + e.nearest.px;
126
171
  const screenY = svgRect.top + margin.top;
127
- const cardWidth = card.offsetWidth;
128
- const cardHeight = card.offsetHeight;
172
+ const cardWidth = layerHost.offsetWidth;
173
+ const cardHeight = layerHost.offsetHeight;
129
174
  const viewportWidth = window.innerWidth;
130
175
  const viewportHeight = window.innerHeight;
131
176
  const gap = 8;
@@ -150,27 +195,31 @@ export function ChartTooltip({
150
195
  }
151
196
  }
152
197
 
153
- // Clamp to the viewport so the card never clips off-screen — it's
154
- // portaled and position:fixed, so this keeps it fully visible for every
155
- // placement (pinned placements and the near-edge `auto` flip alike).
198
+ // Clamp the card coordinates to the viewport. Oversized custom content
199
+ // keeps its caller-owned dimensions and may extend past the far edge.
156
200
  x = Math.max(gap, Math.min(x, viewportWidth - cardWidth - gap));
157
201
  y = Math.max(gap, Math.min(y, viewportHeight - cardHeight - gap));
158
- card.style.left = `${x}px`;
159
- card.style.top = `${y}px`;
160
- card.style.display = 'block';
161
- }, [svgRef, margin, placement]);
202
+ setCardPosition(current => current.x === x && current.y === y ? current : {
203
+ x,
204
+ y
205
+ });
206
+ }, [svgRef, margin, placement, hideLayer, showLayer]);
162
207
 
163
208
  // ─── Subscribe to pointer events ───────────────────────────────────────
164
209
  useEffect(() => {
165
210
  let currentIndex = null;
166
211
  const unsub = onPointer(e => {
212
+ lastPointerEventRef.current = e;
167
213
  const newIndex = e.nearest?.dataIndex ?? null;
168
214
  if (newIndex !== currentIndex) {
169
215
  currentIndex = newIndex;
170
- // Optimistically treat the new index as showable; the visibility effect
171
- // re-hides it after commit if there's no content (e.g. custom `render`
172
- // returned null). This keeps the card appearing on the first move.
173
- cardHiddenRef.current = false;
216
+ // Keep a closed/suppressed card closed until React resolves content.
217
+ // Do not preemptively close an already-visible card for another index:
218
+ // the visibility effect closes absent content after commit, while
219
+ // content-bearing transitions keep the same Layer continuously open.
220
+ if (newIndex == null) {
221
+ cardHiddenRef.current = true;
222
+ }
174
223
  setHoveredIndex(newIndex);
175
224
  }
176
225
  positionCard(e);
@@ -269,24 +318,31 @@ export function ChartTooltip({
269
318
  });
270
319
  }, [hoverIndicator, hoveredIndex, series, xScale, data, xKey, width, height, margin.top]);
271
320
 
272
- // Single source of truth for whether the card has anything to show. It's
273
- // hidden when there's no hover, when the hovered index is stale/out-of-range
274
- // (e.g. `data` shrank while hovering, so `datum` is undefined), or when a
275
- // custom `render` opts out by returning null — the documented contract, which
276
- // still shows the band highlight + dots. The decision is stored in a ref so
277
- // the imperative positionCard honors it on subsequent same-index moves
278
- // (otherwise it would re-reveal an empty bordered box). Runs after commit, so
279
- // `render` (which may return null, or throw) never executes on the SSR path.
321
+ // Render props are ordinary React content. Resolve them once per commit so a
322
+ // custom renderer is not invoked separately by the visibility synchronizer.
323
+ // Keep it browser-only: the layer has no portal target during SSR.
324
+ const cardContent = typeof document === 'undefined' || hoveredIndex == null || datum == null ? null : render ? render(xValue, seriesValues) : /*#__PURE__*/_jsx(DefaultTooltipContent, {
325
+ xValue: xValue,
326
+ rows: seriesValues
327
+ });
328
+ const isCardHidden = hoveredIndex == null || datum == null || render != null && cardContent == null;
329
+ const hasNativePopover = typeof HTMLElement !== 'undefined' && typeof HTMLElement.prototype.showPopover === 'function';
330
+ const shouldHideLayerHost = isCardHidden || !hasNativePopover && !isLayerOpen;
331
+
332
+ // Synchronize the shared Layer's native Popover state after React commits the
333
+ // new card body. The second positioning pass measures that final body; later
334
+ // moves within the same data point usually resolve to the existing state.
280
335
  useEffect(() => {
281
- const hidden = hoveredIndex == null || datum == null || render != null && render(xValue, seriesValues) == null;
282
- cardHiddenRef.current = hidden;
283
- if (hidden) {
284
- const card = cardRef.current;
285
- if (card) {
286
- card.style.display = 'none';
287
- }
336
+ cardHiddenRef.current = isCardHidden;
337
+ if (isCardHidden) {
338
+ hideLayer();
339
+ return;
340
+ }
341
+ const pointerEvent = lastPointerEventRef.current;
342
+ if (pointerEvent) {
343
+ positionCard(pointerEvent);
288
344
  }
289
- }, [render, hoveredIndex, datum, xValue, seriesValues]);
345
+ }, [isCardHidden, hoveredIndex, xValue, seriesValues, render, hideLayer, positionCard]);
290
346
 
291
347
  // ─── Render ────────────────────────────────────────────────────────────
292
348
  if (typeof document === 'undefined') {
@@ -295,22 +351,21 @@ export function ChartTooltip({
295
351
  children: [hoverIndicatorElement, dots]
296
352
  });
297
353
  }
298
-
299
- // Mirrors the visibility effect's first two conditions: no card when there's
300
- // no hover or the hovered datum is stale/out-of-range (so `render` and the
301
- // default body are never called with an undefined x-value + empty rows).
302
- const cardContent = hoveredIndex == null || datum == null ? null : render ? render(xValue, seriesValues) : /*#__PURE__*/_jsx(DefaultTooltipContent, {
303
- xValue: xValue,
304
- rows: seriesValues
305
- });
306
354
  return /*#__PURE__*/_jsxs(_Fragment, {
307
- children: [hoverIndicatorElement, dots, /*#__PURE__*/createPortal(/*#__PURE__*/_jsx("div", {
355
+ children: [hoverIndicatorElement, dots, portalTarget ? /*#__PURE__*/createPortal(renderLayer(/*#__PURE__*/_jsx("div", {
308
356
  ref: cardRef,
309
357
  role: "tooltip",
310
- ...{
311
- className: "xixxii4 x1prclbq x1hviunn xce4md1 xrrkdod x14hfi27 x47corl xuxw1ft x1q2oy4v x1s85apg"
312
- },
313
358
  children: cardContent
314
- }), document.body)]
359
+ }), {
360
+ x: cardPosition.x,
361
+ y: cardPosition.y,
362
+ // Native Popover keeps a closed host out of layout itself, so
363
+ // remove our guard before showPopover() measures it. Layer's
364
+ // reduced fallback needs the explicit closed display state.
365
+ style: shouldHideLayerHost ? {
366
+ display: 'none'
367
+ } : undefined,
368
+ xstyle: styles.card
369
+ }), portalTarget) : null]
315
370
  });
316
371
  }
package/dist/charts.css CHANGED
@@ -14,15 +14,12 @@
14
14
  .x1prclbq:not(#\#):not(#\#){background-color:var(--color-background-popover)}
15
15
  .xl8spv7:not(#\#):not(#\#){background-color:var(--x-backgroundColor)}
16
16
  .x14hfi27:not(#\#):not(#\#){box-shadow:var(--shadow-med)}
17
- .x1s85apg:not(#\#):not(#\#){display:none}
18
17
  .x2lah0s:not(#\#):not(#\#){flex-shrink:0}
19
18
  .x47corl:not(#\#):not(#\#){pointer-events:none}
20
- .xixxii4:not(#\#):not(#\#){position:fixed}
21
19
  .xnpr05h:not(#\#):not(#\#){stroke-width:1}
22
20
  .x113i6qz:not(#\#):not(#\#){stroke:var(--color-border-emphasized)}
23
21
  .x1lo1t26:not(#\#):not(#\#){stroke:var(--color-text-primary)}
24
22
  .xuxw1ft:not(#\#):not(#\#){white-space:nowrap}
25
- .x1q2oy4v:not(#\#):not(#\#){z-index:9999}
26
23
  .xuoj239:not(#\#):not(#\#):not(#\#){height:3px}
27
24
  .xdk7pt:not(#\#):not(#\#):not(#\#){height:8px}
28
25
  .xwh1t77:not(#\#):not(#\#):not(#\#){margin-bottom:var(--spacing-4)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/charts",
3
- "version": "0.6.2-canary.eec3a19",
3
+ "version": "0.6.2-canary.fc74d7e",
4
4
  "description": "Astryx charts — a config-model data visualization library (d3-based). Published to npm only under the @canary dist-tag for early testing; never released as a stable (latest) version.",
5
5
  "author": "Meta Open Source",
6
6
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@stylexjs/stylex": ">=0.10.0",
50
- "@astryxdesign/core": "0.6.2-canary.eec3a19",
50
+ "@astryxdesign/core": "0.6.2-canary.fc74d7e",
51
51
  "react": ">=19.0.0",
52
52
  "react-dom": ">=19.0.0"
53
53
  },
@@ -57,7 +57,7 @@
57
57
  "d3-shape": "^3.2.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@astryxdesign/cli": "0.6.2-canary.eec3a19",
60
+ "@astryxdesign/cli": "0.6.2-canary.fc74d7e",
61
61
  "@babel/cli": "^7.29.7",
62
62
  "@babel/core": "^7.29.7",
63
63
  "@babel/preset-react": "^7.29.7",
@@ -0,0 +1,167 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */
4
+
5
+ export const docs = {
6
+ name: 'ChartTooltip',
7
+ displayName: 'Chart Tooltip',
8
+ group: 'Charts',
9
+ category: 'Data Visualization',
10
+ isHiddenFromOverview: true,
11
+ keywords: [
12
+ 'chart',
13
+ 'tooltip',
14
+ 'hover',
15
+ 'series',
16
+ 'crosshair',
17
+ 'data visualization',
18
+ ],
19
+
20
+ usage: {
21
+ description:
22
+ 'ChartTooltip shows grouped values for the chart position nearest the pointer. Use Chart’s tooltip prop or its configuration object for the standard integration; direct composition remains available when you need explicit child composition.',
23
+ bestPractices: [
24
+ {
25
+ guidance: true,
26
+ description:
27
+ 'Treat tooltip content as supplemental pointer detail. Give the parent Chart an accessible name and preserve its equivalent data table or another complete data view.',
28
+ },
29
+ {
30
+ guidance: true,
31
+ description:
32
+ 'When composing ChartTooltip directly, pass the same series definitions used by Chart so rows, swatches, and hover dots stay aligned with the plotted marks.',
33
+ },
34
+ {
35
+ guidance: false,
36
+ description:
37
+ 'Put information required to understand the chart only in the tooltip. The current interaction is pointer-driven and does not establish a focus trigger or aria-describedby relationship.',
38
+ },
39
+ {
40
+ guidance: false,
41
+ description:
42
+ 'Render interactive controls inside the custom tooltip body. The surface is presentational and does not accept pointer input.',
43
+ },
44
+ ],
45
+ accessibility: [
46
+ {
47
+ name: 'Supplemental detail',
48
+ category: 'Content',
49
+ criterion: '1.1.1 Non-text Content',
50
+ requirement: 'Required on the parent Chart',
51
+ states: ['All'],
52
+ description:
53
+ 'The tooltip supplements the parent Chart. It does not replace the Chart accessible name, hidden data table, summary, or another equivalent data view.',
54
+ },
55
+ {
56
+ name: 'Tooltip semantics',
57
+ category: 'Semantics',
58
+ criterion: '1.3.1 Info and Relationships',
59
+ requirement: 'Built in with a documented limitation',
60
+ states: ['Hovered'],
61
+ description:
62
+ 'The visible card uses role tooltip. Chart does not currently expose a focusable data-point trigger or an aria-describedby relationship, so required information must remain available outside this pointer-only surface.',
63
+ },
64
+ ],
65
+ anatomy: [
66
+ {
67
+ name: 'Layer host',
68
+ required: true,
69
+ description:
70
+ 'Layer host mounted under the chart’s nearest HTML container so nested Theme and MediaTheme scopes remain inherited. It uses the browser top layer when the Popover API is available and otherwise keeps the card visible through Layer’s reduced fallback.',
71
+ },
72
+ {
73
+ name: 'Tooltip card',
74
+ required: true,
75
+ description:
76
+ 'Non-interactive surface containing the current x value and series values.',
77
+ },
78
+ {
79
+ name: 'Series row',
80
+ required: false,
81
+ description:
82
+ 'For multi-series charts, a decorative swatch, visible label, and value.',
83
+ },
84
+ {
85
+ name: 'Hover indicator',
86
+ required: false,
87
+ description:
88
+ 'Band highlight for bar series on a band scale, or a vertical crosshair otherwise.',
89
+ },
90
+ {
91
+ name: 'Hover dot',
92
+ required: false,
93
+ description:
94
+ 'Point marker for each eligible non-bar series at the hovered data index.',
95
+ },
96
+ ],
97
+ },
98
+
99
+ props: [
100
+ {
101
+ name: 'series',
102
+ type: 'readonly SeriesDef[]',
103
+ description:
104
+ 'Series definitions used to derive tooltip rows and hover dots. Chart supplies this automatically through its tooltip prop; direct composition should pass the same array used by Chart.',
105
+ default: '[]',
106
+ },
107
+ {
108
+ name: 'render',
109
+ type: '(xValue: unknown, seriesValues: TooltipSeriesValue[]) => ReactNode',
110
+ description:
111
+ 'Replaces the default card body. Return null to hide the card while preserving enabled hover indicators and dots.',
112
+ default: 'Default grouped value content',
113
+ },
114
+ {
115
+ name: 'hoverIndicator',
116
+ type: 'boolean',
117
+ description:
118
+ 'Shows a band highlight for bar series on a band scale, or a vertical crosshair for other series.',
119
+ default: 'true',
120
+ },
121
+ {
122
+ name: 'showHoverDots',
123
+ type: 'boolean',
124
+ description:
125
+ 'Shows a point marker for each eligible non-bar series at the hovered index.',
126
+ default: 'true',
127
+ },
128
+ {
129
+ name: 'placement',
130
+ type: "'auto' | 'right' | 'left' | 'top'",
131
+ description:
132
+ 'Selects one of the shipped placement algorithms. The current implementation positions from the hovered x coordinate and the plot top; whether placement should instead be point-relative on both axes remains unresolved. Custom renderers own their content sizing.',
133
+ default: "'auto'",
134
+ },
135
+ ],
136
+
137
+ examples: [
138
+ {
139
+ label: 'Generated chart tooltip',
140
+ code: `import {Chart, bar, line} from '@astryxdesign/charts';
141
+
142
+ <Chart
143
+ data={monthlyRevenue}
144
+ xKey="month"
145
+ series={[
146
+ bar('revenue', {label: 'Revenue'}),
147
+ line('forecast', {label: 'Forecast'}),
148
+ ]}
149
+ tooltip
150
+ />;`,
151
+ },
152
+ {
153
+ label: 'Direct composition',
154
+ code: `import {Chart, ChartTooltip, line} from '@astryxdesign/charts';
155
+
156
+ const series = [line('revenue', {label: 'Revenue'})];
157
+
158
+ <Chart data={monthlyRevenue} xKey="month" series={series}>
159
+ <ChartTooltip
160
+ series={series}
161
+ placement="top"
162
+ showHoverDots={false}
163
+ />
164
+ </Chart>;`,
165
+ },
166
+ ],
167
+ };