layerchart 0.42.0 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Arc.svelte +27 -20
- package/dist/components/Arc.svelte.d.ts +2 -2
- package/dist/components/Area.svelte +11 -7
- package/dist/components/Area.svelte.d.ts +3 -3
- package/dist/components/AreaStack.svelte +3 -2
- package/dist/components/Axis.svelte +38 -41
- package/dist/components/Axis.svelte.d.ts +5 -4
- package/dist/components/Bar.svelte +6 -5
- package/dist/components/Bar.svelte.d.ts +3 -2
- package/dist/components/Bars.svelte +5 -4
- package/dist/components/Bars.svelte.d.ts +3 -2
- package/dist/components/Bounds.svelte +7 -5
- package/dist/components/Bounds.svelte.d.ts +8 -8
- package/dist/components/Brush.svelte +8 -6
- package/dist/components/Brush.svelte.d.ts +2 -2
- package/dist/components/Calendar.svelte +4 -3
- package/dist/components/Chart.svelte +71 -85
- package/dist/components/Chart.svelte.d.ts +216 -24
- package/dist/components/ChartClipPath.svelte +6 -6
- package/dist/components/ChartContext.svelte +19 -0
- package/dist/components/ChartContext.svelte.d.ts +89 -0
- package/dist/components/Circle.svelte +1 -0
- package/dist/components/ClipPath.svelte +1 -0
- package/dist/components/ForceSimulation.svelte +4 -3
- package/dist/components/ForceSimulation.svelte.d.ts +1 -2
- package/dist/components/Frame.svelte +8 -7
- package/dist/components/Frame.svelte.d.ts +1 -1
- package/dist/components/GeoCircle.svelte.d.ts +1 -2
- package/dist/components/GeoContext.svelte +2 -1
- package/dist/components/GeoContext.svelte.d.ts +5 -5
- package/dist/components/GeoEdgeFade.svelte +2 -5
- package/dist/components/GeoPath.svelte +9 -5
- package/dist/components/GeoPath.svelte.d.ts +7 -4
- package/dist/components/GeoPoint.svelte +0 -1
- package/dist/components/GeoSpline.svelte +2 -11
- package/dist/components/GeoTile.svelte +3 -1
- package/dist/components/Group.svelte +4 -2
- package/dist/components/Highlight.svelte +16 -10
- package/dist/components/Highlight.svelte.d.ts +16 -15
- package/dist/components/HitCanvas.svelte +5 -2
- package/dist/components/HitCanvas.svelte.d.ts +1 -1
- package/dist/components/Hull.svelte +6 -3
- package/dist/components/Labels.svelte +5 -4
- package/dist/components/Labels.svelte.d.ts +0 -1
- package/dist/components/Legend.svelte +4 -4
- package/dist/components/Legend.svelte.d.ts +2 -2
- package/dist/components/Line.svelte +1 -0
- package/dist/components/Link.svelte +3 -1
- package/dist/components/Pack.svelte +4 -3
- package/dist/components/Partition.svelte +3 -3
- package/dist/components/Partition.svelte.d.ts +2 -1
- package/dist/components/Pie.svelte +7 -6
- package/dist/components/Pie.svelte.d.ts +2 -4
- package/dist/components/Point.svelte +2 -2
- package/dist/components/Points.svelte +4 -3
- package/dist/components/RadialGradient.svelte +2 -2
- package/dist/components/RadialGradient.svelte.d.ts +0 -1
- package/dist/components/Rect.svelte +1 -0
- package/dist/components/Rule.svelte +3 -3
- package/dist/components/Sankey.svelte +9 -3
- package/dist/components/Sankey.svelte.d.ts +2 -2
- package/dist/components/Spline.svelte +9 -6
- package/dist/components/Spline.svelte.d.ts +2 -2
- package/dist/components/Text.svelte +1 -2
- package/dist/components/Threshold.svelte +2 -2
- package/dist/components/Threshold.svelte.d.ts +2 -2
- package/dist/components/TileImage.svelte +4 -1
- package/dist/components/Tooltip.svelte +3 -3
- package/dist/components/TooltipContext.svelte +46 -15
- package/dist/components/TooltipContext.svelte.d.ts +1 -1
- package/dist/components/TooltipItem.svelte.d.ts +1 -1
- package/dist/components/TransformContext.svelte +17 -6
- package/dist/components/TransformControls.svelte +1 -0
- package/dist/components/Tree.svelte +4 -3
- package/dist/components/Tree.svelte.d.ts +3 -3
- package/dist/components/Treemap.svelte +11 -12
- package/dist/components/Treemap.svelte.d.ts +6 -6
- package/dist/components/Voronoi.svelte +8 -3
- package/dist/components/layout/Canvas.svelte +5 -3
- package/dist/components/layout/Html.svelte +3 -3
- package/dist/components/layout/Svg.svelte +6 -3
- package/dist/docs/Code.svelte +2 -3
- package/dist/docs/GeoDebug.svelte +4 -4
- package/dist/docs/Link.svelte +2 -4
- package/dist/docs/Link.svelte.d.ts +14 -5
- package/dist/docs/Preview.svelte +1 -1
- package/dist/docs/TilesetField.svelte +1 -1
- package/dist/docs/TilesetField.svelte.d.ts +1 -1
- package/dist/docs/ViewSourceButton.svelte +4 -4
- package/dist/docs/ViewSourceButton.svelte.d.ts +5 -3
- package/dist/stores/motionStore.d.ts +2 -2
- package/dist/stores/motionStore.js +4 -2
- package/dist/utils/array.d.ts +5 -0
- package/dist/utils/array.js +7 -0
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.js +18 -0
- package/dist/utils/genData.d.ts +23 -23
- package/dist/utils/genData.js +3 -2
- package/dist/utils/geo.d.ts +3 -3
- package/dist/utils/geo.js +2 -0
- package/dist/utils/graph.d.ts +1 -1
- package/dist/utils/graph.js +3 -3
- package/dist/utils/hierarchy.d.ts +1 -1
- package/dist/utils/hierarchy.js +1 -0
- package/dist/utils/rect.d.ts +5 -3
- package/dist/utils/rect.js +7 -11
- package/dist/utils/scales.d.ts +21 -12
- package/dist/utils/scales.js +3 -1
- package/dist/utils/stack.d.ts +5 -2
- package/dist/utils/stack.js +20 -7
- package/dist/utils/threshold.js +1 -0
- package/dist/utils/treemap.d.ts +5 -2
- package/dist/utils/treemap.js +1 -1
- package/package.json +5 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
<script>import { createEventDispatcher
|
|
1
|
+
<script>import { createEventDispatcher } from 'svelte';
|
|
2
2
|
import { forceSimulation } from 'd3-force';
|
|
3
|
-
|
|
3
|
+
import { chartContext } from './ChartContext.svelte';
|
|
4
|
+
const { data } = chartContext();
|
|
4
5
|
const dispatch = createEventDispatcher();
|
|
5
6
|
export let forces;
|
|
6
7
|
export let alpha = 1;
|
|
@@ -8,7 +9,7 @@ export let alphaTarget = 0;
|
|
|
8
9
|
export let alphaDecay = 1 - Math.pow(0.001, 1 / 300);
|
|
9
10
|
export let alphaMin = 0.001;
|
|
10
11
|
export let velocityDecay = 0.4;
|
|
11
|
-
|
|
12
|
+
/** Stop simulation */
|
|
12
13
|
export let stopped = false;
|
|
13
14
|
let _static = false;
|
|
14
15
|
/** If true, will only update nodes after simulation has completed */
|
|
@@ -8,8 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
alphaDecay?: number;
|
|
9
9
|
alphaMin?: number;
|
|
10
10
|
velocityDecay?: number;
|
|
11
|
-
|
|
12
|
-
stopped?: boolean;
|
|
11
|
+
/** Stop simulation */ stopped?: boolean;
|
|
13
12
|
/** If true, will only update nodes after simulation has completed */ static?: boolean;
|
|
14
13
|
/** Clone data since simulation mutates original */ cloneData?: boolean;
|
|
15
14
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
const { width, height, padding } =
|
|
1
|
+
<script>import { chartContext } from './ChartContext.svelte';
|
|
2
|
+
const { width, height, padding } = chartContext();
|
|
3
3
|
/** Include padding area */
|
|
4
4
|
export let full = false;
|
|
5
5
|
/** Access underlying `<rect>` element */
|
|
6
|
-
export let rectEl;
|
|
6
|
+
export let rectEl = undefined;
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
9
10
|
<rect
|
|
10
|
-
x={full ? -$padding.left : 0}
|
|
11
|
-
y={full ? -$padding.top : 0}
|
|
12
|
-
width={$width + (full ? $padding
|
|
13
|
-
height={$height + (full ? $padding
|
|
11
|
+
x={full && $padding?.left ? -$padding.left : 0}
|
|
12
|
+
y={full && $padding?.top ? -$padding.top : 0}
|
|
13
|
+
width={$width + (full ? ($padding?.left ?? 0) + ($padding?.right ?? 0) : 0)}
|
|
14
|
+
height={$height + (full ? ($padding?.top ?? 0) + ($padding?.bottom ?? 0) : 0)}
|
|
14
15
|
on:click
|
|
15
16
|
on:pointerdown
|
|
16
17
|
on:dblclick
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import GeoPath from './GeoPath.svelte';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
@@ -11,7 +10,7 @@ declare const __propDef: {
|
|
|
11
10
|
pointermove: PointerEvent;
|
|
12
11
|
pointerleave: PointerEvent;
|
|
13
12
|
click: CustomEvent<{
|
|
14
|
-
geoPath:
|
|
13
|
+
geoPath: ReturnType<typeof import("..").geoCurvePath>;
|
|
15
14
|
event: MouseEvent;
|
|
16
15
|
}>;
|
|
17
16
|
} & {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script context="module">import { getContext, setContext } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
3
|
import {} from 'd3-geo';
|
|
4
|
+
import { chartContext } from './ChartContext.svelte';
|
|
4
5
|
import { transformContext } from './TransformContext.svelte';
|
|
5
6
|
export const geoContextKey = Symbol();
|
|
6
7
|
export function geoContext() {
|
|
@@ -11,7 +12,7 @@ function setGeoContext(geo) {
|
|
|
11
12
|
}
|
|
12
13
|
</script>
|
|
13
14
|
|
|
14
|
-
<script>const { width, height } =
|
|
15
|
+
<script>const { width, height } = chartContext();
|
|
15
16
|
/** @type {Function} projection - A d3 projection function. Pass this in as an uncalled function, e.g. `projection={geoAlbersUsa}`. */
|
|
16
17
|
export let projection = undefined;
|
|
17
18
|
export let fitGeojson = undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import { type Writable } from 'svelte/store';
|
|
3
|
-
import { type
|
|
3
|
+
import { type GeoPermissibleObjects, type GeoProjection } from 'd3-geo';
|
|
4
4
|
export declare const geoContextKey: unique symbol;
|
|
5
|
-
export type GeoContext = Writable<GeoProjection
|
|
5
|
+
export type GeoContext = Writable<GeoProjection>;
|
|
6
6
|
export declare function geoContext(): GeoContext;
|
|
7
7
|
declare const __propDef: {
|
|
8
8
|
props: {
|
|
9
|
-
/** @type {Function} projection - A d3 projection function. Pass this in as an uncalled function, e.g. `projection={geoAlbersUsa}`. */ projection?: (() => GeoProjection
|
|
9
|
+
/** @type {Function} projection - A d3 projection function. Pass this in as an uncalled function, e.g. `projection={geoAlbersUsa}`. */ projection?: (() => GeoProjection) | undefined;
|
|
10
10
|
fitGeojson?: GeoPermissibleObjects | undefined;
|
|
11
11
|
/** By default, the map fills to fit the $width and $height. If instead you want a fixed-aspect ratio, like for a server-side rendered map, set that here. */ fixedAspectRatio?: number | undefined;
|
|
12
12
|
clipAngle?: number | undefined;
|
|
@@ -25,14 +25,14 @@ declare const __propDef: {
|
|
|
25
25
|
/** Apply TransformContext to the selected properties. Typically `translate` or `rotate` are mutually selected */ applyTransform?: ("scale" | "translate" | "rotate")[];
|
|
26
26
|
reflectX?: boolean | undefined;
|
|
27
27
|
reflectY?: boolean | undefined;
|
|
28
|
-
/** Exposed to allow binding in Chart */ geo?: Writable<GeoProjection
|
|
28
|
+
/** Exposed to allow binding in Chart */ geo?: Writable<GeoProjection>;
|
|
29
29
|
};
|
|
30
30
|
events: {
|
|
31
31
|
[evt: string]: CustomEvent<any>;
|
|
32
32
|
};
|
|
33
33
|
slots: {
|
|
34
34
|
default: {
|
|
35
|
-
projection: GeoProjection
|
|
35
|
+
projection: GeoProjection;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { scaleLinear } from 'd3-scale';
|
|
1
|
+
<script>import { scaleLinear } from 'd3-scale';
|
|
3
2
|
import { geoDistance } from 'd3-geo';
|
|
4
3
|
import { geoContext } from './GeoContext.svelte';
|
|
5
4
|
export let link;
|
|
6
|
-
const { width, height } = getContext('LayerCake');
|
|
7
5
|
const geo = geoContext();
|
|
8
6
|
const fade = scaleLinear().domain([-0.1, 0]).range([0, 0.1]);
|
|
9
7
|
const clamper = scaleLinear().domain([0, 1]).range([0, 1]).clamp(true);
|
|
10
|
-
|
|
11
|
-
$: center = $geo.invert($geo.translate());
|
|
8
|
+
$: center = $geo.invert?.($geo.translate()) ?? [0, 0];
|
|
12
9
|
$: source = link.source;
|
|
13
10
|
$: target = link.target;
|
|
14
11
|
$: startDistance = 1.57 - geoDistance(source, center);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { createEventDispatcher, getContext } from 'svelte';
|
|
2
2
|
import { geoTransform as d3geoTransform, } from 'd3-geo';
|
|
3
3
|
import { cls } from 'svelte-ux';
|
|
4
|
+
import { chartContext } from './ChartContext.svelte';
|
|
4
5
|
import { geoContext } from './GeoContext.svelte';
|
|
5
6
|
import { curveLinearClosed } from 'd3-shape';
|
|
6
7
|
import { geoCurvePath } from '../utils/geo.js';
|
|
@@ -27,7 +28,7 @@ export let curve = curveLinearClosed;
|
|
|
27
28
|
let className = undefined;
|
|
28
29
|
export { className as class };
|
|
29
30
|
const dispatch = createEventDispatcher();
|
|
30
|
-
const { containerWidth, containerHeight, padding } =
|
|
31
|
+
const { containerWidth, containerHeight, padding } = chartContext();
|
|
31
32
|
const canvas = getContext('canvas');
|
|
32
33
|
const geo = geoContext();
|
|
33
34
|
/**
|
|
@@ -58,25 +59,28 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
58
59
|
$ctx.beginPath();
|
|
59
60
|
// Set the context here since setting it in `$: geoPath` is a circular reference
|
|
60
61
|
geoPath = geoCurvePath(_projection, curve, $ctx);
|
|
61
|
-
|
|
62
|
+
if (geojson) {
|
|
63
|
+
geoPath(geojson);
|
|
64
|
+
}
|
|
62
65
|
$ctx.fillStyle =
|
|
63
66
|
fill ??
|
|
64
67
|
(computedStyles.fill !== DEFAULT_FILL ? computedStyles.fill : undefined) ??
|
|
65
68
|
'transparent';
|
|
66
69
|
$ctx.fill();
|
|
67
|
-
$ctx.lineWidth = strokeWidth;
|
|
70
|
+
$ctx.lineWidth = Number(strokeWidth ?? 0);
|
|
68
71
|
$ctx.strokeStyle =
|
|
69
|
-
stroke ?? computedStyles.stroke === 'none' ? 'transparent' : computedStyles.stroke;
|
|
72
|
+
stroke ?? computedStyles.stroke === 'none' ? 'transparent' : computedStyles.stroke ?? '';
|
|
70
73
|
$ctx.stroke();
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
</script>
|
|
74
77
|
|
|
78
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
75
79
|
{#if renderContext === 'svg'}
|
|
76
80
|
<slot {geoPath}>
|
|
77
81
|
<path
|
|
78
82
|
{...$$restProps}
|
|
79
|
-
d={geoPath(geojson)}
|
|
83
|
+
d={geojson ? geoPath(geojson) : ''}
|
|
80
84
|
{fill}
|
|
81
85
|
{stroke}
|
|
82
86
|
stroke-width={strokeWidth}
|
|
@@ -2,11 +2,14 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
import { type GeoIdentityTransform, type GeoPermissibleObjects, type GeoProjection, type GeoTransformPrototype } from 'd3-geo';
|
|
3
3
|
import type { TooltipContextValue } from './TooltipContext.svelte';
|
|
4
4
|
import { type CurveFactory, type CurveFactoryLineOnly } from 'd3-shape';
|
|
5
|
+
import { geoCurvePath } from '../utils/geo.js';
|
|
5
6
|
declare const __propDef: {
|
|
6
7
|
props: {
|
|
7
8
|
[x: string]: any;
|
|
8
|
-
geojson?: GeoPermissibleObjects;
|
|
9
|
-
render?: ((ctx: CanvasRenderingContext2D,
|
|
9
|
+
geojson?: GeoPermissibleObjects | null | undefined;
|
|
10
|
+
render?: ((ctx: CanvasRenderingContext2D, options: {
|
|
11
|
+
geoPath: ReturnType<typeof geoCurvePath>;
|
|
12
|
+
}) => any) | undefined;
|
|
10
13
|
fill?: string | undefined;
|
|
11
14
|
stroke?: string | undefined;
|
|
12
15
|
strokeWidth?: number | string | undefined;
|
|
@@ -21,7 +24,7 @@ declare const __propDef: {
|
|
|
21
24
|
pointerleave: PointerEvent;
|
|
22
25
|
pointerdown: PointerEvent;
|
|
23
26
|
click: CustomEvent<{
|
|
24
|
-
geoPath:
|
|
27
|
+
geoPath: ReturnType<typeof geoCurvePath>;
|
|
25
28
|
event: MouseEvent;
|
|
26
29
|
}>;
|
|
27
30
|
} & {
|
|
@@ -29,7 +32,7 @@ declare const __propDef: {
|
|
|
29
32
|
};
|
|
30
33
|
slots: {
|
|
31
34
|
default: {
|
|
32
|
-
geoPath: (
|
|
35
|
+
geoPath: import("d3-geo").GeoPath<unknown, GeoPermissibleObjects>;
|
|
33
36
|
};
|
|
34
37
|
};
|
|
35
38
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { curveNatural } from 'd3-shape';
|
|
1
|
+
<script>import { curveNatural } from 'd3-shape';
|
|
3
2
|
import { geoOrthographic, geoInterpolate } from 'd3-geo';
|
|
4
3
|
import { geoContext } from './GeoContext.svelte';
|
|
5
4
|
import Spline from './Spline.svelte';
|
|
@@ -16,7 +15,6 @@ export let loft = 1.0;
|
|
|
16
15
|
* @type {CurveFactory | CurveFactoryLineOnly | undefined}
|
|
17
16
|
*/
|
|
18
17
|
export let curve = curveNatural;
|
|
19
|
-
const { width, height } = getContext('LayerCake');
|
|
20
18
|
const geo = geoContext();
|
|
21
19
|
$: loftedProjection = geoOrthographic()
|
|
22
20
|
.translate($geo.translate())
|
|
@@ -27,11 +25,4 @@ $: target = $geo(link.target);
|
|
|
27
25
|
$: middle = loftedProjection(geoInterpolate(link.source, link.target)(0.5));
|
|
28
26
|
</script>
|
|
29
27
|
|
|
30
|
-
<Spline
|
|
31
|
-
data={[source, middle, target]}
|
|
32
|
-
x={(d) => d[0]}
|
|
33
|
-
y={(d) => d[1]}
|
|
34
|
-
defined={(d) => $geo.invert(d)}
|
|
35
|
-
{curve}
|
|
36
|
-
{...$$restProps}
|
|
37
|
-
/>
|
|
28
|
+
<Spline data={[source, middle, target]} x={(d) => d[0]} y={(d) => d[1]} {curve} {...$$restProps} />
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
+
// @ts-expect-error
|
|
2
3
|
import { tile as d3Tile } from 'd3-tile';
|
|
4
|
+
import { chartContext } from './ChartContext.svelte';
|
|
3
5
|
import { geoContext } from './GeoContext.svelte';
|
|
4
6
|
import Group from './Group.svelte';
|
|
5
7
|
import TileImage from './TileImage.svelte';
|
|
@@ -8,7 +10,7 @@ export let zoomDelta = 0;
|
|
|
8
10
|
export let tileSize = 256;
|
|
9
11
|
export let disableCache = false;
|
|
10
12
|
export let debug = false;
|
|
11
|
-
const { containerWidth, containerHeight, padding } =
|
|
13
|
+
const { containerWidth, containerHeight, padding } = chartContext();
|
|
12
14
|
const canvas = getContext('canvas');
|
|
13
15
|
const geo = geoContext();
|
|
14
16
|
$: center = $geo([0, 0]) ?? [0, 0];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { tick } from 'svelte';
|
|
2
|
+
import { chartContext } from './ChartContext.svelte';
|
|
2
3
|
import { motionStore } from '../stores/motionStore.js';
|
|
3
|
-
const { width, height } =
|
|
4
|
+
const { width, height } = chartContext();
|
|
4
5
|
/**
|
|
5
6
|
* Translate x
|
|
6
7
|
*/
|
|
@@ -33,6 +34,7 @@ $: if (center || x != null || y != null) {
|
|
|
33
34
|
}
|
|
34
35
|
</script>
|
|
35
36
|
|
|
37
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
36
38
|
<g
|
|
37
39
|
{transform}
|
|
38
40
|
{...$$restProps}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import {} from 'svelte';
|
|
2
2
|
import { max, min } from 'd3-array';
|
|
3
3
|
import { cls, notNull } from 'svelte-ux';
|
|
4
|
-
import {
|
|
4
|
+
import { chartContext } from './ChartContext.svelte';
|
|
5
5
|
import Circle from './Circle.svelte';
|
|
6
6
|
import Line from './Line.svelte';
|
|
7
7
|
import Bar from './Bar.svelte';
|
|
8
8
|
import Rect from './Rect.svelte';
|
|
9
9
|
import { tooltipContext } from './TooltipContext.svelte';
|
|
10
|
-
|
|
10
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
11
|
+
const { flatData, x, xDomain, xScale, xRange, xGet, y, yDomain, yScale, yRange, yGet, rGet, config, } = chartContext();
|
|
11
12
|
const tooltip = tooltipContext();
|
|
12
13
|
/** Highlight specific data (annotate), espect uses tooltip data */
|
|
13
14
|
export let data = undefined;
|
|
@@ -173,6 +174,7 @@ $: if (highlightData) {
|
|
|
173
174
|
{..._area}
|
|
174
175
|
{...typeof area === 'object' ? area : null}
|
|
175
176
|
class={cls(
|
|
177
|
+
// @ts-expect-error
|
|
176
178
|
!area.fill && 'fill-surface-content/5',
|
|
177
179
|
typeof area === 'object' ? area.class : null
|
|
178
180
|
)}
|
|
@@ -185,14 +187,18 @@ $: if (highlightData) {
|
|
|
185
187
|
<slot name="bar" {bar}>
|
|
186
188
|
<Bar
|
|
187
189
|
spring={motion}
|
|
188
|
-
x={typeof bar === 'object' ? bar.x :
|
|
189
|
-
y={typeof bar === 'object' ? bar.y :
|
|
190
|
-
inset={typeof bar === 'object' ? bar.inset :
|
|
191
|
-
stroke={typeof bar === 'object' ? bar.stroke :
|
|
192
|
-
strokeWidth={typeof bar === 'object' ? bar.strokeWidth :
|
|
193
|
-
radius={typeof bar === 'object' ? bar.radius :
|
|
190
|
+
x={typeof bar === 'object' ? bar.x : undefined}
|
|
191
|
+
y={typeof bar === 'object' ? bar.y : undefined}
|
|
192
|
+
inset={typeof bar === 'object' ? bar.inset : undefined}
|
|
193
|
+
stroke={typeof bar === 'object' ? bar.stroke : undefined}
|
|
194
|
+
strokeWidth={typeof bar === 'object' ? bar.strokeWidth : undefined}
|
|
195
|
+
radius={typeof bar === 'object' ? bar.radius : undefined}
|
|
194
196
|
bar={highlightData}
|
|
195
|
-
class={cls(
|
|
197
|
+
class={cls(
|
|
198
|
+
// @ts-expect-error
|
|
199
|
+
!bar.fill && 'fill-primary',
|
|
200
|
+
typeof bar === 'object' ? bar.class : null
|
|
201
|
+
)}
|
|
196
202
|
on:click
|
|
197
203
|
/>
|
|
198
204
|
</slot>
|
|
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
import { type ComponentProps } from 'svelte';
|
|
3
3
|
import Circle from './Circle.svelte';
|
|
4
4
|
import Line from './Line.svelte';
|
|
5
|
+
import Bar from './Bar.svelte';
|
|
5
6
|
import Rect from './Rect.svelte';
|
|
6
7
|
declare const __propDef: {
|
|
7
8
|
props: {
|
|
@@ -10,7 +11,7 @@ declare const __propDef: {
|
|
|
10
11
|
/** Show points and pass props to Circles */ points?: boolean | Partial<ComponentProps<Circle>>;
|
|
11
12
|
/** Show lines and pass props to Lines */ lines?: boolean | Partial<ComponentProps<Line>>;
|
|
12
13
|
/** Show area and pass props to Rect */ area?: boolean | Partial<ComponentProps<Rect>>;
|
|
13
|
-
/** Show bar and pass props to Rect */ bar?: boolean | Partial<ComponentProps<
|
|
14
|
+
/** Show bar and pass props to Rect */ bar?: boolean | Partial<ComponentProps<Bar>>;
|
|
14
15
|
/** Set to false to disable spring transitions */ motion?: boolean;
|
|
15
16
|
};
|
|
16
17
|
events: {
|
|
@@ -30,20 +31,20 @@ declare const __propDef: {
|
|
|
30
31
|
bar: {
|
|
31
32
|
bar: boolean | Partial<{
|
|
32
33
|
[x: string]: any;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
y?:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
bar: Object;
|
|
35
|
+
x?: import("../utils/common").Accessor;
|
|
36
|
+
y?: import("../utils/common").Accessor;
|
|
37
|
+
fill?: string | undefined;
|
|
38
|
+
stroke?: string;
|
|
39
|
+
strokeWidth?: number;
|
|
40
|
+
radius?: number;
|
|
41
|
+
rounded?: "all" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
42
|
+
inset?: number;
|
|
43
|
+
groupBy?: string | undefined;
|
|
44
|
+
groupPaddingInner?: number;
|
|
45
|
+
groupPaddingOuter?: number;
|
|
46
|
+
spring?: ComponentProps<Rect>["spring"];
|
|
47
|
+
tweened?: ComponentProps<Rect>["tweened"];
|
|
47
48
|
}>;
|
|
48
49
|
};
|
|
49
50
|
lines: {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
<script>import { createEventDispatcher,
|
|
1
|
+
<script>import { createEventDispatcher, onMount, setContext } from 'svelte';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
3
|
import { scaleCanvas } from 'layercake';
|
|
4
4
|
import { cls } from 'svelte-ux';
|
|
5
|
+
import { chartContext } from './ChartContext.svelte';
|
|
5
6
|
import Canvas from './layout/Canvas.svelte';
|
|
6
7
|
import { transformContext } from './TransformContext.svelte';
|
|
7
|
-
const { width, height } =
|
|
8
|
+
const { width, height } = chartContext();
|
|
9
|
+
// @ts-expect-error: this will immediately be defined on mount via `bind:context`
|
|
8
10
|
export let context = undefined;
|
|
9
11
|
/** Show canvas for debugging */
|
|
10
12
|
export let debug = false;
|
|
@@ -29,6 +31,7 @@ function* rgbColorGenerator(step = 500) {
|
|
|
29
31
|
nextColor += step;
|
|
30
32
|
yield `rgb(${rgb.join(',')})`;
|
|
31
33
|
}
|
|
34
|
+
return 'rgb(0,0,0)';
|
|
32
35
|
}
|
|
33
36
|
$: colorGenerator = rgbColorGenerator();
|
|
34
37
|
// Reset color generator whenever updated (width/height) so always reusing same colors (and not exhausting)
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
<script>import { createEventDispatcher
|
|
1
|
+
<script>import { createEventDispatcher } from 'svelte';
|
|
2
2
|
import { cls } from 'svelte-ux';
|
|
3
3
|
import { min } from 'd3-array';
|
|
4
4
|
import { Delaunay } from 'd3-delaunay';
|
|
5
|
+
// @ts-expect-error
|
|
5
6
|
import { geoVoronoi } from 'd3-geo-voronoi';
|
|
7
|
+
import { curveLinearClosed } from 'd3-shape';
|
|
8
|
+
import { chartContext } from './ChartContext.svelte';
|
|
6
9
|
import GeoPath from './GeoPath.svelte';
|
|
7
10
|
import { geoContext } from './GeoContext.svelte';
|
|
8
11
|
import Spline from './Spline.svelte';
|
|
9
|
-
|
|
10
|
-
const { flatData, x: xContext, y: yContext } = getContext('LayerCake');
|
|
12
|
+
const { flatData, x: xContext, y: yContext } = chartContext();
|
|
11
13
|
const geo = geoContext();
|
|
12
14
|
/** Override data instead of using context */
|
|
13
15
|
export let data = undefined;
|
|
@@ -20,6 +22,7 @@ $: points = (data ?? $flatData).map((d) => {
|
|
|
20
22
|
const x = Array.isArray(xValue) ? min(xValue) : xValue;
|
|
21
23
|
const y = Array.isArray(yValue) ? min(yValue) : yValue;
|
|
22
24
|
const point = [x, y];
|
|
25
|
+
// @ts-expect-error
|
|
23
26
|
point.data = d;
|
|
24
27
|
return point;
|
|
25
28
|
});
|
|
@@ -3,24 +3,25 @@
|
|
|
3
3
|
* - [ ] Support step curves (center like scaleBand())
|
|
4
4
|
* - [ ] Support multiple values (threshold, stacks, etc)
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import {} from 'svelte';
|
|
7
7
|
import { format as formatValue, cls } from 'svelte-ux';
|
|
8
8
|
import { greatestAbs } from 'svelte-ux/utils/array';
|
|
9
|
+
const { flatData, yScale, x, y, custom } = chartContext();
|
|
9
10
|
import Text from './Text.svelte';
|
|
10
11
|
import { isScaleBand } from '../utils/scales.js';
|
|
11
12
|
import { createDimensionGetter } from '../utils/rect.js';
|
|
12
|
-
|
|
13
|
+
import { chartContext } from './ChartContext.svelte';
|
|
13
14
|
// TODO: Support 'auto' to switch `inside` to `outside` if not enough room
|
|
14
15
|
export let placement = 'outside';
|
|
15
16
|
export let offset = 4;
|
|
16
|
-
export let significantDigits = 3;
|
|
17
17
|
export let format = undefined;
|
|
18
18
|
// export let overlap = false;
|
|
19
|
+
// @ts-expect-error
|
|
19
20
|
$: yBaseline = $custom?.yBaseline ?? 0;
|
|
20
21
|
export let groupBy = undefined;
|
|
21
22
|
export let groupPaddingInner = 0.2;
|
|
22
23
|
export let groupPaddingOuter = 0;
|
|
23
|
-
$: getDimensions = createDimensionGetter(
|
|
24
|
+
$: getDimensions = createDimensionGetter(chartContext(), {
|
|
24
25
|
// x,
|
|
25
26
|
// y,
|
|
26
27
|
groupBy,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { scaleBand, scaleLinear } from 'd3-scale';
|
|
1
|
+
<script>import { scaleBand, scaleLinear } from 'd3-scale';
|
|
3
2
|
import { quantize, interpolate, interpolateRound } from 'd3-interpolate';
|
|
4
3
|
import { quantile, range } from 'd3-array';
|
|
5
4
|
import { format } from 'svelte-ux';
|
|
5
|
+
import { chartContext } from './ChartContext.svelte';
|
|
6
6
|
import ColorRamp from './ColorRamp.svelte';
|
|
7
7
|
import { cls } from 'svelte-ux';
|
|
8
|
-
const { rScale } =
|
|
8
|
+
const { rScale } = chartContext() ?? {};
|
|
9
9
|
export let scale = undefined;
|
|
10
10
|
export let title = '';
|
|
11
11
|
export let width = 320;
|
|
@@ -123,7 +123,7 @@ else {
|
|
|
123
123
|
)}
|
|
124
124
|
>
|
|
125
125
|
<div class={cls('text-[10px] font-semibold', classes.title)}>{title}</div>
|
|
126
|
-
<slot values={tickValues} {scale}>
|
|
126
|
+
<slot values={tickValues ?? []} {scale}>
|
|
127
127
|
<svg
|
|
128
128
|
{width}
|
|
129
129
|
height={height + tickLength + tickFontSize}
|
|
@@ -8,7 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
width?: number;
|
|
9
9
|
height?: number;
|
|
10
10
|
ticks?: number;
|
|
11
|
-
tickFormat?: FormatType;
|
|
11
|
+
tickFormat?: FormatType | undefined;
|
|
12
12
|
tickValues?: any[] | undefined;
|
|
13
13
|
tickFontSize?: number;
|
|
14
14
|
tickLength?: number;
|
|
@@ -25,7 +25,7 @@ declare const __propDef: {
|
|
|
25
25
|
};
|
|
26
26
|
slots: {
|
|
27
27
|
default: {
|
|
28
|
-
values: any[]
|
|
28
|
+
values: any[];
|
|
29
29
|
scale: any;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
@@ -15,17 +15,19 @@ export let x = (d) => (sankey ? d[0] : orientation === 'horizontal' ? d.y : d.x)
|
|
|
15
15
|
export let y = (d) => (sankey ? d[1] : orientation === 'horizontal' ? d.x : d.y);
|
|
16
16
|
export let curve = orientation === 'horizontal' ? curveBumpX : curveBumpY;
|
|
17
17
|
export let tweened = undefined;
|
|
18
|
+
// @ts-expect-error
|
|
18
19
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
19
20
|
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
20
21
|
$: {
|
|
21
22
|
orientation; // subscribe to orientation changes to update link
|
|
22
23
|
const link = d3Link(curve).source(source).target(target).x(x).y(y);
|
|
23
|
-
const d = link(data);
|
|
24
|
+
const d = link(data) ?? '';
|
|
24
25
|
tweened_d.set(d);
|
|
25
26
|
}
|
|
26
27
|
</script>
|
|
27
28
|
|
|
28
29
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
|
30
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
29
31
|
<path
|
|
30
32
|
class="path-link"
|
|
31
33
|
d={$tweened_d}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
3
|
-
const { data, width, height } =
|
|
1
|
+
<script>import { pack as d3Pack } from 'd3-hierarchy';
|
|
2
|
+
import { chartContext } from './ChartContext.svelte';
|
|
3
|
+
const { data, width, height } = chartContext();
|
|
4
4
|
export let size = undefined;
|
|
5
5
|
/**
|
|
6
6
|
* see: https://github.com/d3/d3-hierarchy#pack_padding
|
|
@@ -13,6 +13,7 @@ $: {
|
|
|
13
13
|
pack.padding(padding);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
// @ts-expect-error
|
|
16
17
|
$: packData = pack($data);
|
|
17
18
|
</script>
|
|
18
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
3
|
-
const { data, width, height } =
|
|
1
|
+
<script>import { partition as d3Partition, } from 'd3-hierarchy';
|
|
2
|
+
import { chartContext } from './ChartContext.svelte';
|
|
3
|
+
const { data, width, height } = chartContext();
|
|
4
4
|
export let orientation = 'horizontal';
|
|
5
5
|
export let size = undefined;
|
|
6
6
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type HierarchyRectangularNode } from 'd3-hierarchy';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
orientation?: "vertical" | "horizontal";
|
|
@@ -15,7 +16,7 @@ declare const __propDef: {
|
|
|
15
16
|
};
|
|
16
17
|
slots: {
|
|
17
18
|
default: {
|
|
18
|
-
nodes:
|
|
19
|
+
nodes: HierarchyRectangularNode<any>[];
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
};
|