Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
31e28ad
BrushState WIP
techniq Jun 21, 2025
c7add51
Merge branch 'next' into brush-state
techniq Jul 14, 2025
9141f25
Merge branch 'next' into brush-state
techniq Jul 14, 2025
d8486dd
Merge branch 'next' into brush-state
techniq Sep 11, 2025
d394745
Add missing import after merge
techniq Sep 11, 2025
c19464c
Fix some svelte/type checks
techniq Sep 11, 2025
d9c45a4
Update @layerstack/utils with improved clamp() types. Fix remaining …
techniq Sep 12, 2025
53797b4
Merge branch 'next' into brush-state
techniq Sep 28, 2025
d91841b
fix merge
techniq Sep 28, 2025
9fc08f0
Move BrushState to $lib/states
techniq Sep 29, 2025
cb20ec2
Fix CI
techniq Sep 29, 2025
b9de0f7
Fix CI
techniq Sep 29, 2025
bbd11b6
Move Chart state into ChartState
techniq Oct 19, 2025
2130761
Refactor chart context to use ChartState instead of ChartContextValue…
techniq Oct 19, 2025
4e0b0de
Fix prop reactivity (brushing, etc)
techniq Oct 19, 2025
3e320ec
Cleanup
techniq Oct 19, 2025
c858e18
More cleanup
techniq Oct 19, 2025
52da3c7
Merge branch 'docs-v2' into state-refactor
techniq Oct 19, 2025
3ec5992
Extract GeoState from GeoContext component
techniq Oct 19, 2025
dd6594c
Merge branch 'docs-v2' into state-refactor
techniq Oct 19, 2025
aeabf39
Merge branch 'docs-v2' into state-refactor
techniq Oct 20, 2025
5ac9391
Fix import
techniq Oct 20, 2025
7368208
Merge branch 'docs-v2' into state-refactor
techniq Oct 20, 2025
3d8ec93
Merge branch 'docs-v2' into state-refactor
techniq Oct 21, 2025
a0cccf8
Merge branch 'docs-v2' into state-refactor
techniq Oct 22, 2025
a8b82b1
Merge branch 'docs-v2' into state-refactor
techniq Oct 23, 2025
f574beb
Merge branch 'brush-state' into state-refactor
techniq Oct 23, 2025
6a1d0ff
Merge branch 'docs-v2' into state-refactor
techniq Oct 23, 2025
3cf8406
Merge branch 'docs-v2' into state-refactor
techniq Oct 27, 2025
9a863be
Update .gitignore
techniq Nov 13, 2025
45f06e2
Merge branch 'docs-v2' into state-refactor
techniq Nov 13, 2025
d74ff78
Fix type
techniq Nov 13, 2025
573dc8f
Merge branch 'docs-v2' into state-refactor
techniq Nov 14, 2025
e82a674
Merge branch 'docs-v2' into state-refactor
techniq Nov 28, 2025
3fe2d48
Extract TransformState from TransformContext component
techniq Nov 28, 2025
8b6756b
Update brush examples
techniq Nov 28, 2025
3c7f3fb
Merge branch 'docs-v2' into state-refactor
techniq Nov 30, 2025
d890d46
Format
techniq Nov 30, 2025
65b11b1
Begin to expose SeriesState on chart context. Simplify highlightKey
techniq Dec 1, 2025
84a5966
Replace usage of `getGeoContext` with `getChartContext` and use `ctx.…
techniq Dec 1, 2025
525792d
Update examples to use `context.series`
techniq Dec 2, 2025
1328c15
Update missed example
techniq Dec 2, 2025
51394e8
Update ChartAnnotations to use context.series directly
techniq Dec 2, 2025
70c351c
Rename GeoContext component to GeoProjection and consolidate state lo…
techniq Dec 2, 2025
ca785a0
Rename `<TransformContext bind:transformContext>` to `<TransformConte…
techniq Dec 2, 2025
3614f4e
Rename `<BrushContext bind:brushContext>` to `<BrushContext bind:stat…
techniq Dec 2, 2025
45aee8d
Remove Svelte `Context` (getBrushContext / setBrushContext) within Br…
techniq Dec 2, 2025
60eb7eb
Update GeoContext => GeoProjection docs
techniq Dec 2, 2025
dde788c
Extract `TooltipState` from `TooltipContext`. Rename `TooltipContext…
techniq Dec 2, 2025
12bf13a
Remove `getTooltipContext` / `setTooltipContext` (use `getChartContex…
techniq Dec 2, 2025
7a2b247
Remove export for removed tooltip context
techniq Dec 2, 2025
327571e
format
techniq Dec 2, 2025
88b22ea
Remove `getTransformContext` / `setTransformContext` (use `getChartCo…
techniq Dec 2, 2025
86fa5fd
Rough in some state docs
techniq Dec 2, 2025
a1f3792
Remove outdated GeoContext reference
techniq Dec 2, 2025
0d6e1ab
Cleanup `setTransformContext`
techniq Dec 2, 2025
a3b91db
Merge branch 'docs-v2' into state-refactor
techniq Dec 5, 2025
d174665
Merge branch 'docs-v2' into state-refactor
techniq Dec 7, 2025
0b03cc1
Begin to add data guide
techniq Dec 7, 2025
a5094cb
Merge branch 'docs-v2' into state-refactor
techniq Dec 7, 2025
c8304db
separate TODOs
techniq Dec 7, 2025
66b319d
Merge branch 'docs-v2' into state-refactor
techniq Dec 7, 2025
0738446
Merge branch 'docs-v2' into state-refactor
techniq Dec 7, 2025
a112c84
Merge branch 'docs-v2' into state-refactor
techniq Dec 7, 2025
3ad3fcc
Merge branch 'docs-v2' into state-refactor
techniq Dec 8, 2025
9a852d9
Merge branch 'docs-v2' into state-refactor
techniq Dec 16, 2025
4a89104
Pass `orientation` to `<Chart>` (exposed on ChartState/context along …
techniq Dec 18, 2025
b0722ff
Begin moving logic from LineChart into Chart/ChartChildren/Spline com…
techniq Dec 18, 2025
26bd385
Merge branch 'docs-v2' into state-refactor
techniq Dec 18, 2025
555d4ec
More LineChart => Chart functionality
techniq Dec 20, 2025
34b3e6c
Merge branch 'docs-v2' into state-refactor
techniq Dec 21, 2025
41b0fea
breaking(Arc|Pie|Calendar|GeoPath): Rename `tooltipContext` to simple…
techniq Dec 22, 2025
67569d0
Fix tooltip prop
techniq Dec 22, 2025
05035cb
breaking(Chart): Rename `tooltip` prop to `tooltipContext` to better …
techniq Dec 22, 2025
da0119c
Merge branch 'docs-v2' into state-refactor
techniq Dec 22, 2025
2a6d483
Pass `tooltip` snippet from LineChart to Chart/ChartChildren
techniq Dec 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pretty-roses-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

breaking(Chart): Rename `tooltip` prop to `tooltipContext` to better describe purpose and fix conflict with new `tooltip` snippet
5 changes: 5 additions & 0 deletions .changeset/silver-baboons-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

breaking(Arc|Pie|Calendar|GeoPath): Rename `tooltipContext` to simple `tooltip` (boolean), simplifying use case
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ order: 1
import Example from '$lib/components/Example.svelte';
</script>

> Geographic projections / state are integrated into `<Chart geo={...}>` but `GeoProjection` can be used to provide a secondary projection / context, such as for a translucent globe effect

## Playground

<Example name="projection-playground" />
4 changes: 2 additions & 2 deletions docs/src/examples/components/ArcChart/series-labels.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
cornerRadius={10}
height={180}
>
{#snippet arc({ props, seriesIndex, visibleSeries })}
{#snippet arc({ context, props, seriesIndex })}
<Arc {...props}>
{#snippet children({ getArcTextProps })}
<Text
{...getArcTextProps('middle')}
value={visibleSeries[seriesIndex].key}
value={context.series.visibleSeries[seriesIndex].key}
class="fill-black pointer-events-none"
font-size="12px"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
padding={{ ...defaultChartPadding(), right: 10 }}
height={300}
>
{#snippet marks({ series, context })}
{#each series as s}
{#snippet marks({ context })}
{#each context.series.series as s}
{@const activeSeries =
context.tooltip?.data == null || context.tooltip?.data?.fruit === s.key}

Expand All @@ -61,13 +61,17 @@
{/each}
{/snippet}

{#snippet highlight({ series, context })}
{@const activeSeries = series.find((s) => s.key === context.tooltip?.data?.fruit)}
{#snippet highlight({ context })}
{@const activeSeries = context.series.series.find(
(s) => s.key === context.tooltip?.data?.fruit
)}
<Highlight lines points={{ fill: activeSeries?.color }} />
{/snippet}

{#snippet tooltip({ series, context })}
{@const activeSeries = series.find((s) => s.key === context.tooltip?.data?.fruit)}
{#snippet tooltip({ context })}
{@const activeSeries = context.series.series.find(
(s) => s.key === context.tooltip?.data?.fruit
)}
<Tooltip.Root>
{#snippet children({ data })}
<Tooltip.Header>{format(context.x(data))}</Tooltip.Header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
padding={{ ...defaultChartPadding(), right: 10 }}
height={300}
>
{#snippet marks({ series, getAreaProps })}
{#each series as s, i (s.key)}
{#snippet marks({ context, getAreaProps })}
{#each context.series.series as s, i (s.key)}
<!-- Can also use basic 'transparent' for second stop for better browser compatibility -->
<LinearGradient
stops={s.color
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/components/BarChart/gradient.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</script>

<BarChart {data} x="date" y="value" height={300}>
{#snippet marks({ series, getBarsProps })}
{#each series as s, i (s.key)}
{#snippet marks({ context, getBarsProps })}
{#each context.series.series as s, i (s.key)}
<LinearGradient class="from-blue-500 to-green-400" vertical units="userSpaceOnUse">
{#snippet children({ gradient })}
<Bars {...getBarsProps(s, i)} fill={gradient} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
height={300}
>
<!-- Workaround until x1Scale is directly handled by Points/Labels: https://github.com/techniq/layerchart/issues/473#issuecomment-3266370636 -->
{#snippet aboveMarks({ context, visibleSeries })}
{#each visibleSeries as s}
{#snippet aboveMarks({ context })}
{#each context.series.visibleSeries as s}
{#each wideData as d}
{@const valueAccessor = accessor(s.key)}
{@const value = valueAccessor(d)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
]}
height={600}
>
{#snippet tooltip({ series, context })}
{#snippet tooltip({ context })}
<Tooltip.Root>
{#snippet children({ data })}
<Tooltip.Header>Age: {format(context.y(data))}</Tooltip.Header>
<Tooltip.List>
{#each series as s}
{#each context.series.series as s}
{@const valueAccessor = accessor(s.value ?? s.key)}
{@const value = Math.abs(valueAccessor(data))}
<Tooltip.Item label={s.key} color={s.color}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
<Layer>
<Area line={{ class: 'stroke-2 stroke-primary' }} class="fill-primary/20" />

{#if context.brush.isActive}
{#if context.brush.active}
<Text
x={-4}
y={context.height / 2}
value={format(context.brush.xDomain?.[0] as any)}
value={format(context.brush.x?.[0] as any)}
textAnchor="end"
verticalAnchor="middle"
class="text-xs"
/>
<Text
x={context.width + 4}
y={context.height / 2}
value={format(context.brush.xDomain?.[1] as any)}
value={format(context.brush.x?.[1] as any)}
verticalAnchor="middle"
class="text-xs"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Layer>
<Area line={{ class: 'stroke-2 stroke-primary' }} class="fill-primary/20" />

{#if context.brush.isActive}
{#if context.brush.active}
<rect
x={context.brush.range.x}
width={context.brush.handleSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
{#snippet children({ context })}
<Layer>
<Area line={{ class: 'stroke-2 stroke-primary' }} class="fill-primary/20" />
{#if context.brush.isActive}
{#if context.brush.active}
<Text
x={context.brush.range.x - 4}
y={context.brush.range.height / 2}
value={format(context.brush.xDomain?.[0] as any)}
value={format(context.brush.x?.[0] as any)}
textAnchor="end"
verticalAnchor="middle"
class="text-xs"
/>
<Text
x={context.brush.range.x + context.brush.range.width + 4}
y={context.brush.range.height / 2}
value={format(context.brush.xDomain?.[1] as any)}
value={format(context.brush.x?.[1] as any)}
verticalAnchor="middle"
class="text-xs"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
axis: 'both',
resetOnEnd: true,
onBrushEnd: (e) => {
xDomain = e.xDomain;
yDomain = e.yDomain;
xDomain = e.brush.x;
yDomain = e.brush.y;
}
}}
height={300}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
brush={{
resetOnEnd: true,
onBrushEnd: (e) => {
xDomain = e.xDomain;
xDomain = e.brush.x;
}
}}
height={300}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
axis: 'y',
resetOnEnd: true,
onBrushEnd: (e) => {
yDomain = e.yDomain;
yDomain = e.brush.y;
}
}}
height={300}
Expand Down
12 changes: 6 additions & 6 deletions docs/src/examples/components/BrushContext/minimap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
axis: 'both',
resetOnEnd: true,
onBrushEnd: (e) => {
xDomain = e.xDomain;
yDomain = e.yDomain;
xDomain = e.brush.x;
yDomain = e.brush.y;
}
}}
height={400}
Expand All @@ -50,11 +50,11 @@
brush={{
axis: 'both',
mode: 'separated',
xDomain: xDomain,
yDomain: yDomain,
x: xDomain as any,
y: yDomain as any,
onChange: (e) => {
xDomain = e.xDomain;
yDomain = e.yDomain;
xDomain = e.brush.x;
yDomain = e.brush.y;
}
}}
>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/components/BrushContext/selection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
brush={{
axis: 'both',
onChange: (e) => {
xDomain = e.xDomain;
yDomain = e.yDomain;
xDomain = e.brush.x;
yDomain = e.brush.y;
}
}}
height={400}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
padding={{ left: 16 }}
brush={{
onChange: (e) => {
xDomain = e.xDomain;
xDomain = e.brush.x;
}
}}
height={40}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
brush={{
axis: 'y',
onChange: (e) => {
yDomain = e.yDomain;
yDomain = e.brush.y;
}
}}
height={300}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
padding={{ left: 16 }}
brush={{
onChange: (e) => {
xDomain = e.xDomain;
xDomain = e.brush.x;
}
}}
height={40}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
padding={{ left: 16 }}
brush={{
mode: 'separated',
xDomain,
onChange: (e) => (xDomain = e.xDomain),
x: xDomain as any,
onChange: (e) => (xDomain = e.brush.x),
onReset: (e) => (xDomain = null)
}}
height={20}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
brush={{
resetOnEnd: true,
onBrushEnd: (e) => {
xDomain = e.xDomain;
xDomain = e.brush.x;
}
}}
height={300}
Expand Down
28 changes: 13 additions & 15 deletions docs/src/examples/components/Calendar/90-days.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@
padding={{ top: 20, bottom: 20 }}
height={200}
>
{#snippet children({ context })}
<Layer>
<Calendar start={ninetyDaysAgo} end={now} tooltipContext={context.tooltip} monthPath />
</Layer>
<Layer>
<Calendar start={ninetyDaysAgo} end={now} tooltip monthPath />
</Layer>

<Tooltip.Root>
{#snippet children({ data })}
<Tooltip.Header value={data.date} format="day" />
<Tooltip.Root>
{#snippet children({ data })}
<Tooltip.Header value={data.date} format="day" />

{#if data.value != null}
<Tooltip.List>
<Tooltip.Item label="value" value={data.value} format="integer" valueAlign="right" />
</Tooltip.List>
{/if}
{/snippet}
</Tooltip.Root>
{/snippet}
{#if data.value != null}
<Tooltip.List>
<Tooltip.Item label="value" value={data.value} format="integer" valueAlign="right" />
</Tooltip.List>
{/if}
{/snippet}
</Tooltip.Root>
</Chart>
34 changes: 13 additions & 21 deletions docs/src/examples/components/Calendar/fixed-cell-size.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,19 @@
padding={{ top: 20 }}
height={140}
>
{#snippet children({ context })}
<Layer>
<Calendar
start={firstDayOfYear}
end={lastDayOfYear}
tooltipContext={context.tooltip}
cellSize={16}
monthPath
/>
</Layer>
<Layer>
<Calendar start={firstDayOfYear} end={lastDayOfYear} tooltip cellSize={16} monthPath />
</Layer>

<Tooltip.Root>
{#snippet children({ data })}
<Tooltip.Header value={data.date} format="day" />
<Tooltip.Root>
{#snippet children({ data })}
<Tooltip.Header value={data.date} format="day" />

{#if data.value != null}
<Tooltip.List>
<Tooltip.Item label="value" value={data.value} format="integer" valueAlign="right" />
</Tooltip.List>
{/if}
{/snippet}
</Tooltip.Root>
{/snippet}
{#if data.value != null}
<Tooltip.List>
<Tooltip.Item label="value" value={data.value} format="integer" valueAlign="right" />
</Tooltip.List>
{/if}
{/snippet}
</Tooltip.Root>
</Chart>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
>
{#snippet children({ context })}
<Layer type="html">
<Calendar start={firstDayOfYear} end={lastDayOfYear} tooltipContext={context.tooltip}>
<Calendar start={firstDayOfYear} end={lastDayOfYear}>
{#snippet children({ cells, cellSize })}
{#each cells as cell}
<div
Expand Down
Loading
Loading