layerchart 0.3.3 → 0.3.4

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.
@@ -34,27 +34,30 @@ $: tileFunc =
34
34
  : tile === 'sliceDice'
35
35
  ? d3.treemapSliceDice
36
36
  : tile;
37
- $: treemap = d3.treemap().size([$width, $height]).tile(aspectTile(tileFunc, $width, $height));
38
- $: if (padding) {
39
- treemap.padding(padding);
40
- }
41
- $: if (paddingInner) {
42
- treemap.paddingInner(paddingInner);
43
- }
44
- $: if (paddingOuter) {
45
- treemap.paddingOuter(paddingOuter);
46
- }
47
- $: if (paddingTop) {
48
- treemap.paddingTop(paddingTop);
49
- }
50
- $: if (paddingBottom) {
51
- treemap.paddingBottom(paddingBottom);
52
- }
53
- $: if (paddingLeft) {
54
- treemap.paddingLeft(paddingLeft);
55
- }
56
- $: if (paddingLeft) {
57
- treemap.paddingRight(paddingRight);
37
+ let treemap;
38
+ $: {
39
+ treemap = d3.treemap().size([$width, $height]).tile(aspectTile(tileFunc, $width, $height));
40
+ if (padding) {
41
+ treemap.padding(padding);
42
+ }
43
+ if (paddingInner) {
44
+ treemap.paddingInner(paddingInner);
45
+ }
46
+ if (paddingOuter) {
47
+ treemap.paddingOuter(paddingOuter);
48
+ }
49
+ if (paddingTop) {
50
+ treemap.paddingTop(paddingTop);
51
+ }
52
+ if (paddingBottom) {
53
+ treemap.paddingBottom(paddingBottom);
54
+ }
55
+ if (paddingLeft) {
56
+ treemap.paddingLeft(paddingLeft);
57
+ }
58
+ if (paddingRight) {
59
+ treemap.paddingRight(paddingRight);
60
+ }
58
61
  }
59
62
  $: root = treemap($data);
60
63
  $: selected = root; // set initial selection
@@ -17,7 +17,7 @@ declare const __propDef: {
17
17
  };
18
18
  slots: {
19
19
  node: {
20
- node: d3.HierarchyRectangularNode<unknown>;
20
+ node: unknown;
21
21
  rect: {
22
22
  x: number;
23
23
  y: number;
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.3",
6
+ "version": "0.3.4",
7
7
  "devDependencies": {
8
8
  "@sveltejs/adapter-vercel": "^1.0.0-next.47",
9
9
  "@sveltejs/kit": "^1.0.0-next.303",
@@ -1,6 +1,10 @@
1
1
  /**
2
- * This custom tiling function adapts the built-in binary tiling function
2
+ * This custom tiling function adapts the tiling function
3
3
  * for the appropriate aspect ratio when the treemap is zoomed-in.
4
4
  * see: https://observablehq.com/@d3/zoomable-treemap#tile and https://observablehq.com/@d3/stretched-treemap
5
5
  */
6
6
  export declare function aspectTile(tile: any, width: any, height: any): (node: any, x0: any, y0: any, x1: any, y1: any) => void;
7
+ /**
8
+ * Show if the node (a) is a child of the selected (b), or any parent above selected
9
+ */
10
+ export declare function isNodeVisible(a: any, b: any): boolean;
package/utils/treemap.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * This custom tiling function adapts the built-in binary tiling function
2
+ * This custom tiling function adapts the tiling function
3
3
  * for the appropriate aspect ratio when the treemap is zoomed-in.
4
4
  * see: https://observablehq.com/@d3/zoomable-treemap#tile and https://observablehq.com/@d3/stretched-treemap
5
5
  */
@@ -14,3 +14,14 @@ export function aspectTile(tile, width, height) {
14
14
  }
15
15
  };
16
16
  }
17
+ /**
18
+ * Show if the node (a) is a child of the selected (b), or any parent above selected
19
+ */
20
+ export function isNodeVisible(a, b) {
21
+ while (b) {
22
+ if (a.parent === b)
23
+ return true;
24
+ b = b.parent;
25
+ }
26
+ return false;
27
+ }