layerchart 0.16.0 → 0.17.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 +10 -10
- package/dist/components/Arc.svelte.d.ts +2 -1
- package/dist/components/Area.svelte +10 -10
- package/dist/components/AreaStack.svelte +25 -25
- package/dist/components/Axis.svelte +131 -0
- package/dist/components/Axis.svelte.d.ts +25 -0
- package/dist/components/Bars.svelte +30 -71
- package/dist/components/Bars.svelte.d.ts +1 -1
- package/dist/components/Baseline.svelte +19 -19
- package/dist/components/Blur.svelte +6 -6
- package/dist/components/Chart.svelte +46 -46
- package/dist/components/ChartClipPath.svelte +7 -7
- package/dist/components/Circle.svelte +7 -7
- package/dist/components/CircleClipPath.svelte +4 -4
- package/dist/components/ClipPath.svelte +3 -3
- package/dist/components/ClipPathUse.svelte +4 -4
- package/dist/components/ConnectedPoints.svelte +16 -16
- package/dist/components/GeoPath.svelte +11 -11
- package/dist/components/GeoPoint.svelte +3 -3
- package/dist/components/GeoTile.svelte +5 -5
- package/dist/components/Graticule.svelte +12 -12
- package/dist/components/Group.svelte +1 -1
- package/dist/components/HighlightLine.svelte +30 -30
- package/dist/components/HighlightRect.svelte +1 -1
- package/dist/components/Labels.svelte +82 -73
- package/dist/components/Labels.svelte.d.ts +2 -2
- package/dist/components/Legend.svelte +57 -57
- package/dist/components/Legend.svelte.d.ts +1 -1
- package/dist/components/Line.svelte +8 -8
- package/dist/components/LinearGradient.svelte +22 -22
- package/dist/components/Link.svelte +9 -9
- package/dist/components/Link.svelte.d.ts +1 -1
- package/dist/components/Pack.svelte.d.ts +2 -2
- package/dist/components/Partition.svelte.d.ts +5 -5
- package/dist/components/Path.svelte +16 -16
- package/dist/components/Pattern.svelte +3 -3
- package/dist/components/Pie.svelte +21 -21
- package/dist/components/Pie.svelte.d.ts +18 -18
- package/dist/components/Points.svelte +21 -16
- package/dist/components/Rect.svelte +8 -8
- package/dist/components/RectClipPath.svelte +4 -4
- package/dist/components/Sankey.svelte.d.ts +2 -2
- package/dist/components/Text.svelte +21 -21
- package/dist/components/Threshold.svelte +25 -25
- package/dist/components/TileImage.svelte +21 -21
- package/dist/components/Tooltip.svelte +25 -25
- package/dist/components/TooltipContext.svelte +80 -78
- package/dist/components/TooltipContext.svelte.d.ts +1 -1
- package/dist/components/TooltipItem.svelte +10 -10
- package/dist/components/Tree.svelte.d.ts +9 -9
- package/dist/components/Zoom.svelte +18 -18
- package/dist/components/index.d.ts +1 -2
- package/dist/components/index.js +1 -2
- package/dist/docs/Blockquote.svelte +1 -1
- package/dist/docs/Code.svelte +19 -19
- package/dist/docs/Code.svelte.d.ts +2 -2
- package/dist/docs/GeoDebug.svelte +25 -25
- package/dist/docs/Header1.svelte +1 -1
- package/dist/docs/Layout.svelte +5 -5
- package/dist/docs/Link.svelte +1 -1
- package/dist/docs/Preview.svelte +24 -24
- package/dist/docs/RangeField.svelte +18 -18
- package/dist/docs/TilesetField.svelte +13 -13
- package/dist/docs/ViewSourceButton.svelte +42 -0
- package/dist/docs/ViewSourceButton.svelte.d.ts +19 -0
- package/dist/docs/ZoomControls.svelte +39 -39
- package/dist/docs/ZoomControls.svelte.d.ts +2 -2
- package/dist/utils/genData.d.ts +2 -2
- package/dist/utils/rect.d.ts +19 -0
- package/dist/utils/rect.js +97 -0
- package/dist/utils/scales.d.ts +8 -0
- package/dist/utils/scales.js +17 -0
- package/package.json +90 -90
- package/dist/components/AxisX.svelte +0 -43
- package/dist/components/AxisX.svelte.d.ts +0 -38
- package/dist/components/AxisY.svelte +0 -55
- package/dist/components/AxisY.svelte.d.ts +0 -38
|
@@ -11,28 +11,28 @@ export let rotate = undefined;
|
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<defs>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
<linearGradient
|
|
15
|
+
{id}
|
|
16
|
+
{x1}
|
|
17
|
+
{y1}
|
|
18
|
+
{x2}
|
|
19
|
+
{y2}
|
|
20
|
+
gradientTransform={rotate ? `rotate(${rotate})` : ''}
|
|
21
|
+
{...$$restProps}
|
|
22
|
+
>
|
|
23
|
+
<slot>
|
|
24
|
+
{#if from}
|
|
25
|
+
<stop offset="0%" stop-color={from === true ? 'var(--tw-gradient-from)' : from} />
|
|
26
|
+
{/if}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
{#if via}
|
|
29
|
+
<!-- <stop offset="50%" stop-color={via === true ? 'var(--tw-gradient-via)' : via} /> -->
|
|
30
|
+
<stop offset="50%" stop-color={via} />
|
|
31
|
+
{/if}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
{#if to}
|
|
34
|
+
<stop offset="100%" stop-color={to === true ? 'var(--tw-gradient-to)' : to} />
|
|
35
|
+
{/if}
|
|
36
|
+
</slot>
|
|
37
|
+
</linearGradient>
|
|
38
38
|
</defs>
|
|
@@ -28,13 +28,13 @@ $: {
|
|
|
28
28
|
|
|
29
29
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
|
30
30
|
<path
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
class="path-link"
|
|
32
|
+
d={$tweened_d}
|
|
33
|
+
stroke={color}
|
|
34
|
+
stroke-width={width}
|
|
35
|
+
fill="none"
|
|
36
|
+
on:click
|
|
37
|
+
on:mouseover
|
|
38
|
+
on:mouseout
|
|
39
|
+
{...$$restProps}
|
|
40
40
|
/>
|
|
@@ -4,7 +4,7 @@ declare const __propDef: {
|
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
data?: any;
|
|
7
|
-
orientation?: "
|
|
7
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
8
8
|
sankey?: boolean | undefined;
|
|
9
9
|
source?: ((d: any) => any) | undefined;
|
|
10
10
|
target?: ((d: any) => any) | undefined;
|
|
@@ -3,8 +3,8 @@ declare const __propDef: {
|
|
|
3
3
|
props: {
|
|
4
4
|
size?: [number, number] | undefined;
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* see: https://github.com/d3/d3-hierarchy#pack_padding
|
|
7
|
+
*/ padding?: number | undefined;
|
|
8
8
|
};
|
|
9
9
|
events: {
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
orientation?: "
|
|
4
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
5
5
|
size?: [number, number] | undefined;
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* see: https://github.com/d3/d3-hierarchy#tree_nodeSize
|
|
8
|
+
*/ padding?: number | undefined;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* see: https://github.com/d3/d3-hierarchy#tree_nodeSize
|
|
11
|
+
*/ round?: boolean | undefined;
|
|
12
12
|
};
|
|
13
13
|
events: {
|
|
14
14
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
2
|
+
TODO:
|
|
3
|
+
- [ ] Show path progressively show / animated in on load. Also fix sliding in from left side (at last in from bottom)
|
|
4
|
+
*/
|
|
5
5
|
import { getContext } from 'svelte';
|
|
6
6
|
import { line as d3Line } from 'd3-shape';
|
|
7
7
|
// import { interpolateString } from 'd3-interpolate';
|
|
@@ -34,20 +34,20 @@ $: {
|
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
<path
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
class="path-line"
|
|
38
|
+
d={$tweened_d}
|
|
39
|
+
stroke={color}
|
|
40
|
+
stroke-width={width}
|
|
41
|
+
{...$$restProps}
|
|
42
|
+
on:click
|
|
43
|
+
on:mousemove
|
|
44
|
+
on:mouseleave
|
|
45
45
|
/>
|
|
46
46
|
|
|
47
47
|
<style>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
.path-line {
|
|
49
|
+
fill: none;
|
|
50
|
+
stroke-linejoin: round;
|
|
51
|
+
stroke-linecap: round;
|
|
52
|
+
}
|
|
53
53
|
</style>
|
|
@@ -7,7 +7,7 @@ export let height;
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<defs>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<pattern {id} {width} {height} patternUnits="userSpaceOnUse" {...$$restProps}>
|
|
11
|
+
<slot />
|
|
12
|
+
</pattern>
|
|
13
13
|
</defs>
|
|
@@ -6,11 +6,11 @@ import Group from './Group.svelte';
|
|
|
6
6
|
import { degreesToRadians } from '../utils/math';
|
|
7
7
|
import { motionStore } from '../stores/motionStore';
|
|
8
8
|
/*
|
|
9
|
-
TODO:
|
|
10
|
-
- [ ] Offset (always, on hover)
|
|
11
|
-
- [ ] Labels
|
|
12
|
-
- [ ] Multiple nested circles (zScale, or take in data to override context data). See Path/Area/Threshold
|
|
13
|
-
- [ ] Hover events / change innerRadius / outerRadius, etc
|
|
9
|
+
TODO:
|
|
10
|
+
- [ ] Offset (always, on hover)
|
|
11
|
+
- [ ] Labels
|
|
12
|
+
- [ ] Multiple nested circles (zScale, or take in data to override context data). See Path/Area/Threshold
|
|
13
|
+
- [ ] Hover events / change innerRadius / outerRadius, etc
|
|
14
14
|
*/
|
|
15
15
|
export let data = undefined; // TODO: Update Type
|
|
16
16
|
/**
|
|
@@ -76,20 +76,20 @@ function getColor(item, index) {
|
|
|
76
76
|
</script>
|
|
77
77
|
|
|
78
78
|
<Group center>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
79
|
+
<slot {arcs}>
|
|
80
|
+
{#each arcs as arc, index}
|
|
81
|
+
<Arc
|
|
82
|
+
startAngle={arc.startAngle}
|
|
83
|
+
endAngle={arc.endAngle}
|
|
84
|
+
padAngle={arc.padAngle}
|
|
85
|
+
{innerRadius}
|
|
86
|
+
{outerRadius}
|
|
87
|
+
{cornerRadius}
|
|
88
|
+
{offset}
|
|
89
|
+
fill={getColor(arc.data, index)}
|
|
90
|
+
on:mousemove={(e) => tooltip?.show(e, arc.data)}
|
|
91
|
+
on:mouseleave={(e) => tooltip?.hide()}
|
|
92
|
+
/>
|
|
93
|
+
{/each}
|
|
94
|
+
</slot>
|
|
95
95
|
</Group>
|
|
@@ -5,24 +5,24 @@ declare const __propDef: {
|
|
|
5
5
|
props: {
|
|
6
6
|
data?: any;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* Range [min,max] in degrees. See also startAngle/endAngle
|
|
9
|
+
*/ range?: number[] | undefined;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Start angle in radians
|
|
12
|
+
*/ startAngle?: number | undefined;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* End angle in radians
|
|
15
|
+
*/ endAngle?: number | undefined;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
* Define innerRadius.
|
|
18
|
+
* value >= 1: discrete value
|
|
19
|
+
* value > 0: percent of `outerRadius`
|
|
20
|
+
* value < 0: offset of `outerRadius`
|
|
21
|
+
* default: yRange min
|
|
22
|
+
*/ innerRadius?: undefined;
|
|
23
23
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
* Define outerRadius. Defaults to yRange max/2 (ie. chart height / 2)
|
|
25
|
+
*/ outerRadius?: undefined;
|
|
26
26
|
cornerRadius?: number | undefined;
|
|
27
27
|
padAngle?: number | undefined;
|
|
28
28
|
color?: string | ((obj: {
|
|
@@ -33,11 +33,11 @@ declare const __propDef: {
|
|
|
33
33
|
spring?: boolean | Parameters<typeof springStore>[1];
|
|
34
34
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* Offset all arcs from center
|
|
37
|
+
*/ offset?: number | undefined;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
* Tooltip context to setup mouse events to show tooltip for related data
|
|
40
|
+
*/ tooltip?: TooltipContextValue | undefined;
|
|
41
41
|
};
|
|
42
42
|
events: {
|
|
43
43
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import Circle from './Circle.svelte';
|
|
3
3
|
import { isScaleBand } from '../utils/scales';
|
|
4
|
+
import { notNull } from 'svelte-ux';
|
|
4
5
|
const context = getContext('LayerCake');
|
|
5
6
|
const { data, xGet, y, yGet, xScale, yScale, rGet, config } = context;
|
|
6
7
|
export let r = 5;
|
|
@@ -36,10 +37,12 @@ function getColor(item, index) {
|
|
|
36
37
|
$: points = $data.flatMap((d) => {
|
|
37
38
|
if (Array.isArray($config.x)) {
|
|
38
39
|
/*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return $xGet(d)
|
|
40
|
+
x={["prop1" ,"prop2"]}
|
|
41
|
+
y="prop3"
|
|
42
|
+
*/
|
|
43
|
+
return $xGet(d)
|
|
44
|
+
.filter(notNull)
|
|
45
|
+
.map((x) => {
|
|
43
46
|
return {
|
|
44
47
|
x: x + getOffset(x, offsetX, $xScale),
|
|
45
48
|
y: $yGet(d) + getOffset($yGet(d), offsetY, $yScale),
|
|
@@ -49,10 +52,12 @@ $: points = $data.flatMap((d) => {
|
|
|
49
52
|
}
|
|
50
53
|
else if (Array.isArray($config.y)) {
|
|
51
54
|
/*
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return $yGet(d)
|
|
55
|
+
x="prop1"
|
|
56
|
+
y={["prop2" ,"prop3"]}
|
|
57
|
+
*/
|
|
58
|
+
return $yGet(d)
|
|
59
|
+
.filter(notNull)
|
|
60
|
+
.map((y) => {
|
|
56
61
|
return {
|
|
57
62
|
x: $xGet(d) + getOffset($xGet(d), offsetX, $xScale),
|
|
58
63
|
y: y + getOffset(y, offsetY, $yScale),
|
|
@@ -62,9 +67,9 @@ $: points = $data.flatMap((d) => {
|
|
|
62
67
|
}
|
|
63
68
|
else {
|
|
64
69
|
/*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
x="prop1"
|
|
71
|
+
y="prop2"
|
|
72
|
+
*/
|
|
68
73
|
return {
|
|
69
74
|
x: $xGet(d) + getOffset($xGet(d), offsetX, $xScale),
|
|
70
75
|
y: $yGet(d) + getOffset($yGet(d), offsetY, $yScale),
|
|
@@ -75,9 +80,9 @@ $: points = $data.flatMap((d) => {
|
|
|
75
80
|
</script>
|
|
76
81
|
|
|
77
82
|
<slot {points}>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
<g class="point-group">
|
|
84
|
+
{#each points as point, index}
|
|
85
|
+
<Circle cx={point.x} cy={point.y} {r} fill={getColor(point.data, index)} {...$$restProps} />
|
|
86
|
+
{/each}
|
|
87
|
+
</g>
|
|
83
88
|
</slot>
|
|
@@ -17,12 +17,12 @@ $: tweened_height.set(height);
|
|
|
17
17
|
|
|
18
18
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
|
19
19
|
<rect
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
x={$tweened_x}
|
|
21
|
+
y={$tweened_y}
|
|
22
|
+
width={$tweened_width}
|
|
23
|
+
height={$tweened_height}
|
|
24
|
+
{...$$restProps}
|
|
25
|
+
on:click
|
|
26
|
+
on:mouseover
|
|
27
|
+
on:mouseout
|
|
28
28
|
/>
|
|
@@ -12,11 +12,11 @@ export let tweened = undefined;
|
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<ClipPath {id}>
|
|
15
|
-
|
|
15
|
+
<Rect {x} {y} {width} {height} {spring} {tweened} />
|
|
16
16
|
</ClipPath>
|
|
17
17
|
|
|
18
18
|
{#if $$slots.default}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
<g style="clip-path: url(#{id})" on:click on:mousemove on:mouseleave>
|
|
20
|
+
<slot {id} />
|
|
21
|
+
</g>
|
|
22
22
|
{/if}
|
|
@@ -5,8 +5,8 @@ declare const __propDef: {
|
|
|
5
5
|
nodes?: ((d: any) => any) | undefined;
|
|
6
6
|
nodeId?: ((d: any) => any) | undefined;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* see: https://github.com/d3/d3-sankey#alignments
|
|
9
|
+
*/ nodeAlign?: "left" | "right" | "center" | "justify" | ((node: SankeyNode<any, any>, n: number) => number) | undefined;
|
|
10
10
|
nodeWidth?: number | undefined;
|
|
11
11
|
nodePadding?: number | undefined;
|
|
12
12
|
nodeSort?: undefined;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script>import { getStringWidth } from '../utils/string';
|
|
2
2
|
/*
|
|
3
|
-
TODO:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
TODO:
|
|
4
|
+
- [ ] Handle styled text (use <slot /> to measure?)
|
|
5
|
+
- [ ] Simplify by using `alignment-baseline` / `dominant-baseline`, rework multiline or drop support, etc
|
|
6
|
+
- https://svelte.dev/repl/f12d3003313a43ba8a0be53e5786f1c7?version=3.44.3
|
|
7
|
+
- https://observablehq.com/@neocartocnrs/cheat-sheet-on-texts-in-svg
|
|
8
8
|
|
|
9
|
-
Reference:
|
|
10
|
-
- https://bl.ocks.org/mbostock/7555321
|
|
11
|
-
- https://github.com/airbnb/visx/blob/master/packages/visx-text/src/Text.tsx
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
Reference:
|
|
10
|
+
- https://bl.ocks.org/mbostock/7555321
|
|
11
|
+
- https://github.com/airbnb/visx/blob/master/packages/visx-text/src/Text.tsx
|
|
12
|
+
- https://airbnb.io/visx/text
|
|
13
|
+
- https://github.com/airbnb/visx/blob/master/packages/visx-demo/src/pages/text.tsx
|
|
14
14
|
*/
|
|
15
15
|
/** text value */
|
|
16
16
|
export let value = 0;
|
|
@@ -119,16 +119,16 @@ function isValidXOrY(xOrY) {
|
|
|
119
119
|
}
|
|
120
120
|
</script>
|
|
121
121
|
|
|
122
|
-
<!-- overflow: visible
|
|
123
|
-
<!-- paint-order: stroke
|
|
122
|
+
<!-- `overflow: visible` allow contents to be shown outside element -->
|
|
123
|
+
<!-- `paint-order: stroke` supports stroke outlining text -->
|
|
124
124
|
<svg x={dx} y={dy} style="overflow: visible; paint-order: stroke;">
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
{#if isValidXOrY(x) && isValidXOrY(y)}
|
|
126
|
+
<text {x} {y} {transform} text-anchor={textAnchor} {...$$restProps}>
|
|
127
|
+
{#each wordsByLines as line, index}
|
|
128
|
+
<tspan {x} dy={index === 0 ? startDy : lineHeight}>
|
|
129
|
+
{line.words.join(' ')}
|
|
130
|
+
</tspan>
|
|
131
|
+
{/each}
|
|
132
|
+
</text>
|
|
133
|
+
{/if}
|
|
134
134
|
</svg>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>/*
|
|
2
|
-
See also:
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
See also:
|
|
3
|
+
- https://observablehq.com/@d3/difference-chart
|
|
4
|
+
- https://github.com/airbnb/visx/issues/245
|
|
5
5
|
*/
|
|
6
6
|
import { getContext } from 'svelte';
|
|
7
7
|
import { area as d3Area, line as d3Line } from 'd3-shape';
|
|
@@ -57,30 +57,30 @@ $: if (defined)
|
|
|
57
57
|
|
|
58
58
|
<!-- Recreate on curve change as otherwise is 1 state change behind for some reason -->
|
|
59
59
|
{#key curve}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
<g class="clip-paths">
|
|
61
|
+
<defs>
|
|
62
|
+
<clipPath id="threshold-clip-below-{id}">
|
|
63
|
+
<path d={clipPathBelow(data ?? $contextData)} />
|
|
64
|
+
</clipPath>
|
|
65
|
+
<clipPath id="threshold-clip-above-{id}">
|
|
66
|
+
<path d={clipPathAbove(data ?? $contextData)} />
|
|
67
|
+
</clipPath>
|
|
68
|
+
</defs>
|
|
69
|
+
</g>
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
<slot
|
|
72
|
+
name="pathAbove"
|
|
73
|
+
areaPathData={areaPath(data ?? $contextData)}
|
|
74
|
+
clipPath="url(#threshold-clip-below-{id})"
|
|
75
|
+
linePathData={linePathAbove(data ?? $contextData)}
|
|
76
|
+
/>
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
<slot
|
|
79
|
+
name="pathBelow"
|
|
80
|
+
areaPathData={areaPath(data ?? $contextData)}
|
|
81
|
+
clipPath="url(#threshold-clip-above-{id})"
|
|
82
|
+
linePathData={linePathBelow(data ?? $contextData)}
|
|
83
|
+
/>
|
|
84
84
|
{/key}
|
|
85
85
|
|
|
86
86
|
<!-- Fix `<Threshold> received an unexpected slot "default".` warning -->
|
|
@@ -57,28 +57,28 @@ $: if (!disableCache) {
|
|
|
57
57
|
|
|
58
58
|
<!-- To avoid aliasing artifacts (thin white lines) between tiles, two layers of tiles are drawn, with the lower layer’s tiles enlarged by one pixel -->
|
|
59
59
|
<image
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
xlink:href={href}
|
|
61
|
+
x={(x + tx) * k - 0.5}
|
|
62
|
+
y={(y + ty) * k - 0.5}
|
|
63
|
+
width={k + 1}
|
|
64
|
+
height={k + 1}
|
|
65
65
|
/>
|
|
66
66
|
<image xlink:href={href} x={(x + tx) * k} y={(y + ty) * k} width={k} height={k} />
|
|
67
67
|
{#if debug}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
<rect
|
|
69
|
+
x={(x + tx) * k}
|
|
70
|
+
y={(y + ty) * k}
|
|
71
|
+
width={k}
|
|
72
|
+
height={k}
|
|
73
|
+
class="stroke-red-500/50 fill-none"
|
|
74
|
+
/>
|
|
75
|
+
<Text
|
|
76
|
+
x={(x + tx) * k}
|
|
77
|
+
y={(y + ty) * k}
|
|
78
|
+
verticalAnchor="start"
|
|
79
|
+
dx={2}
|
|
80
|
+
dy={-2}
|
|
81
|
+
value="{x}-{y}-{z}"
|
|
82
|
+
class="text-[8px] fill-black/50"
|
|
83
|
+
/>
|
|
84
84
|
{/if}
|
|
@@ -35,30 +35,30 @@ $: if ($tooltip) {
|
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
37
|
{#if $tooltip.data}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
<div
|
|
39
|
+
class="absolute pointer-events-none z-50"
|
|
40
|
+
style:top="{$top}px"
|
|
41
|
+
style:left="{$left}px"
|
|
42
|
+
transition:fade={{ duration: 100 }}
|
|
43
|
+
bind:clientWidth={tooltipWidth}
|
|
44
|
+
bind:clientHeight={tooltipHeight}
|
|
45
|
+
>
|
|
46
|
+
<div
|
|
47
|
+
class="bg-gray-900/90 backdrop-filter backdrop-blur-[2px] text-white rounded elevation-1 px-2 py-1"
|
|
48
|
+
>
|
|
49
|
+
{#if header || $$slots.header}
|
|
50
|
+
<div class="text-center font-semibold whitespace-nowrap">
|
|
51
|
+
<slot name="header">
|
|
52
|
+
{header($tooltip.data)}
|
|
53
|
+
</slot>
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
{#if $$slots.default}
|
|
58
|
+
<div class="grid grid-cols-[1fr,auto] gap-x-2 gap-y-1 items-center pt-1">
|
|
59
|
+
<slot data={$tooltip.data} />
|
|
60
|
+
</div>
|
|
61
|
+
{/if}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
64
|
{/if}
|