diff --git a/.changeset/chilly-years-vanish.md b/.changeset/chilly-years-vanish.md new file mode 100644 index 000000000..50a93e40a --- /dev/null +++ b/.changeset/chilly-years-vanish.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Bars): Support passing `data` override diff --git a/.changeset/cold-taxis-sit.md b/.changeset/cold-taxis-sit.md new file mode 100644 index 000000000..8e084c953 --- /dev/null +++ b/.changeset/cold-taxis-sit.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Chart): Expose `config` as slot prop diff --git a/.changeset/cool-needles-divide.md b/.changeset/cool-needles-divide.md new file mode 100644 index 000000000..ccc3f07d5 --- /dev/null +++ b/.changeset/cool-needles-divide.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +feat: Add simplified charts to streamline creating common chart types with recommended conventions and granular extensibility (AreaChart, BarChart, LineChart, PieChart, and ScatterChart) diff --git a/.changeset/cuddly-avocados-trade.md b/.changeset/cuddly-avocados-trade.md new file mode 100644 index 000000000..30d4c7b62 --- /dev/null +++ b/.changeset/cuddly-avocados-trade.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Bar): Forward pointer events to enable individual bar tooltips diff --git a/.changeset/eight-llamas-pump.md b/.changeset/eight-llamas-pump.md new file mode 100644 index 000000000..b534e24a8 --- /dev/null +++ b/.changeset/eight-llamas-pump.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Highlight): Handle non-zero y values when drawing lines (ex. radial line chart with inner radius) diff --git a/.changeset/empty-pianos-add.md b/.changeset/empty-pianos-add.md new file mode 100644 index 000000000..30594e304 --- /dev/null +++ b/.changeset/empty-pianos-add.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Voronoi): Support radial coordinates. Issue #112 diff --git a/.changeset/five-plums-speak.md b/.changeset/five-plums-speak.md new file mode 100644 index 000000000..91cf1d6ad --- /dev/null +++ b/.changeset/five-plums-speak.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking(Tooltip): Rename Tooltip to Tooltip.Root diff --git a/.changeset/flat-ties-trade.md b/.changeset/flat-ties-trade.md new file mode 100644 index 000000000..4eee48aff --- /dev/null +++ b/.changeset/flat-ties-trade.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +breaking(Bar/Bars): Replace groupBy/groupPadding with Chart-level x1/y1 derived scales diff --git a/.changeset/four-months-judge.md b/.changeset/four-months-judge.md new file mode 100644 index 000000000..072a5fee2 --- /dev/null +++ b/.changeset/four-months-judge.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Labels): Handle multiple x or y properties (stack, diverting) by leveraging Points component internally diff --git a/.changeset/four-rockets-cry.md b/.changeset/four-rockets-cry.md new file mode 100644 index 000000000..11114952a --- /dev/null +++ b/.changeset/four-rockets-cry.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking(Tooltip): Remove default grid on Tooltip.Root and add Tooltip.List as Tooltip.Item container diff --git a/.changeset/fresh-houses-run.md b/.changeset/fresh-houses-run.md new file mode 100644 index 000000000..aa59311f7 --- /dev/null +++ b/.changeset/fresh-houses-run.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking(Chart): Default domain sorting to `false` (instead of LayerCake's `true`) to simplify bandScale use cases diff --git a/.changeset/green-crews-change.md b/.changeset/green-crews-change.md new file mode 100644 index 000000000..3613c3398 --- /dev/null +++ b/.changeset/green-crews-change.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Points): Add `xValue` and `yValue` to each point, and improve types diff --git a/.changeset/grumpy-masks-agree.md b/.changeset/grumpy-masks-agree.md new file mode 100644 index 000000000..e0c79a167 --- /dev/null +++ b/.changeset/grumpy-masks-agree.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking(Tooltip): Consolidate Tooltip components (TooltipItem, TooltipSeparator, etc) to Tooltip.Item, Tooltip.Separtor, etc diff --git a/.changeset/hot-houses-stare.md b/.changeset/hot-houses-stare.md new file mode 100644 index 000000000..468ae04be --- /dev/null +++ b/.changeset/hot-houses-stare.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Highlight): Support radial coordiantes for `points` and `lines`. Issue #112 diff --git a/.changeset/late-cheetahs-smell.md b/.changeset/late-cheetahs-smell.md new file mode 100644 index 000000000..ec4c0d5e7 --- /dev/null +++ b/.changeset/late-cheetahs-smell.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Spline): Handle null data via defined by default diff --git a/.changeset/little-geese-laugh.md b/.changeset/little-geese-laugh.md new file mode 100644 index 000000000..e36903b16 --- /dev/null +++ b/.changeset/little-geese-laugh.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Points): Add canvas support diff --git a/.changeset/long-crabs-teach.md b/.changeset/long-crabs-teach.md new file mode 100644 index 000000000..c73542b59 --- /dev/null +++ b/.changeset/long-crabs-teach.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Chart): Expose `x`/`y`/`z`/`r` accessors via slot props diff --git a/.changeset/long-pugs-tan.md b/.changeset/long-pugs-tan.md new file mode 100644 index 000000000..5ca073e85 --- /dev/null +++ b/.changeset/long-pugs-tan.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(TooltipSeparator): Use theme color diff --git a/.changeset/lucky-tables-retire.md b/.changeset/lucky-tables-retire.md new file mode 100644 index 000000000..7a6e574d1 --- /dev/null +++ b/.changeset/lucky-tables-retire.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +refactor: Add `@layerstack/svelte-actions`, `@layerstack/svelte-stores`, `@layerstack/tailwind`, and `@layerstack/utils` packages and move `svelte-ux` package to `devDependancies` (components only for docs) diff --git a/.changeset/mighty-teachers-rest.md b/.changeset/mighty-teachers-rest.md new file mode 100644 index 000000000..fd2037030 --- /dev/null +++ b/.changeset/mighty-teachers-rest.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat: Rename `createStackData()` to `groupStackData()`, refine returned structure to simplify tooltips and make consistent with different options combinations, and add tests diff --git a/.changeset/neat-schools-bake.md b/.changeset/neat-schools-bake.md new file mode 100644 index 000000000..c8680c53f --- /dev/null +++ b/.changeset/neat-schools-bake.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking: Remove `AreaStack` as use cases fully supported by `Area` diff --git a/.changeset/new-readers-sparkle.md b/.changeset/new-readers-sparkle.md new file mode 100644 index 000000000..9c97e9cd3 --- /dev/null +++ b/.changeset/new-readers-sparkle.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Labels): Support `center` placement (useful with Points) diff --git a/.changeset/polite-cooks-tease.md b/.changeset/polite-cooks-tease.md new file mode 100644 index 000000000..ecd4ccca8 --- /dev/null +++ b/.changeset/polite-cooks-tease.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +feat(Svg): Add `center` to conveniently center children, useful for radial layouts without requiring `Group` wrapper diff --git a/.changeset/polite-tools-chew.md b/.changeset/polite-tools-chew.md new file mode 100644 index 000000000..c7be14065 --- /dev/null +++ b/.changeset/polite-tools-chew.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking: Remove and replace with diff --git a/.changeset/poor-hats-roll.md b/.changeset/poor-hats-roll.md new file mode 100644 index 000000000..e3a64622f --- /dev/null +++ b/.changeset/poor-hats-roll.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking(Pie): Remove `placement` prop and instead rely Svg `center` or use `Group` for positioning diff --git a/.changeset/red-roses-drive.md b/.changeset/red-roses-drive.md new file mode 100644 index 000000000..8d75f660d --- /dev/null +++ b/.changeset/red-roses-drive.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking: Add new color `cScale` (and related `c` accessor, domain, range, etc) and replace `rScale` usage (which should be used for radius, etc) diff --git a/.changeset/rotten-baboons-design.md b/.changeset/rotten-baboons-design.md new file mode 100644 index 000000000..f359e1f4f --- /dev/null +++ b/.changeset/rotten-baboons-design.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Area): Handle null data via defined by default diff --git a/.changeset/rude-students-lick.md b/.changeset/rude-students-lick.md new file mode 100644 index 000000000..f61938ec7 --- /dev/null +++ b/.changeset/rude-students-lick.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(tooltip): Update bisect-x mode to support radial coordinates diff --git a/.changeset/seven-cars-happen.md b/.changeset/seven-cars-happen.md new file mode 100644 index 000000000..2aa4d8037 --- /dev/null +++ b/.changeset/seven-cars-happen.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Highlight): Handle null value points diff --git a/.changeset/sharp-ways-move.md b/.changeset/sharp-ways-move.md new file mode 100644 index 000000000..2e19b1940 --- /dev/null +++ b/.changeset/sharp-ways-move.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Voronoi): Dispatch custom `pointerevent` instead of forwarding to fix console errors diff --git a/.changeset/short-colts-smash.md b/.changeset/short-colts-smash.md new file mode 100644 index 000000000..483148598 --- /dev/null +++ b/.changeset/short-colts-smash.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Points): Integrate with rScale diff --git a/.changeset/slimy-points-sing.md b/.changeset/slimy-points-sing.md new file mode 100644 index 000000000..34a0aaf1d --- /dev/null +++ b/.changeset/slimy-points-sing.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Points): Remove incorrect points for null/undefined values diff --git a/.changeset/smooth-tomatoes-hug.md b/.changeset/smooth-tomatoes-hug.md new file mode 100644 index 000000000..7dcc469fa --- /dev/null +++ b/.changeset/smooth-tomatoes-hug.md @@ -0,0 +1,5 @@ +--- +'layerchart': minor +--- + +breaking(Threshold): Simplify implementation and rename `pathAbove`/`pathBelow` slots to `above`/`below` diff --git a/.changeset/spotty-moles-rhyme.md b/.changeset/spotty-moles-rhyme.md new file mode 100644 index 000000000..ac9454b6e --- /dev/null +++ b/.changeset/spotty-moles-rhyme.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Area): Pass `x` override to internal Spline diff --git a/.changeset/stale-tools-taste.md b/.changeset/stale-tools-taste.md new file mode 100644 index 000000000..e8a289359 --- /dev/null +++ b/.changeset/stale-tools-taste.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(Spline): Enable passing `fill` prop (useful for Bar with single rounded edge) diff --git a/.changeset/twelve-otters-count.md b/.changeset/twelve-otters-count.md new file mode 100644 index 000000000..4912ffe10 --- /dev/null +++ b/.changeset/twelve-otters-count.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Tooltip.Item): Support `color` prop to add swatch, support theme colors and any color via `color="variable"` diff --git a/.changeset/twenty-queens-remember.md b/.changeset/twenty-queens-remember.md new file mode 100644 index 000000000..3f0d4d459 --- /dev/null +++ b/.changeset/twenty-queens-remember.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +fix(cartesianToPolar): Correctly calculate angle/radians between 0 and 2π diff --git a/.changeset/weak-tigers-poke.md b/.changeset/weak-tigers-poke.md new file mode 100644 index 000000000..ab0e3a6e3 --- /dev/null +++ b/.changeset/weak-tigers-poke.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Arc): Support passing `tooltip` and `data` props to simplify setting up tooltip pointer events diff --git a/.changeset/witty-goats-breathe.md b/.changeset/witty-goats-breathe.md new file mode 100644 index 000000000..e02810250 --- /dev/null +++ b/.changeset/witty-goats-breathe.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat(Chart): Support x1/y1 derived scales, useful for grouped bar charts diff --git a/packages/layerchart/package.json b/packages/layerchart/package.json index c8ce1a523..ec5d8fcc4 100644 --- a/packages/layerchart/package.json +++ b/packages/layerchart/package.json @@ -13,6 +13,7 @@ "prepublishOnly": "svelte-package", "check": "svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", + "test:unit": "TZ=UTC-5 vitest", "lint": "prettier --check .", "format": "prettier --write .", "prepare": "svelte-kit sync" @@ -66,6 +67,7 @@ "svelte-check": "^3.8.5", "svelte-json-tree": "^2.2.0", "svelte-preprocess": "^6.0.2", + "svelte-ux": "^0.74.4", "svelte2tsx": "^0.7.15", "tailwindcss": "^3.4.10", "topojson-client": "^3.1.0", @@ -74,10 +76,15 @@ "typescript": "^5.5.4", "unist-util-visit": "^5.0.0", "us-atlas": "^3.0.1", - "vite": "^5.4.0" + "vite": "^5.4.0", + "vitest": "^2.0.5" }, "type": "module", "dependencies": { + "@layerstack/svelte-actions": "^0.0.3", + "@layerstack/svelte-stores": "^0.0.3", + "@layerstack/tailwind": "^0.0.5", + "@layerstack/utils": "^0.0.3", "d3-array": "^3.2.4", "d3-color": "^3.1.0", "d3-delaunay": "^6.0.4", @@ -102,7 +109,6 @@ "lodash-es": "^4.17.21", "posthog-js": "^1.155.4", "shapefile": "^0.6.6", - "svelte-ux": "^0.74.4", "topojson-client": "^3.1.0" }, "peerDependencies": { diff --git a/packages/layerchart/src/lib/components/Arc.svelte b/packages/layerchart/src/lib/components/Arc.svelte index 05e142591..f23ddd44f 100644 --- a/packages/layerchart/src/lib/components/Arc.svelte +++ b/packages/layerchart/src/lib/components/Arc.svelte @@ -27,6 +27,7 @@ import { chartContext } from './ChartContext.svelte'; import { motionStore } from '$lib/stores/motionStore.js'; import { degreesToRadians } from '$lib/utils/math.js'; + import type { TooltipContextValue } from './tooltip/TooltipContext.svelte'; export let spring: boolean | Parameters[1] = undefined; export let tweened: boolean | Parameters[1] = undefined; @@ -86,7 +87,7 @@ $: scale = scaleLinear().domain(domain).range(range); function getOuterRadius(outerRadius: number | undefined, chartRadius: number) { - if (outerRadius == null) { + if (!outerRadius) { return chartRadius; } else if (outerRadius > 1) { // discrete value @@ -172,6 +173,16 @@ $: angle = ((startAngle ?? 0) + (endAngle ?? 0)) / 2; $: xOffset = Math.sin(angle) * offset; $: yOffset = -Math.cos(angle) * offset; + + /** + * Tooltip context to setup pointer events to show tooltip for related data. Must set `data` prop as well + */ + export let tooltip: TooltipContextValue | undefined = undefined; + + /** + * Data to set when showing tooltip + */ + export let data: any = undefined; {#if track} @@ -188,6 +199,15 @@ d={arc()} transform="translate({xOffset}, {yOffset})" {...$$restProps} + on:pointerenter={(e) => tooltip?.show(e, data)} + on:pointermove={(e) => tooltip?.show(e, data)} + on:pointerleave={(e) => tooltip?.hide()} + on:touchmove={(e) => { + if (tooltip) { + // Prevent touch to not interfer with pointer when using tooltip + e.preventDefault(); + } + }} on:click on:pointerenter on:pointermove diff --git a/packages/layerchart/src/lib/components/Area.svelte b/packages/layerchart/src/lib/components/Area.svelte index d3bf335fd..bf4a1fcdb 100644 --- a/packages/layerchart/src/lib/components/Area.svelte +++ b/packages/layerchart/src/lib/components/Area.svelte @@ -3,10 +3,10 @@ import type { tweened as tweenedStore } from 'svelte/motion'; import { type Area, area as d3Area, areaRadial } from 'd3-shape'; import type { CurveFactory } from 'd3-shape'; - import { max } from 'd3-array'; + import { max, min } from 'd3-array'; import { interpolatePath } from 'd3-interpolate-path'; - import { cls } from 'svelte-ux'; + import { cls } from '@layerstack/tailwind'; import { motionStore } from '$lib/stores/motionStore.js'; @@ -15,7 +15,17 @@ import { accessor, type Accessor } from '../utils/common.js'; import { isScaleBand } from '../utils/scales.js'; - const { data: contextData, xScale, yScale, xGet, yGet, yRange } = chartContext(); + const { + data: contextData, + xScale, + yScale, + x: contextX, + y, + yDomain, + yRange, + config, + radial, + } = chartContext(); /** Override data instead of using context */ export let data: any = undefined; @@ -23,9 +33,6 @@ /** Pass `` explicitly instead of calculating from data / context */ export let pathData: string | undefined | null = undefined; - /** Use radial instead of cartesian area generator, mapping `x` to `angle` and `y0`/`y1 to `innerRadius`/`outerRadius. Radial lines are positioned relative to the origin, use transform (ex. ``) to change the origin */ - export let radial = false; - /** Override x accessor */ export let x: Accessor = undefined; @@ -45,9 +52,9 @@ /** Enable showing line */ export let line: boolean | Partial> = false; - const _x = accessor(x); - const _y0 = accessor(y0); - const _y1 = accessor(y1); + const xAccessor = x ? accessor(x) : $contextX; + const y0Accessor = y0 ? accessor(y0) : (d: any) => min($yDomain); + const y1Accessor = y1 ? accessor(y1) : $y; $: xOffset = isScaleBand($xScale) ? $xScale.bandwidth() / 2 : 0; $: yOffset = isScaleBand($yScale) ? $yScale.bandwidth() / 2 : 0; @@ -57,17 +64,44 @@ : false; $: tweened_d = motionStore('', { tweened: tweenedOptions }); $: { - const path = radial + const path = $radial ? areaRadial() - .angle((d) => (x ? $xScale(_x(d)) : $xGet(d))) - .innerRadius((d) => (y0 ? $yScale(_y0(d)) : max($yRange))) - .outerRadius((d) => (y1 ? $yScale(_y1(d)) : $yGet(d))) + .angle((d) => $xScale(xAccessor(d))) + .innerRadius((d) => $yScale(y0Accessor(d))) + .outerRadius((d) => $yScale(y1Accessor(d))) : d3Area() - .x((d) => (x ? $xScale(_x(d)) : $xGet(d)) + xOffset) - .y0((d) => (y0 ? $yScale(_y0(d)) : max($yRange)) + yOffset) - .y1((d) => (y1 ? $yScale(_y1(d)) : $yGet(d)) + yOffset); + .x((d) => $xScale(xAccessor(d)) + xOffset) + .y0((d) => { + let value = max($yRange)!; + if (y0) { + value = $yScale(y0Accessor(d)); + } else if (Array.isArray($config.y) && $config.y[0] === 0) { + // Use first value if `y` defined as an array (ex. ``) + // TODO: Would be nice if this also handled multi-series () as well as delta values () + value = $yScale($y(d)[0]); + } + + return value + yOffset; + }) + .y1((d) => { + let value = max($yRange)!; + if (y1) { + value = $yScale(y1Accessor(d)); + } else if (Array.isArray($config.y) && $config.y[1] === 1) { + // Use second value if `y` defined as an array (ex. ``) + // TODO: Would be nice if this also handled multi-series () as well as delta values () + value = $yScale($y(d)[1]); + } else { + // Expect single value defined for `y` (ex. ``) + value = $yScale($y(d)); + } + + return value + yOffset; + }); + + path.defined(defined ?? ((d) => xAccessor(d) != null && y1Accessor(d) != null)); + if (curve) path.curve(curve); - if (defined) path.defined(defined); const d = pathData ?? path(data ?? $contextData); tweened_d.set(d ?? ''); @@ -75,7 +109,15 @@ {#if line} - + {/if} diff --git a/packages/layerchart/src/lib/components/AreaStack.svelte b/packages/layerchart/src/lib/components/AreaStack.svelte deleted file mode 100644 index 1bd1650e4..000000000 --- a/packages/layerchart/src/lib/components/AreaStack.svelte +++ /dev/null @@ -1,54 +0,0 @@ - - -{#if line} - - {#each lineData as seriesData} - d[1]} - stroke={$rGet(seriesData)} - {curve} - {defined} - {tweened} - {...line} - /> - {/each} - -{/if} - - - - {#each chartDataArray($data) as seriesData} - d[0]} - y1={(d) => d[1]} - fill={$rGet(seriesData)} - {curve} - {defined} - {opacity} - {tweened} - /> - {/each} - - diff --git a/packages/layerchart/src/lib/components/Axis.svelte b/packages/layerchart/src/lib/components/Axis.svelte index d66bd4132..fef076697 100644 --- a/packages/layerchart/src/lib/components/Axis.svelte +++ b/packages/layerchart/src/lib/components/Axis.svelte @@ -8,7 +8,9 @@ import { extent } from 'd3-array'; import { pointRadial } from 'd3-shape'; - import { format as formatValue, type FormatType, cls, type TransitionParams } from 'svelte-ux'; + import { format as formatValue, type FormatType } from '@layerstack/utils'; + import { cls } from '@layerstack/tailwind'; + import type { TransitionParams } from 'svelte-ux'; // TODO: Replace with `@layerstack/svelte-types` or similar import { chartContext } from './ChartContext.svelte'; import Circle from './Circle.svelte'; diff --git a/packages/layerchart/src/lib/components/Bar.svelte b/packages/layerchart/src/lib/components/Bar.svelte index 8c620fb09..a0fa1d8e0 100644 --- a/packages/layerchart/src/lib/components/Bar.svelte +++ b/packages/layerchart/src/lib/components/Bar.svelte @@ -22,6 +22,16 @@ */ export let y: Accessor = $yContext; + /** + * Override `x1` from context. Useful for multiple Bar instances + */ + export let x1: Accessor = undefined; + + /** + * Override `y1` from context. Useful for multiple Bar instances + */ + export let y1: Accessor = undefined; + export let fill: string | undefined = undefined; export let stroke = 'black'; export let strokeWidth = 0; @@ -40,9 +50,6 @@ | 'bottom-right' = 'all'; export let inset = 0; - export let groupBy: string | undefined = undefined; - export let groupPaddingInner = 0.2; - export let groupPaddingOuter = 0; export let spring: ComponentProps['spring'] = undefined; export let tweened: ComponentProps['tweened'] = undefined; @@ -52,12 +59,9 @@ $: getDimensions = createDimensionGetter(chartContext(), { x, y, - groupBy, + x1, + y1, inset, - groupPadding: { - inner: groupPaddingInner, - outer: groupPaddingOuter, - }, }); $: dimensions = $getDimensions(bar) ?? { x: 0, y: 0, width: 0, height: 0 }; @@ -94,6 +98,10 @@ {...dimensions} {...$$restProps} on:click + on:pointerenter + on:pointermove + on:pointerleave + on:touchmove /> {:else} {/if} diff --git a/packages/layerchart/src/lib/components/Bars.svelte b/packages/layerchart/src/lib/components/Bars.svelte index f052f4313..ea5507690 100644 --- a/packages/layerchart/src/lib/components/Bars.svelte +++ b/packages/layerchart/src/lib/components/Bars.svelte @@ -6,7 +6,12 @@ import Rect from './Rect.svelte'; import { chartDataArray, type Accessor } from '../utils/common.js'; - const { data, rGet, config } = chartContext(); + const { data: contextData, cGet, config } = chartContext(); + + /** + * Override `data` from context. Useful for multiple Bar instances + */ + export let data: any = undefined; /** * Override `x` from context. Useful for multiple Bar instances @@ -18,6 +23,16 @@ */ export let y: Accessor = undefined; + /** + * Override `x1` from context. Useful for multiple Bar instances + */ + export let x1: Accessor = undefined; + + /** + * Override `y1` from context. Useful for multiple Bar instances + */ + export let y1: Accessor = undefined; + export let stroke = 'black'; export let strokeWidth = 0; export let radius = 0; @@ -27,31 +42,24 @@ export let spring: ComponentProps['spring'] = undefined; export let tweened: ComponentProps['tweened'] = undefined; - - // See: https://svelte.dev/repl/7000c5ce05b84cd98ccbfb2768b4be3d?version=3.38.3 - - export let groupBy: string | undefined = undefined; - export let groupPaddingInner = 0.2; - export let groupPaddingOuter = 0; - {#each chartDataArray($data) as item} + {#each chartDataArray(data ?? $contextData) as item} {/each} diff --git a/packages/layerchart/src/lib/components/Blur.svelte b/packages/layerchart/src/lib/components/Blur.svelte index 267989210..868ed9ad3 100644 --- a/packages/layerchart/src/lib/components/Blur.svelte +++ b/packages/layerchart/src/lib/components/Blur.svelte @@ -1,5 +1,5 @@ - + + {#key isMounted} diff --git a/packages/layerchart/src/lib/components/ChartContext.svelte b/packages/layerchart/src/lib/components/ChartContext.svelte index 85bf98c7c..438f26fc5 100644 --- a/packages/layerchart/src/lib/components/ChartContext.svelte +++ b/packages/layerchart/src/lib/components/ChartContext.svelte @@ -1,10 +1,16 @@ - + diff --git a/packages/layerchart/src/lib/components/Circle.svelte b/packages/layerchart/src/lib/components/Circle.svelte index 682eb83ec..03f21befc 100644 --- a/packages/layerchart/src/lib/components/Circle.svelte +++ b/packages/layerchart/src/lib/components/Circle.svelte @@ -1,7 +1,7 @@ diff --git a/packages/layerchart/src/lib/components/HitCanvas.svelte b/packages/layerchart/src/lib/components/HitCanvas.svelte index 68c129e9f..5352fd59a 100644 --- a/packages/layerchart/src/lib/components/HitCanvas.svelte +++ b/packages/layerchart/src/lib/components/HitCanvas.svelte @@ -2,7 +2,7 @@ import { createEventDispatcher, onMount, setContext } from 'svelte'; import { writable } from 'svelte/store'; import { scaleCanvas } from 'layercake'; - import { cls } from 'svelte-ux'; + import { cls } from '@layerstack/tailwind'; import { chartContext } from './ChartContext.svelte'; import Canvas from './layout/Canvas.svelte'; diff --git a/packages/layerchart/src/lib/components/Hull.svelte b/packages/layerchart/src/lib/components/Hull.svelte index 2843138bd..88d69bb1b 100644 --- a/packages/layerchart/src/lib/components/Hull.svelte +++ b/packages/layerchart/src/lib/components/Hull.svelte @@ -1,11 +1,11 @@ - {#each $flatData as item, index} - - - {/each} + + {#each points as point} + + {/each} + diff --git a/packages/layerchart/src/lib/components/Legend.svelte b/packages/layerchart/src/lib/components/Legend.svelte index b6df75aef..46df8600a 100644 --- a/packages/layerchart/src/lib/components/Legend.svelte +++ b/packages/layerchart/src/lib/components/Legend.svelte @@ -1,15 +1,15 @@ - - - {#each arcs as arc} - tooltip?.show(e, arc.data)} - on:pointermove={(e) => tooltip?.show(e, arc.data)} - on:pointerleave={(e) => tooltip?.hide()} - on:touchmove={(e) => { - if (tooltip) { - // Prevent touch to not interfer with pointer when using tooltip - e.preventDefault(); - } - }} - /> - {/each} - - + + {#each arcs as arc} + + {/each} + diff --git a/packages/layerchart/src/lib/components/Points.svelte b/packages/layerchart/src/lib/components/Points.svelte index 419df03ab..001e184f7 100644 --- a/packages/layerchart/src/lib/components/Points.svelte +++ b/packages/layerchart/src/lib/components/Points.svelte @@ -1,8 +1,9 @@ - {#if links} - - {#each _links as link} - + {#each _links as link} + + {/each} + + {/if} + + + {#each points as point} + {@const radialPoint = pointRadial(point.x, point.y)} + {/each} {/if} - - - {#each points as point} - {@const radialPoint = pointRadial(point.x, point.y)} - - {/each} - diff --git a/packages/layerchart/src/lib/components/RadialGradient.svelte b/packages/layerchart/src/lib/components/RadialGradient.svelte index 65d15f0a9..0b1bf6bd1 100644 --- a/packages/layerchart/src/lib/components/RadialGradient.svelte +++ b/packages/layerchart/src/lib/components/RadialGradient.svelte @@ -1,5 +1,5 @@ {#key curve} - - - - - - - - - - + + + $y(d)[0]} y1={(d) => min($yDomain)} {curve} {defined} /> + - + + - -{/key} + + + min($yDomain)} y1={(d) => $y(d)[1]} {curve} {defined} /> + - - + + + + +{/key} diff --git a/packages/layerchart/src/lib/components/TooltipItem.svelte b/packages/layerchart/src/lib/components/TooltipItem.svelte deleted file mode 100644 index 3bc5e4ef7..000000000 --- a/packages/layerchart/src/lib/components/TooltipItem.svelte +++ /dev/null @@ -1,32 +0,0 @@ - - -
- {label}: -
- -
- {format ? formatUtil(value, format) : value} -
diff --git a/packages/layerchart/src/lib/components/TooltipSeparator.svelte b/packages/layerchart/src/lib/components/TooltipSeparator.svelte deleted file mode 100644 index 3436fa175..000000000 --- a/packages/layerchart/src/lib/components/TooltipSeparator.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - -
diff --git a/packages/layerchart/src/lib/components/TransformControls.svelte b/packages/layerchart/src/lib/components/TransformControls.svelte index b4b596720..c933f1121 100644 --- a/packages/layerchart/src/lib/components/TransformControls.svelte +++ b/packages/layerchart/src/lib/components/TransformControls.svelte @@ -1,5 +1,6 @@ + + series.map((s, i) => d.stackData[i][1]) + : series.map((s) => s.value ?? s.key))} + yBaseline={0} + yNice + {radial} + padding={radial || axis === false ? undefined : { left: 16, bottom: 16 }} + tooltip={{ mode: 'bisect-x' }} + {...$$restProps} + let:x + let:xScale + let:y + let:yScale + let:width + let:height + let:padding + let:tooltip +> + {@const slotProps = { x, xScale, y, yScale, width, height, padding, tooltip, series }} + + + + {#if axis} + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.yAxis} + /> + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.xAxis} + /> + {/if} + + + + + + {#each series as s, i} + d.stackData[i][0] + : Array.isArray(s.value) + ? s.value[0] + : undefined} + y1={stackSeries + ? (d) => d.stackData[i][1] + : Array.isArray(s.value) + ? s.value[1] + : (s.value ?? s.key)} + line={{ class: 'stroke-2', stroke: s.color }} + fill={s.color} + fill-opacity={0.3} + {...props.area} + {...s.props} + /> + {/each} + + + + + {#if points} + {#each series as s} + + {/each} + {/if} + + + {#each series as s, i} + d.stackData[i][1] : (s.value ?? s.key)} + points={{ fill: s.color }} + lines={i == 0} + {...props.highlight} + /> + {/each} + + + {#if labels} + + {/if} + + + + + {format(x(data))} + + + {@const seriesItems = stackSeries ? [...series].reverse() : series} + {#each seriesItems as s} + {@const valueAccessor = accessor(s.value ?? s.key)} + + {/each} + + {#if stackSeries} + + + { + const valueAccessor = accessor(s.value ?? s.key); + return valueAccessor(data); + })} + format="integer" + valueAlign="right" + /> + {/if} + + + + + diff --git a/packages/layerchart/src/lib/components/charts/BarChart.svelte b/packages/layerchart/src/lib/components/charts/BarChart.svelte new file mode 100644 index 000000000..8d21617d7 --- /dev/null +++ b/packages/layerchart/src/lib/components/charts/BarChart.svelte @@ -0,0 +1,255 @@ + + + series.map((s, i) => d.stackData[i][1]) + : series.map((s) => s.value ?? s.key))} + {xScale} + {xBaseline} + xNice={orientation === 'horizontal'} + {x1Scale} + {x1Domain} + {x1Range} + y={y ?? + (stackSeries + ? (d) => series.map((s, i) => d.stackData[i][1]) + : series.map((s) => s.value ?? s.key))} + {yScale} + {yBaseline} + yNice={orientation === 'vertical'} + {y1Scale} + {y1Domain} + {y1Range} + padding={axis === false ? undefined : { left: 16, bottom: 16 }} + tooltip={{ mode: 'band' }} + {...$$restProps} + let:x + let:xScale + let:y + let:yScale + let:width + let:height + let:padding + let:tooltip +> + {@const slotProps = { x, xScale, y, yScale, width, height, padding, tooltip, series }} + + + + {#if axis} + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.yAxis} + /> + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.xAxis} + /> + {/if} + + + + + + {#each series as s, i} + d.stackData[i] + : (s.value ?? (s.data ? undefined : s.key)) + : undefined} + y={isVertical + ? stackSeries + ? (d) => d.stackData[i] + : (s.value ?? (s.data ? undefined : s.key)) + : undefined} + x1={isVertical && groupSeries ? (d) => s.value ?? s.key : undefined} + y1={!isVertical && groupSeries ? (d) => s.value ?? s.key : undefined} + radius={4} + strokeWidth={1} + fill={s.color} + {...props.bars} + {...s.props} + /> + {/each} + + + + + + + + + {#if labels} + + {/if} + + + + + {format(isVertical ? x(data) : y(data))} + + + {@const seriesItems = stackSeries ? [...series].reverse() : series} + {#each seriesItems as s} + {@const valueAccessor = accessor(s.value ?? s.key)} + + {/each} + + {#if stackSeries || groupSeries} + + + { + const valueAccessor = accessor(s.value ?? s.key); + return valueAccessor(data); + })} + format="integer" + valueAlign="right" + /> + {/if} + + + + + diff --git a/packages/layerchart/src/lib/components/charts/LineChart.svelte b/packages/layerchart/src/lib/components/charts/LineChart.svelte new file mode 100644 index 000000000..5886f213c --- /dev/null +++ b/packages/layerchart/src/lib/components/charts/LineChart.svelte @@ -0,0 +1,175 @@ + + + s.value ?? s.key)} + yBaseline={0} + yNice + {radial} + padding={radial || axis === false ? undefined : { left: 16, bottom: 16 }} + tooltip={{ mode: 'bisect-x' }} + {...$$restProps} + let:x + let:xScale + let:y + let:yScale + let:width + let:height + let:padding + let:tooltip +> + {@const slotProps = { x, xScale, y, yScale, width, height, padding, tooltip, series }} + + + + {#if axis} + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.yAxis} + /> + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.xAxis} + /> + {/if} + + + + + + {#each series as s} + + {/each} + + + + + {#if points} + {#each series as s} + + {/each} + {/if} + + {#if labels} + + {/if} + + + {#each series as s, i} + + {/each} + + + + + + {format(x(data))} + + {#each series as s} + {@const valueAccessor = accessor(s.value ?? s.key)} + + {/each} + + + + + diff --git a/packages/layerchart/src/lib/components/charts/PieChart.svelte b/packages/layerchart/src/lib/components/charts/PieChart.svelte new file mode 100644 index 000000000..668d960d6 --- /dev/null +++ b/packages/layerchart/src/lib/components/charts/PieChart.svelte @@ -0,0 +1,192 @@ + + + + {@const slotProps = { label, value, x, xScale, y, yScale, width, height, padding, tooltip }} + + + + + + + {#each series as s, i} + {@const singleArc = s.data?.length === 1 || chartData.length === 1} + {#if singleArc} + {@const d = s.data?.[0] || chartData[0]} + + {:else} + + {#each arcs as arc} + + {/each} + + {/if} + {/each} + + + + + + + + + + + + + + + diff --git a/packages/layerchart/src/lib/components/charts/ScatterChart.svelte b/packages/layerchart/src/lib/components/charts/ScatterChart.svelte new file mode 100644 index 000000000..41f01caa0 --- /dev/null +++ b/packages/layerchart/src/lib/components/charts/ScatterChart.svelte @@ -0,0 +1,161 @@ + + + + {@const slotProps = { x, xScale, y, yScale, width, height, padding, tooltip, series }} + {@const activeSeries = tooltip.data + ? (series.find((s) => s.key === tooltip.data.seriesKey) ?? series[0]) + : null} + + + + + {#if axis} + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.yAxis} + /> + format(value, undefined, { variant: 'short' })} + {...typeof axis === 'object' ? axis : null} + {...props.xAxis} + /> + {/if} + + + + + + {#each series as s} + + {/each} + + + + + + + + + {#if labels} + format(value)} + {...props.highlight} + {...typeof labels === 'object' ? labels : null} + /> + {/if} + + + + + {#if activeSeries?.key !== 'default'} + + {activeSeries?.label ?? activeSeries?.key} + + {/if} + + + + {#if config.r} + + {/if} + + + + + diff --git a/packages/layerchart/src/lib/components/charts/index.ts b/packages/layerchart/src/lib/components/charts/index.ts new file mode 100644 index 000000000..d2f2c6bd3 --- /dev/null +++ b/packages/layerchart/src/lib/components/charts/index.ts @@ -0,0 +1,5 @@ +export { default as AreaChart } from './AreaChart.svelte'; +export { default as BarChart } from './BarChart.svelte'; +export { default as LineChart } from './LineChart.svelte'; +export { default as PieChart } from './PieChart.svelte'; +export { default as ScatterChart } from './ScatterChart.svelte'; diff --git a/packages/layerchart/src/lib/components/index.ts b/packages/layerchart/src/lib/components/index.ts index 5042f5034..b0805d696 100644 --- a/packages/layerchart/src/lib/components/index.ts +++ b/packages/layerchart/src/lib/components/index.ts @@ -1,9 +1,10 @@ // Re-export for easy access (Svg and Canvas are provided by LayerChart) export { Html, WebGL } from 'layercake'; +export * from './charts/index.js'; + export { default as Arc } from './Arc.svelte'; export { default as Area } from './Area.svelte'; -export { default as AreaStack } from './AreaStack.svelte'; export { default as Axis } from './Axis.svelte'; export { default as Bar } from './Bar.svelte'; export { default as Bars } from './Bars.svelte'; @@ -55,10 +56,7 @@ export { default as Svg } from './layout/Svg.svelte'; export { default as Text } from './Text.svelte'; export { default as Threshold } from './Threshold.svelte'; export { default as TileImage } from './TileImage.svelte'; -export { default as Tooltip } from './Tooltip.svelte'; -export { default as TooltipContext } from './TooltipContext.svelte'; -export { default as TooltipItem } from './TooltipItem.svelte'; -export { default as TooltipSeparator } from './TooltipSeparator.svelte'; +export * as Tooltip from './tooltip/index.js'; export { default as TransformContext, transformContext } from './TransformContext.svelte'; export { default as TransformControls } from './TransformControls.svelte'; export { default as Tree } from './Tree.svelte'; diff --git a/packages/layerchart/src/lib/components/layout/Canvas.svelte b/packages/layerchart/src/lib/components/layout/Canvas.svelte index b48b3ba23..7df807ad5 100644 --- a/packages/layerchart/src/lib/components/layout/Canvas.svelte +++ b/packages/layerchart/src/lib/components/layout/Canvas.svelte @@ -2,7 +2,7 @@ import { onMount, setContext } from 'svelte'; import { writable } from 'svelte/store'; import { scaleCanvas } from 'layercake'; - import { cls } from 'svelte-ux'; + import { cls } from '@layerstack/tailwind'; import { chartContext } from '../ChartContext.svelte'; import { transformContext } from '../TransformContext.svelte'; diff --git a/packages/layerchart/src/lib/components/layout/Html.svelte b/packages/layerchart/src/lib/components/layout/Html.svelte index 6bf7c9f5f..81420db9f 100644 --- a/packages/layerchart/src/lib/components/layout/Html.svelte +++ b/packages/layerchart/src/lib/components/layout/Html.svelte @@ -1,5 +1,5 @@ + +
+ {#if color} +
+ {/if} + +
diff --git a/packages/layerchart/src/lib/components/tooltip/TooltipItem.svelte b/packages/layerchart/src/lib/components/tooltip/TooltipItem.svelte new file mode 100644 index 000000000..f380163bd --- /dev/null +++ b/packages/layerchart/src/lib/components/tooltip/TooltipItem.svelte @@ -0,0 +1,45 @@ + + +
+
+ {#if color} +
+ {/if} + {label} +
+ +
+ {format ? formatUtil(value, format) : value} +
+
diff --git a/packages/layerchart/src/lib/components/tooltip/TooltipList.svelte b/packages/layerchart/src/lib/components/tooltip/TooltipList.svelte new file mode 100644 index 000000000..144643220 --- /dev/null +++ b/packages/layerchart/src/lib/components/tooltip/TooltipList.svelte @@ -0,0 +1,13 @@ + + +
+ +
diff --git a/packages/layerchart/src/lib/components/tooltip/TooltipSeparator.svelte b/packages/layerchart/src/lib/components/tooltip/TooltipSeparator.svelte new file mode 100644 index 000000000..baa50dedf --- /dev/null +++ b/packages/layerchart/src/lib/components/tooltip/TooltipSeparator.svelte @@ -0,0 +1,5 @@ + + +
diff --git a/packages/layerchart/src/lib/components/tooltip/index.ts b/packages/layerchart/src/lib/components/tooltip/index.ts new file mode 100644 index 000000000..a3d575a8e --- /dev/null +++ b/packages/layerchart/src/lib/components/tooltip/index.ts @@ -0,0 +1,6 @@ +export { default as Context } from './TooltipContext.svelte'; +export { default as Header } from './TooltipHeader.svelte'; +export { default as Item } from './TooltipItem.svelte'; +export { default as List } from './TooltipList.svelte'; +export { default as Separator } from './TooltipSeparator.svelte'; +export { default as Root } from './Tooltip.svelte'; diff --git a/packages/layerchart/src/lib/docs/Blockquote.svelte b/packages/layerchart/src/lib/docs/Blockquote.svelte index 438ffbafa..adde7486c 100644 --- a/packages/layerchart/src/lib/docs/Blockquote.svelte +++ b/packages/layerchart/src/lib/docs/Blockquote.svelte @@ -1,6 +1,7 @@
import Prism from 'prismjs'; import 'prism-svelte'; - import { CopyButton, cls } from 'svelte-ux'; + import { CopyButton } from 'svelte-ux'; + import { cls } from '@layerstack/tailwind'; export let source: string | null = null; export let language = 'svelte'; diff --git a/packages/layerchart/src/lib/docs/CurveMenuField.svelte b/packages/layerchart/src/lib/docs/CurveMenuField.svelte index bcf6cbf35..10bf08ace 100644 --- a/packages/layerchart/src/lib/docs/CurveMenuField.svelte +++ b/packages/layerchart/src/lib/docs/CurveMenuField.svelte @@ -1,7 +1,8 @@ + +

Examples

+ +

Basic

+ + +
+ +
+
+ +

Gradient

+ +
+ + + + + + + +
+
+ +

Threshold Gradient

+ + {@const colors = { + positive: 'hsl(var(--color-success))', + negative: 'hsl(var(--color-danger))', + }} + +
+ + + {@const thresholdValue = 0} + {@const thresholdOffset = yScale(thresholdValue) / (height + padding.bottom)} + + + thresholdValue} + line={{ stroke: url, class: 'stroke-2' }} + fill={url} + fill-opacity={0.2} + /> + + + + + {@const value = tooltip.data && y(tooltip.data)} + + + + + + {@const value = y(data)} + {format(x(data), PeriodType.Day)} + + + + + + +
+
+ +

Series

+ + +
+ +
+
+ +

Series (highlight on hover)

+ + +
+ + + {#each series as s} + {@const color = + tooltip.data == null || tooltip.data.fruit === s.key + ? s.color + : 'hsl(var(--color-surface-content) / 20%)'} + + + {/each} + + + + + {@const activeSeries = [...series].find((s) => s.key === tooltip.data?.fruit)} + + + + + + {@const activeSeries = [...series].find((s) => s.key === tooltip.data?.fruit)} + + {format(x(data))} + + + + + + +
+
+ +

Stack series

+ + +
+ +
+
+ +

Labels

+ + +
+ +
+
+ +

Points

+ + +
+ +
+
+ +

Radial

+ + +
+ [height / 5, height / 2]} + radial + props={{ + area: { line: false, 'fill-opacity': 1 }, + xAxis: { format: PeriodType.Month }, + yAxis: { ticks: 4, format: (v) => v + '° F' }, + highlight: { points: false }, + }} + series={[ + { + key: 'min_max', + label: 'min/max', + value: ['min', 'max'], + color: 'hsl(var(--color-primary) / 20%)', + }, + { + key: 'minmin_maxmax', + label: 'minmin/maxmax', + value: ['minmin', 'maxmax'], + color: 'hsl(var(--color-primary) / 20%)', + }, + ]} + > + + + + +
+
+ +

Null gaps

+ + +
+ +
+
+ + + +

Sparkline

+ + +
+ +
+
+ +

Custom tooltip

+ + +
+ + + + {y(data)} + + + + {format(x(data), PeriodType.Day)} + + + +
+
+ +

Custom chart

+ + +
+ + + + format(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + + + + + {format(x(data), PeriodType.DayTime)} + + + + + +
+
diff --git a/packages/layerchart/src/routes/docs/components/AreaChart/+page.ts b/packages/layerchart/src/routes/docs/components/AreaChart/+page.ts new file mode 100644 index 000000000..e152576a2 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/AreaChart/+page.ts @@ -0,0 +1,60 @@ +import { csvParse, autoType } from 'd3-dsv'; +import { parse } from '@layerstack/utils'; + +import api from '$lib/components/charts/AreaChart.svelte?raw&sveld'; +import source from '$lib/components/charts/AreaChart.svelte?raw'; +import pageSource from './+page.svelte?raw'; + +import type { AppleStockData } from '$static/data/examples/date/apple-stock.js'; +import { ascending, flatGroup, max, mean, min } from 'd3-array'; +import { celsiusToFahrenheit } from '$lib/utils/math.js'; + +export async function load() { + return { + appleStock: await fetch('/data/examples/date/apple-stock.json').then(async (r) => + parse(await r.text()) + ), + dailyTemperatures: await fetch('/data/examples/dailyTemperatures.csv').then(async (r) => { + return csvParse<{ dayOfYear: number; year: number; value: number | 'NA' }>( + await r.text(), + // @ts-expect-error + autoType + ) + .filter((d) => d.value !== 'NA') + .map((d) => { + const origDate = new Date(d.year, 0, d.dayOfYear); + return { + ...d, + date: new Date(Date.UTC(2000, origDate.getUTCMonth(), origDate.getUTCDate())), + value: d.value !== 'NA' ? celsiusToFahrenheit(d.value) : 'NA', + }; + }); + }), + sfoTemperatures: await fetch('/data/examples/sfoTemperatures.csv').then(async (r) => { + return flatGroup( + csvParse<{ date: Date; tavg: number; tmax: number; tmin: number }>( + await r.text(), + // @ts-expect-error + autoType + ), + (d) => new Date(Date.UTC(2000, d.date.getUTCMonth(), d.date.getUTCDate())) // group by day of year + ) + .sort(([a], [b]) => ascending(a, b)) // sort chronologically + .map(([date, v]) => ({ + date, + avg: mean(v, (d) => d.tavg || NaN), + min: mean(v, (d) => d.tmin || NaN), + max: mean(v, (d) => d.tmax || NaN), + minmin: min(v, (d) => d.tmin || NaN), + maxmax: max(v, (d) => d.tmax || NaN), + })); + }), + meta: { + api, + source, + pageSource, + description: 'Streamlined Chart configuration for Area charts', + related: ['components/Chart', 'components/Area', 'examples/Area'], + }, + }; +} diff --git a/packages/layerchart/src/routes/docs/components/AreaStack/+page.ts b/packages/layerchart/src/routes/docs/components/AreaStack/+page.ts deleted file mode 100644 index de7cfd68b..000000000 --- a/packages/layerchart/src/routes/docs/components/AreaStack/+page.ts +++ /dev/null @@ -1,14 +0,0 @@ -import api from '$lib/components/AreaStack.svelte?raw&sveld'; -import source from '$lib/components/AreaStack.svelte?raw'; -import pageSource from './+page.svelte?raw'; - -export async function load() { - return { - meta: { - api, - source, - pageSource, - related: ['examples/AreaStack'], - }, - }; -} diff --git a/packages/layerchart/src/routes/docs/components/Axis/+page.svelte b/packages/layerchart/src/routes/docs/components/Axis/+page.svelte index 5440ec83a..acf45889b 100644 --- a/packages/layerchart/src/routes/docs/components/Axis/+page.svelte +++ b/packages/layerchart/src/routes/docs/components/Axis/+page.svelte @@ -1,6 +1,8 @@ diff --git a/packages/layerchart/src/routes/docs/components/Bar/+page.ts b/packages/layerchart/src/routes/docs/components/Bar/+page.ts new file mode 100644 index 000000000..6f60ad2a9 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/Bar/+page.ts @@ -0,0 +1,14 @@ +import api from '$lib/components/Bar.svelte?raw&sveld'; +import source from '$lib/components/Bar.svelte?raw'; +import pageSource from './+page.svelte?raw'; + +export async function load() { + return { + meta: { + api, + source, + pageSource, + related: ['components/Bars', 'examples/Bars', 'examples/Columns'], + }, + }; +} diff --git a/packages/layerchart/src/routes/docs/components/BarChart/+page.svelte b/packages/layerchart/src/routes/docs/components/BarChart/+page.svelte new file mode 100644 index 000000000..fabd06940 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/BarChart/+page.svelte @@ -0,0 +1,522 @@ + + +

Examples

+ +

Vertical (default)

+ + +
+ +
+
+ +

Horizontal

+ + +
+ +
+
+ +

Series

+ + +
+ +
+
+ +

Series (horizontal)

+ + +
+ +
+
+ +

Series data

+ + +
+ +
+
+ +

Series (diverging)

+ + +
+ -d.baseline, + color: 'hsl(var(--color-secondary))', + props: { rounded: 'bottom' }, + }, + ]} + > + + + + +
+
+ +

Series (horizontal / diverging)

+ + + {@const totalPopulation = sum(data.worldPopulationDemographics, (d) => d.male + d.female)} +
+ format(Math.abs(value), 'metric') }} + props={{ + xAxis: { format: (value) => format(Math.abs(value), 'metric') }, + yAxis: { rule: false }, + }} + series={[ + { + key: 'male', + value: (d) => -d.male, + color: 'hsl(var(--color-primary))', + props: { rounded: 'left' }, + }, + { + key: 'female', + color: 'hsl(var(--color-secondary))', + props: { rounded: 'right' }, + }, + ]} + > + + + + + + + Age: {format(y(data))} + + {#each series as s} + {@const valueAccessor = accessor(s.value ?? s.key)} + {@const value = Math.abs(valueAccessor(data))} + + {format(value)} + ({format(value / totalPopulation, 'percent')}) + + {/each} + + + + +
+
+ +
+ Data source: + Population pyramid + +
+ +

Series (horizontal / diverging) as percent

+ + + {@const totalPopulation = sum(data.worldPopulationDemographics, (d) => d.male + d.female)} +
+ format(Math.abs(value), 'percent') }} + props={{ + xAxis: { format: (value) => format(Math.abs(value), 'percentRound') }, + yAxis: { rule: false }, + }} + series={[ + { + key: 'male', + value: (d) => -d.male / totalPopulation, + color: 'hsl(var(--color-primary))', + props: { rounded: 'left' }, + }, + { + key: 'female', + value: (d) => d.female / totalPopulation, + color: 'hsl(var(--color-secondary))', + props: { rounded: 'right' }, + }, + ]} + > + + + + + + + Age: {format(y(data))} + + {#each series as s} + {@const valueAccessor = accessor(s.value ?? s.key)} + {@const value = Math.abs(valueAccessor(data))} + + {format(value * totalPopulation)} + ({format(value, 'percent')}) + + {/each} + + + + +
+
+ +
+ Data source: + Population pyramid + +
+ +

Group series

+ + +
+ +
+
+ +

Group series (horizontal)

+ + +
+ +
+
+ +

Group series (series / long data)

+ + +
+ +
+
+ +

Stack series

+ + +
+ +
+
+ +

Stack series (horizontal)

+ + +
+ +
+
+ + + + +

Labels

+ + +
+ +
+
+ +

Labels (inside placement)

+ + +
+ +
+
+ +

Sparkline

+ + +
+ +
+
+ +

Custom tooltip

+ + +
+ + + + {format(x(data), PeriodType.DayTime)} + + + + + + +
+
+ +

Custom chart

+ + +
+ + + format(value, undefined, { variant: 'short' })} + /> + format(value, undefined, { variant: 'short' })} + /> + + + + + + {format(x(data))} + + + + + +
+
diff --git a/packages/layerchart/src/routes/docs/components/BarChart/+page.ts b/packages/layerchart/src/routes/docs/components/BarChart/+page.ts new file mode 100644 index 000000000..4819e4651 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/BarChart/+page.ts @@ -0,0 +1,28 @@ +import { autoType, csvParse } from 'd3-dsv'; + +import api from '$lib/components/charts/BarChart.svelte?raw&sveld'; +import source from '$lib/components/charts/BarChart.svelte?raw'; +import pageSource from './+page.svelte?raw'; + +import type { WorldPopulationDemographicsData } from '$static/data/examples/world-population-demographics.js'; + +export async function load() { + return { + worldPopulationDemographics: (await fetch( + '/data/examples/world-population-demographics.csv' + ).then(async (r) => csvParse(await r.text(), autoType))) as WorldPopulationDemographicsData, + meta: { + api, + source, + pageSource, + description: 'Streamlined Chart configuration for Bar charts', + related: [ + 'components/Chart', + 'components/Bars', + 'examples/Bars', + 'examples/Histogram', + 'examples/Sparkbar', + ], + }, + }; +} diff --git a/packages/layerchart/src/routes/docs/components/Bars/+page.ts b/packages/layerchart/src/routes/docs/components/Bars/+page.ts index 9e2876d8d..f979343fe 100644 --- a/packages/layerchart/src/routes/docs/components/Bars/+page.ts +++ b/packages/layerchart/src/routes/docs/components/Bars/+page.ts @@ -8,7 +8,7 @@ export async function load() { api, source, pageSource, - related: ['examples/Bars', 'examples/Columns', 'examples/Histogram'], + related: ['components/Bar', 'examples/Bars', 'examples/Columns', 'examples/Histogram'], }, }; } diff --git a/packages/layerchart/src/routes/docs/components/Brush/+page.svelte b/packages/layerchart/src/routes/docs/components/Brush/+page.svelte index a4f689c50..3d2090bf0 100644 --- a/packages/layerchart/src/routes/docs/components/Brush/+page.svelte +++ b/packages/layerchart/src/routes/docs/components/Brush/+page.svelte @@ -1,7 +1,9 @@ + +

