@hpcc-js/tree 3.2.12 → 3.2.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/tree",
3
- "version": "3.2.12",
3
+ "version": "3.2.15",
4
4
  "description": "hpcc-js - Viz Tree",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.cjs",
@@ -37,11 +37,11 @@
37
37
  "update-major": "npx --yes npm-check-updates -u"
38
38
  },
39
39
  "dependencies": {
40
- "@hpcc-js/api": "^3.4.12",
41
- "@hpcc-js/common": "^3.7.2"
40
+ "@hpcc-js/api": "^3.4.15",
41
+ "@hpcc-js/common": "^3.7.5"
42
42
  },
43
43
  "devDependencies": {
44
- "@hpcc-js/esbuild-plugins": "^1.8.4",
44
+ "@hpcc-js/esbuild-plugins": "^1.8.7",
45
45
  "@types/d3-transition": "1.3.6",
46
46
  "d3-hierarchy": "^1",
47
47
  "d3-interpolate": "^1",
@@ -61,5 +61,5 @@
61
61
  "url": "https://github.com/hpcc-systems/Visualization/issues"
62
62
  },
63
63
  "homepage": "https://github.com/hpcc-systems/Visualization",
64
- "gitHead": "04460c76008934053c9957c361693aac862ca7dc"
64
+ "gitHead": "f8bdd58fc6914054a2313a87bbe1257dc9720545"
65
65
  }
@@ -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;
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
16
  }
@@ -1,152 +1,152 @@
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
+ 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,41 +1,41 @@
1
- .tree_Dendrogram .node {}
2
-
3
- .tree_Dendrogram .node circle {
4
- fill: #dcf1ff;
5
- stroke: #1f77b4;
6
- stroke-width: 1.0px;
7
- }
8
-
9
- .tree_Dendrogram .node.selected circle {
10
- stroke: red;
11
- }
12
-
13
- .tree_Dendrogram .node.over circle {
14
- stroke: orange;
15
- }
16
-
17
- .tree_Dendrogram .node.selected.over circle {
18
- stroke: red;
19
- }
20
-
21
- .tree_Dendrogram .node.selected text {
22
- fill: red;
23
- }
24
-
25
- .tree_Dendrogram .node.over text {
26
- fill: orange;
27
- }
28
-
29
- .tree_Dendrogram .node.selected.over text {
30
- fill: red;
31
- }
32
-
33
- .tree_Dendrogram .node text {
34
- font-size: 14px;
35
- }
36
-
37
- .tree_Dendrogram .link {
38
- fill: none;
39
- stroke: #656565;
40
- stroke-width: 1.0px;
1
+ .tree_Dendrogram .node {}
2
+
3
+ .tree_Dendrogram .node circle {
4
+ fill: #dcf1ff;
5
+ stroke: #1f77b4;
6
+ stroke-width: 1.0px;
7
+ }
8
+
9
+ .tree_Dendrogram .node.selected circle {
10
+ stroke: red;
11
+ }
12
+
13
+ .tree_Dendrogram .node.over circle {
14
+ stroke: orange;
15
+ }
16
+
17
+ .tree_Dendrogram .node.selected.over circle {
18
+ stroke: red;
19
+ }
20
+
21
+ .tree_Dendrogram .node.selected text {
22
+ fill: red;
23
+ }
24
+
25
+ .tree_Dendrogram .node.over text {
26
+ fill: orange;
27
+ }
28
+
29
+ .tree_Dendrogram .node.selected.over text {
30
+ fill: red;
31
+ }
32
+
33
+ .tree_Dendrogram .node text {
34
+ font-size: 14px;
35
+ }
36
+
37
+ .tree_Dendrogram .link {
38
+ fill: none;
39
+ stroke: #656565;
40
+ stroke-width: 1.0px;
41
41
  }