@hpcc-js/tree 2.44.0 → 2.45.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.
Files changed (48) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +454 -454
  3. package/dist/index.es6.js +2836 -0
  4. package/dist/index.es6.js.map +1 -0
  5. package/dist/index.js +2852 -2020
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.min.js +2 -0
  8. package/dist/index.min.js.map +1 -0
  9. package/package.json +34 -32
  10. package/src/CirclePacking.css +16 -16
  11. package/src/CirclePacking.ts +148 -152
  12. package/src/Dendrogram.css +42 -42
  13. package/src/Dendrogram.ts +284 -296
  14. package/src/DirectoryTree.ts +310 -306
  15. package/src/Indented.css +16 -16
  16. package/src/Indented.ts +283 -290
  17. package/src/SunburstPartition.css +5 -5
  18. package/src/SunburstPartition.ts +151 -157
  19. package/src/Treemap.css +41 -41
  20. package/src/Treemap.ts +320 -346
  21. package/src/__package__.ts +3 -3
  22. package/src/index.ts +7 -7
  23. package/types/CirclePacking.d.ts +6 -7
  24. package/types/CirclePacking.d.ts.map +1 -0
  25. package/types/Dendrogram.d.ts +35 -20
  26. package/types/Dendrogram.d.ts.map +1 -0
  27. package/types/DirectoryTree.d.ts +16 -11
  28. package/types/DirectoryTree.d.ts.map +1 -0
  29. package/types/Indented.d.ts +16 -11
  30. package/types/Indented.d.ts.map +1 -0
  31. package/types/SunburstPartition.d.ts +5 -8
  32. package/types/SunburstPartition.d.ts.map +1 -0
  33. package/types/Treemap.d.ts +96 -51
  34. package/types/Treemap.d.ts.map +1 -0
  35. package/types/__package__.d.ts +3 -2
  36. package/types/__package__.d.ts.map +1 -0
  37. package/types/index.d.ts +8 -7
  38. package/types/index.d.ts.map +1 -0
  39. package/types-3.4/CirclePacking.d.ts +32 -0
  40. package/types-3.4/Dendrogram.d.ts +60 -0
  41. package/types-3.4/DirectoryTree.d.ts +62 -0
  42. package/types-3.4/Indented.d.ts +46 -0
  43. package/types-3.4/SunburstPartition.d.ts +23 -0
  44. package/types-3.4/Treemap.d.ts +125 -0
  45. package/types-3.4/__package__.d.ts +4 -0
  46. package/types-3.4/index.d.ts +8 -0
  47. package/dist/index.umd.cjs +0 -2
  48. package/dist/index.umd.cjs.map +0 -1
