Skip to content

Commit ceaaf81

Browse files
authored
fix(Points): Update point.x / point.y based on ctx.radial to simplify children snippet usage (#611)
1 parent 8190b48 commit ceaaf81

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

.changeset/mean-flies-play.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(Points): Update `point.x` / `point.y` based on `ctx.radial` to simplify children snippet usage

packages/layerchart/src/lib/components/Points.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@
103103
const scaledX: number = ctx.xScale(xVal);
104104
const scaledY: number = ctx.yScale(yVal);
105105
106+
const x = scaledX + getOffset(scaledX, offsetX, ctx.xScale);
107+
const y = scaledY + getOffset(scaledY, offsetY, ctx.yScale);
108+
109+
const radialPoint = pointRadial(x, y);
110+
106111
return {
107-
x: scaledX + getOffset(scaledX, offsetX, ctx.xScale),
108-
y: scaledY + getOffset(scaledY, offsetY, ctx.yScale),
112+
x: ctx.radial ? radialPoint[0] : x,
113+
y: ctx.radial ? radialPoint[1] : y,
109114
r: ctx.config.r ? ctx.rGet(d) : r,
110115
xValue: xVal,
111116
yValue: yVal,
@@ -192,10 +197,9 @@
192197
{/if}
193198

194199
{#each points as point}
195-
{@const radialPoint = pointRadial(point.x, point.y)}
196200
<Circle
197-
cx={ctx.radial ? radialPoint[0] : point.x}
198-
cy={ctx.radial ? radialPoint[1] : point.y}
201+
cx={point.x}
202+
cy={point.y}
199203
r={point.r}
200204
fill={fill ?? (ctx.config.c ? ctx.cGet(point.data) : null)}
201205
{fillOpacity}

packages/layerchart/src/routes/docs/components/LineChart/+page.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import { cls } from '@layerstack/tailwind';
2525
import { slide } from 'svelte/transition';
2626
import { shared } from '../../shared.svelte.js';
27-
import { tick } from 'svelte';
2827
2928
let { data } = $props();
3029

0 commit comments

Comments
 (0)