Skip to content

Commit

Permalink
fix: Compatibility with Svelte 3/4 after accidental introduction of t…
Browse files Browse the repository at this point in the history
…ypescript in markup
  • Loading branch information
techniq committed Jan 16, 2025
1 parent 24a69b9 commit bec9207
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-falcons-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

fix: Compatibility with Svelte 3/4 after accidental introduction of typescript in markup
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
findRelatedData,
type Accessor,
} from '../../utils/common.js';
import { asAny } from '../../utils/types.js';
interface $$Props extends ComponentProps<Chart<TData>> {
axis?: typeof axis;
Expand Down Expand Up @@ -309,7 +310,7 @@
{@const seriesItems = stackSeries ? [...series].reverse() : series}
{#each seriesItems as s}
{@const seriesTooltipData = s.data ? findRelatedData(s.data, data, x) : data}
{@const valueAccessor = accessor(s.value ?? (s.data ? (y as any) : s.key))}
{@const valueAccessor = accessor(s.value ?? (s.data ? asAny(y) : s.key))}

<Tooltip.Item
label={s.label ?? (s.key !== 'default' ? s.key : 'value')}
Expand All @@ -327,7 +328,7 @@
label="total"
value={sum(series, (s) => {
const seriesTooltipData = s.data ? s.data.find((d) => x(d) === x(data)) : data;
const valueAccessor = accessor(s.value ?? (s.data ? (y as any) : s.key));
const valueAccessor = accessor(s.value ?? (s.data ? asAny(y) : s.key));

return valueAccessor(seriesTooltipData);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
findRelatedData,
type Accessor,
} from '../../utils/common.js';
import { asAny } from '../../utils/types.js';
interface $$Props extends ComponentProps<Chart<TData>> {
axis?: typeof axis;
Expand Down Expand Up @@ -247,7 +248,7 @@
<Tooltip.List>
{#each series as s}
{@const seriesTooltipData = s.data ? findRelatedData(s.data, data, x) : data}
{@const valueAccessor = accessor(s.value ?? (s.data ? (y as any) : s.key))}
{@const valueAccessor = accessor(s.value ?? (s.data ? asAny(y) : s.key))}

<Tooltip.Item
label={s.label ?? (s.key !== 'default' ? s.key : 'value')}
Expand Down
3 changes: 3 additions & 0 deletions packages/layerchart/src/lib/utils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function asAny(x: any): any {
return x;
}

0 comments on commit bec9207

Please sign in to comment.