layerchart 0.43.5 → 0.43.7
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/Area.svelte +13 -6
- package/dist/components/Area.svelte.d.ts +4 -3
- package/dist/components/Spline.svelte +12 -6
- package/dist/components/Spline.svelte.d.ts +3 -2
- package/dist/components/Threshold.svelte +20 -16
- package/dist/components/Threshold.svelte.d.ts +4 -3
- package/dist/utils/scales.js +1 -2
- package/package.json +12 -12
|
@@ -6,6 +6,8 @@ import { cls } from 'svelte-ux';
|
|
|
6
6
|
import { motionStore } from '../stores/motionStore.js';
|
|
7
7
|
import { chartContext } from './ChartContext.svelte';
|
|
8
8
|
import Spline from './Spline.svelte';
|
|
9
|
+
import { accessor } from '../utils/common.js';
|
|
10
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
9
11
|
const { data: contextData, xScale, yScale, xGet, yGet, yRange } = chartContext();
|
|
10
12
|
/** Override data instead of using context */
|
|
11
13
|
export let data = undefined;
|
|
@@ -26,6 +28,11 @@ export let curve = undefined;
|
|
|
26
28
|
export let defined = undefined;
|
|
27
29
|
/** Enable showing line */
|
|
28
30
|
export let line = false;
|
|
31
|
+
const _x = accessor(x);
|
|
32
|
+
const _y0 = accessor(y0);
|
|
33
|
+
const _y1 = accessor(y1);
|
|
34
|
+
$: xOffset = isScaleBand($xScale) ? $xScale.bandwidth() / 2 : 0;
|
|
35
|
+
$: yOffset = isScaleBand($yScale) ? $yScale.bandwidth() / 2 : 0;
|
|
29
36
|
$: tweenedOptions = tweened
|
|
30
37
|
? { interpolate: interpolatePath, ...(typeof tweened === 'object' ? tweened : null) }
|
|
31
38
|
: false;
|
|
@@ -33,13 +40,13 @@ $: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
|
33
40
|
$: {
|
|
34
41
|
const path = radial
|
|
35
42
|
? areaRadial()
|
|
36
|
-
.angle((d) => (x ? $xScale(
|
|
37
|
-
.innerRadius((d) => (y0 ? $yScale(
|
|
38
|
-
.outerRadius((d) => (y1 ? $yScale(
|
|
43
|
+
.angle((d) => (x ? $xScale(_x(d)) : $xGet(d)))
|
|
44
|
+
.innerRadius((d) => (y0 ? $yScale(_y0(d)) : max($yRange)))
|
|
45
|
+
.outerRadius((d) => (y1 ? $yScale(_y1(d)) : $yGet(d)))
|
|
39
46
|
: d3Area()
|
|
40
|
-
.x((d) => (x ? $xScale(
|
|
41
|
-
.y0((d) => (y0 ? $yScale(
|
|
42
|
-
.y1((d) => (y1 ? $yScale(
|
|
47
|
+
.x((d) => (x ? $xScale(_x(d)) : $xGet(d)) + xOffset)
|
|
48
|
+
.y0((d) => (y0 ? $yScale(_y0(d)) : max($yRange)) + yOffset)
|
|
49
|
+
.y1((d) => (y1 ? $yScale(_y1(d)) : $yGet(d)) + yOffset);
|
|
43
50
|
if (curve)
|
|
44
51
|
path.curve(curve);
|
|
45
52
|
if (defined)
|
|
@@ -3,15 +3,16 @@ import { type ComponentProps } from 'svelte';
|
|
|
3
3
|
import type { tweened as tweenedStore } from 'svelte/motion';
|
|
4
4
|
import type { CurveFactory } from 'd3-shape';
|
|
5
5
|
import Spline from './Spline.svelte';
|
|
6
|
+
import { type Accessor } from '../utils/common.js';
|
|
6
7
|
declare const __propDef: {
|
|
7
8
|
props: {
|
|
8
9
|
[x: string]: any;
|
|
9
10
|
data?: any;
|
|
10
11
|
pathData?: string | undefined | null;
|
|
11
12
|
radial?: boolean;
|
|
12
|
-
x?:
|
|
13
|
-
y0?:
|
|
14
|
-
y1?:
|
|
13
|
+
x?: Accessor;
|
|
14
|
+
y0?: Accessor;
|
|
15
|
+
y1?: Accessor;
|
|
15
16
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
16
17
|
clipPath?: string | undefined;
|
|
17
18
|
curve?: CurveFactory | undefined;
|
|
@@ -10,6 +10,8 @@ import { cls } from 'svelte-ux';
|
|
|
10
10
|
import { chartContext } from './ChartContext.svelte';
|
|
11
11
|
import Group from './Group.svelte';
|
|
12
12
|
import { motionStore } from '../stores/motionStore.js';
|
|
13
|
+
import { accessor } from '../utils/common.js';
|
|
14
|
+
import { isScaleBand } from '../utils/scales.js';
|
|
13
15
|
const { data: contextData, xScale, yScale, x: contextX, y: contextY } = chartContext();
|
|
14
16
|
/** Override data instead of using context */
|
|
15
17
|
export let data = undefined;
|
|
@@ -18,9 +20,9 @@ export let pathData = undefined;
|
|
|
18
20
|
/** Use radial instead of cartesian line generator, mapping `x` to `angle` and `y` to `radius`. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
|
|
19
21
|
export let radial = false;
|
|
20
22
|
/** Override `x` accessor from Chart context. Applies to `angle` when `radial=true` */
|
|
21
|
-
export let x = undefined;
|
|
23
|
+
export let x = undefined;
|
|
22
24
|
/** Override `y` accessor from Chart context. Applies to `radius` when `radial=true` */
|
|
23
|
-
export let y = undefined;
|
|
25
|
+
export let y = undefined;
|
|
24
26
|
/** Interpolate path data using d3-interpolate-path. Works best without `draw` enabled */
|
|
25
27
|
export let tweened = undefined;
|
|
26
28
|
/** Draw path over time. Works best without `tweened` enabled */
|
|
@@ -46,6 +48,10 @@ function getScaleValue(data, scale, accessor) {
|
|
|
46
48
|
return accessor(data);
|
|
47
49
|
}
|
|
48
50
|
}
|
|
51
|
+
const _x = accessor(x);
|
|
52
|
+
const _y = accessor(y);
|
|
53
|
+
$: xOffset = isScaleBand($xScale) ? $xScale.bandwidth() / 2 : 0;
|
|
54
|
+
$: yOffset = isScaleBand($yScale) ? $yScale.bandwidth() / 2 : 0;
|
|
49
55
|
let d = '';
|
|
50
56
|
// @ts-expect-error
|
|
51
57
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
@@ -53,11 +59,11 @@ $: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
|
53
59
|
$: {
|
|
54
60
|
const path = radial
|
|
55
61
|
? lineRadial()
|
|
56
|
-
.angle((d) => getScaleValue(d, $xScale, x
|
|
57
|
-
.radius((d) => getScaleValue(d, $yScale, y
|
|
62
|
+
.angle((d) => getScaleValue(d, $xScale, x ? _x : $contextX))
|
|
63
|
+
.radius((d) => getScaleValue(d, $yScale, y ? _y : $contextY))
|
|
58
64
|
: d3Line()
|
|
59
|
-
.x((d) => getScaleValue(d, $xScale, x
|
|
60
|
-
.y((d) => getScaleValue(d, $yScale, y
|
|
65
|
+
.x((d) => getScaleValue(d, $xScale, x ? _x : $contextX) + xOffset)
|
|
66
|
+
.y((d) => getScaleValue(d, $yScale, y ? _y : $contextY) + yOffset);
|
|
61
67
|
if (curve)
|
|
62
68
|
path.curve(curve);
|
|
63
69
|
if (defined)
|
|
@@ -2,14 +2,15 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
import { tweened as tweenedStore } from 'svelte/motion';
|
|
3
3
|
import { draw as _drawTransition } from 'svelte/transition';
|
|
4
4
|
import type { CurveFactory, CurveFactoryLineOnly, Line } from 'd3-shape';
|
|
5
|
+
import { type Accessor } from '../utils/common.js';
|
|
5
6
|
declare const __propDef: {
|
|
6
7
|
props: {
|
|
7
8
|
[x: string]: any;
|
|
8
9
|
data?: any;
|
|
9
10
|
pathData?: string | undefined | null;
|
|
10
11
|
radial?: boolean;
|
|
11
|
-
x?:
|
|
12
|
-
y?:
|
|
12
|
+
x?: Accessor;
|
|
13
|
+
y?: Accessor;
|
|
13
14
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
14
15
|
draw?: boolean | Parameters<typeof _drawTransition>[1];
|
|
15
16
|
curve?: CurveFactory | CurveFactoryLineOnly | undefined;
|
|
@@ -6,49 +6,53 @@
|
|
|
6
6
|
import { area as d3Area, line as d3Line } from 'd3-shape';
|
|
7
7
|
import { min, max } from 'd3-array';
|
|
8
8
|
import { chartContext } from './ChartContext.svelte';
|
|
9
|
+
import { accessor } from '../utils/common.js';
|
|
9
10
|
const { data: contextData, xGet, yGet, yRange } = chartContext();
|
|
10
11
|
// Properties to override what is used from context
|
|
11
12
|
export let data = undefined; // TODO: Update Type
|
|
12
|
-
export let x = undefined;
|
|
13
|
-
export let y0 = undefined;
|
|
14
|
-
export let y1 = undefined;
|
|
13
|
+
export let x = undefined;
|
|
14
|
+
export let y0 = undefined;
|
|
15
|
+
export let y1 = undefined;
|
|
15
16
|
export let curve = undefined;
|
|
16
17
|
export let defined = undefined;
|
|
17
18
|
export let id = Math.random().toString(16).slice(-4);
|
|
19
|
+
const _x = accessor(x);
|
|
20
|
+
const _y0 = accessor(y0);
|
|
21
|
+
const _y1 = accessor(y1);
|
|
18
22
|
$: areaPath = d3Area()
|
|
19
|
-
.x(x
|
|
20
|
-
.y0(y0
|
|
21
|
-
.y1(y1
|
|
23
|
+
.x(x ? _x : $xGet)
|
|
24
|
+
.y0(y0 ? _y0 : (d) => $yGet(d)[0])
|
|
25
|
+
.y1(y1 ? _y1 : (d) => $yGet(d)[1]);
|
|
22
26
|
$: if (curve)
|
|
23
27
|
areaPath.curve(curve);
|
|
24
28
|
$: if (defined)
|
|
25
29
|
areaPath.defined(defined);
|
|
26
30
|
$: clipPathBelow = d3Area()
|
|
27
|
-
.x(x
|
|
28
|
-
.y0(y0
|
|
29
|
-
.y1(y1
|
|
31
|
+
.x(x ? _x : $xGet)
|
|
32
|
+
.y0(y0 ? _y0 : (d) => $yGet(d)[0])
|
|
33
|
+
.y1(y1 ? _y1 : (d) => max($yRange));
|
|
30
34
|
$: if (curve)
|
|
31
35
|
clipPathBelow.curve(curve);
|
|
32
36
|
$: if (defined)
|
|
33
37
|
clipPathBelow.defined(defined);
|
|
34
38
|
$: clipPathAbove = d3Area()
|
|
35
|
-
.x(x
|
|
36
|
-
.y0(y0
|
|
37
|
-
.y1(y1
|
|
39
|
+
.x(x ? _x : $xGet)
|
|
40
|
+
.y0(y0 ? _y0 : (d) => max($yRange))
|
|
41
|
+
.y1(y1 ? _y1 : (d) => $yGet(d)[1]);
|
|
38
42
|
$: if (curve)
|
|
39
43
|
clipPathAbove.curve(curve);
|
|
40
44
|
$: if (defined)
|
|
41
45
|
clipPathAbove.defined(defined);
|
|
42
46
|
$: linePathAbove = d3Line()
|
|
43
|
-
.x(x
|
|
44
|
-
.y(y0
|
|
47
|
+
.x(x ? _x : $xGet)
|
|
48
|
+
.y(y0 ? _y0 : (d) => $yGet(d)[0]);
|
|
45
49
|
$: if (curve)
|
|
46
50
|
linePathAbove.curve(curve);
|
|
47
51
|
$: if (defined)
|
|
48
52
|
linePathAbove.defined(defined);
|
|
49
53
|
$: linePathBelow = d3Line()
|
|
50
|
-
.x(x
|
|
51
|
-
.y(y1
|
|
54
|
+
.x(x ? _x : $xGet)
|
|
55
|
+
.y(y1 ? _y1 : (d) => $yGet(d)[1]);
|
|
52
56
|
$: if (curve)
|
|
53
57
|
linePathBelow.curve(curve);
|
|
54
58
|
$: if (defined)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { CurveFactory } from 'd3-shape';
|
|
3
|
+
import { type Accessor } from '../utils/common.js';
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
data?: any;
|
|
6
|
-
x?:
|
|
7
|
-
y0?:
|
|
8
|
-
y1?:
|
|
7
|
+
x?: Accessor;
|
|
8
|
+
y0?: Accessor;
|
|
9
|
+
y1?: Accessor;
|
|
9
10
|
curve?: CurveFactory | undefined;
|
|
10
11
|
defined?: Parameters<{
|
|
11
12
|
(): (d: [number, number], index: number, data: [number, number][]) => boolean;
|
package/dist/utils/scales.js
CHANGED
|
@@ -18,8 +18,7 @@ export function scaleBandInvert(scale) {
|
|
|
18
18
|
const eachBand = scale.step();
|
|
19
19
|
const paddingOuter = eachBand * (scale.paddingOuter?.() ?? scale.padding()); // `scaleBand` uses paddingOuter(), while `scalePoint` uses padding() for outer paddding - https://github.com/d3/d3-scale#point_padding
|
|
20
20
|
return function (value) {
|
|
21
|
-
|
|
22
|
-
const index = Math.floor((value - paddingOuter) / eachBand);
|
|
21
|
+
const index = Math.floor((value - paddingOuter / 2) / eachBand);
|
|
23
22
|
return domain[Math.max(0, Math.min(index, domain.length - 1))];
|
|
24
23
|
};
|
|
25
24
|
}
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "techniq/layerchart",
|
|
7
|
-
"version": "0.43.
|
|
7
|
+
"version": "0.43.7",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@changesets/cli": "^2.27.
|
|
9
|
+
"@changesets/cli": "^2.27.7",
|
|
10
10
|
"@mdi/js": "^7.4.47",
|
|
11
11
|
"@rollup/plugin-dsv": "^3.0.4",
|
|
12
12
|
"@sveltejs/adapter-auto": "^3.2.2",
|
|
13
|
-
"@sveltejs/kit": "^2.5.
|
|
13
|
+
"@sveltejs/kit": "^2.5.18",
|
|
14
14
|
"@sveltejs/package": "^2.3.2",
|
|
15
15
|
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
16
16
|
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/topojson-simplify": "^3.0.3",
|
|
40
40
|
"@types/topojson-specification": "^1.0.5",
|
|
41
41
|
"autoprefixer": "^10.4.19",
|
|
42
|
-
"marked": "^13.0.
|
|
42
|
+
"marked": "^13.0.2",
|
|
43
43
|
"mdsvex": "^0.11.2",
|
|
44
44
|
"posthog-js": "^1.95.1",
|
|
45
45
|
"prettier": "^3.3.2",
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
"shapefile": "^0.6.6",
|
|
52
52
|
"solar-calculator": "^0.3.0",
|
|
53
53
|
"svelte": "^4.2.18",
|
|
54
|
-
"svelte-check": "^3.8.
|
|
54
|
+
"svelte-check": "^3.8.4",
|
|
55
55
|
"svelte-json-tree": "^2.2.0",
|
|
56
|
-
"svelte-preprocess": "^6.0.
|
|
57
|
-
"svelte2tsx": "^0.7.
|
|
56
|
+
"svelte-preprocess": "^6.0.2",
|
|
57
|
+
"svelte2tsx": "^0.7.13",
|
|
58
58
|
"tailwindcss": "^3.4.4",
|
|
59
59
|
"topojson-client": "^3.1.0",
|
|
60
60
|
"topojson-simplify": "^3.0.3",
|
|
61
61
|
"tslib": "^2.6.3",
|
|
62
|
-
"typescript": "^5.5.
|
|
62
|
+
"typescript": "^5.5.3",
|
|
63
63
|
"unist-util-visit": "^5.0.0",
|
|
64
64
|
"us-atlas": "^3.0.1",
|
|
65
|
-
"vite": "^5.3.
|
|
65
|
+
"vite": "^5.3.3"
|
|
66
66
|
},
|
|
67
67
|
"type": "module",
|
|
68
68
|
"dependencies": {
|
|
@@ -86,11 +86,11 @@
|
|
|
86
86
|
"d3-tile": "^1.0.0",
|
|
87
87
|
"d3-time": "^3.1.0",
|
|
88
88
|
"date-fns": "^3.6.0",
|
|
89
|
-
"layercake": "^8.3.
|
|
89
|
+
"layercake": "^8.3.4",
|
|
90
90
|
"lodash-es": "^4.17.21",
|
|
91
|
-
"posthog-js": "^1.
|
|
91
|
+
"posthog-js": "^1.145.0",
|
|
92
92
|
"shapefile": "^0.6.6",
|
|
93
|
-
"svelte-ux": "^0.
|
|
93
|
+
"svelte-ux": "^0.72.4",
|
|
94
94
|
"topojson-client": "^3.1.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|