layerchart 0.3.0 → 0.3.3
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/components/Treemap.svelte +10 -16
- package/components/Treemap.svelte.d.ts +3 -3
- package/components/index.d.ts +8 -0
- package/components/index.js +8 -0
- package/package.json +2 -1
- package/utils/hierarchy.d.ts +6 -0
- package/utils/hierarchy.js +13 -0
|
@@ -8,7 +8,6 @@ import { cubicOut } from 'svelte/easing';
|
|
|
8
8
|
import * as d3 from 'd3-hierarchy';
|
|
9
9
|
import { scaleLinear } from 'd3-scale';
|
|
10
10
|
import { group } from 'd3-array';
|
|
11
|
-
import Group from './Group.svelte';
|
|
12
11
|
import RectClipPath from './RectClipPath.svelte';
|
|
13
12
|
import { aspectTile } from '../utils/treemap';
|
|
14
13
|
const { data, width, height } = getContext('LayerCake');
|
|
@@ -84,21 +83,16 @@ $: yScale = scaleLinear().domain([$extents.y0, $extents.y1]).rangeRound([0, $hei
|
|
|
84
83
|
{#each Array.from(nodesByHeight) as [height, nodes]}
|
|
85
84
|
<g>
|
|
86
85
|
{#each nodes as node}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
height: nodeHeight
|
|
98
|
-
}}
|
|
99
|
-
/>
|
|
100
|
-
</RectClipPath>
|
|
101
|
-
</Group>
|
|
86
|
+
<slot
|
|
87
|
+
name="node"
|
|
88
|
+
{node}
|
|
89
|
+
rect={{
|
|
90
|
+
x: xScale(node.x0),
|
|
91
|
+
y: yScale(node.y0),
|
|
92
|
+
width: xScale(node.x1) - xScale(node.x0),
|
|
93
|
+
height: yScale(node.y1) - yScale(node.y0)
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
102
96
|
{/each}
|
|
103
97
|
</g>
|
|
104
98
|
{/each}
|
|
@@ -16,13 +16,13 @@ declare const __propDef: {
|
|
|
16
16
|
[evt: string]: CustomEvent<any>;
|
|
17
17
|
};
|
|
18
18
|
slots: {
|
|
19
|
-
|
|
19
|
+
node: {
|
|
20
20
|
node: d3.HierarchyRectangularNode<unknown>;
|
|
21
21
|
rect: {
|
|
22
22
|
x: number;
|
|
23
23
|
y: number;
|
|
24
|
-
width:
|
|
25
|
-
height:
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
};
|
package/components/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export { default as Bars } from './Bars.svelte';
|
|
|
7
7
|
export { default as Baseline } from './Baseline.svelte';
|
|
8
8
|
export { default as Chart } from './Chart.svelte';
|
|
9
9
|
export { default as Circle } from './Circle.svelte';
|
|
10
|
+
export { default as CircleClipPath } from './CircleClipPath.svelte';
|
|
11
|
+
export { default as ClipPath } from './ClipPath.svelte';
|
|
10
12
|
export { default as ConnectedPoints } from './ConnectedPoints.svelte';
|
|
11
13
|
export { default as Group } from './Group.svelte';
|
|
12
14
|
export { default as HighlightLine } from './HighlightLine.svelte';
|
|
@@ -14,9 +16,15 @@ export { default as HighlightRect } from './HighlightRect.svelte';
|
|
|
14
16
|
export { default as Labels } from './Labels.svelte';
|
|
15
17
|
export { default as Line } from './Line.svelte';
|
|
16
18
|
export { default as LinearGradient } from './LinearGradient.svelte';
|
|
19
|
+
export { default as Link } from './Link.svelte';
|
|
17
20
|
export { default as Path } from './Path.svelte';
|
|
21
|
+
export { default as Pattern } from './Pattern.svelte';
|
|
22
|
+
export { default as Pie } from './Pie.svelte';
|
|
18
23
|
export { default as Points } from './Points.svelte';
|
|
19
24
|
export { default as Rect } from './Rect.svelte';
|
|
25
|
+
export { default as RectClipPath } from './RectClipPath.svelte';
|
|
26
|
+
export { default as Sankey } from './Sankey.svelte';
|
|
20
27
|
export { default as Text } from './Text.svelte';
|
|
21
28
|
export { default as Threshold } from './Threshold.svelte';
|
|
22
29
|
export { default as Tooltip } from './Tooltip.svelte';
|
|
30
|
+
export { default as Treemap } from './Treemap.svelte';
|
package/components/index.js
CHANGED
|
@@ -7,6 +7,8 @@ export { default as Bars } from './Bars.svelte';
|
|
|
7
7
|
export { default as Baseline } from './Baseline.svelte';
|
|
8
8
|
export { default as Chart } from './Chart.svelte';
|
|
9
9
|
export { default as Circle } from './Circle.svelte';
|
|
10
|
+
export { default as CircleClipPath } from './CircleClipPath.svelte';
|
|
11
|
+
export { default as ClipPath } from './ClipPath.svelte';
|
|
10
12
|
export { default as ConnectedPoints } from './ConnectedPoints.svelte';
|
|
11
13
|
export { default as Group } from './Group.svelte';
|
|
12
14
|
export { default as HighlightLine } from './HighlightLine.svelte';
|
|
@@ -14,9 +16,15 @@ export { default as HighlightRect } from './HighlightRect.svelte';
|
|
|
14
16
|
export { default as Labels } from './Labels.svelte';
|
|
15
17
|
export { default as Line } from './Line.svelte';
|
|
16
18
|
export { default as LinearGradient } from './LinearGradient.svelte';
|
|
19
|
+
export { default as Link } from './Link.svelte';
|
|
17
20
|
export { default as Path } from './Path.svelte';
|
|
21
|
+
export { default as Pattern } from './Pattern.svelte';
|
|
22
|
+
export { default as Pie } from './Pie.svelte';
|
|
18
23
|
export { default as Points } from './Points.svelte';
|
|
19
24
|
export { default as Rect } from './Rect.svelte';
|
|
25
|
+
export { default as RectClipPath } from './RectClipPath.svelte';
|
|
26
|
+
export { default as Sankey } from './Sankey.svelte';
|
|
20
27
|
export { default as Text } from './Text.svelte';
|
|
21
28
|
export { default as Threshold } from './Threshold.svelte';
|
|
22
29
|
export { default as Tooltip } from './Tooltip.svelte';
|
|
30
|
+
export { default as Treemap } from './Treemap.svelte';
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "techniq/layerchart",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.3",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@sveltejs/adapter-vercel": "^1.0.0-next.47",
|
|
9
9
|
"@sveltejs/kit": "^1.0.0-next.303",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"./utils/event": "./utils/event.js",
|
|
92
92
|
"./utils/genData": "./utils/genData.js",
|
|
93
93
|
"./utils/graph": "./utils/graph.js",
|
|
94
|
+
"./utils/hierarchy": "./utils/hierarchy.js",
|
|
94
95
|
"./utils": "./utils/index.js",
|
|
95
96
|
"./utils/math": "./utils/math.js",
|
|
96
97
|
"./utils/path": "./utils/path.js",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HierarchyNode } from 'd3-hierarchy';
|
|
2
|
+
/**
|
|
3
|
+
* Find first ancestor matching filter, including node.
|
|
4
|
+
* Similar to `node.find()` (https://github.com/d3/d3-hierarchy#node_find) but checks ancestors instead of descendants
|
|
5
|
+
*/
|
|
6
|
+
export declare function findAncestor<T = any>(node: HierarchyNode<T>, filter: (node: any) => boolean): HierarchyNode<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find first ancestor matching filter, including node.
|
|
3
|
+
* Similar to `node.find()` (https://github.com/d3/d3-hierarchy#node_find) but checks ancestors instead of descendants
|
|
4
|
+
*/
|
|
5
|
+
export function findAncestor(node, filter) {
|
|
6
|
+
while (node) {
|
|
7
|
+
if (filter(node)) {
|
|
8
|
+
return node;
|
|
9
|
+
}
|
|
10
|
+
node = node.parent;
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|