Skip to content

Commit d617d04

Browse files
committed
fix: Support passing <*Chart tooltip={...}> to underlying TooltipContext (as types already indicate)
1 parent 5c14e67 commit d617d04

7 files changed

Lines changed: 15 additions & 2 deletions

File tree

.changeset/tame-lamps-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'layerchart': patch
3+
---
4+
5+
fix: Support passing `<*Chart tooltip={...}>` to underlying TooltipContext (as types already indicate)

packages/layerchart/src/lib/components/charts/ArcChart.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@
384384
]}
385385
padding={{ bottom: legend === true ? 32 : 0 }}
386386
{...restProps}
387-
tooltip={tooltip === false ? false : props.tooltip?.context}
387+
tooltip={tooltip === false
388+
? false
389+
: { ...props.tooltip?.context, ...(typeof tooltip === 'object' ? tooltip : null) }}
388390
>
389391
{#snippet children({ context })}
390392
{@const snippetProps = {

packages/layerchart/src/lib/components/charts/AreaChart.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@
447447
onclick: onTooltipClick,
448448
debug,
449449
...props.tooltip?.context,
450+
...(typeof tooltip === 'object' ? tooltip : null),
450451
}}
451452
brush={brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')
452453
? {

packages/layerchart/src/lib/components/charts/BarChart.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@
455455
onclick: onTooltipClick,
456456
debug,
457457
...props.tooltip?.context,
458+
...(typeof tooltip === 'object' ? tooltip : null),
458459
}}
459460
brush={brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')
460461
? {

packages/layerchart/src/lib/components/charts/LineChart.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@
347347
onclick: onTooltipClick,
348348
debug,
349349
...props.tooltip?.context,
350+
...(typeof tooltip === 'object' ? tooltip : null),
350351
}}
351352
brush={brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')
352353
? {

packages/layerchart/src/lib/components/charts/PieChart.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@
409409
]}
410410
padding={{ bottom: legend === true ? 32 : 0 }}
411411
{...restProps}
412-
tooltip={tooltip === false ? false : props.tooltip?.context}
412+
tooltip={tooltip === false
413+
? false
414+
: { ...props.tooltip?.context, ...(typeof tooltip === 'object' ? tooltip : null) }}
413415
>
414416
{#snippet children({ context })}
415417
{@const snippetProps = {

packages/layerchart/src/lib/components/charts/ScatterChart.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
onclick: onTooltipClick,
258258
debug,
259259
...props.tooltip?.context,
260+
...(typeof tooltip === 'object' ? tooltip : null),
260261
}}
261262
brush={brush && (brush === true || brush.mode == undefined || brush.mode === 'integrated')
262263
? {

0 commit comments

Comments
 (0)