package/package.json CHANGED
@@ -1,54 +1,56 @@
1
1
  {
2
2
  "name": "@hpcc-js/tree",
3
- "version": "2.44.0",
3
+ "version": "2.45.1",
4
4
  "description": "hpcc-js - Viz Tree",
5
- "type": "module",
6
- "main": "./dist/index.umd.cjs",
7
- "module": "./dist/index.js",
8
- "exports": {
9
- ".": {
10
- "types": "./types/index.d.ts",
11
- "import": "./dist/index.js",
12
- "require": "./dist/index.umd.cjs"
13
- },
14
- "./dist/*": "./dist/*"
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.es6",
7
+ "unpkg": "dist/index.min.js",
8
+ "jsdelivr": "dist/index.min.js",
9
+ "types": "types/index.d.ts",
10
+ "typesVersions": {
11
+ "<3.8": {
12
+ "*": [
13
+ "types-3.4/index.d.ts"
14
+ ]
15
+ }
15
16
  },
16
- "browser": "./dist/index.umd.cjs",
17
- "types": "./types/index.d.ts",
18
17
  "files": [
19
18
  "dist/*",
20
- "src/*",
21
- "types/*"
19
+ "types/*",
20
+ "types-3.4/*",
21
+ "src/*"
22
22
  ],
23
23
  "scripts": {
24
- "clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo",
25
- "bundle": "vite build",
26
- "bundle-watch": "vite --port 5519",
27
- "gen-types": "tsc --project tsconfig.json",
28
- "gen-types-watch": "npm run gen-types -- --watch",
29
- "build": "run-p gen-types bundle",
24
+ "clean": "rimraf --glob lib* types dist *.tsbuildinfo",
25
+ "compile-es6": "tsc --module es6 --outDir ./lib-es6",
26
+ "compile-es6-watch": "npm run compile-es6 -- -w",
27
+ "compile-umd": "tsc --module umd --outDir ./lib-umd",
28
+ "compile-umd-watch": "npm run compile-umd -- -w",
29
+ "bundle": "rollup -c",
30
+ "bundle-watch": "npm run bundle -- -w",
31
+ "minimize": "terser dist/index.js -c -m --source-map \"content='dist/index.js.map',url='index.min.js.map'\" -o dist/index.min.js",
32
+ "gen-legacy-types": "downlevel-dts ./types ./types-3.4",
33
+ "build": "npm run compile-es6 && npm run bundle",
34
+ "watch": "npm-run-all compile-es6 -p compile-es6-watch bundle-watch",
35
+ "stamp": "node ../../node_modules/@hpcc-js/bundle/src/stamp.js",
30
36
  "lint": "eslint ./src",
31
- "lint-fix": "eslint --fix src/**/*.ts",
32
37
  "docs": "typedoc --options tdoptions.json .",
33
- "test-browser": "vitest run --project browser",
34
- "test": "vitest run",
35
- "coverage": "vitest run --coverage",
36
- "update": "npx --yes npm-check-updates -u -t minor",
37
- "update-major": "npx --yes npm-check-updates -u"
38
+ "update": "npx --yes npm-check-updates -u -t minor"
38
39
  },
39
40
  "dependencies": {
40
- "@hpcc-js/api": "^3.3.12",
41
- "@hpcc-js/common": "^3.4.2"
41
+ "@hpcc-js/api": "^2.14.3",
42
+ "@hpcc-js/common": "^2.73.3"
42
43
  },
43
44
  "devDependencies": {
44
- "@hpcc-js/esbuild-plugins": "^1.5.2",
45
+ "@hpcc-js/bundle": "^2.12.0",
45
46
  "@types/d3-transition": "1.3.6",
46
47
  "d3-hierarchy": "^1",
47
48
  "d3-interpolate": "^1",
48
49
  "d3-scale": "^1",
49
50
  "d3-selection": "^1",
50
51
  "d3-shape": "^1",
51
- "d3-transition": "^1"
52
+ "d3-transition": "^1",
53
+ "tslib": "2.8.1"
52
54
  },
53
55
  "repository": {
54
56
  "type": "git",
@@ -61,5 +63,5 @@
61
63
  "url": "https://github.com/hpcc-systems/Visualization/issues"
62
64
  },
63
65
  "homepage": "https://github.com/hpcc-systems/Visualization",
64
- "gitHead": "a35882216a554b24a2586f30ce829d511941aecd"
66
+ "gitHead": "0907b8d15d369c89483954a1d96e2247ba020cb6"
65
67
  }
@@ -1,16 +1,16 @@
1
- .tree_CirclePacking circle {
2
- fill: rgb(31, 119, 180);
3
- fill-opacity: .25;
4
- stroke: rgb(31, 119, 180);
5
- stroke-width: 1px;
6
- }
7
-
8
- .tree_CirclePacking .leaf circle {
9
- fill: #ff7f0e;
10
- fill-opacity: 1;
11
- }
12
-
13
- .tree_CirclePacking .label {
14
- fill:white;
15
- text-anchor: middle;
16
- }
1
+ .tree_CirclePacking circle {
2
+ fill: rgb(31, 119, 180);
3
+ fill-opacity: .25;
4
+ stroke: rgb(31, 119, 180);
5
+ stroke-width: 1px;
6
+ }
7
+
8
+ .tree_CirclePacking .leaf circle {
9
+ fill: #ff7f0e;
10
+ fill-opacity: 1;
11
+ }
12
+
13
+ .tree_CirclePacking .label {
14
+ fill:white;
15
+ text-anchor: middle;
16
+ }
@@ -1,152 +1,148 @@
1
- import { ITree } from "@hpcc-js/api";
2
- import { d3Event, SVGWidget } from "@hpcc-js/common";
3
- import { rgb as d3Rgb } from "d3-color";
4
- import { hierarchy as d3Hierarchy, pack as d3Pack } from "d3-hierarchy";
5
- import { interpolateZoom as d3InterpolateZoom } from "d3-interpolate";
6
- import "d3-transition";
7
-
8
- import "../src/CirclePacking.css";
9
-
10
- export class CirclePacking extends SVGWidget {
11
- diameter;
12
- pack;
13
- svg;
14
- _focus;
15
- circle;
16
- view;
17
- protected _node;
18
-
19
- constructor() {
20
- super();
21
- ITree.call(this);
22
- }
23
-
24
- enter(_domNode, element) {
25
- this.diameter = Math.min(this.width(), this.height());
26
-
27
- this.pack = d3Pack()
28
- .size([this.diameter - 4, this.diameter - 4])
29
- .padding(1.5)
30
- ;
31
-
32
- this.svg = element
33
- .append("g")
34
- ;
35
- }
36
-
37
- update(_domNode, _element) {
38
- const context = this;
39
-
40
- this.diameter = Math.min(this.width(), this.height());
41
- this.pack
42
- .size([this.diameter - 4, this.diameter - 4])
43
- .padding(1.5)
44
- ;
45
-
46
- this._palette = this._palette.switch(this.paletteID());
47
- if (this.useClonedPalette()) {
48
- this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
49
- }
50
-
51
- this.svg.selectAll("circle").remove();
52
- this.svg.selectAll("text").remove();
53
-
54
- const root: any = d3Hierarchy(this.data())
55
- .sum(function (d) {
56
- return d && d.size ? d.size : 1;
57
- }).sort(function (a, b) {
58
- return a.value < b.value ? -1 : a.value > b.value ? 1 : 0;
59
- })
60
- ;
61
- this._focus = root;
62
- this.pack(root);
63
-
64
- this.circle = this.svg.selectAll("circle").data(root.descendants())
65
- .enter().append("circle")
66
- .attr("class", function (d) { return d.parent ? d.children ? "node" : "node leaf" : "node root"; })
67
- .style("fill", function (d) {
68
- d.color = context.paletteDepthLevel_exists() && d.depth > context.paletteDepthLevel() ? d3Rgb(d.parent.color)[context.paletteDepthVariant()](1) : context._palette(d.data.label);
69
- return d.color;
70
- })
71
- .on("click", function (d) { context.click(d.data, null, null); })
72
- .on("dblclick", function (d) {
73
- if (this._focus !== d) {
74
- context.zoom(d);
75
- }
76
- d3Event().stopPropagation();
77
- })
78
- ;
79
- this.circle.append("title").text(function (d) { return d.data.label; });
80
-
81
- this.svg.selectAll("text").data(root.descendants())
82
- .enter().append("text")
83
- .attr("class", "label")
84
- .style("fill-opacity", function (d) { return d.parent === root ? 1 : 0; })
85
- .style("display", function (d) { return d.parent === root ? null : "none"; })
86
- .text(function (d) {
87
- return d.data.label + (context.showSize() && typeof d.data.size !== "undefined" ? " " + d.data.size : "");
88
- })
89
- ;
90
-
91
- this._node = this.svg.selectAll("circle,text");
92
-
93
- this.zoomTo([root.x, root.y, root.r * 2]);
94
- }
95
-
96
- zoom(newFocus) {
97
- this._focus = newFocus;
98
- const context = this;
99
- const transition = this.svg.transition()
100
- .duration(d3Event().altKey ? 7500 : 750)
101
- .tween("zoom", function () {
102
- const i = d3InterpolateZoom(context.view, [context._focus.x, context._focus.y, context._focus.r * 2]);
103
- return function (t) { context.zoomTo(i(t)); };
104
- });
105
-
106
- function showText(d) {
107
- return (d === context._focus && !d.children) || d.parent === context._focus;
108
- }
109
-
110
- transition.selectAll("text")
111
- .filter(function (d) { return showText(d) || this.style.display === "inline"; })
112
- .style("fill-opacity", function (d) { return showText(d) ? 1 : 0; })
113
- .on("start", function (d) { if (showText(d)) this.style.display = "inline"; })
114
- .on("end", function (d) { if (!showText(d)) this.style.display = "none"; });
115
- }
116
-
117
- zoomTo(v) {
118
- const k = this.diameter / v[2];
119
- this.view = v;
120
- this._node.attr("transform", function (d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; });
121
- this.circle.attr("r", function (d) { return d.r * k; });
122
- }
123
- }
124
- CirclePacking.prototype._class += " tree_CirclePacking";
125
- CirclePacking.prototype.implements(ITree.prototype);
126
-
127
- export interface CirclePacking {
128
- _palette;
129
-
130
- // I2DChart ---
131
- click(row, column, selected): void;
132
- dblclick(row, column, selected): void;
133
-
134
- // Properties ---
135
- showSize(): boolean;
136
- showSize(_: boolean): this;
137
- paletteDepthLevel(): number;
138
- paletteDepthLevel(_: number): this;
139
- paletteDepthLevel_exists(): boolean;
140
- paletteDepthVariant(): "brighter" | "darker";
141
- paletteDepthVariant(_: "brighter" | "darker"): this;
142
- paletteID(): string;
143
- paletteID(_: string): this;
144
- useClonedPalette(): boolean;
145
- useClonedPalette(_: boolean): this;
146
- }
147
-
148
- CirclePacking.prototype.publish("showSize", true, "boolean", "Show size along with label");
149
- CirclePacking.prototype.publish("paletteDepthLevel", null, "number", "If not null then beyond this depth number the child node colors are based on parent", null, { optional: true });
150
- CirclePacking.prototype.publish("paletteDepthVariant", "brighter", "set", "Determines paletteDepthLevel decendant color shade variant", ["brighter", "darker"], { disable: w => w.paletteDepthLevel_exists() });
151
- CirclePacking.prototype.publish("paletteID", "default", "set", "Color palette for this widget", CirclePacking.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
152
- CirclePacking.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
1
+ import { ITree } from "@hpcc-js/api";
2
+ import { d3Event, SVGWidget } from "@hpcc-js/common";
3
+ import { rgb as d3Rgb } from "d3-color";
4
+ import { hierarchy as d3Hierarchy, pack as d3Pack } from "d3-hierarchy";
5
+ import { interpolateZoom as d3InterpolateZoom } from "d3-interpolate";
6
+ import "d3-transition";
7
+
8
+ import "../src/CirclePacking.css";
9
+
10
+ export class CirclePacking extends SVGWidget {
11
+ diameter;
12
+ pack;
13
+ svg;
14
+ _focus;
15
+ circle;
16
+ view;
17
+ protected _node;
18
+
19
+ constructor() {
20
+ super();
21
+ ITree.call(this);
22
+ }
23
+
24
+ enter(_domNode, element) {
25
+ this.diameter = Math.min(this.width(), this.height());
26
+
27
+ this.pack = d3Pack()
28
+ .size([this.diameter - 4, this.diameter - 4])
29
+ .padding(1.5)
30
+ ;
31
+
32
+ this.svg = element
33
+ .append("g")
34
+ ;
35
+ }
36
+
37
+ update(_domNode, _element) {
38
+ const context = this;
39
+
40
+ this.diameter = Math.min(this.width(), this.height());
41
+ this.pack
42
+ .size([this.diameter - 4, this.diameter - 4])
43
+ .padding(1.5)
44
+ ;
45
+
46
+ this._palette = this._palette.switch(this.paletteID());
47
+ if (this.useClonedPalette()) {
48
+ this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
49
+ }
50
+
51
+ this.svg.selectAll("circle").remove();
52
+ this.svg.selectAll("text").remove();
53
+
54
+ const root: any = d3Hierarchy(this.data())
55
+ .sum(function (d) {
56
+ return d && d.size ? d.size : 1;
57
+ }).sort(function (a, b) {
58
+ return a.value < b.value ? -1 : a.value > b.value ? 1 : 0;
59
+ })
60
+ ;
61
+ this._focus = root;
62
+ this.pack(root);
63
+
64
+ this.circle = this.svg.selectAll("circle").data(root.descendants())
65
+ .enter().append("circle")
66
+ .attr("class", function (d) { return d.parent ? d.children ? "node" : "node leaf" : "node root"; })
67
+ .style("fill", function (d) {
68
+ d.color = context.paletteDepthLevel_exists() && d.depth > context.paletteDepthLevel() ? d3Rgb(d.parent.color)[context.paletteDepthVariant()](1) : context._palette(d.data.label);
69
+ return d.color;
70
+ })
71
+ .on("click", function (d) { context.click(d.data, null, null); })
72
+ .on("dblclick", function (d) {
73
+ if (this._focus !== d) {
74
+ context.zoom(d);
75
+ }
76
+ d3Event().stopPropagation();
77
+ })
78
+ ;
79
+ this.circle.append("title").text(function (d) { return d.data.label; });
80
+
81
+ this.svg.selectAll("text").data(root.descendants())
82
+ .enter().append("text")
83
+ .attr("class", "label")
84
+ .style("fill-opacity", function (d) { return d.parent === root ? 1 : 0; })
85
+ .style("display", function (d) { return d.parent === root ? null : "none"; })
86
+ .text(function (d) {
87
+ return d.data.label + (context.showSize() && typeof d.data.size !== "undefined" ? " " + d.data.size : "");
88
+ })
89
+ ;
90
+
91
+ this._node = this.svg.selectAll("circle,text");
92
+
93
+ this.zoomTo([root.x, root.y, root.r * 2]);
94
+ }
95
+
96
+ zoom(newFocus) {
97
+ this._focus = newFocus;
98
+ const context = this;
99
+ const transition = this.svg.transition()
100
+ .duration(d3Event().altKey ? 7500 : 750)
101
+ .tween("zoom", function () {
102
+ const i = d3InterpolateZoom(context.view, [context._focus.x, context._focus.y, context._focus.r * 2]);
103
+ return function (t) { context.zoomTo(i(t)); };
104
+ });
105
+
106
+ function showText(d) {
107
+ return (d === context._focus && !d.children) || d.parent === context._focus;
108
+ }
109
+
110
+ transition.selectAll("text")
111
+ .filter(function (d) { return showText(d) || this.style.display === "inline"; })
112
+ .style("fill-opacity", function (d) { return showText(d) ? 1 : 0; })
113
+ .on("start", function (d) { if (showText(d)) this.style.display = "inline"; })
114
+ .on("end", function (d) { if (!showText(d)) this.style.display = "none"; });
115
+ }
116
+
117
+ zoomTo(v) {
118
+ const k = this.diameter / v[2];
119
+ this.view = v;
120
+ this._node.attr("transform", function (d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; });
121
+ this.circle.attr("r", function (d) { return d.r * k; });
122
+ }
123
+
124
+ paletteID: (_?: string) => string | CirclePacking;
125
+ useClonedPalette: (_?: boolean) => boolean | CirclePacking;
126
+
127
+ // I2DChart
128
+ _palette;
129
+ click: (row, column, selected) => void;
130
+ dblclick: (row, column, selected) => void;
131
+ }
132
+ CirclePacking.prototype._class += " tree_CirclePacking";
133
+ CirclePacking.prototype.implements(ITree.prototype);
134
+ export interface CirclePacking {
135
+ showSize(): boolean;
136
+ showSize(_: boolean): this;
137
+ paletteDepthLevel(): number;
138
+ paletteDepthLevel(_: number): this;
139
+ paletteDepthLevel_exists(): boolean;
140
+ paletteDepthVariant(): "brighter" | "darker";
141
+ paletteDepthVariant(_: "brighter" | "darker"): this;
142
+ }
143
+
144
+ CirclePacking.prototype.publish("showSize", true, "boolean", "Show size along with label");
145
+ CirclePacking.prototype.publish("paletteDepthLevel", null, "number", "If not null then beyond this depth number the child node colors are based on parent", null, { optional: true });
146
+ CirclePacking.prototype.publish("paletteDepthVariant", "brighter", "set", "Determines paletteDepthLevel decendant color shade variant", ["brighter", "darker"], { disable: w => w.paletteDepthLevel_exists() });
147
+ CirclePacking.prototype.publish("paletteID", "default", "set", "Color palette for this widget", CirclePacking.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
148
+ CirclePacking.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
@@ -1,42 +1,42 @@
1
- .tree_Dendrogram .node {
2
- }
3
-
4
- .tree_Dendrogram .node circle {
5
- fill: #dcf1ff;
6
- stroke: #1f77b4;
7
- stroke-width: 1.0px;
8
- }
9
-
10
- .tree_Dendrogram .node.selected circle {
11
- stroke: red;
12
- }
13
-
14
- .tree_Dendrogram .node.over circle {
15
- stroke: orange;
16
- }
17
-
18
- .tree_Dendrogram .node.selected.over circle {
19
- stroke: red;
20
- }
21
-
22
- .tree_Dendrogram .node.selected text {
23
- fill: red;
24
- }
25
-
26
- .tree_Dendrogram .node.over text {
27
- fill: orange;
28
- }
29
-
30
- .tree_Dendrogram .node.selected.over text {
31
- fill: red;
32
- }
33
-
34
- .tree_Dendrogram .node text {
35
- font-size: 14px;
36
- }
37
-
38
- .tree_Dendrogram .link {
39
- fill: none;
40
- stroke: #656565;
41
- stroke-width: 1.0px;
42
- }
1
+ .tree_Dendrogram .node {
2
+ }
3
+
4
+ .tree_Dendrogram .node circle {
5
+ fill: #dcf1ff;
6
+ stroke: #1f77b4;
7
+ stroke-width: 1.0px;
8
+ }
9
+
10
+ .tree_Dendrogram .node.selected circle {
11
+ stroke: red;
12
+ }
13
+
14
+ .tree_Dendrogram .node.over circle {
15
+ stroke: orange;
16
+ }
17
+
18
+ .tree_Dendrogram .node.selected.over circle {
19
+ stroke: red;
20
+ }
21
+
22
+ .tree_Dendrogram .node.selected text {
23
+ fill: red;
24
+ }
25
+
26
+ .tree_Dendrogram .node.over text {
27
+ fill: orange;
28
+ }
29
+
30
+ .tree_Dendrogram .node.selected.over text {
31
+ fill: red;
32
+ }
33
+
34
+ .tree_Dendrogram .node text {
35
+ font-size: 14px;
36
+ }
37
+
38
+ .tree_Dendrogram .link {
39
+ fill: none;
40
+ stroke: #656565;
41
+ stroke-width: 1.0px;
42
+ }