Examples

+ +

Basic

+ + +
+ +
+
+ +

Series

+ + +
+ +
+
+ +

Series (highlight on hover)

+ + +
+ + {@const series = [ + { key: 'apples', color: 'hsl(var(--color-danger))' }, + { key: 'bananas', color: 'hsl(var(--color-success))' }, + { key: 'oranges', color: 'hsl(var(--color-warning))' }, + ]} + {@const activeSeriesColor = series.find((s) => s.key === tooltip.data?.fruit)?.color} + + format(value, undefined, { variant: 'short' })} + /> + format(value, undefined, { variant: 'short' })} + /> + + {#each series as s} + {@const color = + tooltip.data == null || tooltip.data.fruit === s.key + ? s.color + : 'hsl(var(--color-surface-content) / 20%)'} + + {/each} + + + + + + {format(x(data))} + + + + + +
+
+ +

Labels

+ + +
+ +
+
+ +

Points

+ + +
+ +
+
+ +

Labels with Points

+ + +
+ +
+
+ +

Labels within points

+ + +
+ +
+
+ +

Radar

+ + +
+ '', + grid: { + class: 'stroke-surface-content/20 fill-surface-200/50', + }, + }, + highlight: { + lines: false, + }, + }} + tooltip={{ mode: 'voronoi' }} + /> +
+
+ +

