From 779f78ecd7dc26391df5eb3e085829bb33731769 Mon Sep 17 00:00:00 2001 From: rajanpanth Date: Fri, 24 Jul 2026 10:15:01 +0545 Subject: [PATCH 1/2] fix: make prop-derived chart values reactive to prop changes Area computed its default label position from swapXY and Sparkline its series type from type with plain let declarations, so both froze at mount-time values while their consumers are reactive: toggling swapXY left area labels falling back to 'top' instead of 'right', and changing a sparkline's type from bar to line kept rendering bars. Same class as the BarChart stacked100 fix (#3310): derive with $: so the reactive consumers see current values. --- .changeset/reactive-prop-derivations.md | 5 +++++ .../ui/core-components/src/lib/unsorted/viz/area/Area.svelte | 2 +- .../src/lib/unsorted/viz/core/_Sparkline.svelte | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/reactive-prop-derivations.md diff --git a/.changeset/reactive-prop-derivations.md b/.changeset/reactive-prop-derivations.md new file mode 100644 index 0000000000..7915f79dc9 --- /dev/null +++ b/.changeset/reactive-prop-derivations.md @@ -0,0 +1,5 @@ +--- +'@evidence-dev/core-components': patch +--- + +Make prop-derived chart values reactive: Area's default label position now follows `swapXY`, and Sparkline's series type follows `type`, instead of freezing at their mount-time values. diff --git a/packages/ui/core-components/src/lib/unsorted/viz/area/Area.svelte b/packages/ui/core-components/src/lib/unsorted/viz/area/Area.svelte index a70379fbc7..9cb11494e8 100644 --- a/packages/ui/core-components/src/lib/unsorted/viz/area/Area.svelte +++ b/packages/ui/core-components/src/lib/unsorted/viz/area/Area.svelte @@ -117,7 +117,7 @@ middle: 'inside' }; - let defaultLabelPosition = swapXY ? 'right' : 'top'; + $: defaultLabelPosition = swapXY ? 'right' : 'top'; $: labelPosition = (swapXY ? swapXYLabelPositions[labelPosition] : labelPositions[labelPosition]) ?? defaultLabelPosition; diff --git a/packages/ui/core-components/src/lib/unsorted/viz/core/_Sparkline.svelte b/packages/ui/core-components/src/lib/unsorted/viz/core/_Sparkline.svelte index 10db89655b..34b2f0ed09 100644 --- a/packages/ui/core-components/src/lib/unsorted/viz/core/_Sparkline.svelte +++ b/packages/ui/core-components/src/lib/unsorted/viz/core/_Sparkline.svelte @@ -37,7 +37,7 @@ export let yScale = false; // scale the y axis to the data $: yScale = yScale === 'true' || yScale === true; - let seriesType = type === 'area' ? 'line' : type; + $: seriesType = type === 'area' ? 'line' : type; export let connectGroup = undefined; // connects to all other connected sparklines with the same group name (shared tooltip behaviour) From 1c09c69f128e8aae77a6e41a4190a101fbd9b5fb Mon Sep 17 00:00:00 2001 From: rajanpanth Date: Sat, 25 Jul 2026 08:14:52 +0545 Subject: [PATCH 2/2] fix: apply the same reactive derivation to Line's default label position Untruncated re-sweep of the viz tree found the identical pattern in Line.svelte (the earlier sweep output was truncated). _Chart's ySet/xSet are intentionally non-reactive per their in-code comment and stay as-is. --- .changeset/reactive-prop-derivations.md | 2 +- .../ui/core-components/src/lib/unsorted/viz/line/Line.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/reactive-prop-derivations.md b/.changeset/reactive-prop-derivations.md index 7915f79dc9..7fc917150b 100644 --- a/.changeset/reactive-prop-derivations.md +++ b/.changeset/reactive-prop-derivations.md @@ -2,4 +2,4 @@ '@evidence-dev/core-components': patch --- -Make prop-derived chart values reactive: Area's default label position now follows `swapXY`, and Sparkline's series type follows `type`, instead of freezing at their mount-time values. +Make prop-derived chart values reactive: Area's and Line's default label positions now follow `swapXY`, and Sparkline's series type follows `type`, instead of freezing at their mount-time values. diff --git a/packages/ui/core-components/src/lib/unsorted/viz/line/Line.svelte b/packages/ui/core-components/src/lib/unsorted/viz/line/Line.svelte index 3541f27388..d0ff12e0a3 100644 --- a/packages/ui/core-components/src/lib/unsorted/viz/line/Line.svelte +++ b/packages/ui/core-components/src/lib/unsorted/viz/line/Line.svelte @@ -139,7 +139,7 @@ middle: 'inside' }; - let defaultLabelPosition = swapXY ? 'right' : 'top'; + $: defaultLabelPosition = swapXY ? 'right' : 'top'; $: labelPosition = (swapXY ? swapXYLabelPositions[labelPosition] : labelPositions[labelPosition]) ?? defaultLabelPosition;