Skip to content

Commit

Permalink
feat: Pass visibleSeries as slot props (along with series) to ena…
Browse files Browse the repository at this point in the history
…ble filteirng custom tooltip implementations (slot override)
  • Loading branch information
techniq committed Jan 24, 2025
1 parent be7e002 commit 12a8068
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/popular-doors-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': minor
---

feat: Pass `visibleSeries` as slot props (along with `series`) to enable filteirng custom tooltip implementations (slot override)
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
padding,
tooltip,
series,
visibleSeries,
getAreaProps,
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
padding,
tooltip,
series,
visibleSeries,
getBarsProps,
}}
<slot {...slotProps}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
padding,
tooltip,
series,
visibleSeries,
getSplineProps,
}}
<slot {...slotProps}>
Expand Down
2 changes: 2 additions & 0 deletions packages/layerchart/src/lib/components/charts/PieChart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@
height,
padding,
tooltip,
series,
visibleData,
}}
<slot {...slotProps}>
<svelte:component this={renderContext === 'canvas' ? Canvas : Svg} {center}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,21 @@
let:tooltip
let:config
>
{@const slotProps = { x, xScale, y, yScale, c, cScale, width, height, padding, tooltip, series }}
{@const slotProps = {
x,
xScale,
y,
yScale,
c,
cScale,
width,
height,
padding,
tooltip,
series,
visibleSeries,
getPointsProps,
}}
{@const activeSeries = tooltip.data
? (series.find((s) => s.key === tooltip.data.seriesKey) ?? series[0])
: null}
Expand Down

0 comments on commit 12a8068

Please # to comment.