Radar with series data

+ + +
+ +
+
+ +

Gradient encoding

+ + +
+ + + + + + + + + {#if tooltip.data} + + {/if} + + + + + {@const value = y(data)} + {format(x(data))} + + + + + + +
+
+ +

Gradient threshold

+ + +
+ + + {@const thresholdOffset = (yScale(50) / (height + padding.bottom)) * 100 + '%'} + + + + + +
+
+ +

Large series

+ + +
+ v + '° F' }, + highlight: { points: false }, + }} + series={flatGroup(data.dailyTemperatures, (d) => d.year).map(([year, data]) => { + return { + key: year, + data, + color: + year === 2024 + ? 'hsl(var(--color-primary))' + : year === 2023 + ? 'hsl(var(--color-primary) / 50%)' + : 'hsl(var(--color-surface-content))', + props: { opacity: [2023, 2024].includes(year) ? 1 : 0.1 }, + }; + })} + tooltip={{ mode: 'manual' }} + /> +
+
+ +

Radial large series

+ + +
+ [height / 5, height / 2]} + yNice={false} + yPadding={[0, 20]} + radial + props={{ + spline: { class: 'stroke' }, + xAxis: { format: PeriodType.Month }, + yAxis: { ticks: 4, format: (v) => v + '° F' }, + highlight: { points: false }, + }} + series={flatGroup(data.dailyTemperatures, (d) => d.year).map(([year, data]) => { + return { + key: year, + data, + color: + year === 2024 + ? 'hsl(var(--color-primary))' + : year === 2023 + ? 'hsl(var(--color-primary) / 50%)' + : 'hsl(var(--color-surface-content))', + props: { opacity: [2023, 2024].includes(year) ? 1 : 0.1 }, + }; + })} + tooltip={{ mode: 'manual' }} + /> +
+
+ +

Null gaps

+ + +
+ +
+
+ +

Null with dashed lines

+ + +
+ + + {#each series as s} + d.value !== null)} + y={s.value} + class="stroke-2 [stroke-dasharray:3,3]" + stroke={s.color} + /> + {/each} + + +
+
+ +

Sparkline

+ + +
+ +
+
+ +

Custom tooltip

+ + +
+ + + + {y(data)} + + + + {format(x(data), PeriodType.Day)} + + + +
+
+ +

Custom chart

+ + +
+ + + + format(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + + + + + {format(x(data), PeriodType.DayTime)} + + + + + +
+
diff --git a/packages/layerchart/src/routes/docs/components/LineChart/+page.ts b/packages/layerchart/src/routes/docs/components/LineChart/+page.ts new file mode 100644 index 000000000..204bda6c9 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/LineChart/+page.ts @@ -0,0 +1,43 @@ +import { csvParse, autoType } from 'd3-dsv'; +import { parse } from '@layerstack/utils'; + +import api from '$lib/components/charts/LineChart.svelte?raw&sveld'; +import source from '$lib/components/charts/LineChart.svelte?raw'; +import { celsiusToFahrenheit } from '$lib/utils/math.js'; +import pageSource from './+page.svelte?raw'; + +import type { AppleStockData } from '$static/data/examples/date/apple-stock.js'; + +export async function load() { + return { + appleStock: await fetch('/data/examples/date/apple-stock.json').then(async (r) => + parse(await r.text()) + ), + dailyTemperatures: await fetch('/data/examples/dailyTemperatures.csv').then(async (r) => { + return csvParse<{ dayOfYear: number; year: number; value: number | 'NA' }>( + await r.text(), + // @ts-expect-error + autoType + ) + .filter((d) => d.value !== 'NA' && d.dayOfYear <= 365 /* Ignore 366th day */) + .map((d) => { + const origDate = new Date(d.year, 0, d.dayOfYear); + return { + ...d, + date: new Date(Date.UTC(2000, origDate.getUTCMonth(), origDate.getUTCDate())), + value: d.value !== 'NA' ? celsiusToFahrenheit(d.value) : 'NA', + }; + }); + }), + dailyTemperature: await fetch('/data/examples/date/daily-temperature.json').then(async (r) => + parse<{ date: Date; value: number }[]>(await r.text()) + ), + meta: { + api, + source, + pageSource, + description: 'Streamlined Chart configuration for Line charts', + related: ['components/Chart', 'components/Spline', 'examples/Line'], + }, + }; +} diff --git a/packages/layerchart/src/routes/docs/components/Pie/+page.svelte b/packages/layerchart/src/routes/docs/components/Pie/+page.svelte index 8751ff79e..0c2a7ad5f 100644 --- a/packages/layerchart/src/routes/docs/components/Pie/+page.svelte +++ b/packages/layerchart/src/routes/docs/components/Pie/+page.svelte @@ -2,9 +2,10 @@ import { scaleOrdinal } from 'd3-scale'; import { format } from 'date-fns'; import { sum } from 'd3-array'; - import { cls, format as formatUtil } from 'svelte-ux'; + import { cls } from '@layerstack/tailwind'; + import { format as formatUtil } from '@layerstack/utils'; - import { Arc, Chart, Group, Pie, Svg, Text, Tooltip, TooltipItem } from 'layerchart'; + import { Arc, Chart, Group, Pie, Svg, Text, Tooltip } from 'layerchart'; import Preview from '$lib/docs/Preview.svelte'; import { createDateSeries } from '$lib/utils/genData.js'; @@ -36,8 +37,8 @@
- - + + @@ -48,16 +49,8 @@
- - + + @@ -68,8 +61,8 @@
- - + + @@ -80,8 +73,8 @@
- - + + @@ -92,8 +85,8 @@
- - + + @@ -106,8 +99,8 @@
- - + + @@ -118,8 +111,8 @@
- - + + @@ -130,8 +123,8 @@
- - + + @@ -142,8 +135,8 @@
- - + + @@ -154,8 +147,8 @@
- - + + @@ -167,8 +160,8 @@
- - + + @@ -179,8 +172,8 @@
- - + + @@ -191,8 +184,8 @@
- - + + {#each arcs as arc, index}
- - + + {#each arcs as arc, index} {@const colors = keyClasses[index]} @@ -231,7 +224,7 @@ y={centroid[1]} dy={-8} textAnchor="middle" - verticalAnchor="middle" + verticalAnchoc="middle" class={cls('text-base', colors.content)} /> @@ -255,27 +248,22 @@
- - + + - format(data.date, 'eee, MMMM do')} let:data> - - - + + {format(data.date, 'eee, MMMM do')} + + + + +
@@ -284,16 +272,8 @@
- - + + {#each arcs as arc, index} {@const colors = keyClasses[index]} @@ -322,7 +302,7 @@ x={centroid[0]} y={centroid[1]} textAnchor="middle" - verticalAnchor="middle" + verticalAnchoc="middle" class={cls('text-base', colors.content)} /> @@ -331,15 +311,18 @@ - format(data.date, 'eee, MMMM do')} let:data> - - - + + {format(data.date, 'eee, MMMM do')} + + + + +
@@ -350,20 +333,22 @@
- + - + + +
-

center (default)

+

center

- - + + @@ -374,9 +359,11 @@
- + - + + +
diff --git a/packages/layerchart/src/routes/docs/components/PieChart/+page.svelte b/packages/layerchart/src/routes/docs/components/PieChart/+page.svelte new file mode 100644 index 000000000..65127dfe9 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/PieChart/+page.svelte @@ -0,0 +1,240 @@ + + +

Examples

+ +

Basic

+ + +
+ +
+
+ +

Donut (innerRadius)

+ + +
+ +
+
+ +

Arc (range)

+ + +
+ +
+
+ +

Single value

+ + +
+ +
+
+ +

Single value gradient with text

+ + +
+ + + + + + + + + +
+
+ +

Single value (arc)

+ + +
+ +
+
+ +

Series data

+ + +
+ ({ key, data }))} + outerRadius={-25} + innerRadius={-20} + cornerRadius={5} + padAngle={0.01} + /> +
+
+ +

Series data (individual tracks)

+ + +
+ ({ key: d.fruit, data: [d] }))} + outerRadius={-25} + innerRadius={-20} + cornerRadius={10} + /> +
+
+ +

Series data (arc)

+ + +
+ ({ key: d.fruit, data: [d] }))} + range={[-90, 90]} + outerRadius={-25} + innerRadius={-20} + cornerRadius={10} + props={{ group: { y: 70 } }} + /> +
+
+ +

Series data (track color)

+ + +
+ ({ key: d.fruit, data: [d] }))} + props={{ + arc: { + track: { fill: 'hsl(var(--color-surface-content) / 10%)' }, + }, + }} + outerRadius={-25} + innerRadius={-20} + cornerRadius={10} + /> +
+
+ +

Series data (individual tracks, max value, and color)

+ + +
+ { + return { + key: d.label, + data: [d], + maxValue: d.maxValue, + color: d.color, + }; + })} + outerRadius={-25} + innerRadius={-20} + cornerRadius={10} + /> +
+
+ +

Inner component props (Arc class)

+ + +
+ +
+
+ +

Customize colors

+ + +
+ +
+
+ + diff --git a/packages/layerchart/src/routes/docs/components/PieChart/+page.ts b/packages/layerchart/src/routes/docs/components/PieChart/+page.ts new file mode 100644 index 000000000..d1eaceae4 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/PieChart/+page.ts @@ -0,0 +1,15 @@ +import api from '$lib/components/charts/PieChart.svelte?raw&sveld'; +import source from '$lib/components/charts/PieChart.svelte?raw'; +import pageSource from './+page.svelte?raw'; + +export async function load() { + return { + meta: { + api, + source, + pageSource, + description: 'Streamlined Chart configuration for Pie charts', + related: ['components/Chart', 'components/Pie', 'examples/Arc'], + }, + }; +} diff --git a/packages/layerchart/src/routes/docs/components/ScatterChart/+page.svelte b/packages/layerchart/src/routes/docs/components/ScatterChart/+page.svelte new file mode 100644 index 000000000..54a4cdfd3 --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/ScatterChart/+page.svelte @@ -0,0 +1,167 @@ + + +

Examples

+ +

Basic

+ + +
+ +
+
+ +

Radius via rScale

+ + +
+ +
+
+ +

Series

+ + +
+ { + return { + key: species, + data, + color: [ + 'hsl(var(--color-primary))', + 'hsl(var(--color-secondary))', + 'hsl(var(--color-success))', + ][i], + }; + })} + /> +
+
+ +

Series with radius

+ + +
+ { + return { + key: species, + data, + color: [ + 'hsl(var(--color-primary))', + 'hsl(var(--color-secondary))', + 'hsl(var(--color-success))', + ][i], + }; + })} + /> +
+
+ +

Labels

+ + +
+ +
+
+ +

Single dimension

+ + +
+ 0} + axis={false} + props={{ highlight: { lines: false } }} + > + + + {format(x(data))} + + + +
+
+ +

Custom tooltip

+ + +
+ + + + {format(y(data), 'integer')} + + + + {format(x(data), 'integer')} + + + +
+
+ +

Custom chart

+ + +
+ + + + + + + + + + {format(x(data), 'integer')} + + + + + +
+
diff --git a/packages/layerchart/src/routes/docs/components/ScatterChart/+page.ts b/packages/layerchart/src/routes/docs/components/ScatterChart/+page.ts new file mode 100644 index 000000000..caeed1dcc --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/ScatterChart/+page.ts @@ -0,0 +1,22 @@ +import { autoType, csvParse } from 'd3-dsv'; + +import api from '$lib/components/charts/ScatterChart.svelte?raw&sveld'; +import source from '$lib/components/charts/ScatterChart.svelte?raw'; +import pageSource from './+page.svelte?raw'; + +import type { PenguinsData } from '$static/data/examples/penguins.js'; + +export async function load() { + return { + penguins: (await fetch('/data/examples/penguins.csv').then(async (r) => + csvParse(await r.text(), autoType) + )) as PenguinsData, + meta: { + api, + source, + pageSource, + description: 'Streamlined Chart configuration for Scatter charts', + related: ['components/Chart', 'components/Points', 'examples/Scatter'], + }, + }; +} diff --git a/packages/layerchart/src/routes/docs/components/Tooltip/+page.svelte b/packages/layerchart/src/routes/docs/components/Tooltip/+page.svelte index f0171276f..74d5130b4 100644 --- a/packages/layerchart/src/routes/docs/components/Tooltip/+page.svelte +++ b/packages/layerchart/src/routes/docs/components/Tooltip/+page.svelte @@ -1,34 +1,13 @@ @@ -174,9 +153,109 @@ - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, 'eee, MMMM do')} + + + + +
+
+
+ +

Custom content

+ + +
+ + + + formatDate(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + + + Anything can go here test + +
+
+ +

color swatch

+ + +
+ + + + formatDate(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + + + + {format(data.date, 'eee, MMMM do')} + + + + + +
+
+ +

color swatch using theme

+ + +
+ + + + formatDate(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + + + + {format(data.date, 'eee, MMMM do')} + + + +
@@ -205,12 +284,14 @@ - -
+ + {format(data.date, 'eee, MMMM do')} -
- -
+ + + + +
@@ -240,9 +321,12 @@ - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, 'eee, MMMM do')} + + + +
@@ -271,9 +355,12 @@ - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, 'eee, MMMM do')} + + + +
@@ -305,28 +392,26 @@ - {data.value} - + - {formatDate(data.date, PeriodType.Day)} - +
@@ -388,17 +473,19 @@ - format(data.date, 'eee, MMMM do')} let:data > - - + {format(data.date, 'eee, MMMM do')} + + + +
@@ -441,14 +528,16 @@ axis={charts.area.axis} /> - format(data.date, 'eee, MMMM do')} let:data > - - + {format(data.date, 'eee, MMMM do')} + + + +
@@ -468,15 +557,16 @@ xScale={scaleTime()} y={[0, 1]} yNice - r="key" - rScale={scaleOrdinal()} - rDomain={keys} - rRange={['hsl(var(--color-info))', 'hsl(var(--color-success))', 'hsl(var(--color-warning))']} + c="key" + cScale={scaleOrdinal()} + cDomain={keys} + cRange={['hsl(var(--color-info))', 'hsl(var(--color-success))', 'hsl(var(--color-warning))']} padding={{ left: 16, bottom: 24 }} tooltip={{ mode: charts.areaStack.mode, debug: charts.areaStack.debug, }} + let:cGet > @@ -485,7 +575,17 @@ format={(d) => formatDate(d, PeriodType.Day, { variant: 'short' })} rule /> - + + {#each stackData as seriesData} + {@const color = cGet(seriesData)} + + {/each} + - format(data.data.date, 'eee, MMMM do')} let:data > - {#each keys as key} - - {/each} - + {format(data.data.date, 'eee, MMMM do')} + + {#each keys as key} + + {/each} + +
@@ -521,7 +623,6 @@ xScale={scaleTime()} y="name" yScale={scaleBand()} - yDomain={[...new Set(timeSeries.map((d) => d.name))]} padding={{ left: 36, bottom: 36 }} tooltip={{ mode: charts.dateTime.mode, @@ -539,14 +640,16 @@ axis={charts.dateTime.axis} /> - data.name} let:data > - - + {data.name} + + + +
@@ -567,7 +670,6 @@ xScale={scaleTime()} y="name" yScale={scaleBand()} - yDomain={[...new Set(timeSeries.map((d) => d.name))]} padding={{ left: 36, bottom: 36 }} tooltip={{ mode: charts.duration.mode, @@ -585,19 +687,21 @@ axis={charts.duration.axis} /> - data.name} let:data > - - - - - - - + {data.name} + + + + + + + + +
@@ -617,7 +721,6 @@ xScale={scaleTime()} y="name" yScale={scaleBand()} - yDomain={[...new Set(overlapTimeSeries.map((d) => d.name))]} padding={{ left: 36, bottom: 36 }} tooltip={{ mode: charts.multiDuration.mode, @@ -635,19 +738,21 @@ axis={charts.multiDuration.axis} /> - data.name} let:data > - - - - - - - + {data.name} + + + + + + + + +
@@ -691,14 +796,16 @@ axis={charts.bars.axis} /> - format(data.date, 'eee, MMMM do')} let:data > - - + {format(data.date, 'eee, MMMM do')} + + + +
@@ -751,15 +858,17 @@ : false} /> - format(data.date, 'eee, MMMM do')} let:data > - - - + {format(data.date, 'eee, MMMM do')} + + + + +
@@ -793,14 +902,16 @@ axis={charts.scatter.axis} /> - - - - + + + + +
diff --git a/packages/layerchart/src/routes/docs/components/Tooltip/+page.ts b/packages/layerchart/src/routes/docs/components/Tooltip/+page.ts index 54c872feb..91ffed3ef 100644 --- a/packages/layerchart/src/routes/docs/components/Tooltip/+page.ts +++ b/packages/layerchart/src/routes/docs/components/Tooltip/+page.ts @@ -1,5 +1,5 @@ -import api from '$lib/components/Tooltip.svelte?raw&sveld'; -import source from '$lib/components/Tooltip.svelte?raw'; +import api from '$lib/components/tooltip/Tooltip.svelte?raw&sveld'; +import source from '$lib/components/tooltip/Tooltip.svelte?raw'; import pageSource from './+page.svelte?raw'; export async function load() { diff --git a/packages/layerchart/src/routes/docs/components/Tooltip/TooltipControls.svelte b/packages/layerchart/src/routes/docs/components/Tooltip/TooltipControls.svelte index dc2876356..30f405b66 100644 --- a/packages/layerchart/src/routes/docs/components/Tooltip/TooltipControls.svelte +++ b/packages/layerchart/src/routes/docs/components/Tooltip/TooltipControls.svelte @@ -2,7 +2,7 @@ import type { ComponentProps } from 'svelte'; import { Field, MenuField, MultiSelectField, Switch } from 'svelte-ux'; - import type TooltipContext from '$lib/components/TooltipContext.svelte'; + import type TooltipContext from '$lib/components/tooltip/TooltipContext.svelte'; import type Highlight from '$lib/components/Highlight.svelte'; type TooltipContextProps = ComponentProps; @@ -18,7 +18,7 @@ }; -
+
options.map((x) => x.name).join(', ')} + formatSelected={({ options }) => options.map((x) => x.label).join(', ')} /> - -
{data.properties.name}
-
+ + {data.properties.name} +
@@ -269,7 +273,9 @@ /> - data.properties.name} /> + + {data.properties.name} +
diff --git a/packages/layerchart/src/routes/docs/examples/Arc/+page.svelte b/packages/layerchart/src/routes/docs/examples/Arc/+page.svelte index 40653b90e..e990ee4ba 100644 --- a/packages/layerchart/src/routes/docs/examples/Arc/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Arc/+page.svelte @@ -11,7 +11,9 @@ Tooltip, radiansToDegrees, } from 'layerchart'; - import { Field, RangeField, SpringValue, Switch, Toggle, cls, round } from 'svelte-ux'; + import { Field, RangeField, SpringValue, Switch, Toggle } from 'svelte-ux'; + import { cls } from '@layerstack/tailwind'; + import { round } from '@layerstack/utils'; import Preview from '$lib/docs/Preview.svelte'; @@ -49,30 +51,28 @@
- - - - - - - - - + + + + + + + @@ -84,35 +84,33 @@
- - - - - - + + + +
@@ -125,38 +123,36 @@
-
+
- - + + {#each { length: segments } as _, segmentIndex} {@const segmentAngle = (2 * Math.PI) / segments} {@const startAngle = segmentIndex * segmentAngle} {@const endAngle = (segmentIndex + 1) * segmentAngle} - - - - - + {/each} - + + +
@@ -167,32 +163,32 @@
- - - {#each { length: layerCount } as _, layerIndex} - {@const layer = layerIndex + 1} - {#each { length: divisions } as _, segmentIndex} - {@const segmentAngle = (2 * Math.PI) / divisions} - {@const startAngle = segmentIndex * segmentAngle} - {@const endAngle = (segmentIndex + 1) * segmentAngle} - {@const color = wheelSegmentColor(startAngle, layer)} - tooltip?.show(e, color)} - on:pointerleave={(e) => tooltip?.hide()} - /> - {/each} + + {#each { length: layerCount } as _, layerIndex} + {@const layer = layerIndex + 1} + {#each { length: divisions } as _, segmentIndex} + {@const segmentAngle = (2 * Math.PI) / divisions} + {@const startAngle = segmentIndex * segmentAngle} + {@const endAngle = (segmentIndex + 1) * segmentAngle} + {@const color = wheelSegmentColor(startAngle, layer)} + tooltip?.show(e, color)} + on:pointerleave={(e) => tooltip?.hide()} + /> {/each} - + {/each} - data} /> + + {data} +
@@ -209,40 +205,38 @@
- - - {#if show} - - - - {/if} - + + {#if show} + + + + {/if}
diff --git a/packages/layerchart/src/routes/docs/examples/Area/+page.svelte b/packages/layerchart/src/routes/docs/examples/Area/+page.svelte index 9562ba594..e8f4384fa 100644 --- a/packages/layerchart/src/routes/docs/examples/Area/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Area/+page.svelte @@ -2,7 +2,9 @@ import { cubicInOut } from 'svelte/easing'; import { scaleOrdinal, scaleTime } from 'd3-scale'; import { flatGroup } from 'd3-array'; + import { stack } from 'd3-shape'; import { format as formatDate } from 'date-fns'; + import { flatten } from 'layercake'; import { Area, @@ -14,14 +16,16 @@ LinearGradient, Point, RectClipPath, + Rule, Spline, Svg, Text, Tooltip, - TooltipItem, + chartDataArray, pivotLonger, } from 'layerchart'; - import { format, Field, Switch, Toggle, PeriodType } from 'svelte-ux'; + import { Field, Switch, Toggle, PeriodType } from 'svelte-ux'; + import { format } from '@layerstack/utils'; import Preview from '$lib/docs/Preview.svelte'; import { createDateSeries } from '$lib/utils/genData.js'; @@ -29,6 +33,12 @@ export let data; const dateSeriesData = createDateSeries({ count: 30, min: 50, max: 100, value: 'integer' }); + const negativeDateSeriesData = createDateSeries({ + count: 30, + min: -20, + max: 50, + value: 'integer', + }); const keys = ['apples', 'bananas', 'oranges']; const multiSeriesData = createDateSeries({ @@ -38,12 +48,14 @@ value: 'integer', keys, }); + const stackData = stack().keys(keys)(multiSeriesData) as any[]; const multiSeriesFlatData = pivotLonger(multiSeriesData, keys, 'fruit', 'value'); const dataByFruit = flatGroup(multiSeriesFlatData, (d) => d.fruit); + const fruitColors = { - apples: 'hsl(var(--color-info))', + apples: 'hsl(var(--color-danger))', bananas: 'hsl(var(--color-success))', - oranges: 'hsl(var(--color-warning))', + oranges: 'hsl(var(--color-info))', }; @@ -99,9 +111,12 @@ - formatDate(data.date, 'eee, MMMM do')} let:data> - - + + {formatDate(data.date, 'eee, MMMM do')} + + + +
@@ -203,13 +218,13 @@ y="value" yDomain={[0, null]} yNice - r="fruit" - rScale={scaleOrdinal()} - rDomain={Object.keys(fruitColors)} - rRange={Object.values(fruitColors)} + c="fruit" + cScale={scaleOrdinal()} + cDomain={Object.keys(fruitColors)} + cRange={Object.values(fruitColors)} padding={{ left: 16, bottom: 24, right: 48 }} tooltip={{ mode: 'voronoi' }} - let:rScale + let:cScale > @@ -219,7 +234,7 @@ rule /> {#each dataByFruit as [fruit, data]} - {@const color = rScale(fruit)} + {@const color = cScale(fruit)} - formatDate(data.date, 'eee, MMMM do')} let:data> - - + + {formatDate(data.date, 'eee, MMMM do')} + + + +
@@ -299,11 +317,14 @@ d.oranges} points={{ fill: fruitColors.oranges }} /> - formatDate(data.date, 'eee, MMMM do')} let:data> - - - - + + {formatDate(data.date, 'eee, MMMM do')} + + + + + +
@@ -319,14 +340,14 @@ y="value" yDomain={[0, null]} yNice - r="fruit" - rScale={scaleOrdinal()} - rDomain={Object.keys(fruitColors)} - rRange={Object.values(fruitColors)} + c="fruit" + cScale={scaleOrdinal()} + cDomain={Object.keys(fruitColors)} + cRange={Object.values(fruitColors)} padding={{ left: 16, bottom: 24, right: 48 }} tooltip={{ mode: 'voronoi' }} let:tooltip - let:rScale + let:cScale > @@ -338,7 +359,7 @@ {#each dataByFruit as [fruit, data]} {@const color = tooltip.data == null || tooltip.data.fruit === fruit - ? rScale(fruit) + ? cScale(fruit) : 'hsl(var(--color-surface-content) / 20%)'} - formatDate(data.date, 'eee, MMMM do')} let:data> - - + + {formatDate(data.date, 'eee, MMMM do')} + + + +
@@ -380,13 +404,13 @@ y="value" yDomain={[0, null]} yNice - r="fruit" - rScale={scaleOrdinal()} - rDomain={Object.keys(fruitColors)} - rRange={Object.values(fruitColors)} + c="fruit" + cScale={scaleOrdinal()} + cDomain={Object.keys(fruitColors)} + cRange={Object.values(fruitColors)} padding={{ left: 16, bottom: 24 }} tooltip={{ mode: 'voronoi' }} - let:rScale + let:cScale > @@ -396,7 +420,7 @@ rule /> {#each dataByFruit as [fruit, data]} - {@const color = rScale(fruit)} + {@const color = cScale(fruit)} - formatDate(data.date, 'eee, MMMM do')} let:data> - - + + {formatDate(data.date, 'eee, MMMM do')} + + + + + +
+ + +

Stack

+ + +
+ d.data.date} + xScale={scaleTime()} + y={[0, 1]} + yNice + c="key" + cScale={scaleOrdinal()} + cDomain={Object.keys(fruitColors)} + cRange={Object.values(fruitColors)} + padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'bisect-x' }} + let:data + let:cGet + let:cScale + > + + + format(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + {#each stackData as seriesData} + {@const color = cGet(seriesData)} + + {/each} + + + + + + {formatDate(data.data.date, 'eee, MMMM do')} + + {#each keys as key} + + {/each} + + + +
+
+ +

Stack with gradient

+ + +
+ d.data.date} + xScale={scaleTime()} + y={[0, 1]} + yNice + padding={{ left: 16, bottom: 24 }} + > + + + format(d, PeriodType.Day, { variant: 'short' })} + rule + /> + {@const primaryColors = [ + 'hsl(var(--color-danger-500))', + 'hsl(var(--color-success-500))', + 'hsl(var(--color-info-500))', + ]} + {@const secondaryColors = [ + 'hsl(var(--color-danger-500) / 10%)', + 'hsl(var(--color-success-500) / 10%)', + 'hsl(var(--color-info-500) / 10%)', + ]} + + {#each chartDataArray(stackData) as seriesData, index} + {@const primaryColor = primaryColors[index]} + {@const secondaryColor = secondaryColors[index]} + + + + + {/each} +
@@ -539,6 +664,239 @@ +

Threshold with RectClipPath

+ + +
+ + + + format(d, PeriodType.Day, { variant: 'short' })} /> + + + + + + + + + +
+
+ +

Threshold with RectClipPath (over/under)

+ + +
+ + + + format(d, PeriodType.Day, { variant: 'short' })} /> + + + + + + 0} line={{ class: 'stroke-2 stroke-danger' }} class="fill-danger/20" /> + + + +
+
+ +

Highlight color based on value using color scale

+ + +
+ (d.value < 0 ? 'under' : 'over')} + cScale={scaleOrdinal()} + cDomain={['over', 'under']} + cRange={['hsl(var(--color-success))', 'hsl(var(--color-danger))']} + let:width + let:height + let:yScale + > + + + format(d, PeriodType.Day, { variant: 'short' })} /> + + + 0} line={{ class: 'stroke-2 stroke-success' }} class="fill-success/20" /> + + + 0} line={{ class: 'stroke-2 stroke-danger' }} class="fill-danger/20" /> + + + + + + {formatDate(data.date, 'eee, MMMM do')} + + + + + +
+
+ +

Highlight color based on value using tooltip slot prop

+ + +
+ + + + format(d, PeriodType.Day, { variant: 'short' })} /> + + + 0} line={{ class: 'stroke-2 stroke-success' }} class="fill-success/20" /> + + + 0} line={{ class: 'stroke-2 stroke-danger' }} class="fill-danger/20" /> + + + + + + {formatDate(data.date, 'eee, MMMM do')} + + + + + +
+
+ +

Threshold with LinearGradient

+ + +
+ + {@const thresholdValue = 0} + {@const thresholdOffset = yScale(thresholdValue) / (height + padding.bottom)} + + + format(d, PeriodType.Day, { variant: 'short' })} /> + + + + + + +
+
+ +

Threshold with LinearGradient (over/under)

+ + +
+ + {@const thresholdValue = 0} + {@const thresholdOffset = yScale(thresholdValue) / (height + padding.bottom)} + + + format(d, PeriodType.Day, { variant: 'short' })} /> + + + 0} + line={{ stroke: url, class: 'stroke-2' }} + fill={url} + fill-opacity={0.2} + /> + + + +
+
+

Clipped area on Tooltip

@@ -568,7 +926,7 @@ - {format(data.value, 'currency')} - +
- + {format(data.date, PeriodType.Day)} - + - {format(data.date, PeriodType.Day)} - + diff --git a/packages/layerchart/src/routes/docs/examples/Area/+page.ts b/packages/layerchart/src/routes/docs/examples/Area/+page.ts index 035a27e5b..92d05db4d 100644 --- a/packages/layerchart/src/routes/docs/examples/Area/+page.ts +++ b/packages/layerchart/src/routes/docs/examples/Area/+page.ts @@ -1,4 +1,4 @@ -import { parse } from 'svelte-ux'; +import { parse } from '@layerstack/utils'; import pageSource from './+page.svelte?raw'; import type { AppleStockData } from '$static/data/examples/date/apple-stock.js'; diff --git a/packages/layerchart/src/routes/docs/examples/AreaStack/+page.svelte b/packages/layerchart/src/routes/docs/examples/AreaStack/+page.svelte deleted file mode 100644 index e076c3592..000000000 --- a/packages/layerchart/src/routes/docs/examples/AreaStack/+page.svelte +++ /dev/null @@ -1,182 +0,0 @@ - - -

Examples

- -

Basic

- - -
- d.data.date} - xScale={scaleTime()} - y={[0, 1]} - yNice - r="key" - rScale={scaleOrdinal()} - rDomain={keys} - rRange={['hsl(var(--color-danger))', 'hsl(var(--color-success))', 'hsl(var(--color-info))']} - padding={{ left: 16, bottom: 24 }} - > - - - formatDate(d, PeriodType.Day, { variant: 'short' })} - rule - /> - - - -
-
- -

With Tooltip and Highlight

- - -
- d.data.date} - xScale={scaleTime()} - y={[0, 1]} - yNice - r="key" - rScale={scaleOrdinal()} - rDomain={keys} - rRange={['hsl(var(--color-danger))', 'hsl(var(--color-success))', 'hsl(var(--color-info))']} - padding={{ left: 16, bottom: 24 }} - tooltip={{ mode: 'bisect-x' }} - > - - - formatDate(d, PeriodType.Day, { variant: 'short' })} - rule - /> - - - - format(data.data.date, 'eee, MMMM do')} let:data> - {#each keys as key} - - {/each} - - -
-
- - - - -

Slot with gradient

- - -
- d.data.date} - xScale={scaleTime()} - y={[0, 1]} - yNice - padding={{ left: 16, bottom: 24 }} - > - - - formatDate(d, PeriodType.Day, { variant: 'short' })} - rule - /> - - {@const primaryColorScale = scaleOrdinal([ - 'hsl(var(--color-danger-500))', - 'hsl(var(--color-success-500))', - 'hsl(var(--color-info-500))', - ])} - {@const secondaryColorScale = scaleOrdinal([ - 'hsl(var(--color-danger-500) / 10%)', - 'hsl(var(--color-success-500) / 10%)', - 'hsl(var(--color-info-500) / 10%)', - ])} - - {#each chartDataArray(data) as seriesData, index} - {@const primaryColor = primaryColorScale(String(index))} - {@const secondaryColor = secondaryColorScale(String(index))} - - - d[0]} - y1={(d) => d[1]} - fill={url} - fill-opacity={0.5} - line={{ stroke: primaryColor }} - /> - - {/each} - - - -
-
diff --git a/packages/layerchart/src/routes/docs/examples/Bars/+page.svelte b/packages/layerchart/src/routes/docs/examples/Bars/+page.svelte index 2f0162a66..4fd0624b1 100644 --- a/packages/layerchart/src/routes/docs/examples/Bars/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Bars/+page.svelte @@ -1,19 +1,11 @@

Examples

@@ -119,7 +118,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -145,7 +144,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -172,15 +171,20 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + @@ -203,7 +207,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + @@ -238,7 +247,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + @@ -277,7 +291,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -302,7 +316,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -328,7 +342,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -355,7 +369,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -383,7 +397,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} ticks={4} rule /> @@ -410,7 +424,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} ticks={(scale) => scaleTime(scale.domain(), scale.range()).ticks(4)} rule /> @@ -437,7 +451,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -465,7 +479,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -500,7 +514,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -534,7 +548,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -567,7 +581,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -604,7 +618,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -630,7 +644,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -644,7 +658,7 @@
Math.max(d.value, d.baseline)} + x={['value', 'baseline']} xDomain={[0, null]} xNice y="date" @@ -656,17 +670,63 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + + + +
+ + +

Multiple (diverging)

+ + +
+ -d.baseline]} + xNice + y="date" + yScale={scaleBand().padding(0.4)} + padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + > + + + format(d, PeriodType.Day, { variant: 'short' })} /> + + -d.baseline} + radius={4} + rounded="left" + strokeWidth={1} + class="fill-secondary" + /> + + + + + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + +
@@ -695,7 +755,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> {#if show} @@ -723,23 +783,53 @@
d.values))} + x="value" xNice y="year" yScale={scaleBand().paddingInner(0.3).paddingOuter(0.1)} - r={(d) => d} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + y1="fruit" + y1Scale={scaleBand()} + y1Domain={colorKeys} + y1Range={({ yScale }) => [0, yScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > - + + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + +
@@ -751,21 +841,48 @@ d.values))} xNice y="year" yScale={scaleBand().paddingInner(0.4).paddingOuter(0.1)} - r={(d) => d.keys[1]} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + + @@ -777,74 +894,105 @@ d.values))} xNice y="year" yScale={scaleBand().paddingInner(0.4).paddingOuter(0.1)} - r={(d) => d.keys[1]} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + + - -

Grouped and Stacked

d.values))} xNice y="year" yScale={scaleBand().paddingInner(0.4).paddingOuter(0.1)} - r={(d) => d} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + y1="basket" + y1Scale={scaleBand().padding(0.1)} + y1Domain={[1, 2]} + y1Range={({ yScale }) => [0, yScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > - + + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + +
@@ -867,35 +1015,33 @@ d.values))} xNice y="year" yScale={scaleBand().paddingInner(0.2).paddingOuter(0.1)} - r={(d) => { - // Color by fruit (last key) - return d.keys.at(-1); - }} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + y1={transitionChart.groupBy} + y1Scale={scaleBand().padding(0.1)} + y1Domain={transitionChart.groupBy + ? unique(transitionData.map((d) => d[transitionChart.groupBy])) + : undefined} + y1Range={({ yScale }) => [0, yScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} let:data - let:rScale + let:cScale > - {#each transitionData as bar (bar.keys - .filter((key) => typeof key !== 'number') - .join('-'))} + {#each transitionData as bar (bar.year + '-' + bar.fruit)} {/each} + - - - -

Click handler

+ + {data.year} + + {#each data.data as d} + + {/each} - -
- - - - formatDate(d, PeriodType.Day, { variant: 'short' })} - rule - /> - - - + + + + d.value)} + format="integer" + valueAlign="right" + /> + +
-

Click handlers for stack/grouped bars

+

Tooltip and click handlers for individual stack/grouped bar

@@ -963,35 +1102,33 @@ d.values))} xNice y="year" yScale={scaleBand().paddingInner(0.2).paddingOuter(0.1)} - r={(d) => { - // Color by fruit (last key) - return d.keys.at(-1); - }} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + y1={transitionChart.groupBy} + y1Scale={scaleBand().padding(0.1)} + y1Domain={transitionChart.groupBy + ? unique(transitionData.map((d) => d[transitionChart.groupBy])) + : undefined} + y1Range={({ yScale }) => [0, yScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} + let:tooltip let:data - let:rScale + let:cScale > - {#each transitionData as bar (bar.keys - .filter((key) => typeof key !== 'number') - .join('-'))} + {#each transitionData as bar (bar.year + '-' + bar.fruit)} { alert('You clicked on:\n' + JSON.stringify(bar, null, 2)); }} + on:pointerenter={(e) => tooltip?.show(e, bar)} + on:pointermove={(e) => tooltip?.show(e, bar)} + on:pointerleave={(e) => tooltip?.hide()} /> {/each} + + + {data.year} + + + + + +
+ + +

Click handler

+ + +
+ + + + format(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + +
diff --git a/packages/layerchart/src/routes/docs/examples/Bars/+page.ts b/packages/layerchart/src/routes/docs/examples/Bars/+page.ts index e737de2ed..b40169ef0 100644 --- a/packages/layerchart/src/routes/docs/examples/Bars/+page.ts +++ b/packages/layerchart/src/routes/docs/examples/Bars/+page.ts @@ -5,7 +5,7 @@ export async function load() { meta: { title: 'Bar Chart (Horizontal)', pageSource, - related: ['components/Bars', 'examples/Columns', 'examples/Histogram'], + related: ['components/Bars', 'examples/Columns', 'examples/Histogram', 'charts/BarChart'], }, }; } diff --git a/packages/layerchart/src/routes/docs/examples/Beeswarm/+page.svelte b/packages/layerchart/src/routes/docs/examples/Beeswarm/+page.svelte index b873137a8..0bb41a0b9 100644 --- a/packages/layerchart/src/routes/docs/examples/Beeswarm/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Beeswarm/+page.svelte @@ -1,9 +1,9 @@ @@ -126,7 +118,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -152,7 +144,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -179,15 +171,20 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + @@ -210,7 +207,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + @@ -245,7 +247,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + @@ -284,7 +291,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -309,7 +316,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -336,7 +343,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -364,7 +371,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -392,7 +399,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} ticks={4} rule /> @@ -419,7 +426,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} ticks={(scale) => scaleTime(scale.domain(), scale.range()).ticks(4)} rule /> @@ -446,7 +453,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -474,7 +481,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -509,7 +516,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -543,7 +550,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -577,7 +584,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -614,7 +621,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -640,7 +647,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> @@ -656,7 +663,7 @@ {data} x="date" xScale={scaleBand().padding(0.4)} - y={(d) => Math.max(d.value, d.baseline)} + y={['value', 'baseline']} yDomain={[0, null]} yNice={4} padding={{ left: 16, bottom: 24 }} @@ -666,17 +673,62 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> - format(data.date, 'eee, MMMM do')} let:data> - - - + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + + + + + + +

Multiple (diverging)

+ + +
+ -d.baseline]} + yNice={4} + padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'bisect-x' }} + > + + format(Math.abs(d), 'integer')} /> + format(d, PeriodType.Day, { variant: 'short' })} /> + + -d.baseline} + radius={4} + rounded="bottom" + strokeWidth={1} + class="fill-secondary" + /> + + + + + {format(data.date, PeriodType.Custom, { custom: 'eee, MMMM do' })} + + + + +
@@ -705,7 +757,7 @@ formatDate(d, PeriodType.Day, { variant: 'short' })} + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} rule /> {#if show} @@ -733,23 +785,53 @@
d.values))} + y="value" yNice={4} - r={(d) => d} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + x1="fruit" + x1Scale={scaleBand()} + x1Domain={colorKeys} + x1Range={({ xScale }) => [0, xScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > - + + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + +
@@ -763,19 +845,46 @@ x="year" xScale={scaleBand().paddingInner(0.4).paddingOuter(0.1)} y="values" - yDomain={extent(stackedData.flatMap((d) => d.values))} yNice={4} - r={(d) => d.keys[1]} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + + @@ -789,72 +898,103 @@ x="year" xScale={scaleBand().paddingInner(0.4).paddingOuter(0.1)} y="values" - yDomain={extent(stackedPercentData.flatMap((d) => d.values))} yNice={4} - r={(d) => d.keys[1]} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + + - -

Grouped and Stacked

d.values))} yNice={4} - r={(d) => d} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + x1="basket" + x1Scale={scaleBand().padding(0.1)} + x1Domain={[1, 2]} + x1Range={({ xScale }) => [0, xScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} + let:cScale > - + + + + + {data.year} + + {#each data.data as d} + + {/each} + + + + + d.value)} + format="integer" + valueAlign="right" + /> + +
@@ -873,39 +1013,36 @@
- d.values))} yNice={4} - r={(d) => { - // Color by fruit (last key) - return d.keys.at(-1); - }} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + x1={transitionChart.groupBy} + x1Scale={scaleBand().padding(0.1)} + x1Domain={transitionChart.groupBy + ? unique(transitionData.map((d) => d[transitionChart.groupBy])) + : undefined} + x1Range={({ xScale }) => [0, xScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} + tooltip={{ mode: 'band' }} let:data - let:rScale + let:cScale > - {#each transitionData as bar (bar.keys - .filter((key) => typeof key !== 'number') - .join('-'))} + {#each transitionData as bar (bar.year + '-' + bar.fruit)} {/each} + - -
-
-

Click handler

+ + {data.year} + + {#each data.data as d} + + {/each} - -
- - - - formatDate(d, PeriodType.Day, { variant: 'short' })} - rule - /> - - - + + + + d.value)} + format="integer" + valueAlign="right" + /> + +
-

Click handlers for stack/grouped bars

+

Tooltip and click handlers for individual stack/grouped bar

@@ -969,39 +1099,36 @@
- d.values))} yNice={4} - r={(d) => { - // Color by fruit (last key) - return d.keys.at(-1); - }} - rScale={scaleOrdinal()} - rDomain={colorKeys} - rRange={keyColors} + c="fruit" + cScale={scaleOrdinal()} + cDomain={colorKeys} + cRange={keyColors} + x1={transitionChart.groupBy} + x1Scale={scaleBand().padding(0.1)} + x1Domain={transitionChart.groupBy + ? unique(transitionData.map((d) => d[transitionChart.groupBy])) + : undefined} + x1Range={({ xScale }) => [0, xScale.bandwidth?.()]} padding={{ left: 16, bottom: 24 }} let:data - let:rScale + let:cScale + let:tooltip > - {#each transitionData as bar (bar.keys - .filter((key) => typeof key !== 'number') - .join('-'))} + {#each transitionData as bar (bar.year + '-' + bar.fruit)} { alert('You clicked on:\n' + JSON.stringify(bar, null, 2)); }} + on:pointerenter={(e) => tooltip?.show(e, bar)} + on:pointermove={(e) => tooltip?.show(e, bar)} + on:pointerleave={(e) => tooltip?.hide()} /> {/each} + + + {data.year} + + + + + +
+
+ +

Click handler

+ + +
+ + + + format(d, PeriodType.Day, { variant: 'short' })} + rule + /> + + +
diff --git a/packages/layerchart/src/routes/docs/examples/Compound/+page.svelte b/packages/layerchart/src/routes/docs/examples/Compound/+page.svelte index 998be57b1..15407e4ff 100644 --- a/packages/layerchart/src/routes/docs/examples/Compound/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Compound/+page.svelte @@ -1,19 +1,7 @@

Examples

@@ -23,15 +16,20 @@
+ yScale.domain()} padding={{ top: 24, bottom: 24, left: 24, right: 24 }} tooltip={{ mode: 'bisect-x' }} let:height + let:y1Scale > - efficiencyScale(d.efficiency)} class="stroke-2 stroke-secondary" /> + y1Scale(d.efficiency)} class="stroke-2 stroke-secondary" /> - efficiencyScale(d.efficiency)} /> + y1Scale(d.efficiency)} /> - data.year} let:data> - - - + + {data.year} + + + + +
@@ -115,10 +116,13 @@ - data.year} let:data> - - - + + {data.year} + + + + +
diff --git a/packages/layerchart/src/routes/docs/examples/EarthquakeGlobe/+page.svelte b/packages/layerchart/src/routes/docs/examples/EarthquakeGlobe/+page.svelte index c99111b5f..5f4de7b67 100644 --- a/packages/layerchart/src/routes/docs/examples/EarthquakeGlobe/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/EarthquakeGlobe/+page.svelte @@ -3,18 +3,10 @@ import { scaleSqrt } from 'd3-scale'; import { feature } from 'topojson-client'; - import { Button, ButtonGroup, Field, RangeField, timerStore } from 'svelte-ux'; - - import { - Chart, - GeoCircle, - GeoPath, - Graticule, - Svg, - Tooltip, - TooltipItem, - TransformContext, - } from 'layerchart'; + import { Button, ButtonGroup, Field, RangeField } from 'svelte-ux'; + import { timerStore } from '@layerstack/svelte-stores'; + + import { Chart, GeoCircle, GeoPath, Graticule, Svg, Tooltip, TransformContext } from 'layerchart'; import Preview from '$lib/docs/Preview.svelte'; export let data; @@ -123,11 +115,14 @@ {/each} - d.place} let:data> - - - - + + {data.place} + + + + + + diff --git a/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.svelte b/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.svelte index 58a966090..e742ef545 100644 --- a/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.svelte @@ -7,16 +7,10 @@ import { Chart, GeoPath, Graticule, Legend, Svg, Tooltip, TransformContext } from 'layerchart'; - import { - Button, - ButtonGroup, - Field, - RangeField, - format, - timerStore, - PeriodType, - cls, - } from 'svelte-ux'; + import { Button, ButtonGroup, Field, RangeField } from 'svelte-ux'; + import { format, PeriodType } from '@layerstack/utils'; + import { cls } from '@layerstack/tailwind'; + import { timerStore } from '@layerstack/svelte-stores'; import Preview from '$lib/docs/Preview.svelte'; @@ -128,7 +122,9 @@ {/each} - format(d.Date, PeriodType.Day, { variant: 'long' })} /> + + {format(data.Date, PeriodType.Day, { variant: 'long' })} + diff --git a/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.ts b/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.ts index debc9a49d..b7f81d1f3 100644 --- a/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.ts +++ b/packages/layerchart/src/routes/docs/examples/EclipsesGlobe/+page.ts @@ -1,6 +1,6 @@ import type { GeometryCollection, Topology } from 'topojson-specification'; import pageSource from './+page.svelte?raw'; -import { parse } from 'svelte-ux'; +import { parse } from '@layerstack/utils'; export async function load({ fetch }) { return { diff --git a/packages/layerchart/src/routes/docs/examples/ForceDisjointGraph/+page.svelte b/packages/layerchart/src/routes/docs/examples/ForceDisjointGraph/+page.svelte index 3a2c88e68..b488e5ad9 100644 --- a/packages/layerchart/src/routes/docs/examples/ForceDisjointGraph/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/ForceDisjointGraph/+page.svelte @@ -4,7 +4,7 @@ import { scaleOrdinal } from 'd3-scale'; import { schemeCategory10 } from 'd3-scale-chromatic'; - import { Chart, Circle, ForceSimulation, Group, Link, Svg } from 'layerchart'; + import { Chart, Circle, ForceSimulation, Link, Svg } from 'layerchart'; import Preview from '$lib/docs/Preview.svelte'; @@ -26,7 +26,7 @@
- + - - {#key nodes} - {#each links as link} - - {/each} - {/key} - - {#each nodes as node} - + {#key nodes} + {#each links as link} + {/each} - + {/key} + + {#each nodes as node} + + {/each} diff --git a/packages/layerchart/src/routes/docs/examples/ForceGraph/+page.svelte b/packages/layerchart/src/routes/docs/examples/ForceGraph/+page.svelte index e71a76cdd..8018f16d5 100644 --- a/packages/layerchart/src/routes/docs/examples/ForceGraph/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/ForceGraph/+page.svelte @@ -290,7 +290,9 @@ - d.id} /> + + {data.id} +
diff --git a/packages/layerchart/src/routes/docs/examples/ForceLattice/+page.svelte b/packages/layerchart/src/routes/docs/examples/ForceLattice/+page.svelte index c89e68727..5bf98a343 100644 --- a/packages/layerchart/src/routes/docs/examples/ForceLattice/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/ForceLattice/+page.svelte @@ -2,7 +2,7 @@ import { forceManyBody, forceLink } from 'd3-force'; import { curveLinear } from 'd3-shape'; - import { Chart, Circle, ForceSimulation, Group, Link, Svg } from 'layerchart'; + import { Chart, Circle, ForceSimulation, Link, Svg } from 'layerchart'; import Preview from '$lib/docs/Preview.svelte'; @@ -25,7 +25,7 @@
- + - - {#key nodes} - {#each links as link} - - {/each} - {/key} - - {#each nodes as node} - + {#key nodes} + {#each links as link} + {/each} - + {/key} + + {#each nodes as node} + + {/each} diff --git a/packages/layerchart/src/routes/docs/examples/ForceText/+page.svelte b/packages/layerchart/src/routes/docs/examples/ForceText/+page.svelte new file mode 100644 index 000000000..80495ca98 --- /dev/null +++ b/packages/layerchart/src/routes/docs/examples/ForceText/+page.svelte @@ -0,0 +1,140 @@ + + +

Examples

+ +
+ + + + +
+
+ + + + + + + +
+ + +
+ + (i ? 0 : (-width * 2) / 10)), + }), + }} + alphaTarget={1} + velocityDecay={0.2} + let:nodes + > + + + + + + + + { + mouseNode.xTarget = e.offsetX; + mouseNode.yTarget = e.offsetY; + }} + class="fill-transparent" + /> + + + +
+
diff --git a/packages/layerchart/src/routes/docs/examples/AreaStack/+page.ts b/packages/layerchart/src/routes/docs/examples/ForceText/+page.ts similarity index 61% rename from packages/layerchart/src/routes/docs/examples/AreaStack/+page.ts rename to packages/layerchart/src/routes/docs/examples/ForceText/+page.ts index 48dcda64e..cdeabe134 100644 --- a/packages/layerchart/src/routes/docs/examples/AreaStack/+page.ts +++ b/packages/layerchart/src/routes/docs/examples/ForceText/+page.ts @@ -4,6 +4,7 @@ export async function load() { return { meta: { pageSource, + related: ['https://d3og.com/armollica/06a202c9f7df191ace8a1f97e33ffb97/'], }, }; } diff --git a/packages/layerchart/src/routes/docs/examples/ForceTree/+page.svelte b/packages/layerchart/src/routes/docs/examples/ForceTree/+page.svelte index 3c9e99cd0..acb6e8fa2 100644 --- a/packages/layerchart/src/routes/docs/examples/ForceTree/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/ForceTree/+page.svelte @@ -2,17 +2,8 @@ import { hierarchy } from 'd3-hierarchy'; import { forceX, forceY, forceManyBody, forceLink } from 'd3-force'; - import { - Chart, - Circle, - ForceSimulation, - Group, - Link, - Svg, - Tooltip, - TooltipItem, - } from 'layerchart'; - import { cls } from 'svelte-ux'; + import { Chart, Circle, ForceSimulation, Link, Svg, Tooltip } from 'layerchart'; + import { cls } from '@layerstack/tailwind'; import Preview from '$lib/docs/Preview.svelte'; @@ -33,7 +24,7 @@
- + - - {#key nodes} - {#each links as link} - - {/each} - {/key} - - {#each nodes as node} - tooltip.show(e, node)} - on:pointerleave={tooltip.hide} - /> + {#key nodes} + {#each links as link} + {/each} - + {/key} + + {#each nodes as node} + tooltip.show(e, node)} + on:pointerleave={tooltip.hide} + /> + {/each} - d.data.name} let:data> - {#if data.data.children} - - {/if} - {#if data.data.value} - - {/if} - + + {data.data.name} + + {#if data.data.children} + + {/if} + {#if data.data.value} + + {/if} + +
diff --git a/packages/layerchart/src/routes/docs/examples/GeoPath/+page.svelte b/packages/layerchart/src/routes/docs/examples/GeoPath/+page.svelte index 36469c810..210db93d7 100644 --- a/packages/layerchart/src/routes/docs/examples/GeoPath/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/GeoPath/+page.svelte @@ -2,7 +2,7 @@ import { geoAlbersUsa } from 'd3-geo'; import { feature } from 'topojson-client'; - import { Canvas, Chart, GeoPath, HitCanvas, Svg, Tooltip, TooltipItem } from 'layerchart'; + import { Canvas, Chart, GeoPath, HitCanvas, Svg, Tooltip } from 'layerchart'; import Preview from '$lib/docs/Preview.svelte'; export let data; @@ -38,11 +38,15 @@ class="fill-none stroke-surface-content/20 pointer-events-none" /> - data.properties.name} let:data> + + {@const [longitude, latitude] = projection.invert?.([tooltip.x, tooltip.y]) ?? []} - - - + {data.properties.name} + + + + +
@@ -94,11 +98,14 @@ /> - data.properties.name} let:data> + {@const [longitude, latitude] = projection.invert?.([tooltip.x, tooltip.y]) ?? []} - - - + {data.properties.name} + + + + +
diff --git a/packages/layerchart/src/routes/docs/examples/GeoPoint/+page.svelte b/packages/layerchart/src/routes/docs/examples/GeoPoint/+page.svelte index 00b9fd2ec..460978a99 100644 --- a/packages/layerchart/src/routes/docs/examples/GeoPoint/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/GeoPoint/+page.svelte @@ -3,7 +3,7 @@ import { feature } from 'topojson-client'; import { Field, Switch } from 'svelte-ux'; - import { Canvas, Chart, GeoPath, GeoPoint, Svg, Text, Tooltip, TooltipItem } from 'layerchart'; + import { Canvas, Chart, GeoPath, GeoPoint, Svg, Text, Tooltip } from 'layerchart'; import Preview from '$lib/docs/Preview.svelte'; export let data; @@ -112,11 +112,13 @@ - + @@ -173,10 +175,13 @@ - d.name} let:data> - - - + + {data.name} + + + + + @@ -229,10 +234,13 @@ - d.name} let:data> - - - + + {data.name} + + + + + diff --git a/packages/layerchart/src/routes/docs/examples/GeoProjection/+page.svelte b/packages/layerchart/src/routes/docs/examples/GeoProjection/+page.svelte index 7fc74608b..67d2331ff 100644 --- a/packages/layerchart/src/routes/docs/examples/GeoProjection/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/GeoProjection/+page.svelte @@ -95,7 +95,10 @@ /> {/each} - data.properties.name} let:data /> + + + {data.properties.name} + diff --git a/packages/layerchart/src/routes/docs/examples/GeoTile/+page.svelte b/packages/layerchart/src/routes/docs/examples/GeoTile/+page.svelte index 9d7b548f9..bd0956f91 100644 --- a/packages/layerchart/src/routes/docs/examples/GeoTile/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/GeoTile/+page.svelte @@ -3,7 +3,7 @@ import { geoMercator } from 'd3-geo'; import { feature } from 'topojson-client'; - import { Canvas, ClipPath, Chart, GeoPath, GeoTile, Svg, Tooltip, TooltipItem } from 'layerchart'; + import { Canvas, ClipPath, Chart, GeoPath, GeoTile, Svg, Tooltip } from 'layerchart'; import { Field, RangeField, Switch } from 'svelte-ux'; import Preview from '$lib/docs/Preview.svelte'; @@ -61,11 +61,15 @@ /> {/each} - data.properties.name} let:data> + + {@const [longitude, latitude] = projection.invert?.([tooltip.x, tooltip.y]) ?? []} - - - + {data.properties.name} + + + + +
@@ -97,11 +101,15 @@ /> {/each} - data.properties.name} let:data> + + {@const [longitude, latitude] = projection.invert?.([tooltip.x, tooltip.y]) ?? []} - - - + {data.properties.name} + + + + + diff --git a/packages/layerchart/src/routes/docs/examples/Histogram/+page.svelte b/packages/layerchart/src/routes/docs/examples/Histogram/+page.svelte index fd9d83f60..b67962c43 100644 --- a/packages/layerchart/src/routes/docs/examples/Histogram/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Histogram/+page.svelte @@ -12,18 +12,9 @@ import { timeDays, timeMonths, timeWeeks } from 'd3-time'; import { subDays } from 'date-fns'; - import { - Axis, - Bars, - Chart, - Highlight, - Svg, - Tooltip, - TooltipItem, - TooltipSeparator, - thresholdTime, - } from 'layerchart'; - import { MenuField, RangeField, NumberStepper, format, PeriodType, State } from 'svelte-ux'; + import { Axis, Bars, Chart, Highlight, Svg, Tooltip, thresholdTime } from 'layerchart'; + import { MenuField, RangeField, NumberStepper, State } from 'svelte-ux'; + import { format, PeriodType } from '@layerstack/utils'; import Preview from '$lib/docs/Preview.svelte'; @@ -80,17 +71,20 @@ - data.x0 + ' - ' + (data.x1 - 1)} let:data> - - - {#each data.slice(0, 5) as d} - - {/each} - {#if data.length > 5} - - ... - {/if} - + + {data.x0 + ' - ' + (data.x1 - 1)} + + + + {#each data.slice(0, 5) as d} + + {/each} + {#if data.length > 5} + + ... + {/if} + + @@ -115,17 +109,20 @@ - data.x0 + ' - ' + (data.x1 - 1)} let:data> - - - {#each data.slice(0, 5) as d} - - {/each} - {#if data.length > 5} - - ... - {/if} - + + {data.x0 + ' - ' + (data.x1 - 1)} + + + + {#each data.slice(0, 5) as d} + + {/each} + {#if data.length > 5} + + ... + {/if} + + @@ -207,17 +204,20 @@ - data.x0 + ' - ' + (data.x1 - 0.01)} let:data> - - - {#each data.slice(0, 5) as d} - - {/each} - {#if data.length > 5} - - ... - {/if} - + + {data.x0 + ' - ' + (data.x1 - 0.01)} + + + + {#each data.slice(0, 5) as d} + + {/each} + {#if data.length > 5} + + ... + {/if} + + @@ -262,25 +262,28 @@ - - format(data.x0, PeriodType.Day) + ' - ' + format(data.x1, PeriodType.Day)} - let:data - > - - - {#each data.slice(0, 5) as d} - format(value, PeriodType.DayTime)} - /> - {/each} - {#if data.length > 5} - - ... - {/if} - + + + {format(data.x0, PeriodType.Day) + + ' - ' + + format(data.x1, PeriodType.Day)} + + + + {#each data.slice(0, 5) as d} + format(value, PeriodType.DayTime)} + /> + {/each} + {#if data.length > 5} + + ... + {/if} + + @@ -339,25 +342,28 @@ - - format(data.x0, PeriodType.Day) + ' - ' + format(new Date(data.x1 - 1), PeriodType.Day)} - let:data - > - - - {#each data.slice(0, 5) as d} - format(value, PeriodType.DayTime)} - /> - {/each} - {#if data.length > 5} - - ... - {/if} - + + {format(data.x0, PeriodType.Day) + + ' - ' + + format(new Date(data.x1 - 1), PeriodType.Day)} + + + + {#each data.slice(0, 5) as d} + format(value, PeriodType.DayTime)} + /> + {/each} + {#if data.length > 5} + + ... + {/if} + + diff --git a/packages/layerchart/src/routes/docs/examples/Line/+page.svelte b/packages/layerchart/src/routes/docs/examples/Line/+page.svelte index 7a6136e88..47a6985bb 100644 --- a/packages/layerchart/src/routes/docs/examples/Line/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Line/+page.svelte @@ -3,7 +3,7 @@ import { extent, flatGroup, ticks } from 'd3-array'; import { interpolateTurbo } from 'd3-scale-chromatic'; import { format } from 'date-fns'; - import { formatDate, PeriodType } from 'svelte-ux/utils/date'; + import { formatDate, PeriodType } from '@layerstack/utils'; import { Axis, @@ -16,7 +16,6 @@ Svg, Text, Tooltip, - TooltipItem, pivotLonger, } from 'layerchart'; @@ -104,9 +103,13 @@ - format(data.date, 'eee, MMMM do')} let:data> - - + + + {format(data.date, 'eee, MMMM do')} + + + + @@ -226,13 +229,13 @@ y="value" yDomain={[0, null]} yNice - r="fruit" - rScale={scaleOrdinal()} - rDomain={Object.keys(fruitColors)} - rRange={Object.values(fruitColors)} + c="fruit" + cScale={scaleOrdinal()} + cDomain={Object.keys(fruitColors)} + cRange={Object.values(fruitColors)} padding={{ left: 16, bottom: 24, right: 48 }} tooltip={{ mode: 'voronoi' }} - let:rScale + let:cScale > @@ -242,7 +245,7 @@ rule /> {#each dataByFruit as [fruit, data]} - {@const color = rScale(fruit)} + {@const color = cScale(fruit)} @@ -259,9 +262,13 @@ {/each} - format(data.date, 'eee, MMMM do')} let:data> - - + + + {format(data.date, 'eee, MMMM do')} + + + + @@ -280,7 +287,7 @@ y="y" yDomain={[0, null]} yNice - padding={{ left: 16, bottom: 24, right: 48 }} + padding={{ left: 16, bottom: 24 }} tooltip={{ mode: 'bisect-x' }} > @@ -296,10 +303,13 @@ d.y1} points={{ fill: fruitColors.oranges }} /> - - - - + + + + + + + @@ -315,14 +325,14 @@ y="value" yDomain={[0, null]} yNice - r="fruit" - rScale={scaleOrdinal()} - rDomain={Object.keys(fruitColors)} - rRange={Object.values(fruitColors)} + c="fruit" + cScale={scaleOrdinal()} + cDomain={Object.keys(fruitColors)} + cRange={Object.values(fruitColors)} padding={{ left: 16, bottom: 24, right: 48 }} tooltip={{ mode: 'voronoi' }} let:tooltip - let:rScale + let:cScale > @@ -334,7 +344,7 @@ {#each dataByFruit as [fruit, data]} {@const color = tooltip.data == null || tooltip.data.fruit === fruit - ? rScale(fruit) + ? cScale(fruit) : 'hsl(var(--color-surface-content) / 20%)'} @@ -352,9 +362,12 @@ {/each} - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, 'eee, MMMM do')} + + + + @@ -370,13 +383,13 @@ y="value" yDomain={[0, null]} yNice - r="fruit" - rScale={scaleOrdinal()} - rDomain={Object.keys(fruitColors)} - rRange={Object.values(fruitColors)} + c="fruit" + cScale={scaleOrdinal()} + cDomain={Object.keys(fruitColors)} + cRange={Object.values(fruitColors)} padding={{ left: 16, bottom: 24 }} tooltip={{ mode: 'voronoi' }} - let:rScale + let:cScale > @@ -386,15 +399,18 @@ rule /> {#each dataByFruit as [fruit, data]} - {@const color = rScale(fruit)} + {@const color = cScale(fruit)} {/each} - format(data.date, 'eee, MMMM do')} let:data> - - + + {format(data.date, 'eee, MMMM do')} + + + + diff --git a/packages/layerchart/src/routes/docs/examples/Line/+page.ts b/packages/layerchart/src/routes/docs/examples/Line/+page.ts index 5805f073b..f2cb67afe 100644 --- a/packages/layerchart/src/routes/docs/examples/Line/+page.ts +++ b/packages/layerchart/src/routes/docs/examples/Line/+page.ts @@ -1,4 +1,4 @@ -import { parse } from 'svelte-ux'; +import { parse } from '@layerstack/utils'; import pageSource from './+page.svelte?raw'; diff --git a/packages/layerchart/src/routes/docs/examples/Pack/+page.svelte b/packages/layerchart/src/routes/docs/examples/Pack/+page.svelte index 8ed65a7de..a686b0e2b 100644 --- a/packages/layerchart/src/routes/docs/examples/Pack/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Pack/+page.svelte @@ -8,16 +8,8 @@ import { hsl } from 'd3-color'; import { Chart, Circle, Group, Pack, Svg, TransformContext, findAncestor } from 'layerchart'; - import { - Breadcrumb, - Button, - Field, - RangeField, - ToggleGroup, - ToggleOption, - format, - sortFunc, - } from 'svelte-ux'; + import { Breadcrumb, Button, Field, RangeField, ToggleGroup, ToggleOption } from 'svelte-ux'; + import { format, sortFunc } from '@layerstack/utils'; import Preview from '$lib/docs/Preview.svelte'; diff --git a/packages/layerchart/src/routes/docs/examples/Partition/+page.svelte b/packages/layerchart/src/routes/docs/examples/Partition/+page.svelte index 7b3f426d8..84b68314e 100644 --- a/packages/layerchart/src/routes/docs/examples/Partition/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Partition/+page.svelte @@ -28,10 +28,9 @@ Switch, ToggleGroup, ToggleOption, - cls, - format, - sortFunc, } from 'svelte-ux'; + import { format, sortFunc } from '@layerstack/utils'; + import { cls } from '@layerstack/tailwind'; import Preview from '$lib/docs/Preview.svelte'; diff --git a/packages/layerchart/src/routes/docs/examples/PunchCard/+page.svelte b/packages/layerchart/src/routes/docs/examples/PunchCard/+page.svelte index 0e14265fa..47696ef01 100644 --- a/packages/layerchart/src/routes/docs/examples/PunchCard/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/PunchCard/+page.svelte @@ -3,8 +3,8 @@ import { max, range } from 'd3-array'; import { getDay, getWeek } from 'date-fns'; - import { Axis, Chart, Circle, Highlight, Points, Svg, Tooltip, TooltipItem } from 'layerchart'; - import { formatDate, PeriodType } from 'svelte-ux'; + import { Axis, Chart, Circle, Highlight, Points, Svg, Tooltip } from 'layerchart'; + import { formatDate, PeriodType } from '@layerstack/utils'; import Preview from '$lib/docs/Preview.svelte'; import { createDateSeries } from '$lib/utils/genData.js'; @@ -59,9 +59,12 @@ - formatDate(d.date, PeriodType.Day)} let:data> - - + + {formatDate(data.date, PeriodType.Day)} + + + + diff --git a/packages/layerchart/src/routes/docs/examples/RadialLine/+page.svelte b/packages/layerchart/src/routes/docs/examples/RadialLine/+page.svelte index b88c1207e..8d20134aa 100644 --- a/packages/layerchart/src/routes/docs/examples/RadialLine/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/RadialLine/+page.svelte @@ -2,9 +2,10 @@ import { scaleBand, scaleUtc } from 'd3-scale'; import { flatGroup } from 'd3-array'; import { curveLinearClosed, curveCatmullRomClosed, curveCatmullRom } from 'd3-shape'; - import { Field, PeriodType, ToggleGroup, ToggleOption, cls } from 'svelte-ux'; + import { Field, PeriodType, ToggleGroup, ToggleOption } from 'svelte-ux'; + import { cls } from '@layerstack/tailwind'; - import { Area, Axis, Chart, Group, Points, Spline, Svg } from 'layerchart'; + import { Area, Axis, Chart, Points, Spline, Svg } from 'layerchart'; import Preview from '$lib/docs/Preview.svelte'; @@ -38,25 +39,23 @@ data={pitchData} x="name" xScale={scaleBand()} - xDomain={pitchData.map((d) => d.name)} xRange={[0, 2 * Math.PI]} y="value" yRange={({ height }) => [0, height / 2]} yPadding={[0, 10]} padding={{ top: 32, bottom: 8 }} + radial > - - - ''} - /> - - - - + + ''} + /> + + + @@ -73,27 +72,24 @@ xRange={[0, 2 * Math.PI]} y={['minmin', 'maxmax']} yRange={({ height }) => [height / 5, height / 2]} + radial > - - - d.avg} radial curve={curveCatmullRom} class="stroke-primary" /> - d.min} - y1={(d) => d.max} - curve={curveCatmullRomClosed} - class="fill-primary/20" - /> - d.minmin} - y1={(d) => d.maxmax} - curve={curveCatmullRomClosed} - class="fill-primary/20" - /> - - v + '° F'} /> - + + d.avg} curve={curveCatmullRom} class="stroke-primary" /> + d.min} + y1={(d) => d.max} + curve={curveCatmullRomClosed} + class="fill-primary/20" + /> + d.minmin} + y1={(d) => d.maxmax} + curve={curveCatmullRomClosed} + class="fill-primary/20" + /> + + v + '° F'} /> @@ -113,28 +109,26 @@ yPadding={[0, 20]} zDomain={[1940, 2024]} zRange={[0.1, 0.2]} + radial let:zScale > - - - {#each flatGroup(data.dailyTemperatures, (d) => d.year) as [year, yearData]} - - {/each} - - v + '° F'} /> - + + {#each flatGroup(data.dailyTemperatures, (d) => d.year) as [year, yearData]} + + {/each} + + v + '° F'} /> diff --git a/packages/layerchart/src/routes/docs/examples/Sankey/+page.svelte b/packages/layerchart/src/routes/docs/examples/Sankey/+page.svelte index ea725ecf6..633683866 100644 --- a/packages/layerchart/src/routes/docs/examples/Sankey/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Sankey/+page.svelte @@ -5,7 +5,9 @@ import { hierarchy } from 'd3-hierarchy'; import { interpolateCool } from 'd3-scale-chromatic'; import { extent } from 'd3-array'; - import { Icon, cls, sortFunc } from 'svelte-ux'; + import { Icon } from 'svelte-ux'; + import { sortFunc } from '@layerstack/utils'; + import { cls } from '@layerstack/tailwind'; import { mdiArrowRightBold } from '@mdi/js'; import { @@ -17,8 +19,6 @@ Svg, Text, Tooltip, - TooltipItem, - TooltipSeparator, graphFromHierarchy, graphFromNode, } from 'layerchart'; @@ -26,8 +26,6 @@ import Preview from '$lib/docs/Preview.svelte'; import SankeyControls from './SankeyControls.svelte'; - import { simpleData, complexData, greenhouse } from '../_data/graph.js'; - export let data; const colorScale = scaleSequential(interpolateCool); @@ -76,9 +74,9 @@

Simple

- +
- + d.id} let:links let:nodes> {#each links as link ([link.source.id, link.target.id].join('_'))} @@ -106,9 +104,9 @@

Tooltip

- +
- + d.name} nodeWidth={8} let:links let:nodes> {#each links as link ([link.source.name, link.target.name].join('_'))} @@ -146,8 +144,8 @@ - -
+ + {#if data.node} {data.node.name} {:else if data.link} @@ -155,39 +153,41 @@ {data.link.target.name} {/if} -
- - {#if data.node} - - - {#if data.node.targetLinks.length} - -
Sources
- {#each data.node.targetLinks as link} - - {/each} - {/if} + - {#if data.node.sourceLinks.length} - -
Targets
- {#each data.node.sourceLinks as link} - - {/each} + + {#if data.node} + + + {#if data.node.targetLinks.length} + +
Sources
+ {#each data.node.targetLinks as link} + + {/each} + {/if} + + {#if data.node.sourceLinks.length} + +
Targets
+ {#each data.node.sourceLinks as link} + + {/each} + {/if} + {:else if data.link} + {/if} - {:else if data.link} - - {/if} -
+ +

Node select

- +
- + d.name} nodeWidth={8} let:links let:nodes> {#each links as link ([link.source.name, link.target.name].join('_'))} @@ -237,9 +237,9 @@ - +
- + - -
+ + {#if data.node} {data.node.name} {:else if data.link} @@ -326,30 +326,32 @@ {data.link.target.name} {/if} -
+ - {#if data.node} - - - {#if data.node.targetLinks.length} - -
Sources
- {#each data.node.targetLinks as link} - - {/each} - {/if} - - {#if data.node.sourceLinks.length} - -
Targets
- {#each data.node.sourceLinks as link} - - {/each} + + {#if data.node} + + + {#if data.node.targetLinks.length} + +
Sources
+ {#each data.node.targetLinks as link} + + {/each} + {/if} + + {#if data.node.sourceLinks.length} + +
Targets
+ {#each data.node.sourceLinks as link} + + {/each} + {/if} + {:else if data.link} + {/if} - {:else if data.link} - - {/if} -
+ +
diff --git a/packages/layerchart/src/routes/docs/examples/Sankey/+page.ts b/packages/layerchart/src/routes/docs/examples/Sankey/+page.ts index ad5a1908d..406d807ea 100644 --- a/packages/layerchart/src/routes/docs/examples/Sankey/+page.ts +++ b/packages/layerchart/src/routes/docs/examples/Sankey/+page.ts @@ -2,7 +2,11 @@ import pageSource from './+page.svelte?raw'; export async function load() { return { + simple: await fetch('/data/examples/graph/simple.json').then((r) => r.json()), + complex: await fetch('/data/examples/graph/complex.json').then((r) => r.json()), + greenhouse: await fetch('/data/examples/graph/greenhouse.json').then((r) => r.json()), flare: await fetch('/data/examples/hierarchy/flare.json').then((r) => r.json()), + meta: { pageSource, related: ['components/Sankey', 'components/Link'], diff --git a/packages/layerchart/src/routes/docs/examples/Scatter/+page.svelte b/packages/layerchart/src/routes/docs/examples/Scatter/+page.svelte index 15de49826..d78f38caf 100644 --- a/packages/layerchart/src/routes/docs/examples/Scatter/+page.svelte +++ b/packages/layerchart/src/routes/docs/examples/Scatter/+page.svelte @@ -1,9 +1,9 @@
@@ -96,16 +105,27 @@ geo={{ projection, fitGeojson: geojson, + applyTransform: ['translate', 'scale'], + }} + transform={{ + translateOnScale: true, + initialScrollMode: 'scale', }} padding={{ top: 8, bottom: 8, left: 8, right: 8 }} let:tooltip > {#if projection === geoMercator} - + + + + + - + {/if} + + {#if projection === geoMercator} @@ -158,11 +178,14 @@ /> - data.properties.id} let:data> - {#each Object.entries(data.properties) as [key, value]} - - {/each} - + + {data.properties.id} + + {#each Object.entries(data.properties) as [key, value]} + + {/each} + + {:else} Please enter input below diff --git a/packages/layerchart/static/data/examples/graph/complex.json b/packages/layerchart/static/data/examples/graph/complex.json new file mode 100644 index 000000000..2c36a790b --- /dev/null +++ b/packages/layerchart/static/data/examples/graph/complex.json @@ -0,0 +1,122 @@ +{ + "nodes": [ + { "name": "Agricultural 'waste'" }, + { "name": "Bio-conversion" }, + { "name": "Liquid" }, + { "name": "Losses" }, + { "name": "Solid" }, + { "name": "Gas" }, + { "name": "Biofuel imports" }, + { "name": "Biomass imports" }, + { "name": "Coal imports" }, + { "name": "Coal" }, + { "name": "Coal reserves" }, + { "name": "District heating" }, + { "name": "Industry" }, + { "name": "Heating and cooling - commercial" }, + { "name": "Heating and cooling - homes" }, + { "name": "Electricity grid" }, + { "name": "Over generation / exports" }, + { "name": "H2 conversion" }, + { "name": "Road transport" }, + { "name": "Agriculture" }, + { "name": "Rail transport" }, + { "name": "Lighting & appliances - commercial" }, + { "name": "Lighting & appliances - homes" }, + { "name": "Gas imports" }, + { "name": "Ngas" }, + { "name": "Gas reserves" }, + { "name": "Thermal generation" }, + { "name": "Geothermal" }, + { "name": "H2" }, + { "name": "Hydro" }, + { "name": "International shipping" }, + { "name": "Domestic aviation" }, + { "name": "International aviation" }, + { "name": "National navigation" }, + { "name": "Marine algae" }, + { "name": "Nuclear" }, + { "name": "Oil imports" }, + { "name": "Oil" }, + { "name": "Oil reserves" }, + { "name": "Other waste" }, + { "name": "Pumped heat" }, + { "name": "Solar PV" }, + { "name": "Solar Thermal" }, + { "name": "Solar" }, + { "name": "Tidal" }, + { "name": "UK land based bioenergy" }, + { "name": "Wave" }, + { "name": "Wind" } + ], + "links": [ + { "source": 0, "target": 1, "value": 124.729 }, + { "source": 1, "target": 2, "value": 0.597 }, + { "source": 1, "target": 3, "value": 26.862 }, + { "source": 1, "target": 4, "value": 280.322 }, + { "source": 1, "target": 5, "value": 81.144 }, + { "source": 6, "target": 2, "value": 35 }, + { "source": 7, "target": 4, "value": 35 }, + { "source": 8, "target": 9, "value": 11.606 }, + { "source": 10, "target": 9, "value": 63.965 }, + { "source": 9, "target": 4, "value": 75.571 }, + { "source": 11, "target": 12, "value": 10.639 }, + { "source": 11, "target": 13, "value": 22.505 }, + { "source": 11, "target": 14, "value": 46.184 }, + { "source": 15, "target": 16, "value": 104.453 }, + { "source": 15, "target": 14, "value": 113.726 }, + { "source": 15, "target": 17, "value": 27.14 }, + { "source": 15, "target": 12, "value": 342.165 }, + { "source": 15, "target": 18, "value": 37.797 }, + { "source": 15, "target": 19, "value": 4.412 }, + { "source": 15, "target": 13, "value": 40.858 }, + { "source": 15, "target": 3, "value": 56.691 }, + { "source": 15, "target": 20, "value": 7.863 }, + { "source": 15, "target": 21, "value": 90.008 }, + { "source": 15, "target": 22, "value": 93.494 }, + { "source": 23, "target": 24, "value": 40.719 }, + { "source": 25, "target": 24, "value": 82.233 }, + { "source": 5, "target": 13, "value": 0.129 }, + { "source": 5, "target": 3, "value": 1.401 }, + { "source": 5, "target": 26, "value": 151.891 }, + { "source": 5, "target": 19, "value": 2.096 }, + { "source": 5, "target": 12, "value": 48.58 }, + { "source": 27, "target": 15, "value": 7.013 }, + { "source": 17, "target": 28, "value": 20.897 }, + { "source": 17, "target": 3, "value": 6.242 }, + { "source": 28, "target": 18, "value": 20.897 }, + { "source": 29, "target": 15, "value": 6.995 }, + { "source": 2, "target": 12, "value": 121.066 }, + { "source": 2, "target": 30, "value": 128.69 }, + { "source": 2, "target": 18, "value": 135.835 }, + { "source": 2, "target": 31, "value": 14.458 }, + { "source": 2, "target": 32, "value": 206.267 }, + { "source": 2, "target": 19, "value": 3.64 }, + { "source": 2, "target": 33, "value": 33.218 }, + { "source": 2, "target": 20, "value": 4.413 }, + { "source": 34, "target": 1, "value": 4.375 }, + { "source": 24, "target": 5, "value": 122.952 }, + { "source": 35, "target": 26, "value": 839.978 }, + { "source": 36, "target": 37, "value": 504.287 }, + { "source": 38, "target": 37, "value": 107.703 }, + { "source": 37, "target": 2, "value": 611.99 }, + { "source": 39, "target": 4, "value": 56.587 }, + { "source": 39, "target": 1, "value": 77.81 }, + { "source": 40, "target": 14, "value": 193.026 }, + { "source": 40, "target": 13, "value": 70.672 }, + { "source": 41, "target": 15, "value": 59.901 }, + { "source": 42, "target": 14, "value": 19.263 }, + { "source": 43, "target": 42, "value": 19.263 }, + { "source": 43, "target": 41, "value": 59.901 }, + { "source": 4, "target": 19, "value": 0.882 }, + { "source": 4, "target": 26, "value": 400.12 }, + { "source": 4, "target": 12, "value": 46.477 }, + { "source": 26, "target": 15, "value": 525.531 }, + { "source": 26, "target": 3, "value": 787.129 }, + { "source": 26, "target": 11, "value": 79.329 }, + { "source": 44, "target": 15, "value": 9.452 }, + { "source": 45, "target": 1, "value": 182.01 }, + { "source": 46, "target": 15, "value": 19.013 }, + { "source": 47, "target": 15, "value": 289.366 } + ] +} diff --git a/packages/layerchart/static/data/examples/graph/greenhouse.json b/packages/layerchart/static/data/examples/graph/greenhouse.json new file mode 100644 index 000000000..51027ee68 --- /dev/null +++ b/packages/layerchart/static/data/examples/graph/greenhouse.json @@ -0,0 +1,131 @@ +{ + "nodes": [ + { "name": "Energy" }, + { "name": "Industrial Processes" }, + { "name": "Electricity and heat" }, + { "name": "Industry" }, + { "name": "Land Use Change" }, + { "name": "Agriculture" }, + { "name": "Waste" }, + { "name": "Transportation" }, + { "name": "Other Fuel Combustion" }, + { "name": "Fugitive Emissions" }, + { "name": "Road" }, + { "name": "Air" }, + { "name": "Rail - Ship and Other Transport" }, + { "name": "Residential Buildings" }, + { "name": "Commercial Buildings" }, + { "name": "Unallocated Fuel Combustion" }, + { "name": "Iron and Steel" }, + { "name": "Aluminium Non-Ferrous Metals" }, + { "name": "Machinery" }, + { "name": "Pulp - Paper and Printing" }, + { "name": "Food and Tobacco" }, + { "name": "Chemicals" }, + { "name": "Cement" }, + { "name": "Other Industry" }, + { "name": "T and D Losses" }, + { "name": "Coal Mining" }, + { "name": "Oil and Gas Processing" }, + { "name": "Deforestation" }, + { "name": "Harvest / Management" }, + { "name": "Agricultural Energy Use" }, + { "name": "Agriculture Soils" }, + { "name": "Livestock and Manure" }, + { "name": "Rice Cultivation" }, + { "name": "Other Agriculture" }, + { "name": "Landfills" }, + { "name": "Waste water - Other Waste" }, + { "name": "Carbon Dioxide" }, + { "name": "HFCs - PFCs" }, + { "name": "Methane" }, + { "name": "Nitrous Oxide" } + ], + "links": [ + { "source": "Agricultural Energy Use", "target": "Carbon Dioxide", "value": "1.4" }, + { "source": "Agriculture", "target": "Agriculture Soils", "value": "5.2" }, + { "source": "Agriculture", "target": "Livestock and Manure", "value": "5.4" }, + { "source": "Agriculture", "target": "Other Agriculture", "value": "1.7" }, + { "source": "Agriculture", "target": "Rice Cultivation", "value": "1.5" }, + { "source": "Agriculture Soils", "target": "Nitrous Oxide", "value": "5.2" }, + { "source": "Air", "target": "Carbon Dioxide", "value": "1.7" }, + { "source": "Aluminium Non-Ferrous Metals", "target": "Carbon Dioxide", "value": "1.0" }, + { "source": "Aluminium Non-Ferrous Metals", "target": "HFCs - PFCs", "value": "0.2" }, + { "source": "Cement", "target": "Carbon Dioxide", "value": "5.0" }, + { "source": "Chemicals", "target": "Carbon Dioxide", "value": "3.4" }, + { "source": "Chemicals", "target": "HFCs - PFCs", "value": "0.5" }, + { "source": "Chemicals", "target": "Nitrous Oxide", "value": "0.2" }, + { "source": "Coal Mining", "target": "Carbon Dioxide", "value": "0.1" }, + { "source": "Coal Mining", "target": "Methane", "value": "1.2" }, + { "source": "Commercial Buildings", "target": "Carbon Dioxide", "value": "6.3" }, + { "source": "Deforestation", "target": "Carbon Dioxide", "value": "10.9" }, + { "source": "Electricity and heat", "target": "Agricultural Energy Use", "value": "0.4" }, + { "source": "Electricity and heat", "target": "Aluminium Non-Ferrous Metals", "value": "0.4" }, + { "source": "Electricity and heat", "target": "Cement", "value": "0.3" }, + { "source": "Electricity and heat", "target": "Chemicals", "value": "1.3" }, + { "source": "Electricity and heat", "target": "Commercial Buildings", "value": "5.0" }, + { "source": "Electricity and heat", "target": "Food and Tobacco", "value": "0.5" }, + { "source": "Electricity and heat", "target": "Iron and Steel", "value": "1.0" }, + { "source": "Electricity and heat", "target": "Machinery", "value": "1.0" }, + { "source": "Electricity and heat", "target": "Oil and Gas Processing", "value": "0.4" }, + { "source": "Electricity and heat", "target": "Other Industry", "value": "2.7" }, + { "source": "Electricity and heat", "target": "Pulp - Paper and Printing", "value": "0.6" }, + { "source": "Electricity and heat", "target": "Residential Buildings", "value": "5.2" }, + { "source": "Electricity and heat", "target": "T and D Losses", "value": "2.2" }, + { "source": "Electricity and heat", "target": "Unallocated Fuel Combustion", "value": "2.0" }, + { "source": "Energy", "target": "Electricity and heat", "value": "24.9" }, + { "source": "Energy", "target": "Fugitive Emissions", "value": "4.0" }, + { "source": "Energy", "target": "Industry", "value": "14.7" }, + { "source": "Energy", "target": "Other Fuel Combustion", "value": "8.6" }, + { "source": "Energy", "target": "Transportation", "value": "14.3" }, + { "source": "Food and Tobacco", "target": "Carbon Dioxide", "value": "1.0" }, + { "source": "Fugitive Emissions", "target": "Coal Mining", "value": "1.3" }, + { "source": "Fugitive Emissions", "target": "Oil and Gas Processing", "value": "3.2" }, + { "source": "Harvest / Management", "target": "Carbon Dioxide", "value": "1.3" }, + { "source": "Industrial Processes", "target": "Aluminium Non-Ferrous Metals", "value": "0.4" }, + { "source": "Industrial Processes", "target": "Cement", "value": "2.8" }, + { "source": "Industrial Processes", "target": "Chemicals", "value": "1.4" }, + { "source": "Industrial Processes", "target": "Other Industry", "value": "0.5" }, + { "source": "Industry", "target": "Aluminium Non-Ferrous Metals", "value": "0.4" }, + { "source": "Industry", "target": "Cement", "value": "1.9" }, + { "source": "Industry", "target": "Chemicals", "value": "1.4" }, + { "source": "Industry", "target": "Food and Tobacco", "value": "0.5" }, + { "source": "Industry", "target": "Iron and Steel", "value": "3.0" }, + { "source": "Industry", "target": "Oil and Gas Processing", "value": "2.8" }, + { "source": "Industry", "target": "Other Industry", "value": "3.8" }, + { "source": "Industry", "target": "Pulp - Paper and Printing", "value": "0.5" }, + { "source": "Iron and Steel", "target": "Carbon Dioxide", "value": "4.0" }, + { "source": "Land Use Change", "target": "Deforestation", "value": "10.9" }, + { "source": "Land Use Change", "target": "Harvest / Management", "value": "1.3" }, + { "source": "Landfills", "target": "Methane", "value": "1.7" }, + { "source": "Livestock and Manure", "target": "Methane", "value": "5.1" }, + { "source": "Livestock and Manure", "target": "Nitrous Oxide", "value": "0.3" }, + { "source": "Machinery", "target": "Carbon Dioxide", "value": "1.0" }, + { "source": "Oil and Gas Processing", "target": "Carbon Dioxide", "value": "3.6" }, + { "source": "Oil and Gas Processing", "target": "Methane", "value": "2.8" }, + { "source": "Other Agriculture", "target": "Methane", "value": "1.4" }, + { "source": "Other Agriculture", "target": "Nitrous Oxide", "value": "0.3" }, + { "source": "Other Fuel Combustion", "target": "Agricultural Energy Use", "value": "1.0" }, + { "source": "Other Fuel Combustion", "target": "Commercial Buildings", "value": "1.3" }, + { "source": "Other Fuel Combustion", "target": "Residential Buildings", "value": "5.0" }, + { "source": "Other Fuel Combustion", "target": "Unallocated Fuel Combustion", "value": "1.8" }, + { "source": "Other Industry", "target": "Carbon Dioxide", "value": "6.6" }, + { "source": "Other Industry", "target": "HFCs - PFCs", "value": "0.4" }, + { "source": "Pulp - Paper and Printing", "target": "Carbon Dioxide", "value": "1.1" }, + { "source": "Rail - Ship and Other Transport", "target": "Carbon Dioxide", "value": "2.5" }, + { "source": "Residential Buildings", "target": "Carbon Dioxide", "value": "10.2" }, + { "source": "Rice Cultivation", "target": "Methane", "value": "1.5" }, + { "source": "Road", "target": "Carbon Dioxide", "value": "10.5" }, + { "source": "T and D Losses", "target": "Carbon Dioxide", "value": "2.2" }, + { "source": "Transportation", "target": "Air", "value": "1.7" }, + { "source": "Transportation", "target": "Rail - Ship and Other Transport", "value": "2.5" }, + { "source": "Transportation", "target": "Road", "value": "10.5" }, + { "source": "Unallocated Fuel Combustion", "target": "Carbon Dioxide", "value": "3.0" }, + { "source": "Unallocated Fuel Combustion", "target": "Methane", "value": "0.4" }, + { "source": "Unallocated Fuel Combustion", "target": "Nitrous Oxide", "value": "0.4" }, + { "source": "Waste", "target": "Landfills", "value": "1.7" }, + { "source": "Waste", "target": "Waste water - Other Waste", "value": "1.5" }, + { "source": "Waste water - Other Waste", "target": "Methane", "value": "1.2" }, + { "source": "Waste water - Other Waste", "target": "Nitrous Oxide", "value": "0.3" } + ] +} diff --git a/packages/layerchart/static/data/examples/graph/simple.json b/packages/layerchart/static/data/examples/graph/simple.json new file mode 100644 index 000000000..452635b64 --- /dev/null +++ b/packages/layerchart/static/data/examples/graph/simple.json @@ -0,0 +1,31 @@ +{ + "nodes": [ + { "id": "A1" }, + { "id": "A2" }, + { "id": "A3" }, + { "id": "B1" }, + { "id": "B2" }, + { "id": "B3" }, + { "id": "B4" }, + { "id": "C1" }, + { "id": "C2" }, + { "id": "C3" }, + { "id": "D1" }, + { "id": "D2" } + ], + "links": [ + { "source": "A1", "target": "B1", "value": 27 }, + { "source": "A1", "target": "B2", "value": 9 }, + { "source": "A2", "target": "B2", "value": 5 }, + { "source": "A2", "target": "B3", "value": 11 }, + { "source": "A3", "target": "B2", "value": 12 }, + { "source": "A3", "target": "B4", "value": 7 }, + { "source": "B1", "target": "C1", "value": 13 }, + { "source": "B1", "target": "C2", "value": 10 }, + { "source": "B4", "target": "C2", "value": 5 }, + { "source": "B4", "target": "C3", "value": 2 }, + { "source": "B1", "target": "D1", "value": 4 }, + { "source": "C3", "target": "D1", "value": 1 }, + { "source": "C3", "target": "D2", "value": 1 } + ] +} diff --git a/packages/layerchart/static/data/examples/graph/trade-volume.json b/packages/layerchart/static/data/examples/graph/trade-volume.json new file mode 100644 index 000000000..5bfb63a61 --- /dev/null +++ b/packages/layerchart/static/data/examples/graph/trade-volume.json @@ -0,0 +1,168 @@ +{ + "nodes": [ + { + "label": "Netherlands" + }, + { + "label": "Canada" + }, + { + "label": "Belgium" + }, + { + "label": "Italy" + }, + { + "label": "Mexico" + }, + { + "label": "Russia" + }, + { + "label": "Spain" + }, + { + "label": "South Korea" + }, + { + "label": "Germany" + }, + { + "label": "China" + }, + { + "label": "European Union" + }, + { + "label": "Japan" + }, + { + "label": "United Kingdom" + }, + { + "label": "United States" + }, + { + "label": "France" + }, + { + "label": "Hong Kong" + }, + { + "label": "Switzerland" + }, + { + "label": "Austria" + }, + { + "label": "Sweden" + } + ], + "links": [ + { + "from": "Netherlands", + "to": "European Union", + "value": 798744 + }, + { + "from": "Germany", + "to": "European Union", + "value": 1468990 + }, + { + "from": "European Union", + "to": "France", + "value": 745931 + }, + { + "from": "European Union", + "to": "United States", + "value": 660541 + }, + { + "from": "Canada", + "to": "United States", + "value": 594546 + }, + { + "from": "Belgium", + "to": "European Union", + "value": 628796 + }, + { + "from": "China", + "to": "Hong Kong", + "value": 400571 + }, + { + "from": "China", + "to": "United States", + "value": 526454 + }, + { + "from": "European Union", + "to": "United Kingdom", + "value": 520318 + }, + { + "from": "China", + "to": "European Union", + "value": 560536 + }, + { + "from": "Italy", + "to": "European Union", + "value": 539556 + }, + { + "from": "Mexico", + "to": "United States", + "value": 492715 + }, + { + "from": "Russia", + "to": "European Union", + "value": 385778 + }, + { + "from": "Spain", + "to": "European Union", + "value": 365191 + }, + { + "from": "China", + "to": "Japan", + "value": 312062 + }, + { + "from": "European Union", + "to": "Switzerland", + "value": 328609 + }, + { + "from": "South Korea", + "to": "China", + "value": 229073 + }, + { + "from": "European Union", + "to": "Austria", + "value": 244913 + }, + { + "from": "Japan", + "to": "United States", + "value": 206091 + }, + { + "from": "European Union", + "to": "Sweden", + "value": 204849 + }, + { + "from": "Germany", + "to": "United States", + "value": 184287 + } + ] +} diff --git a/packages/layerchart/static/data/examples/penguins.csv b/packages/layerchart/static/data/examples/penguins.csv new file mode 100644 index 000000000..af24f5270 --- /dev/null +++ b/packages/layerchart/static/data/examples/penguins.csv @@ -0,0 +1,345 @@ +species,island,bill_length_mm,bill_depth_mm,flipper_length_mm,body_mass_g,sex,year +Adelie,Torgersen,39.1,18.7,181,3750,male,2007 +Adelie,Torgersen,39.5,17.4,186,3800,female,2007 +Adelie,Torgersen,40.3,18,195,3250,female,2007 +Adelie,Torgersen,NA,NA,NA,NA,NA,2007 +Adelie,Torgersen,36.7,19.3,193,3450,female,2007 +Adelie,Torgersen,39.3,20.6,190,3650,male,2007 +Adelie,Torgersen,38.9,17.8,181,3625,female,2007 +Adelie,Torgersen,39.2,19.6,195,4675,male,2007 +Adelie,Torgersen,34.1,18.1,193,3475,NA,2007 +Adelie,Torgersen,42,20.2,190,4250,NA,2007 +Adelie,Torgersen,37.8,17.1,186,3300,NA,2007 +Adelie,Torgersen,37.8,17.3,180,3700,NA,2007 +Adelie,Torgersen,41.1,17.6,182,3200,female,2007 +Adelie,Torgersen,38.6,21.2,191,3800,male,2007 +Adelie,Torgersen,34.6,21.1,198,4400,male,2007 +Adelie,Torgersen,36.6,17.8,185,3700,female,2007 +Adelie,Torgersen,38.7,19,195,3450,female,2007 +Adelie,Torgersen,42.5,20.7,197,4500,male,2007 +Adelie,Torgersen,34.4,18.4,184,3325,female,2007 +Adelie,Torgersen,46,21.5,194,4200,male,2007 +Adelie,Biscoe,37.8,18.3,174,3400,female,2007 +Adelie,Biscoe,37.7,18.7,180,3600,male,2007 +Adelie,Biscoe,35.9,19.2,189,3800,female,2007 +Adelie,Biscoe,38.2,18.1,185,3950,male,2007 +Adelie,Biscoe,38.8,17.2,180,3800,male,2007 +Adelie,Biscoe,35.3,18.9,187,3800,female,2007 +Adelie,Biscoe,40.6,18.6,183,3550,male,2007 +Adelie,Biscoe,40.5,17.9,187,3200,female,2007 +Adelie,Biscoe,37.9,18.6,172,3150,female,2007 +Adelie,Biscoe,40.5,18.9,180,3950,male,2007 +Adelie,Dream,39.5,16.7,178,3250,female,2007 +Adelie,Dream,37.2,18.1,178,3900,male,2007 +Adelie,Dream,39.5,17.8,188,3300,female,2007 +Adelie,Dream,40.9,18.9,184,3900,male,2007 +Adelie,Dream,36.4,17,195,3325,female,2007 +Adelie,Dream,39.2,21.1,196,4150,male,2007 +Adelie,Dream,38.8,20,190,3950,male,2007 +Adelie,Dream,42.2,18.5,180,3550,female,2007 +Adelie,Dream,37.6,19.3,181,3300,female,2007 +Adelie,Dream,39.8,19.1,184,4650,male,2007 +Adelie,Dream,36.5,18,182,3150,female,2007 +Adelie,Dream,40.8,18.4,195,3900,male,2007 +Adelie,Dream,36,18.5,186,3100,female,2007 +Adelie,Dream,44.1,19.7,196,4400,male,2007 +Adelie,Dream,37,16.9,185,3000,female,2007 +Adelie,Dream,39.6,18.8,190,4600,male,2007 +Adelie,Dream,41.1,19,182,3425,male,2007 +Adelie,Dream,37.5,18.9,179,2975,NA,2007 +Adelie,Dream,36,17.9,190,3450,female,2007 +Adelie,Dream,42.3,21.2,191,4150,male,2007 +Adelie,Biscoe,39.6,17.7,186,3500,female,2008 +Adelie,Biscoe,40.1,18.9,188,4300,male,2008 +Adelie,Biscoe,35,17.9,190,3450,female,2008 +Adelie,Biscoe,42,19.5,200,4050,male,2008 +Adelie,Biscoe,34.5,18.1,187,2900,female,2008 +Adelie,Biscoe,41.4,18.6,191,3700,male,2008 +Adelie,Biscoe,39,17.5,186,3550,female,2008 +Adelie,Biscoe,40.6,18.8,193,3800,male,2008 +Adelie,Biscoe,36.5,16.6,181,2850,female,2008 +Adelie,Biscoe,37.6,19.1,194,3750,male,2008 +Adelie,Biscoe,35.7,16.9,185,3150,female,2008 +Adelie,Biscoe,41.3,21.1,195,4400,male,2008 +Adelie,Biscoe,37.6,17,185,3600,female,2008 +Adelie,Biscoe,41.1,18.2,192,4050,male,2008 +Adelie,Biscoe,36.4,17.1,184,2850,female,2008 +Adelie,Biscoe,41.6,18,192,3950,male,2008 +Adelie,Biscoe,35.5,16.2,195,3350,female,2008 +Adelie,Biscoe,41.1,19.1,188,4100,male,2008 +Adelie,Torgersen,35.9,16.6,190,3050,female,2008 +Adelie,Torgersen,41.8,19.4,198,4450,male,2008 +Adelie,Torgersen,33.5,19,190,3600,female,2008 +Adelie,Torgersen,39.7,18.4,190,3900,male,2008 +Adelie,Torgersen,39.6,17.2,196,3550,female,2008 +Adelie,Torgersen,45.8,18.9,197,4150,male,2008 +Adelie,Torgersen,35.5,17.5,190,3700,female,2008 +Adelie,Torgersen,42.8,18.5,195,4250,male,2008 +Adelie,Torgersen,40.9,16.8,191,3700,female,2008 +Adelie,Torgersen,37.2,19.4,184,3900,male,2008 +Adelie,Torgersen,36.2,16.1,187,3550,female,2008 +Adelie,Torgersen,42.1,19.1,195,4000,male,2008 +Adelie,Torgersen,34.6,17.2,189,3200,female,2008 +Adelie,Torgersen,42.9,17.6,196,4700,male,2008 +Adelie,Torgersen,36.7,18.8,187,3800,female,2008 +Adelie,Torgersen,35.1,19.4,193,4200,male,2008 +Adelie,Dream,37.3,17.8,191,3350,female,2008 +Adelie,Dream,41.3,20.3,194,3550,male,2008 +Adelie,Dream,36.3,19.5,190,3800,male,2008 +Adelie,Dream,36.9,18.6,189,3500,female,2008 +Adelie,Dream,38.3,19.2,189,3950,male,2008 +Adelie,Dream,38.9,18.8,190,3600,female,2008 +Adelie,Dream,35.7,18,202,3550,female,2008 +Adelie,Dream,41.1,18.1,205,4300,male,2008 +Adelie,Dream,34,17.1,185,3400,female,2008 +Adelie,Dream,39.6,18.1,186,4450,male,2008 +Adelie,Dream,36.2,17.3,187,3300,female,2008 +Adelie,Dream,40.8,18.9,208,4300,male,2008 +Adelie,Dream,38.1,18.6,190,3700,female,2008 +Adelie,Dream,40.3,18.5,196,4350,male,2008 +Adelie,Dream,33.1,16.1,178,2900,female,2008 +Adelie,Dream,43.2,18.5,192,4100,male,2008 +Adelie,Biscoe,35,17.9,192,3725,female,2009 +Adelie,Biscoe,41,20,203,4725,male,2009 +Adelie,Biscoe,37.7,16,183,3075,female,2009 +Adelie,Biscoe,37.8,20,190,4250,male,2009 +Adelie,Biscoe,37.9,18.6,193,2925,female,2009 +Adelie,Biscoe,39.7,18.9,184,3550,male,2009 +Adelie,Biscoe,38.6,17.2,199,3750,female,2009 +Adelie,Biscoe,38.2,20,190,3900,male,2009 +Adelie,Biscoe,38.1,17,181,3175,female,2009 +Adelie,Biscoe,43.2,19,197,4775,male,2009 +Adelie,Biscoe,38.1,16.5,198,3825,female,2009 +Adelie,Biscoe,45.6,20.3,191,4600,male,2009 +Adelie,Biscoe,39.7,17.7,193,3200,female,2009 +Adelie,Biscoe,42.2,19.5,197,4275,male,2009 +Adelie,Biscoe,39.6,20.7,191,3900,female,2009 +Adelie,Biscoe,42.7,18.3,196,4075,male,2009 +Adelie,Torgersen,38.6,17,188,2900,female,2009 +Adelie,Torgersen,37.3,20.5,199,3775,male,2009 +Adelie,Torgersen,35.7,17,189,3350,female,2009 +Adelie,Torgersen,41.1,18.6,189,3325,male,2009 +Adelie,Torgersen,36.2,17.2,187,3150,female,2009 +Adelie,Torgersen,37.7,19.8,198,3500,male,2009 +Adelie,Torgersen,40.2,17,176,3450,female,2009 +Adelie,Torgersen,41.4,18.5,202,3875,male,2009 +Adelie,Torgersen,35.2,15.9,186,3050,female,2009 +Adelie,Torgersen,40.6,19,199,4000,male,2009 +Adelie,Torgersen,38.8,17.6,191,3275,female,2009 +Adelie,Torgersen,41.5,18.3,195,4300,male,2009 +Adelie,Torgersen,39,17.1,191,3050,female,2009 +Adelie,Torgersen,44.1,18,210,4000,male,2009 +Adelie,Torgersen,38.5,17.9,190,3325,female,2009 +Adelie,Torgersen,43.1,19.2,197,3500,male,2009 +Adelie,Dream,36.8,18.5,193,3500,female,2009 +Adelie,Dream,37.5,18.5,199,4475,male,2009 +Adelie,Dream,38.1,17.6,187,3425,female,2009 +Adelie,Dream,41.1,17.5,190,3900,male,2009 +Adelie,Dream,35.6,17.5,191,3175,female,2009 +Adelie,Dream,40.2,20.1,200,3975,male,2009 +Adelie,Dream,37,16.5,185,3400,female,2009 +Adelie,Dream,39.7,17.9,193,4250,male,2009 +Adelie,Dream,40.2,17.1,193,3400,female,2009 +Adelie,Dream,40.6,17.2,187,3475,male,2009 +Adelie,Dream,32.1,15.5,188,3050,female,2009 +Adelie,Dream,40.7,17,190,3725,male,2009 +Adelie,Dream,37.3,16.8,192,3000,female,2009 +Adelie,Dream,39,18.7,185,3650,male,2009 +Adelie,Dream,39.2,18.6,190,4250,male,2009 +Adelie,Dream,36.6,18.4,184,3475,female,2009 +Adelie,Dream,36,17.8,195,3450,female,2009 +Adelie,Dream,37.8,18.1,193,3750,male,2009 +Adelie,Dream,36,17.1,187,3700,female,2009 +Adelie,Dream,41.5,18.5,201,4000,male,2009 +Gentoo,Biscoe,46.1,13.2,211,4500,female,2007 +Gentoo,Biscoe,50,16.3,230,5700,male,2007 +Gentoo,Biscoe,48.7,14.1,210,4450,female,2007 +Gentoo,Biscoe,50,15.2,218,5700,male,2007 +Gentoo,Biscoe,47.6,14.5,215,5400,male,2007 +Gentoo,Biscoe,46.5,13.5,210,4550,female,2007 +Gentoo,Biscoe,45.4,14.6,211,4800,female,2007 +Gentoo,Biscoe,46.7,15.3,219,5200,male,2007 +Gentoo,Biscoe,43.3,13.4,209,4400,female,2007 +Gentoo,Biscoe,46.8,15.4,215,5150,male,2007 +Gentoo,Biscoe,40.9,13.7,214,4650,female,2007 +Gentoo,Biscoe,49,16.1,216,5550,male,2007 +Gentoo,Biscoe,45.5,13.7,214,4650,female,2007 +Gentoo,Biscoe,48.4,14.6,213,5850,male,2007 +Gentoo,Biscoe,45.8,14.6,210,4200,female,2007 +Gentoo,Biscoe,49.3,15.7,217,5850,male,2007 +Gentoo,Biscoe,42,13.5,210,4150,female,2007 +Gentoo,Biscoe,49.2,15.2,221,6300,male,2007 +Gentoo,Biscoe,46.2,14.5,209,4800,female,2007 +Gentoo,Biscoe,48.7,15.1,222,5350,male,2007 +Gentoo,Biscoe,50.2,14.3,218,5700,male,2007 +Gentoo,Biscoe,45.1,14.5,215,5000,female,2007 +Gentoo,Biscoe,46.5,14.5,213,4400,female,2007 +Gentoo,Biscoe,46.3,15.8,215,5050,male,2007 +Gentoo,Biscoe,42.9,13.1,215,5000,female,2007 +Gentoo,Biscoe,46.1,15.1,215,5100,male,2007 +Gentoo,Biscoe,44.5,14.3,216,4100,NA,2007 +Gentoo,Biscoe,47.8,15,215,5650,male,2007 +Gentoo,Biscoe,48.2,14.3,210,4600,female,2007 +Gentoo,Biscoe,50,15.3,220,5550,male,2007 +Gentoo,Biscoe,47.3,15.3,222,5250,male,2007 +Gentoo,Biscoe,42.8,14.2,209,4700,female,2007 +Gentoo,Biscoe,45.1,14.5,207,5050,female,2007 +Gentoo,Biscoe,59.6,17,230,6050,male,2007 +Gentoo,Biscoe,49.1,14.8,220,5150,female,2008 +Gentoo,Biscoe,48.4,16.3,220,5400,male,2008 +Gentoo,Biscoe,42.6,13.7,213,4950,female,2008 +Gentoo,Biscoe,44.4,17.3,219,5250,male,2008 +Gentoo,Biscoe,44,13.6,208,4350,female,2008 +Gentoo,Biscoe,48.7,15.7,208,5350,male,2008 +Gentoo,Biscoe,42.7,13.7,208,3950,female,2008 +Gentoo,Biscoe,49.6,16,225,5700,male,2008 +Gentoo,Biscoe,45.3,13.7,210,4300,female,2008 +Gentoo,Biscoe,49.6,15,216,4750,male,2008 +Gentoo,Biscoe,50.5,15.9,222,5550,male,2008 +Gentoo,Biscoe,43.6,13.9,217,4900,female,2008 +Gentoo,Biscoe,45.5,13.9,210,4200,female,2008 +Gentoo,Biscoe,50.5,15.9,225,5400,male,2008 +Gentoo,Biscoe,44.9,13.3,213,5100,female,2008 +Gentoo,Biscoe,45.2,15.8,215,5300,male,2008 +Gentoo,Biscoe,46.6,14.2,210,4850,female,2008 +Gentoo,Biscoe,48.5,14.1,220,5300,male,2008 +Gentoo,Biscoe,45.1,14.4,210,4400,female,2008 +Gentoo,Biscoe,50.1,15,225,5000,male,2008 +Gentoo,Biscoe,46.5,14.4,217,4900,female,2008 +Gentoo,Biscoe,45,15.4,220,5050,male,2008 +Gentoo,Biscoe,43.8,13.9,208,4300,female,2008 +Gentoo,Biscoe,45.5,15,220,5000,male,2008 +Gentoo,Biscoe,43.2,14.5,208,4450,female,2008 +Gentoo,Biscoe,50.4,15.3,224,5550,male,2008 +Gentoo,Biscoe,45.3,13.8,208,4200,female,2008 +Gentoo,Biscoe,46.2,14.9,221,5300,male,2008 +Gentoo,Biscoe,45.7,13.9,214,4400,female,2008 +Gentoo,Biscoe,54.3,15.7,231,5650,male,2008 +Gentoo,Biscoe,45.8,14.2,219,4700,female,2008 +Gentoo,Biscoe,49.8,16.8,230,5700,male,2008 +Gentoo,Biscoe,46.2,14.4,214,4650,NA,2008 +Gentoo,Biscoe,49.5,16.2,229,5800,male,2008 +Gentoo,Biscoe,43.5,14.2,220,4700,female,2008 +Gentoo,Biscoe,50.7,15,223,5550,male,2008 +Gentoo,Biscoe,47.7,15,216,4750,female,2008 +Gentoo,Biscoe,46.4,15.6,221,5000,male,2008 +Gentoo,Biscoe,48.2,15.6,221,5100,male,2008 +Gentoo,Biscoe,46.5,14.8,217,5200,female,2008 +Gentoo,Biscoe,46.4,15,216,4700,female,2008 +Gentoo,Biscoe,48.6,16,230,5800,male,2008 +Gentoo,Biscoe,47.5,14.2,209,4600,female,2008 +Gentoo,Biscoe,51.1,16.3,220,6000,male,2008 +Gentoo,Biscoe,45.2,13.8,215,4750,female,2008 +Gentoo,Biscoe,45.2,16.4,223,5950,male,2008 +Gentoo,Biscoe,49.1,14.5,212,4625,female,2009 +Gentoo,Biscoe,52.5,15.6,221,5450,male,2009 +Gentoo,Biscoe,47.4,14.6,212,4725,female,2009 +Gentoo,Biscoe,50,15.9,224,5350,male,2009 +Gentoo,Biscoe,44.9,13.8,212,4750,female,2009 +Gentoo,Biscoe,50.8,17.3,228,5600,male,2009 +Gentoo,Biscoe,43.4,14.4,218,4600,female,2009 +Gentoo,Biscoe,51.3,14.2,218,5300,male,2009 +Gentoo,Biscoe,47.5,14,212,4875,female,2009 +Gentoo,Biscoe,52.1,17,230,5550,male,2009 +Gentoo,Biscoe,47.5,15,218,4950,female,2009 +Gentoo,Biscoe,52.2,17.1,228,5400,male,2009 +Gentoo,Biscoe,45.5,14.5,212,4750,female,2009 +Gentoo,Biscoe,49.5,16.1,224,5650,male,2009 +Gentoo,Biscoe,44.5,14.7,214,4850,female,2009 +Gentoo,Biscoe,50.8,15.7,226,5200,male,2009 +Gentoo,Biscoe,49.4,15.8,216,4925,male,2009 +Gentoo,Biscoe,46.9,14.6,222,4875,female,2009 +Gentoo,Biscoe,48.4,14.4,203,4625,female,2009 +Gentoo,Biscoe,51.1,16.5,225,5250,male,2009 +Gentoo,Biscoe,48.5,15,219,4850,female,2009 +Gentoo,Biscoe,55.9,17,228,5600,male,2009 +Gentoo,Biscoe,47.2,15.5,215,4975,female,2009 +Gentoo,Biscoe,49.1,15,228,5500,male,2009 +Gentoo,Biscoe,47.3,13.8,216,4725,NA,2009 +Gentoo,Biscoe,46.8,16.1,215,5500,male,2009 +Gentoo,Biscoe,41.7,14.7,210,4700,female,2009 +Gentoo,Biscoe,53.4,15.8,219,5500,male,2009 +Gentoo,Biscoe,43.3,14,208,4575,female,2009 +Gentoo,Biscoe,48.1,15.1,209,5500,male,2009 +Gentoo,Biscoe,50.5,15.2,216,5000,female,2009 +Gentoo,Biscoe,49.8,15.9,229,5950,male,2009 +Gentoo,Biscoe,43.5,15.2,213,4650,female,2009 +Gentoo,Biscoe,51.5,16.3,230,5500,male,2009 +Gentoo,Biscoe,46.2,14.1,217,4375,female,2009 +Gentoo,Biscoe,55.1,16,230,5850,male,2009 +Gentoo,Biscoe,44.5,15.7,217,4875,NA,2009 +Gentoo,Biscoe,48.8,16.2,222,6000,male,2009 +Gentoo,Biscoe,47.2,13.7,214,4925,female,2009 +Gentoo,Biscoe,NA,NA,NA,NA,NA,2009 +Gentoo,Biscoe,46.8,14.3,215,4850,female,2009 +Gentoo,Biscoe,50.4,15.7,222,5750,male,2009 +Gentoo,Biscoe,45.2,14.8,212,5200,female,2009 +Gentoo,Biscoe,49.9,16.1,213,5400,male,2009 +Chinstrap,Dream,46.5,17.9,192,3500,female,2007 +Chinstrap,Dream,50,19.5,196,3900,male,2007 +Chinstrap,Dream,51.3,19.2,193,3650,male,2007 +Chinstrap,Dream,45.4,18.7,188,3525,female,2007 +Chinstrap,Dream,52.7,19.8,197,3725,male,2007 +Chinstrap,Dream,45.2,17.8,198,3950,female,2007 +Chinstrap,Dream,46.1,18.2,178,3250,female,2007 +Chinstrap,Dream,51.3,18.2,197,3750,male,2007 +Chinstrap,Dream,46,18.9,195,4150,female,2007 +Chinstrap,Dream,51.3,19.9,198,3700,male,2007 +Chinstrap,Dream,46.6,17.8,193,3800,female,2007 +Chinstrap,Dream,51.7,20.3,194,3775,male,2007 +Chinstrap,Dream,47,17.3,185,3700,female,2007 +Chinstrap,Dream,52,18.1,201,4050,male,2007 +Chinstrap,Dream,45.9,17.1,190,3575,female,2007 +Chinstrap,Dream,50.5,19.6,201,4050,male,2007 +Chinstrap,Dream,50.3,20,197,3300,male,2007 +Chinstrap,Dream,58,17.8,181,3700,female,2007 +Chinstrap,Dream,46.4,18.6,190,3450,female,2007 +Chinstrap,Dream,49.2,18.2,195,4400,male,2007 +Chinstrap,Dream,42.4,17.3,181,3600,female,2007 +Chinstrap,Dream,48.5,17.5,191,3400,male,2007 +Chinstrap,Dream,43.2,16.6,187,2900,female,2007 +Chinstrap,Dream,50.6,19.4,193,3800,male,2007 +Chinstrap,Dream,46.7,17.9,195,3300,female,2007 +Chinstrap,Dream,52,19,197,4150,male,2007 +Chinstrap,Dream,50.5,18.4,200,3400,female,2008 +Chinstrap,Dream,49.5,19,200,3800,male,2008 +Chinstrap,Dream,46.4,17.8,191,3700,female,2008 +Chinstrap,Dream,52.8,20,205,4550,male,2008 +Chinstrap,Dream,40.9,16.6,187,3200,female,2008 +Chinstrap,Dream,54.2,20.8,201,4300,male,2008 +Chinstrap,Dream,42.5,16.7,187,3350,female,2008 +Chinstrap,Dream,51,18.8,203,4100,male,2008 +Chinstrap,Dream,49.7,18.6,195,3600,male,2008 +Chinstrap,Dream,47.5,16.8,199,3900,female,2008 +Chinstrap,Dream,47.6,18.3,195,3850,female,2008 +Chinstrap,Dream,52,20.7,210,4800,male,2008 +Chinstrap,Dream,46.9,16.6,192,2700,female,2008 +Chinstrap,Dream,53.5,19.9,205,4500,male,2008 +Chinstrap,Dream,49,19.5,210,3950,male,2008 +Chinstrap,Dream,46.2,17.5,187,3650,female,2008 +Chinstrap,Dream,50.9,19.1,196,3550,male,2008 +Chinstrap,Dream,45.5,17,196,3500,female,2008 +Chinstrap,Dream,50.9,17.9,196,3675,female,2009 +Chinstrap,Dream,50.8,18.5,201,4450,male,2009 +Chinstrap,Dream,50.1,17.9,190,3400,female,2009 +Chinstrap,Dream,49,19.6,212,4300,male,2009 +Chinstrap,Dream,51.5,18.7,187,3250,male,2009 +Chinstrap,Dream,49.8,17.3,198,3675,female,2009 +Chinstrap,Dream,48.1,16.4,199,3325,female,2009 +Chinstrap,Dream,51.4,19,201,3950,male,2009 +Chinstrap,Dream,45.7,17.3,193,3600,female,2009 +Chinstrap,Dream,50.7,19.7,203,4050,male,2009 +Chinstrap,Dream,42.5,17.3,187,3350,female,2009 +Chinstrap,Dream,52.2,18.8,197,3450,male,2009 +Chinstrap,Dream,45.2,16.6,191,3250,female,2009 +Chinstrap,Dream,49.3,19.9,203,4050,male,2009 +Chinstrap,Dream,50.2,18.8,202,3800,male,2009 +Chinstrap,Dream,45.6,19.4,194,3525,female,2009 +Chinstrap,Dream,51.9,19.5,206,3950,male,2009 +Chinstrap,Dream,46.8,16.5,189,3650,female,2009 +Chinstrap,Dream,45.7,17,195,3650,female,2009 +Chinstrap,Dream,55.8,19.8,207,4000,male,2009 +Chinstrap,Dream,43.5,18.1,202,3400,female,2009 +Chinstrap,Dream,49.6,18.2,193,3775,male,2009 +Chinstrap,Dream,50.8,19,210,4100,male,2009 +Chinstrap,Dream,50.2,18.7,198,3775,female,2009 \ No newline at end of file diff --git a/packages/layerchart/static/data/examples/penguins.d.ts b/packages/layerchart/static/data/examples/penguins.d.ts new file mode 100644 index 000000000..61e70451d --- /dev/null +++ b/packages/layerchart/static/data/examples/penguins.d.ts @@ -0,0 +1,10 @@ +export type PenguinsData = { + species: string; + island: string; + bill_length_mm: number | 'NA'; + bill_depth_mm: number | 'NA'; + flipper_length_mm: number | 'NA'; + body_mass_g: number | 'NA'; + sex: 'male' | 'female' | 'NA'; + year: number; +}[]; diff --git a/packages/layerchart/static/data/examples/world-population-demographics.csv b/packages/layerchart/static/data/examples/world-population-demographics.csv new file mode 100644 index 000000000..c7ccf5a79 --- /dev/null +++ b/packages/layerchart/static/data/examples/world-population-demographics.csv @@ -0,0 +1,22 @@ +age,male,female +0-4,337082467,319557714 +5-9,351715561,331015496 +10-14,346898098,325046485 +15-19,328189555,307629576 +20-24,313191215,294184526 +25-29,304421477,287497451 +30-34,308206126,294461443 +35-39,293650660,283742580 +40-44,264954566,258134000 +45-49,238892693,235655907 +50-54,230886182,231469447 +55-59,204396487,210274344 +60-64,162559789,173807303 +65-69,135678685,152556237 +70-74,99662458,119189625 +75-79,61653088,78620257 +80-84,36107650,52173305 +85-89,17564615,30311032 +90-94,5956267,12939489 +95-99,1189572,3510425 +100+,130480,547105 diff --git a/packages/layerchart/static/data/examples/world-population-demographics.d.ts b/packages/layerchart/static/data/examples/world-population-demographics.d.ts new file mode 100644 index 000000000..cd9d8155f --- /dev/null +++ b/packages/layerchart/static/data/examples/world-population-demographics.d.ts @@ -0,0 +1,5 @@ +export type WorldPopulationDemographicsData = { + age: string; + male: number; + female: number; +}[]; diff --git a/packages/layerchart/tailwind.config.cjs b/packages/layerchart/tailwind.config.cjs index 42e4d37d8..513003c32 100644 --- a/packages/layerchart/tailwind.config.cjs +++ b/packages/layerchart/tailwind.config.cjs @@ -1,7 +1,7 @@ const colors = require('tailwindcss/colors'); const plugin = require('tailwindcss/plugin'); -const svelteUx = require('svelte-ux/plugins/tailwind.cjs'); +const svelteUx = require('@layerstack/tailwind/plugin'); module.exports = { content: ['./src/**/*.{html,svelte,md}', './node_modules/svelte-ux/**/*.{svelte,js,md}'], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7283f7b3..819fb7e08 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,18 @@ importers: packages/layerchart: dependencies: + '@layerstack/svelte-actions': + specifier: ^0.0.3 + version: 0.0.3 + '@layerstack/svelte-stores': + specifier: ^0.0.3 + version: 0.0.3 + '@layerstack/tailwind': + specifier: ^0.0.5 + version: 0.0.5 + '@layerstack/utils': + specifier: ^0.0.3 + version: 0.0.3 d3-array: specifier: ^3.2.4 version: 3.2.4 @@ -95,9 +107,6 @@ importers: shapefile: specifier: ^0.6.6 version: 0.6.6 - svelte-ux: - specifier: ^0.74.4 - version: 0.74.4(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18) topojson-client: specifier: ^3.1.0 version: 3.1.0 @@ -233,13 +242,16 @@ importers: version: 4.2.18 svelte-check: specifier: ^3.8.5 - version: 3.8.5(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18) + version: 3.8.5(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18) svelte-json-tree: specifier: ^2.2.0 version: 2.2.0(svelte@4.2.18) svelte-preprocess: specifier: ^6.0.2 - version: 6.0.2(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4) + version: 6.0.2(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4) + svelte-ux: + specifier: ^0.74.4 + version: 0.74.4(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18) svelte2tsx: specifier: ^0.7.15 version: 0.7.15(svelte@4.2.18)(typescript@5.5.4) @@ -264,6 +276,9 @@ importers: vite: specifier: ^5.4.0 version: 5.4.0(@types/node@22.3.0) + vitest: + specifier: ^2.0.5 + version: 2.0.5(@types/node@22.3.0) packages: @@ -706,6 +721,18 @@ packages: '@jridgewell/trace-mapping@0.3.9': resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + '@layerstack/svelte-actions@0.0.3': + resolution: {integrity: sha512-StExYf7MRSecjUrYIAIzgkw5NzvSNJJYiK+/daVAjCEyX/JS6zW541MkoFM+XfafA57jZ0Ryz70rG5wNKJJj4Q==} + + '@layerstack/svelte-stores@0.0.3': + resolution: {integrity: sha512-tkSzYhoecDvhbev6VbCJk8vPCRSnFB44IDa3gNZ2esU0k6Fxgz1vcboGDUvGJtZ+Q8IcJV05MeGA89ViW6nBQA==} + + '@layerstack/tailwind@0.0.5': + resolution: {integrity: sha512-FB2r00fUXxACAh0q1MRJFEitTPBdavK1HPs/PbgTkaKHVu/2uF8coKhTFE/cUnYA7qxHgpt1lFvlzo1twK3IYg==} + + '@layerstack/utils@0.0.3': + resolution: {integrity: sha512-OmqtoBsC8Xfp2lYUDBp05kLrEc5jNkLmVFSOWlrs5p5lFG9JemkQZOhdBN6JwubcaQGwOzrflJ4QeSFC5PAd2A==} + '@manypkg/find-root@1.1.0': resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -1013,6 +1040,24 @@ packages: '@types/unist@3.0.2': resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} + '@vitest/expect@2.0.5': + resolution: {integrity: sha512-yHZtwuP7JZivj65Gxoi8upUN2OzHTi3zVfjwdpu2WrvCZPLwsJ2Ey5ILIPccoW23dd/zQBlJ4/dhi7DWNyXCpA==} + + '@vitest/pretty-format@2.0.5': + resolution: {integrity: sha512-h8k+1oWHfwTkyTkb9egzwNMfJAEx4veaPSnMeKbVSjp4euqGSbQlm5+6VHwTr7u4FJslVVsUG5nopCaAYdOmSQ==} + + '@vitest/runner@2.0.5': + resolution: {integrity: sha512-TfRfZa6Bkk9ky4tW0z20WKXFEwwvWhRY+84CnSEtq4+3ZvDlJyY32oNTJtM7AW9ihW90tX/1Q78cb6FjoAs+ig==} + + '@vitest/snapshot@2.0.5': + resolution: {integrity: sha512-SgCPUeDFLaM0mIUHfaArq8fD2WbaXG/zVXjRupthYfYGzc8ztbFbu6dUNOblBG7XLMR1kEhS/DNnfCZ2IhdDew==} + + '@vitest/spy@2.0.5': + resolution: {integrity: sha512-c/jdthAhvJdpfVuaexSrnawxZz6pywlTPe84LUB2m/4t3rl2fTo9NFGBG4oWgaD+FTgDDV8hJ/nibT7IfH3JfA==} + + '@vitest/utils@2.0.5': + resolution: {integrity: sha512-d8HKbqIcya+GR67mkZbrzhS5kKhtp8dQLcmRZLGTscGVg7yImT82cIrhtn2L8+VujWcy6KZweApgNmPsTAO/UQ==} + acorn-walk@8.3.3: resolution: {integrity: sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==} engines: {node: '>=0.4.0'} @@ -1077,6 +1122,10 @@ packages: as-table@1.0.55: resolution: {integrity: sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==} + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + autoprefixer@10.4.20: resolution: {integrity: sha512-XY25y5xSv/wEoqzDyXXME4AFfkZI0P23z6Fs3YgymDnKJkCGOnkL0iTxCa85UTqaSgfcqyf3UA6+c7wUvx/16g==} engines: {node: ^10 || ^12 || >=14} @@ -1128,6 +1177,10 @@ packages: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} + cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + camelcase-css@2.0.1: resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==} engines: {node: '>= 6'} @@ -1138,6 +1191,10 @@ packages: capnp-ts@0.7.0: resolution: {integrity: sha512-XKxXAC3HVPv7r674zP0VC3RTXz+/JKhfyw94ljvF80yynK6VkTnqE3jMuN8b3dUVmmc43TjyxjW4KTsmB3c86g==} + chai@5.1.1: + resolution: {integrity: sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==} + engines: {node: '>=12'} + chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -1145,6 +1202,10 @@ packages: chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + check-error@2.1.1: + resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} + engines: {node: '>= 16'} + chokidar@3.6.0: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} @@ -1360,6 +1421,10 @@ packages: dedent-js@1.0.1: resolution: {integrity: sha512-OUepMozQULMLUmhxS95Vudo0jb0UchLimi3+pQ2plj61Fcy8axbP9hbiD4Sz6DPqn6XG3kfmziVfQ1rSys5AJQ==} + deep-eql@5.0.2: + resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} + engines: {node: '>=6'} + deepmerge@4.3.1: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} @@ -1456,6 +1521,10 @@ packages: estree-walker@3.0.3: resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + execa@8.0.1: + resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} + engines: {node: '>=16.17'} + exit-hook@2.2.1: resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} engines: {node: '>=6'} @@ -1525,9 +1594,16 @@ packages: function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + get-func-name@2.0.2: + resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} + get-source@2.0.12: resolution: {integrity: sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==} + get-stream@8.0.1: + resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} + engines: {node: '>=16'} + github-slugger@2.0.0: resolution: {integrity: sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==} @@ -1585,6 +1661,10 @@ packages: human-id@1.0.2: resolution: {integrity: sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw==} + human-signals@5.0.0: + resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} + engines: {node: '>=16.17.0'} + iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -1651,6 +1731,10 @@ packages: is-reference@3.0.2: resolution: {integrity: sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==} + is-stream@3.0.0: + resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + is-subdir@1.2.0: resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} engines: {node: '>=4'} @@ -1731,6 +1815,9 @@ packages: lodash.startcase@4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} + loupe@3.1.1: + resolution: {integrity: sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==} + lower-case@2.0.2: resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==} @@ -1766,6 +1853,9 @@ packages: peerDependencies: svelte: ^3.56.0 || ^4.0.0 || ^5.0.0-next.120 + merge-stream@2.0.0: + resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} @@ -1783,6 +1873,10 @@ packages: engines: {node: '>=10.0.0'} hasBin: true + mimic-fn@4.0.0: + resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} + engines: {node: '>=12'} + min-indent@1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -1867,6 +1961,10 @@ packages: resolution: {integrity: sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==} engines: {node: '>=0.10.0'} + npm-run-path@5.3.0: + resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -1878,6 +1976,10 @@ packages: once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + onetime@6.0.0: + resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} + engines: {node: '>=12'} + os-tmpdir@1.0.2: resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} @@ -1931,6 +2033,10 @@ packages: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} + path-key@4.0.0: + resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} + engines: {node: '>=12'} + path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} @@ -1955,6 +2061,10 @@ packages: pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} + pathval@2.0.0: + resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} + engines: {node: '>= 14.16'} + periscopic@3.1.0: resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==} @@ -2005,24 +2115,6 @@ packages: ts-node: optional: true - postcss-load-config@6.0.1: - resolution: {integrity: sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==} - engines: {node: '>= 18'} - peerDependencies: - jiti: '>=1.21.0' - postcss: '>=8.0.9' - tsx: ^4.8.1 - yaml: ^2.4.2 - peerDependenciesMeta: - jiti: - optional: true - postcss: - optional: true - tsx: - optional: true - yaml: - optional: true - postcss-nested@6.2.0: resolution: {integrity: sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==} engines: {node: '>=12.0'} @@ -2222,6 +2314,9 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} + siginfo@2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + signal-exit@3.0.7: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} @@ -2265,9 +2360,15 @@ packages: sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + stackback@0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + stacktracey@2.1.8: resolution: {integrity: sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==} + std-env@3.7.0: + resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} + stoppable@1.1.0: resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} engines: {node: '>=4', npm: '>=6'} @@ -2295,6 +2396,10 @@ packages: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} + strip-final-newline@3.0.0: + resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} + engines: {node: '>=12'} + strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -2448,6 +2553,21 @@ packages: tiny-glob@0.2.9: resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==} + tinybench@2.9.0: + resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + + tinypool@1.0.1: + resolution: {integrity: sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==} + engines: {node: ^18.0.0 || >=20.0.0} + + tinyrainbow@1.2.0: + resolution: {integrity: sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==} + engines: {node: '>=14.0.0'} + + tinyspy@3.0.0: + resolution: {integrity: sha512-q5nmENpTHgiPVd1cJDDc9cVoYN5x4vCvwT3FMilvKPKneCBZAxn2YWQjDF0UMcE9k0Cay1gBiDfTMU0g+mPMQA==} + engines: {node: '>=14.0.0'} + tmp@0.0.33: resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} engines: {node: '>=0.6.0'} @@ -2533,6 +2653,11 @@ packages: vfile-message@2.0.4: resolution: {integrity: sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==} + vite-node@2.0.5: + resolution: {integrity: sha512-LdsW4pxj0Ot69FAoXZ1yTnA9bjGohr2yNBU7QKRxpz8ITSkhuDl6h3zS/tvgz4qrNjeRnvrWeXQ8ZF7Um4W00Q==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + vite@5.4.0: resolution: {integrity: sha512-5xokfMX0PIiwCMCMb9ZJcMyh5wbBun0zUzKib+L65vAZ8GY9ePZMXxFrHbr/Kyll2+LSCY7xtERPpxkBDKngwg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -2572,6 +2697,31 @@ packages: vite: optional: true + vitest@2.0.5: + resolution: {integrity: sha512-8GUxONfauuIdeSl5f9GTgVEpg5BTOlplET4WEDaeY2QBiN8wSm68vxN/tb5z405OwppfoCavnwXafiaYBC/xOA==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/node': ^18.0.0 || >=20.0.0 + '@vitest/browser': 2.0.5 + '@vitest/ui': 2.0.5 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + web-vitals@4.2.3: resolution: {integrity: sha512-/CFAm1mNxSmOj6i0Co+iGFJ58OS4NRGVP+AWS/l509uIK5a1bSoIVaHz/ZumpHTfHSZBpgrJ+wjfpAOrTHok5Q==} @@ -2594,6 +2744,11 @@ packages: engines: {node: '>= 8'} hasBin: true + why-is-node-running@2.3.0: + resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} + engines: {node: '>=8'} + hasBin: true + workerd@1.20240806.0: resolution: {integrity: sha512-yyNtyzTMgVY0sgYijHBONqZFVXsOFGj2jDjS8MF/RbO2ZdGROvs4Hkc/9QnmqFWahE0STxXeJ1yW1yVotdF0UQ==} engines: {node: '>=16'} @@ -3053,6 +3208,43 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 + '@layerstack/svelte-actions@0.0.3': + dependencies: + '@floating-ui/dom': 1.6.10 + '@layerstack/utils': 0.0.3 + d3-array: 3.2.4 + d3-scale: 4.0.2 + date-fns: 3.6.0 + lodash-es: 4.17.21 + + '@layerstack/svelte-stores@0.0.3': + dependencies: + '@layerstack/utils': 0.0.3 + d3-array: 3.2.4 + date-fns: 3.6.0 + immer: 10.1.1 + lodash-es: 4.17.21 + zod: 3.23.8 + + '@layerstack/tailwind@0.0.5': + dependencies: + '@layerstack/utils': 0.0.3 + clsx: 2.1.1 + culori: 4.0.1 + d3-array: 3.2.4 + date-fns: 3.6.0 + lodash-es: 4.17.21 + tailwind-merge: 2.5.2 + tailwindcss: 3.4.10 + transitivePeerDependencies: + - ts-node + + '@layerstack/utils@0.0.3': + dependencies: + d3-array: 3.2.4 + date-fns: 3.6.0 + lodash-es: 4.17.21 + '@manypkg/find-root@1.1.0': dependencies: '@babel/runtime': 7.24.7 @@ -3365,6 +3557,39 @@ snapshots: '@types/unist@3.0.2': {} + '@vitest/expect@2.0.5': + dependencies: + '@vitest/spy': 2.0.5 + '@vitest/utils': 2.0.5 + chai: 5.1.1 + tinyrainbow: 1.2.0 + + '@vitest/pretty-format@2.0.5': + dependencies: + tinyrainbow: 1.2.0 + + '@vitest/runner@2.0.5': + dependencies: + '@vitest/utils': 2.0.5 + pathe: 1.1.2 + + '@vitest/snapshot@2.0.5': + dependencies: + '@vitest/pretty-format': 2.0.5 + magic-string: 0.30.11 + pathe: 1.1.2 + + '@vitest/spy@2.0.5': + dependencies: + tinyspy: 3.0.0 + + '@vitest/utils@2.0.5': + dependencies: + '@vitest/pretty-format': 2.0.5 + estree-walker: 3.0.3 + loupe: 3.1.1 + tinyrainbow: 1.2.0 + acorn-walk@8.3.3: dependencies: acorn: 8.12.1 @@ -3414,6 +3639,8 @@ snapshots: dependencies: printable-characters: 1.0.42 + assertion-error@2.0.1: {} + autoprefixer@10.4.20(postcss@8.4.41): dependencies: browserslist: 4.23.3 @@ -3466,6 +3693,8 @@ snapshots: builtin-modules@3.3.0: {} + cac@6.7.14: {} + camelcase-css@2.0.1: {} caniuse-lite@1.0.30001651: {} @@ -3477,6 +3706,14 @@ snapshots: transitivePeerDependencies: - supports-color + chai@5.1.1: + dependencies: + assertion-error: 2.0.1 + check-error: 2.1.1 + deep-eql: 5.0.2 + loupe: 3.1.1 + pathval: 2.0.0 + chalk@2.4.2: dependencies: ansi-styles: 3.2.1 @@ -3485,6 +3722,8 @@ snapshots: chardet@0.7.0: {} + check-error@2.1.1: {} + chokidar@3.6.0: dependencies: anymatch: 3.1.3 @@ -3680,6 +3919,8 @@ snapshots: dedent-js@1.0.1: {} + deep-eql@5.0.2: {} + deepmerge@4.3.1: {} defu@6.1.4: {} @@ -3790,6 +4031,18 @@ snapshots: dependencies: '@types/estree': 1.0.5 + execa@8.0.1: + dependencies: + cross-spawn: 7.0.3 + get-stream: 8.0.1 + human-signals: 5.0.0 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.3.0 + onetime: 6.0.0 + signal-exit: 4.1.0 + strip-final-newline: 3.0.0 + exit-hook@2.2.1: {} extendable-error@0.1.7: {} @@ -3867,11 +4120,15 @@ snapshots: function-bind@1.1.2: {} + get-func-name@2.0.2: {} + get-source@2.0.12: dependencies: data-uri-to-buffer: 2.0.2 source-map: 0.6.1 + get-stream@8.0.1: {} + github-slugger@2.0.0: {} glob-parent@5.1.2: @@ -3942,6 +4199,8 @@ snapshots: human-id@1.0.2: {} + human-signals@5.0.0: {} + iconv-lite@0.4.24: dependencies: safer-buffer: 2.1.2 @@ -3995,6 +4254,8 @@ snapshots: dependencies: '@types/estree': 1.0.5 + is-stream@3.0.0: {} + is-subdir@1.2.0: dependencies: better-path-resolve: 1.0.0 @@ -4070,6 +4331,10 @@ snapshots: lodash.startcase@4.4.0: {} + loupe@3.1.1: + dependencies: + get-func-name: 2.0.2 + lower-case@2.0.2: dependencies: tslib: 2.6.3 @@ -4107,6 +4372,8 @@ snapshots: svelte: 4.2.18 vfile-message: 2.0.4 + merge-stream@2.0.0: {} + merge2@1.4.1: {} micromatch@4.0.5: @@ -4121,6 +4388,8 @@ snapshots: mime@3.0.0: {} + mimic-fn@4.0.0: {} + min-indent@1.0.1: {} miniflare@3.20240806.0: @@ -4197,6 +4466,10 @@ snapshots: normalize-range@0.1.2: {} + npm-run-path@5.3.0: + dependencies: + path-key: 4.0.0 + object-assign@4.1.1: {} object-hash@3.0.0: {} @@ -4205,6 +4478,10 @@ snapshots: dependencies: wrappy: 1.0.2 + onetime@6.0.0: + dependencies: + mimic-fn: 4.0.0 + os-tmpdir@1.0.2: {} outdent@0.5.0: {} @@ -4246,6 +4523,8 @@ snapshots: path-key@3.1.1: {} + path-key@4.0.0: {} + path-parse@1.0.7: {} path-scurry@1.11.1: @@ -4269,6 +4548,8 @@ snapshots: pathe@1.1.2: {} + pathval@2.0.0: {} + periscopic@3.1.0: dependencies: '@types/estree': 1.0.5 @@ -4308,13 +4589,6 @@ snapshots: optionalDependencies: postcss: 8.4.41 - postcss-load-config@6.0.1(postcss@8.4.41): - dependencies: - lilconfig: 3.1.2 - optionalDependencies: - postcss: 8.4.41 - optional: true - postcss-nested@6.2.0(postcss@8.4.41): dependencies: postcss: 8.4.41 @@ -4524,6 +4798,8 @@ snapshots: shebang-regex@3.0.0: {} + siginfo@2.0.0: {} + signal-exit@3.0.7: {} signal-exit@4.1.0: {} @@ -4560,11 +4836,15 @@ snapshots: sprintf-js@1.0.3: {} + stackback@0.0.2: {} + stacktracey@2.1.8: dependencies: as-table: 1.0.55 get-source: 2.0.12 + std-env@3.7.0: {} + stoppable@1.1.0: {} stream-source@0.3.5: {} @@ -4591,6 +4871,8 @@ snapshots: strip-bom@3.0.0: {} + strip-final-newline@3.0.0: {} + strip-indent@3.0.0: dependencies: min-indent: 1.0.1 @@ -4611,7 +4893,7 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - sveld@0.20.0(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41): + sveld@0.20.0(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41): dependencies: '@rollup/plugin-node-resolve': 13.3.0(rollup@2.79.1) acorn: 8.12.1 @@ -4621,7 +4903,7 @@ snapshots: rollup: 2.79.1 rollup-plugin-svelte: 7.2.2(rollup@2.79.1)(svelte@4.2.18) svelte: 4.2.18 - svelte-preprocess: 5.1.4(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4) + svelte-preprocess: 5.1.4(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4) typescript: 5.5.4 transitivePeerDependencies: - '@babel/core' @@ -4634,14 +4916,14 @@ snapshots: - stylus - sugarss - svelte-check@3.8.5(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18): + svelte-check@3.8.5(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18): dependencies: '@jridgewell/trace-mapping': 0.3.25 chokidar: 3.6.0 picocolors: 1.0.1 sade: 1.8.1 svelte: 4.2.18 - svelte-preprocess: 5.1.4(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4) + svelte-preprocess: 5.1.4(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4) typescript: 5.5.4 transitivePeerDependencies: - '@babel/core' @@ -4662,7 +4944,7 @@ snapshots: dependencies: svelte: 4.2.18 - svelte-preprocess@5.1.4(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4): + svelte-preprocess@5.1.4(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4): dependencies: '@types/pug': 2.0.10 detect-indent: 6.1.0 @@ -4672,18 +4954,18 @@ snapshots: svelte: 4.2.18 optionalDependencies: postcss: 8.4.41 - postcss-load-config: 6.0.1(postcss@8.4.41) + postcss-load-config: 4.0.2(postcss@8.4.41) typescript: 5.5.4 - svelte-preprocess@6.0.2(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4): + svelte-preprocess@6.0.2(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18)(typescript@5.5.4): dependencies: svelte: 4.2.18 optionalDependencies: postcss: 8.4.41 - postcss-load-config: 6.0.1(postcss@8.4.41) + postcss-load-config: 4.0.2(postcss@8.4.41) typescript: 5.5.4 - svelte-ux@0.74.4(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18): + svelte-ux@0.74.4(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41)(svelte@4.2.18): dependencies: '@floating-ui/dom': 1.6.10 '@fortawesome/fontawesome-common-types': 6.6.0 @@ -4698,7 +4980,7 @@ snapshots: prism-svelte: 0.5.0 prism-themes: 1.9.0 prismjs: 1.29.0 - sveld: 0.20.0(postcss-load-config@6.0.1(postcss@8.4.41))(postcss@8.4.41) + sveld: 0.20.0(postcss-load-config@4.0.2(postcss@8.4.41))(postcss@8.4.41) svelte: 4.2.18 tailwind-merge: 2.5.2 zod: 3.23.8 @@ -4783,6 +5065,14 @@ snapshots: globalyzer: 0.1.0 globrex: 0.1.2 + tinybench@2.9.0: {} + + tinypool@1.0.1: {} + + tinyrainbow@1.2.0: {} + + tinyspy@3.0.0: {} + tmp@0.0.33: dependencies: os-tmpdir: 1.0.2 @@ -4867,6 +5157,24 @@ snapshots: '@types/unist': 2.0.10 unist-util-stringify-position: 2.0.3 + vite-node@2.0.5(@types/node@22.3.0): + dependencies: + cac: 6.7.14 + debug: 4.3.6 + pathe: 1.1.2 + tinyrainbow: 1.2.0 + vite: 5.4.0(@types/node@22.3.0) + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + vite@5.4.0(@types/node@22.3.0): dependencies: esbuild: 0.21.5 @@ -4880,6 +5188,39 @@ snapshots: optionalDependencies: vite: 5.4.0(@types/node@22.3.0) + vitest@2.0.5(@types/node@22.3.0): + dependencies: + '@ampproject/remapping': 2.3.0 + '@vitest/expect': 2.0.5 + '@vitest/pretty-format': 2.0.5 + '@vitest/runner': 2.0.5 + '@vitest/snapshot': 2.0.5 + '@vitest/spy': 2.0.5 + '@vitest/utils': 2.0.5 + chai: 5.1.1 + debug: 4.3.6 + execa: 8.0.1 + magic-string: 0.30.11 + pathe: 1.1.2 + std-env: 3.7.0 + tinybench: 2.9.0 + tinypool: 1.0.1 + tinyrainbow: 1.2.0 + vite: 5.4.0(@types/node@22.3.0) + vite-node: 2.0.5(@types/node@22.3.0) + why-is-node-running: 2.3.0 + optionalDependencies: + '@types/node': 22.3.0 + transitivePeerDependencies: + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + web-vitals@4.2.3: {} webidl-conversions@3.0.1: {} @@ -4902,6 +5243,11 @@ snapshots: dependencies: isexe: 2.0.0 + why-is-node-running@2.3.0: + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 + workerd@1.20240806.0: optionalDependencies: '@cloudflare/workerd-darwin-64': 1.20240806.0