@bytechain.cn/colamd 1.5.0
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/.github/workflows/release.yml +66 -0
- package/.trae/documents/fix-mermaid-colors-and-sankey.md +50 -0
- package/CLAUDE.md +87 -0
- package/LICENSE +21 -0
- package/README.md +540 -0
- package/README_CN.md +543 -0
- package/demo.md +486 -0
- package/dist/main/index.js +735 -0
- package/dist/preload/index.js +71 -0
- package/dist/renderer/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/renderer/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/renderer/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/renderer/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/renderer/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/renderer/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/renderer/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/renderer/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/renderer/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/renderer/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/renderer/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/renderer/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/renderer/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/renderer/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/renderer/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/renderer/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/renderer/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/renderer/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/renderer/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/renderer/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/renderer/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/renderer/assets/arc-tTbbM8LO.js +131 -0
- package/dist/renderer/assets/architectureDiagram-3BPJPVTR-CEgYow6c.js +8720 -0
- package/dist/renderer/assets/blockDiagram-GPEHLZMM-LHyVtPwW.js +3825 -0
- package/dist/renderer/assets/c4Diagram-AAUBKEIU-C1P1eJrf.js +2482 -0
- package/dist/renderer/assets/channel-upve91Tq.js +7 -0
- package/dist/renderer/assets/chunk-2J33WTMH-lag2vhq9.js +24 -0
- package/dist/renderer/assets/chunk-4BX2VUAB-BXJ8Ggh-.js +16 -0
- package/dist/renderer/assets/chunk-55IACEB6-CiBpxRa1.js +13 -0
- package/dist/renderer/assets/chunk-727SXJPM-ODeKQFXC.js +2016 -0
- package/dist/renderer/assets/chunk-AQP2D5EJ-BK7xJolB.js +1953 -0
- package/dist/renderer/assets/chunk-FMBD7UC4-BxpCZPtz.js +19 -0
- package/dist/renderer/assets/chunk-ND2GUHAM-CqqaU9Ue.js +116 -0
- package/dist/renderer/assets/chunk-QZHKN3VN-Biq_K124.js +19 -0
- package/dist/renderer/assets/classDiagram-4FO5ZUOK-Cq95X99o.js +23 -0
- package/dist/renderer/assets/classDiagram-v2-Q7XG4LA2-Cq95X99o.js +23 -0
- package/dist/renderer/assets/cose-bilkent-S5V4N54A-XasiD0bu.js +4942 -0
- package/dist/renderer/assets/cytoscape.esm-CpHeHM5e.js +30269 -0
- package/dist/renderer/assets/dagre-BM42HDAG-Nq84Gfx4.js +705 -0
- package/dist/renderer/assets/defaultLocale-B2RvLBDe.js +206 -0
- package/dist/renderer/assets/diagram-2AECGRRQ-DwuB1GWt.js +301 -0
- package/dist/renderer/assets/diagram-5GNKFQAL-C2tgeI1h.js +169 -0
- package/dist/renderer/assets/diagram-KO2AKTUF-D5KzjNBc.js +632 -0
- package/dist/renderer/assets/diagram-LMA3HP47-C12xHS1c.js +212 -0
- package/dist/renderer/assets/diagram-OG6HWLK6-CnxI9oEa.js +851 -0
- package/dist/renderer/assets/erDiagram-TEJ5UH35-D_uPaKwn.js +1227 -0
- package/dist/renderer/assets/flowDiagram-I6XJVG4X-B6q_1-tE.js +2332 -0
- package/dist/renderer/assets/ganttDiagram-6RSMTGT7-CFo7ifF9.js +3720 -0
- package/dist/renderer/assets/gitGraphDiagram-PVQCEYII-WSexHTnq.js +1373 -0
- package/dist/renderer/assets/graph-DyX_9f6d.js +1988 -0
- package/dist/renderer/assets/index-DW7LS8C1.js +72292 -0
- package/dist/renderer/assets/index-dyHEFYvY.css +2184 -0
- package/dist/renderer/assets/infoDiagram-5YYISTIA-DaeJdLRq.js +31 -0
- package/dist/renderer/assets/init-ZxktEp_H.js +16 -0
- package/dist/renderer/assets/ishikawaDiagram-YF4QCWOH-DDCZc35f.js +967 -0
- package/dist/renderer/assets/journeyDiagram-JHISSGLW-BEdmpAgl.js +1255 -0
- package/dist/renderer/assets/kanban-definition-UN3LZRKU-BEFtQcFb.js +1052 -0
- package/dist/renderer/assets/layout-CAJgQHdw.js +2610 -0
- package/dist/renderer/assets/linear-B2ggJ8Am.js +340 -0
- package/dist/renderer/assets/mindmap-definition-RKZ34NQL-DSxVgHB5.js +1180 -0
- package/dist/renderer/assets/ordinal-DSZU4PqD.js +76 -0
- package/dist/renderer/assets/pieDiagram-4H26LBE5-CwYoJBuL.js +246 -0
- package/dist/renderer/assets/quadrantDiagram-W4KKPZXB-CST9Fvg9.js +1344 -0
- package/dist/renderer/assets/requirementDiagram-4Y6WPE33-DtrH52jS.js +1204 -0
- package/dist/renderer/assets/sankeyDiagram-5OEKKPKP-ca1tPzJ_.js +1274 -0
- package/dist/renderer/assets/sequenceDiagram-3UESZ5HK-Dfp1EJZ7.js +4514 -0
- package/dist/renderer/assets/stateDiagram-AJRCARHV-Bha2QoNB.js +450 -0
- package/dist/renderer/assets/stateDiagram-v2-BHNVJYJU-DWgFUYu1.js +21 -0
- package/dist/renderer/assets/timeline-definition-PNZ67QCA-C3h_-OTj.js +1596 -0
- package/dist/renderer/assets/vennDiagram-CIIHVFJN-DFzjSrZi.js +2486 -0
- package/dist/renderer/assets/wardley-L42UT6IY-Cx-VbqoS.js +30699 -0
- package/dist/renderer/assets/wardleyDiagram-YWT4CUSO-S2D9XqX6.js +975 -0
- package/dist/renderer/assets/xychartDiagram-2RQKCTM6-Cfxigbts.js +1932 -0
- package/dist/renderer/index.html +19 -0
- package/docs/agent-diff-view.md +48 -0
- package/electron-builder.yml +57 -0
- package/electron.vite.config.ts +30 -0
- package/package.json +40 -0
- package/resources/entitlements.mac.plist +12 -0
- package/resources/icon.icns +0 -0
- package/resources/icon.png +0 -0
- package/resources/icon.svg +23 -0
- package/resources/templates/slides/icon.png +0 -0
- package/resources/templates/slides/slides-template.md +74 -0
- package/resources/templates/slides/template.html +535 -0
- package/scripts/afterPack.js +13 -0
- package/src/main/index.ts +881 -0
- package/src/preload/index.ts +110 -0
- package/src/renderer/editor/editor.ts +204 -0
- package/src/renderer/editor/html-view.ts +15 -0
- package/src/renderer/editor/plugins/index.ts +76 -0
- package/src/renderer/editor/plugins/math-plugin.ts +297 -0
- package/src/renderer/editor/plugins/mermaid-plugin-custom.css +431 -0
- package/src/renderer/editor/plugins/mermaid-plugin-dark.css +428 -0
- package/src/renderer/editor/plugins/mermaid-plugin-elegant.css +443 -0
- package/src/renderer/editor/plugins/mermaid-plugin-newsprint.css +208 -0
- package/src/renderer/editor/plugins/mermaid-plugin.css +111 -0
- package/src/renderer/editor/plugins/mermaid-plugin.ts +679 -0
- package/src/renderer/env.d.ts +7 -0
- package/src/renderer/index.html +18 -0
- package/src/renderer/main.ts +303 -0
- package/src/renderer/themes/base.css +509 -0
- package/src/renderer/themes/theme-manager.ts +40 -0
- package/themes/README.md +280 -0
- package/themes/elegant.css +664 -0
- package/themes/guizang.css +732 -0
- package/tsconfig.json +14 -0
- package/tsconfig.main.json +11 -0
- package/tsconfig.preload.json +11 -0
- package/tsconfig.renderer.json +12 -0
|
@@ -0,0 +1,851 @@
|
|
|
1
|
+
import { _ as __name, K as getThemeVariables3, D as getConfig, F as cleanAndMerge, I as selectSvgElement, e as configureSvgSize, l as log, bd as styles2String, d as select, b as setAccTitle, a as getAccTitle, p as setDiagramTitle, q as getDiagramTitle, g as getAccDescription, s as setAccDescription, G as defaultConfig_default, be as isLabelStyle, z as clear } from "./index-DW7LS8C1.js";
|
|
2
|
+
import { s as setupViewPortForSVG } from "./chunk-2J33WTMH-lag2vhq9.js";
|
|
3
|
+
import { p as populateCommonDb } from "./chunk-4BX2VUAB-BXJ8Ggh-.js";
|
|
4
|
+
import { p as parse } from "./wardley-L42UT6IY-Cx-VbqoS.js";
|
|
5
|
+
import { b as format } from "./defaultLocale-B2RvLBDe.js";
|
|
6
|
+
import { o as ordinal } from "./ordinal-DSZU4PqD.js";
|
|
7
|
+
import "./init-ZxktEp_H.js";
|
|
8
|
+
function count(node) {
|
|
9
|
+
var sum = 0, children = node.children, i = children && children.length;
|
|
10
|
+
if (!i) sum = 1;
|
|
11
|
+
else while (--i >= 0) sum += children[i].value;
|
|
12
|
+
node.value = sum;
|
|
13
|
+
}
|
|
14
|
+
function node_count() {
|
|
15
|
+
return this.eachAfter(count);
|
|
16
|
+
}
|
|
17
|
+
function node_each(callback, that) {
|
|
18
|
+
let index = -1;
|
|
19
|
+
for (const node of this) {
|
|
20
|
+
callback.call(that, node, ++index, this);
|
|
21
|
+
}
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
function node_eachBefore(callback, that) {
|
|
25
|
+
var node = this, nodes = [node], children, i, index = -1;
|
|
26
|
+
while (node = nodes.pop()) {
|
|
27
|
+
callback.call(that, node, ++index, this);
|
|
28
|
+
if (children = node.children) {
|
|
29
|
+
for (i = children.length - 1; i >= 0; --i) {
|
|
30
|
+
nodes.push(children[i]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
function node_eachAfter(callback, that) {
|
|
37
|
+
var node = this, nodes = [node], next = [], children, i, n, index = -1;
|
|
38
|
+
while (node = nodes.pop()) {
|
|
39
|
+
next.push(node);
|
|
40
|
+
if (children = node.children) {
|
|
41
|
+
for (i = 0, n = children.length; i < n; ++i) {
|
|
42
|
+
nodes.push(children[i]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
while (node = next.pop()) {
|
|
47
|
+
callback.call(that, node, ++index, this);
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
function node_find(callback, that) {
|
|
52
|
+
let index = -1;
|
|
53
|
+
for (const node of this) {
|
|
54
|
+
if (callback.call(that, node, ++index, this)) {
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function node_sum(value) {
|
|
60
|
+
return this.eachAfter(function(node) {
|
|
61
|
+
var sum = +value(node.data) || 0, children = node.children, i = children && children.length;
|
|
62
|
+
while (--i >= 0) sum += children[i].value;
|
|
63
|
+
node.value = sum;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function node_sort(compare) {
|
|
67
|
+
return this.eachBefore(function(node) {
|
|
68
|
+
if (node.children) {
|
|
69
|
+
node.children.sort(compare);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function node_path(end) {
|
|
74
|
+
var start = this, ancestor = leastCommonAncestor(start, end), nodes = [start];
|
|
75
|
+
while (start !== ancestor) {
|
|
76
|
+
start = start.parent;
|
|
77
|
+
nodes.push(start);
|
|
78
|
+
}
|
|
79
|
+
var k = nodes.length;
|
|
80
|
+
while (end !== ancestor) {
|
|
81
|
+
nodes.splice(k, 0, end);
|
|
82
|
+
end = end.parent;
|
|
83
|
+
}
|
|
84
|
+
return nodes;
|
|
85
|
+
}
|
|
86
|
+
function leastCommonAncestor(a, b) {
|
|
87
|
+
if (a === b) return a;
|
|
88
|
+
var aNodes = a.ancestors(), bNodes = b.ancestors(), c = null;
|
|
89
|
+
a = aNodes.pop();
|
|
90
|
+
b = bNodes.pop();
|
|
91
|
+
while (a === b) {
|
|
92
|
+
c = a;
|
|
93
|
+
a = aNodes.pop();
|
|
94
|
+
b = bNodes.pop();
|
|
95
|
+
}
|
|
96
|
+
return c;
|
|
97
|
+
}
|
|
98
|
+
function node_ancestors() {
|
|
99
|
+
var node = this, nodes = [node];
|
|
100
|
+
while (node = node.parent) {
|
|
101
|
+
nodes.push(node);
|
|
102
|
+
}
|
|
103
|
+
return nodes;
|
|
104
|
+
}
|
|
105
|
+
function node_descendants() {
|
|
106
|
+
return Array.from(this);
|
|
107
|
+
}
|
|
108
|
+
function node_leaves() {
|
|
109
|
+
var leaves = [];
|
|
110
|
+
this.eachBefore(function(node) {
|
|
111
|
+
if (!node.children) {
|
|
112
|
+
leaves.push(node);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return leaves;
|
|
116
|
+
}
|
|
117
|
+
function node_links() {
|
|
118
|
+
var root = this, links = [];
|
|
119
|
+
root.each(function(node) {
|
|
120
|
+
if (node !== root) {
|
|
121
|
+
links.push({ source: node.parent, target: node });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return links;
|
|
125
|
+
}
|
|
126
|
+
function* node_iterator() {
|
|
127
|
+
var node = this, current, next = [node], children, i, n;
|
|
128
|
+
do {
|
|
129
|
+
current = next.reverse(), next = [];
|
|
130
|
+
while (node = current.pop()) {
|
|
131
|
+
yield node;
|
|
132
|
+
if (children = node.children) {
|
|
133
|
+
for (i = 0, n = children.length; i < n; ++i) {
|
|
134
|
+
next.push(children[i]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} while (next.length);
|
|
139
|
+
}
|
|
140
|
+
function hierarchy(data, children) {
|
|
141
|
+
if (data instanceof Map) {
|
|
142
|
+
data = [void 0, data];
|
|
143
|
+
if (children === void 0) children = mapChildren;
|
|
144
|
+
} else if (children === void 0) {
|
|
145
|
+
children = objectChildren;
|
|
146
|
+
}
|
|
147
|
+
var root = new Node(data), node, nodes = [root], child, childs, i, n;
|
|
148
|
+
while (node = nodes.pop()) {
|
|
149
|
+
if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
|
|
150
|
+
node.children = childs;
|
|
151
|
+
for (i = n - 1; i >= 0; --i) {
|
|
152
|
+
nodes.push(child = childs[i] = new Node(childs[i]));
|
|
153
|
+
child.parent = node;
|
|
154
|
+
child.depth = node.depth + 1;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return root.eachBefore(computeHeight);
|
|
159
|
+
}
|
|
160
|
+
function node_copy() {
|
|
161
|
+
return hierarchy(this).eachBefore(copyData);
|
|
162
|
+
}
|
|
163
|
+
function objectChildren(d) {
|
|
164
|
+
return d.children;
|
|
165
|
+
}
|
|
166
|
+
function mapChildren(d) {
|
|
167
|
+
return Array.isArray(d) ? d[1] : null;
|
|
168
|
+
}
|
|
169
|
+
function copyData(node) {
|
|
170
|
+
if (node.data.value !== void 0) node.value = node.data.value;
|
|
171
|
+
node.data = node.data.data;
|
|
172
|
+
}
|
|
173
|
+
function computeHeight(node) {
|
|
174
|
+
var height = 0;
|
|
175
|
+
do
|
|
176
|
+
node.height = height;
|
|
177
|
+
while ((node = node.parent) && node.height < ++height);
|
|
178
|
+
}
|
|
179
|
+
function Node(data) {
|
|
180
|
+
this.data = data;
|
|
181
|
+
this.depth = this.height = 0;
|
|
182
|
+
this.parent = null;
|
|
183
|
+
}
|
|
184
|
+
Node.prototype = hierarchy.prototype = {
|
|
185
|
+
constructor: Node,
|
|
186
|
+
count: node_count,
|
|
187
|
+
each: node_each,
|
|
188
|
+
eachAfter: node_eachAfter,
|
|
189
|
+
eachBefore: node_eachBefore,
|
|
190
|
+
find: node_find,
|
|
191
|
+
sum: node_sum,
|
|
192
|
+
sort: node_sort,
|
|
193
|
+
path: node_path,
|
|
194
|
+
ancestors: node_ancestors,
|
|
195
|
+
descendants: node_descendants,
|
|
196
|
+
leaves: node_leaves,
|
|
197
|
+
links: node_links,
|
|
198
|
+
copy: node_copy,
|
|
199
|
+
[Symbol.iterator]: node_iterator
|
|
200
|
+
};
|
|
201
|
+
function required(f) {
|
|
202
|
+
if (typeof f !== "function") throw new Error();
|
|
203
|
+
return f;
|
|
204
|
+
}
|
|
205
|
+
function constantZero() {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
function constant(x) {
|
|
209
|
+
return function() {
|
|
210
|
+
return x;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function roundNode(node) {
|
|
214
|
+
node.x0 = Math.round(node.x0);
|
|
215
|
+
node.y0 = Math.round(node.y0);
|
|
216
|
+
node.x1 = Math.round(node.x1);
|
|
217
|
+
node.y1 = Math.round(node.y1);
|
|
218
|
+
}
|
|
219
|
+
function treemapDice(parent, x0, y0, x1, y1) {
|
|
220
|
+
var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (x1 - x0) / parent.value;
|
|
221
|
+
while (++i < n) {
|
|
222
|
+
node = nodes[i], node.y0 = y0, node.y1 = y1;
|
|
223
|
+
node.x0 = x0, node.x1 = x0 += node.value * k;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function treemapSlice(parent, x0, y0, x1, y1) {
|
|
227
|
+
var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (y1 - y0) / parent.value;
|
|
228
|
+
while (++i < n) {
|
|
229
|
+
node = nodes[i], node.x0 = x0, node.x1 = x1;
|
|
230
|
+
node.y0 = y0, node.y1 = y0 += node.value * k;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
var phi = (1 + Math.sqrt(5)) / 2;
|
|
234
|
+
function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
|
|
235
|
+
var rows = [], nodes = parent.children, row, nodeValue, i0 = 0, i1 = 0, n = nodes.length, dx, dy, value = parent.value, sumValue, minValue, maxValue, newRatio, minRatio, alpha, beta;
|
|
236
|
+
while (i0 < n) {
|
|
237
|
+
dx = x1 - x0, dy = y1 - y0;
|
|
238
|
+
do
|
|
239
|
+
sumValue = nodes[i1++].value;
|
|
240
|
+
while (!sumValue && i1 < n);
|
|
241
|
+
minValue = maxValue = sumValue;
|
|
242
|
+
alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
|
|
243
|
+
beta = sumValue * sumValue * alpha;
|
|
244
|
+
minRatio = Math.max(maxValue / beta, beta / minValue);
|
|
245
|
+
for (; i1 < n; ++i1) {
|
|
246
|
+
sumValue += nodeValue = nodes[i1].value;
|
|
247
|
+
if (nodeValue < minValue) minValue = nodeValue;
|
|
248
|
+
if (nodeValue > maxValue) maxValue = nodeValue;
|
|
249
|
+
beta = sumValue * sumValue * alpha;
|
|
250
|
+
newRatio = Math.max(maxValue / beta, beta / minValue);
|
|
251
|
+
if (newRatio > minRatio) {
|
|
252
|
+
sumValue -= nodeValue;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
minRatio = newRatio;
|
|
256
|
+
}
|
|
257
|
+
rows.push(row = { value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1) });
|
|
258
|
+
if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
|
|
259
|
+
else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
|
|
260
|
+
value -= sumValue, i0 = i1;
|
|
261
|
+
}
|
|
262
|
+
return rows;
|
|
263
|
+
}
|
|
264
|
+
const squarify = (function custom(ratio) {
|
|
265
|
+
function squarify2(parent, x0, y0, x1, y1) {
|
|
266
|
+
squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
|
267
|
+
}
|
|
268
|
+
squarify2.ratio = function(x) {
|
|
269
|
+
return custom((x = +x) > 1 ? x : 1);
|
|
270
|
+
};
|
|
271
|
+
return squarify2;
|
|
272
|
+
})(phi);
|
|
273
|
+
function treemap() {
|
|
274
|
+
var tile = squarify, round = false, dx = 1, dy = 1, paddingStack = [0], paddingInner = constantZero, paddingTop = constantZero, paddingRight = constantZero, paddingBottom = constantZero, paddingLeft = constantZero;
|
|
275
|
+
function treemap2(root) {
|
|
276
|
+
root.x0 = root.y0 = 0;
|
|
277
|
+
root.x1 = dx;
|
|
278
|
+
root.y1 = dy;
|
|
279
|
+
root.eachBefore(positionNode);
|
|
280
|
+
paddingStack = [0];
|
|
281
|
+
if (round) root.eachBefore(roundNode);
|
|
282
|
+
return root;
|
|
283
|
+
}
|
|
284
|
+
function positionNode(node) {
|
|
285
|
+
var p = paddingStack[node.depth], x0 = node.x0 + p, y0 = node.y0 + p, x1 = node.x1 - p, y1 = node.y1 - p;
|
|
286
|
+
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
287
|
+
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
288
|
+
node.x0 = x0;
|
|
289
|
+
node.y0 = y0;
|
|
290
|
+
node.x1 = x1;
|
|
291
|
+
node.y1 = y1;
|
|
292
|
+
if (node.children) {
|
|
293
|
+
p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
|
|
294
|
+
x0 += paddingLeft(node) - p;
|
|
295
|
+
y0 += paddingTop(node) - p;
|
|
296
|
+
x1 -= paddingRight(node) - p;
|
|
297
|
+
y1 -= paddingBottom(node) - p;
|
|
298
|
+
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
299
|
+
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
300
|
+
tile(node, x0, y0, x1, y1);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
treemap2.round = function(x) {
|
|
304
|
+
return arguments.length ? (round = !!x, treemap2) : round;
|
|
305
|
+
};
|
|
306
|
+
treemap2.size = function(x) {
|
|
307
|
+
return arguments.length ? (dx = +x[0], dy = +x[1], treemap2) : [dx, dy];
|
|
308
|
+
};
|
|
309
|
+
treemap2.tile = function(x) {
|
|
310
|
+
return arguments.length ? (tile = required(x), treemap2) : tile;
|
|
311
|
+
};
|
|
312
|
+
treemap2.padding = function(x) {
|
|
313
|
+
return arguments.length ? treemap2.paddingInner(x).paddingOuter(x) : treemap2.paddingInner();
|
|
314
|
+
};
|
|
315
|
+
treemap2.paddingInner = function(x) {
|
|
316
|
+
return arguments.length ? (paddingInner = typeof x === "function" ? x : constant(+x), treemap2) : paddingInner;
|
|
317
|
+
};
|
|
318
|
+
treemap2.paddingOuter = function(x) {
|
|
319
|
+
return arguments.length ? treemap2.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap2.paddingTop();
|
|
320
|
+
};
|
|
321
|
+
treemap2.paddingTop = function(x) {
|
|
322
|
+
return arguments.length ? (paddingTop = typeof x === "function" ? x : constant(+x), treemap2) : paddingTop;
|
|
323
|
+
};
|
|
324
|
+
treemap2.paddingRight = function(x) {
|
|
325
|
+
return arguments.length ? (paddingRight = typeof x === "function" ? x : constant(+x), treemap2) : paddingRight;
|
|
326
|
+
};
|
|
327
|
+
treemap2.paddingBottom = function(x) {
|
|
328
|
+
return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant(+x), treemap2) : paddingBottom;
|
|
329
|
+
};
|
|
330
|
+
treemap2.paddingLeft = function(x) {
|
|
331
|
+
return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant(+x), treemap2) : paddingLeft;
|
|
332
|
+
};
|
|
333
|
+
return treemap2;
|
|
334
|
+
}
|
|
335
|
+
var TreeMapDB = class {
|
|
336
|
+
constructor() {
|
|
337
|
+
this.nodes = [];
|
|
338
|
+
this.levels = /* @__PURE__ */ new Map();
|
|
339
|
+
this.outerNodes = [];
|
|
340
|
+
this.classes = /* @__PURE__ */ new Map();
|
|
341
|
+
this.setAccTitle = setAccTitle;
|
|
342
|
+
this.getAccTitle = getAccTitle;
|
|
343
|
+
this.setDiagramTitle = setDiagramTitle;
|
|
344
|
+
this.getDiagramTitle = getDiagramTitle;
|
|
345
|
+
this.getAccDescription = getAccDescription;
|
|
346
|
+
this.setAccDescription = setAccDescription;
|
|
347
|
+
}
|
|
348
|
+
static {
|
|
349
|
+
__name(this, "TreeMapDB");
|
|
350
|
+
}
|
|
351
|
+
getNodes() {
|
|
352
|
+
return this.nodes;
|
|
353
|
+
}
|
|
354
|
+
getConfig() {
|
|
355
|
+
const defaultConfig = defaultConfig_default;
|
|
356
|
+
const userConfig = getConfig();
|
|
357
|
+
return cleanAndMerge({
|
|
358
|
+
...defaultConfig.treemap,
|
|
359
|
+
...userConfig.treemap ?? {}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
addNode(node, level) {
|
|
363
|
+
this.nodes.push(node);
|
|
364
|
+
this.levels.set(node, level);
|
|
365
|
+
if (level === 0) {
|
|
366
|
+
this.outerNodes.push(node);
|
|
367
|
+
this.root ??= node;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
getRoot() {
|
|
371
|
+
return { name: "", children: this.outerNodes };
|
|
372
|
+
}
|
|
373
|
+
addClass(id, _style) {
|
|
374
|
+
const styleClass = this.classes.get(id) ?? { id, styles: [], textStyles: [] };
|
|
375
|
+
const styles = _style.replace(/\\,/g, "§§§").replace(/,/g, ";").replace(/§§§/g, ",").split(";");
|
|
376
|
+
if (styles) {
|
|
377
|
+
styles.forEach((s) => {
|
|
378
|
+
if (isLabelStyle(s)) {
|
|
379
|
+
if (styleClass?.textStyles) {
|
|
380
|
+
styleClass.textStyles.push(s);
|
|
381
|
+
} else {
|
|
382
|
+
styleClass.textStyles = [s];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (styleClass?.styles) {
|
|
386
|
+
styleClass.styles.push(s);
|
|
387
|
+
} else {
|
|
388
|
+
styleClass.styles = [s];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
this.classes.set(id, styleClass);
|
|
393
|
+
}
|
|
394
|
+
getClasses() {
|
|
395
|
+
return this.classes;
|
|
396
|
+
}
|
|
397
|
+
getStylesForClass(classSelector) {
|
|
398
|
+
return this.classes.get(classSelector)?.styles ?? [];
|
|
399
|
+
}
|
|
400
|
+
clear() {
|
|
401
|
+
clear();
|
|
402
|
+
this.nodes = [];
|
|
403
|
+
this.levels = /* @__PURE__ */ new Map();
|
|
404
|
+
this.outerNodes = [];
|
|
405
|
+
this.classes = /* @__PURE__ */ new Map();
|
|
406
|
+
this.root = void 0;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
function buildHierarchy(items) {
|
|
410
|
+
if (!items.length) {
|
|
411
|
+
return [];
|
|
412
|
+
}
|
|
413
|
+
const root = [];
|
|
414
|
+
const stack = [];
|
|
415
|
+
items.forEach((item) => {
|
|
416
|
+
const node = {
|
|
417
|
+
name: item.name,
|
|
418
|
+
children: item.type === "Leaf" ? void 0 : []
|
|
419
|
+
};
|
|
420
|
+
node.classSelector = item?.classSelector;
|
|
421
|
+
if (item?.cssCompiledStyles) {
|
|
422
|
+
node.cssCompiledStyles = item.cssCompiledStyles;
|
|
423
|
+
}
|
|
424
|
+
if (item.type === "Leaf" && item.value !== void 0) {
|
|
425
|
+
node.value = item.value;
|
|
426
|
+
}
|
|
427
|
+
while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {
|
|
428
|
+
stack.pop();
|
|
429
|
+
}
|
|
430
|
+
if (stack.length === 0) {
|
|
431
|
+
root.push(node);
|
|
432
|
+
} else {
|
|
433
|
+
const parent = stack[stack.length - 1].node;
|
|
434
|
+
if (parent.children) {
|
|
435
|
+
parent.children.push(node);
|
|
436
|
+
} else {
|
|
437
|
+
parent.children = [node];
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (item.type !== "Leaf") {
|
|
441
|
+
stack.push({ node, level: item.level });
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
return root;
|
|
445
|
+
}
|
|
446
|
+
__name(buildHierarchy, "buildHierarchy");
|
|
447
|
+
var populate = /* @__PURE__ */ __name((ast, db) => {
|
|
448
|
+
populateCommonDb(ast, db);
|
|
449
|
+
const items = [];
|
|
450
|
+
for (const row of ast.TreemapRows ?? []) {
|
|
451
|
+
if (row.$type === "ClassDefStatement") {
|
|
452
|
+
db.addClass(row.className ?? "", row.styleText ?? "");
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
for (const row of ast.TreemapRows ?? []) {
|
|
456
|
+
const item = row.item;
|
|
457
|
+
if (!item) {
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
const level = row.indent ? parseInt(row.indent) : 0;
|
|
461
|
+
const name = getItemName(item);
|
|
462
|
+
const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];
|
|
463
|
+
const cssCompiledStyles = styles.length > 0 ? styles : void 0;
|
|
464
|
+
const itemData = {
|
|
465
|
+
level,
|
|
466
|
+
name,
|
|
467
|
+
type: item.$type,
|
|
468
|
+
value: item.value,
|
|
469
|
+
classSelector: item.classSelector,
|
|
470
|
+
cssCompiledStyles
|
|
471
|
+
};
|
|
472
|
+
items.push(itemData);
|
|
473
|
+
}
|
|
474
|
+
const hierarchyNodes = buildHierarchy(items);
|
|
475
|
+
const addNodesRecursively = /* @__PURE__ */ __name((nodes, level) => {
|
|
476
|
+
for (const node of nodes) {
|
|
477
|
+
db.addNode(node, level);
|
|
478
|
+
if (node.children && node.children.length > 0) {
|
|
479
|
+
addNodesRecursively(node.children, level + 1);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}, "addNodesRecursively");
|
|
483
|
+
addNodesRecursively(hierarchyNodes, 0);
|
|
484
|
+
}, "populate");
|
|
485
|
+
var getItemName = /* @__PURE__ */ __name((item) => {
|
|
486
|
+
return item.name ? String(item.name) : "";
|
|
487
|
+
}, "getItemName");
|
|
488
|
+
var parser = {
|
|
489
|
+
// @ts-expect-error - TreeMapDB is not assignable to DiagramDB
|
|
490
|
+
parser: { yy: void 0 },
|
|
491
|
+
parse: /* @__PURE__ */ __name(async (text) => {
|
|
492
|
+
try {
|
|
493
|
+
const parseFunc = parse;
|
|
494
|
+
const ast = await parseFunc("treemap", text);
|
|
495
|
+
log.debug("Treemap AST:", ast);
|
|
496
|
+
const db = parser.parser?.yy;
|
|
497
|
+
if (!(db instanceof TreeMapDB)) {
|
|
498
|
+
throw new Error(
|
|
499
|
+
"parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
populate(ast, db);
|
|
503
|
+
} catch (error) {
|
|
504
|
+
log.error("Error parsing treemap:", error);
|
|
505
|
+
throw error;
|
|
506
|
+
}
|
|
507
|
+
}, "parse")
|
|
508
|
+
};
|
|
509
|
+
var DEFAULT_INNER_PADDING = 10;
|
|
510
|
+
var SECTION_INNER_PADDING = 10;
|
|
511
|
+
var SECTION_HEADER_HEIGHT = 25;
|
|
512
|
+
var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
|
|
513
|
+
const treemapDb = diagram2.db;
|
|
514
|
+
const config = treemapDb.getConfig();
|
|
515
|
+
const treemapInnerPadding = config.padding ?? DEFAULT_INNER_PADDING;
|
|
516
|
+
const title = treemapDb.getDiagramTitle();
|
|
517
|
+
const root = treemapDb.getRoot();
|
|
518
|
+
const { themeVariables } = getConfig();
|
|
519
|
+
if (!root) {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
const titleHeight = title ? 30 : 0;
|
|
523
|
+
const svg = selectSvgElement(id);
|
|
524
|
+
const width = config.nodeWidth ? config.nodeWidth * SECTION_INNER_PADDING : 960;
|
|
525
|
+
const height = config.nodeHeight ? config.nodeHeight * SECTION_INNER_PADDING : 500;
|
|
526
|
+
const svgWidth = width;
|
|
527
|
+
const svgHeight = height + titleHeight;
|
|
528
|
+
svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
|
|
529
|
+
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
|
|
530
|
+
let valueFormat;
|
|
531
|
+
try {
|
|
532
|
+
const formatStr = config.valueFormat || ",";
|
|
533
|
+
if (formatStr === "$0,0") {
|
|
534
|
+
valueFormat = /* @__PURE__ */ __name((value) => "$" + format(",")(value), "valueFormat");
|
|
535
|
+
} else if (formatStr.startsWith("$") && formatStr.includes(",")) {
|
|
536
|
+
const precision = /\.\d+/.exec(formatStr);
|
|
537
|
+
const precisionStr = precision ? precision[0] : "";
|
|
538
|
+
valueFormat = /* @__PURE__ */ __name((value) => "$" + format("," + precisionStr)(value), "valueFormat");
|
|
539
|
+
} else if (formatStr.startsWith("$")) {
|
|
540
|
+
const restOfFormat = formatStr.substring(1);
|
|
541
|
+
valueFormat = /* @__PURE__ */ __name((value) => "$" + format(restOfFormat || "")(value), "valueFormat");
|
|
542
|
+
} else {
|
|
543
|
+
valueFormat = format(formatStr);
|
|
544
|
+
}
|
|
545
|
+
} catch (error) {
|
|
546
|
+
log.error("Error creating format function:", error);
|
|
547
|
+
valueFormat = format(",");
|
|
548
|
+
}
|
|
549
|
+
const colorScale = ordinal().range([
|
|
550
|
+
"transparent",
|
|
551
|
+
themeVariables.cScale0,
|
|
552
|
+
themeVariables.cScale1,
|
|
553
|
+
themeVariables.cScale2,
|
|
554
|
+
themeVariables.cScale3,
|
|
555
|
+
themeVariables.cScale4,
|
|
556
|
+
themeVariables.cScale5,
|
|
557
|
+
themeVariables.cScale6,
|
|
558
|
+
themeVariables.cScale7,
|
|
559
|
+
themeVariables.cScale8,
|
|
560
|
+
themeVariables.cScale9,
|
|
561
|
+
themeVariables.cScale10,
|
|
562
|
+
themeVariables.cScale11
|
|
563
|
+
]);
|
|
564
|
+
const colorScalePeer = ordinal().range([
|
|
565
|
+
"transparent",
|
|
566
|
+
themeVariables.cScalePeer0,
|
|
567
|
+
themeVariables.cScalePeer1,
|
|
568
|
+
themeVariables.cScalePeer2,
|
|
569
|
+
themeVariables.cScalePeer3,
|
|
570
|
+
themeVariables.cScalePeer4,
|
|
571
|
+
themeVariables.cScalePeer5,
|
|
572
|
+
themeVariables.cScalePeer6,
|
|
573
|
+
themeVariables.cScalePeer7,
|
|
574
|
+
themeVariables.cScalePeer8,
|
|
575
|
+
themeVariables.cScalePeer9,
|
|
576
|
+
themeVariables.cScalePeer10,
|
|
577
|
+
themeVariables.cScalePeer11
|
|
578
|
+
]);
|
|
579
|
+
const colorScaleLabel = ordinal().range([
|
|
580
|
+
themeVariables.cScaleLabel0,
|
|
581
|
+
themeVariables.cScaleLabel1,
|
|
582
|
+
themeVariables.cScaleLabel2,
|
|
583
|
+
themeVariables.cScaleLabel3,
|
|
584
|
+
themeVariables.cScaleLabel4,
|
|
585
|
+
themeVariables.cScaleLabel5,
|
|
586
|
+
themeVariables.cScaleLabel6,
|
|
587
|
+
themeVariables.cScaleLabel7,
|
|
588
|
+
themeVariables.cScaleLabel8,
|
|
589
|
+
themeVariables.cScaleLabel9,
|
|
590
|
+
themeVariables.cScaleLabel10,
|
|
591
|
+
themeVariables.cScaleLabel11
|
|
592
|
+
]);
|
|
593
|
+
if (title) {
|
|
594
|
+
svg.append("text").attr("x", svgWidth / 2).attr("y", titleHeight / 2).attr("class", "treemapTitle").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
|
|
595
|
+
}
|
|
596
|
+
const g = svg.append("g").attr("transform", `translate(0, ${titleHeight})`).attr("class", "treemapContainer");
|
|
597
|
+
const hierarchyRoot = hierarchy(root).sum((d) => d.value ?? 0).sort((a, b) => (b.value ?? 0) - (a.value ?? 0));
|
|
598
|
+
const treemapLayout = treemap().size([width, height]).paddingTop(
|
|
599
|
+
(d) => d.children && d.children.length > 0 ? SECTION_HEADER_HEIGHT + SECTION_INNER_PADDING : 0
|
|
600
|
+
).paddingInner(treemapInnerPadding).paddingLeft((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingRight((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingBottom((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).round(true);
|
|
601
|
+
const treemapData = treemapLayout(hierarchyRoot);
|
|
602
|
+
const branchNodes = treemapData.descendants().filter((d) => d.children && d.children.length > 0);
|
|
603
|
+
const sections = g.selectAll(".treemapSection").data(branchNodes).enter().append("g").attr("class", "treemapSection").attr("transform", (d) => `translate(${d.x0},${d.y0})`);
|
|
604
|
+
sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", SECTION_HEADER_HEIGHT).attr("class", "treemapSectionHeader").attr("fill", "none").attr("fill-opacity", 0.6).attr("stroke-width", 0.6).attr("style", (d) => {
|
|
605
|
+
if (d.depth === 0) {
|
|
606
|
+
return "display: none;";
|
|
607
|
+
}
|
|
608
|
+
return "";
|
|
609
|
+
});
|
|
610
|
+
sections.append("clipPath").attr("id", (_d, i) => `clip-section-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 12)).attr("height", SECTION_HEADER_HEIGHT);
|
|
611
|
+
sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", (_d, i) => {
|
|
612
|
+
return `treemapSection section${i}`;
|
|
613
|
+
}).attr("fill", (d) => colorScale(d.data.name)).attr("fill-opacity", 0.6).attr("stroke", (d) => colorScalePeer(d.data.name)).attr("stroke-width", 2).attr("stroke-opacity", 0.4).attr("style", (d) => {
|
|
614
|
+
if (d.depth === 0) {
|
|
615
|
+
return "display: none;";
|
|
616
|
+
}
|
|
617
|
+
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
|
618
|
+
return styles.nodeStyles + ";" + styles.borderStyles.join(";");
|
|
619
|
+
});
|
|
620
|
+
sections.append("text").attr("class", "treemapSectionLabel").attr("x", 6).attr("y", SECTION_HEADER_HEIGHT / 2).attr("dominant-baseline", "middle").text((d) => d.depth === 0 ? "" : d.data.name).attr("font-weight", "bold").attr("style", (d) => {
|
|
621
|
+
if (d.depth === 0) {
|
|
622
|
+
return "display: none;";
|
|
623
|
+
}
|
|
624
|
+
const labelStyles = "dominant-baseline: middle; font-size: 12px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
|
|
625
|
+
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
|
626
|
+
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
|
627
|
+
}).each(function(d) {
|
|
628
|
+
if (d.depth === 0) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const self = select(this);
|
|
632
|
+
const originalText = d.data.name;
|
|
633
|
+
self.text(originalText);
|
|
634
|
+
const totalHeaderWidth = d.x1 - d.x0;
|
|
635
|
+
const labelXPosition = 6;
|
|
636
|
+
let spaceForTextContent;
|
|
637
|
+
if (config.showValues !== false && d.value) {
|
|
638
|
+
const valueEndsAtXRelative = totalHeaderWidth - 10;
|
|
639
|
+
const estimatedValueTextActualWidth = 30;
|
|
640
|
+
const gapBetweenLabelAndValue = 10;
|
|
641
|
+
const labelMustEndBeforeX = valueEndsAtXRelative - estimatedValueTextActualWidth - gapBetweenLabelAndValue;
|
|
642
|
+
spaceForTextContent = labelMustEndBeforeX - labelXPosition;
|
|
643
|
+
} else {
|
|
644
|
+
const labelOwnRightPadding = 6;
|
|
645
|
+
spaceForTextContent = totalHeaderWidth - labelXPosition - labelOwnRightPadding;
|
|
646
|
+
}
|
|
647
|
+
const minimumWidthToDisplay = 15;
|
|
648
|
+
const actualAvailableWidth = Math.max(minimumWidthToDisplay, spaceForTextContent);
|
|
649
|
+
const textNode = self.node();
|
|
650
|
+
const currentTextContentLength = textNode.getComputedTextLength();
|
|
651
|
+
if (currentTextContentLength > actualAvailableWidth) {
|
|
652
|
+
const ellipsis = "...";
|
|
653
|
+
let currentTruncatedText = originalText;
|
|
654
|
+
while (currentTruncatedText.length > 0) {
|
|
655
|
+
currentTruncatedText = originalText.substring(0, currentTruncatedText.length - 1);
|
|
656
|
+
if (currentTruncatedText.length === 0) {
|
|
657
|
+
self.text(ellipsis);
|
|
658
|
+
if (textNode.getComputedTextLength() > actualAvailableWidth) {
|
|
659
|
+
self.text("");
|
|
660
|
+
}
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
self.text(currentTruncatedText + ellipsis);
|
|
664
|
+
if (textNode.getComputedTextLength() <= actualAvailableWidth) {
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
if (config.showValues !== false) {
|
|
671
|
+
sections.append("text").attr("class", "treemapSectionValue").attr("x", (d) => d.x1 - d.x0 - 10).attr("y", SECTION_HEADER_HEIGHT / 2).attr("text-anchor", "end").attr("dominant-baseline", "middle").text((d) => d.value ? valueFormat(d.value) : "").attr("font-style", "italic").attr("style", (d) => {
|
|
672
|
+
if (d.depth === 0) {
|
|
673
|
+
return "display: none;";
|
|
674
|
+
}
|
|
675
|
+
const labelStyles = "text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
|
|
676
|
+
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
|
677
|
+
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
const leafNodes = treemapData.leaves();
|
|
681
|
+
const cell = g.selectAll(".treemapLeafGroup").data(leafNodes).enter().append("g").attr("class", (d, i) => {
|
|
682
|
+
return `treemapNode treemapLeafGroup leaf${i}${d.data.classSelector ? ` ${d.data.classSelector}` : ""}x`;
|
|
683
|
+
}).attr("transform", (d) => `translate(${d.x0},${d.y0})`);
|
|
684
|
+
cell.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", "treemapLeaf").attr("fill", (d) => {
|
|
685
|
+
return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
|
|
686
|
+
}).attr("style", (d) => {
|
|
687
|
+
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
|
688
|
+
return styles.nodeStyles;
|
|
689
|
+
}).attr("fill-opacity", 0.3).attr("stroke", (d) => {
|
|
690
|
+
return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
|
|
691
|
+
}).attr("stroke-width", 3);
|
|
692
|
+
cell.append("clipPath").attr("id", (_d, i) => `clip-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 4)).attr("height", (d) => Math.max(0, d.y1 - d.y0 - 4));
|
|
693
|
+
const leafLabels = cell.append("text").attr("class", "treemapLabel").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", (d) => (d.y1 - d.y0) / 2).attr("style", (d) => {
|
|
694
|
+
const labelStyles = "text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:" + colorScaleLabel(d.data.name) + ";";
|
|
695
|
+
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
|
696
|
+
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
|
697
|
+
}).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.data.name);
|
|
698
|
+
leafLabels.each(function(d) {
|
|
699
|
+
const self = select(this);
|
|
700
|
+
const nodeWidth = d.x1 - d.x0;
|
|
701
|
+
const nodeHeight = d.y1 - d.y0;
|
|
702
|
+
const textNode = self.node();
|
|
703
|
+
const padding = 4;
|
|
704
|
+
const availableWidth = nodeWidth - 2 * padding;
|
|
705
|
+
const availableHeight = nodeHeight - 2 * padding;
|
|
706
|
+
if (availableWidth < 10 || availableHeight < 10) {
|
|
707
|
+
self.style("display", "none");
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
let currentLabelFontSize = parseInt(self.style("font-size"), 10);
|
|
711
|
+
const minLabelFontSize = 8;
|
|
712
|
+
const originalValueRelFontSize = 28;
|
|
713
|
+
const valueScaleFactor = 0.6;
|
|
714
|
+
const minValueFontSize = 6;
|
|
715
|
+
const spacingBetweenLabelAndValue = 2;
|
|
716
|
+
while (textNode.getComputedTextLength() > availableWidth && currentLabelFontSize > minLabelFontSize) {
|
|
717
|
+
currentLabelFontSize--;
|
|
718
|
+
self.style("font-size", `${currentLabelFontSize}px`);
|
|
719
|
+
}
|
|
720
|
+
let prospectiveValueFontSize = Math.max(
|
|
721
|
+
minValueFontSize,
|
|
722
|
+
Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
|
|
723
|
+
);
|
|
724
|
+
let combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
|
|
725
|
+
while (combinedHeight > availableHeight && currentLabelFontSize > minLabelFontSize) {
|
|
726
|
+
currentLabelFontSize--;
|
|
727
|
+
prospectiveValueFontSize = Math.max(
|
|
728
|
+
minValueFontSize,
|
|
729
|
+
Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
|
|
730
|
+
);
|
|
731
|
+
if (prospectiveValueFontSize < minValueFontSize && currentLabelFontSize === minLabelFontSize) {
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
self.style("font-size", `${currentLabelFontSize}px`);
|
|
735
|
+
combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
|
|
736
|
+
}
|
|
737
|
+
self.style("font-size", `${currentLabelFontSize}px`);
|
|
738
|
+
if (textNode.getComputedTextLength() > availableWidth || currentLabelFontSize < minLabelFontSize || availableHeight < currentLabelFontSize) {
|
|
739
|
+
self.style("display", "none");
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
if (config.showValues !== false) {
|
|
743
|
+
const leafValues = cell.append("text").attr("class", "treemapValue").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", function(d) {
|
|
744
|
+
return (d.y1 - d.y0) / 2;
|
|
745
|
+
}).attr("style", (d) => {
|
|
746
|
+
const labelStyles = "text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:" + colorScaleLabel(d.data.name) + ";";
|
|
747
|
+
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
|
748
|
+
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
|
749
|
+
}).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.value ? valueFormat(d.value) : "");
|
|
750
|
+
leafValues.each(function(d) {
|
|
751
|
+
const valueTextElement = select(this);
|
|
752
|
+
const parentCellNode = this.parentNode;
|
|
753
|
+
if (!parentCellNode) {
|
|
754
|
+
valueTextElement.style("display", "none");
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
const labelElement = select(parentCellNode).select(".treemapLabel");
|
|
758
|
+
if (labelElement.empty() || labelElement.style("display") === "none") {
|
|
759
|
+
valueTextElement.style("display", "none");
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const finalLabelFontSize = parseFloat(labelElement.style("font-size"));
|
|
763
|
+
const originalValueFontSize = 28;
|
|
764
|
+
const valueScaleFactor = 0.6;
|
|
765
|
+
const minValueFontSize = 6;
|
|
766
|
+
const spacingBetweenLabelAndValue = 2;
|
|
767
|
+
const actualValueFontSize = Math.max(
|
|
768
|
+
minValueFontSize,
|
|
769
|
+
Math.min(originalValueFontSize, Math.round(finalLabelFontSize * valueScaleFactor))
|
|
770
|
+
);
|
|
771
|
+
valueTextElement.style("font-size", `${actualValueFontSize}px`);
|
|
772
|
+
const labelCenterY = (d.y1 - d.y0) / 2;
|
|
773
|
+
const valueTopActualY = labelCenterY + finalLabelFontSize / 2 + spacingBetweenLabelAndValue;
|
|
774
|
+
valueTextElement.attr("y", valueTopActualY);
|
|
775
|
+
const nodeWidth = d.x1 - d.x0;
|
|
776
|
+
const nodeTotalHeight = d.y1 - d.y0;
|
|
777
|
+
const cellBottomPadding = 4;
|
|
778
|
+
const maxValueBottomY = nodeTotalHeight - cellBottomPadding;
|
|
779
|
+
const availableWidthForValue = nodeWidth - 2 * 4;
|
|
780
|
+
if (valueTextElement.node().getComputedTextLength() > availableWidthForValue || valueTopActualY + actualValueFontSize > maxValueBottomY || actualValueFontSize < minValueFontSize) {
|
|
781
|
+
valueTextElement.style("display", "none");
|
|
782
|
+
} else {
|
|
783
|
+
valueTextElement.style("display", null);
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
const diagramPadding = config.diagramPadding ?? 8;
|
|
788
|
+
setupViewPortForSVG(svg, diagramPadding, "flowchart", config?.useMaxWidth || false);
|
|
789
|
+
}, "draw");
|
|
790
|
+
var getClasses = /* @__PURE__ */ __name(function(_text, diagramObj) {
|
|
791
|
+
return diagramObj.db.getClasses();
|
|
792
|
+
}, "getClasses");
|
|
793
|
+
var renderer = { draw, getClasses };
|
|
794
|
+
var defaultTreemapStyleOptions = {
|
|
795
|
+
sectionStrokeColor: "black",
|
|
796
|
+
sectionStrokeWidth: "1",
|
|
797
|
+
sectionFillColor: "#efefef",
|
|
798
|
+
leafStrokeColor: "black",
|
|
799
|
+
leafStrokeWidth: "1",
|
|
800
|
+
leafFillColor: "#efefef",
|
|
801
|
+
labelFontSize: "12px",
|
|
802
|
+
valueFontSize: "10px",
|
|
803
|
+
titleFontSize: "14px"
|
|
804
|
+
};
|
|
805
|
+
var getStyles = /* @__PURE__ */ __name(({
|
|
806
|
+
treemap: treemap2
|
|
807
|
+
} = {}) => {
|
|
808
|
+
const defaultThemeVariables = getThemeVariables3();
|
|
809
|
+
const currentConfig = getConfig();
|
|
810
|
+
const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
|
|
811
|
+
const options = cleanAndMerge(defaultTreemapStyleOptions, treemap2);
|
|
812
|
+
const titleColor = options.titleColor ?? themeVariables.titleColor;
|
|
813
|
+
const labelColor = options.labelColor ?? themeVariables.textColor;
|
|
814
|
+
const valueColor = options.valueColor ?? themeVariables.textColor;
|
|
815
|
+
return `
|
|
816
|
+
.treemapNode.section {
|
|
817
|
+
stroke: ${options.sectionStrokeColor};
|
|
818
|
+
stroke-width: ${options.sectionStrokeWidth};
|
|
819
|
+
fill: ${options.sectionFillColor};
|
|
820
|
+
}
|
|
821
|
+
.treemapNode.leaf {
|
|
822
|
+
stroke: ${options.leafStrokeColor};
|
|
823
|
+
stroke-width: ${options.leafStrokeWidth};
|
|
824
|
+
fill: ${options.leafFillColor};
|
|
825
|
+
}
|
|
826
|
+
.treemapLabel {
|
|
827
|
+
fill: ${labelColor};
|
|
828
|
+
font-size: ${options.labelFontSize};
|
|
829
|
+
}
|
|
830
|
+
.treemapValue {
|
|
831
|
+
fill: ${valueColor};
|
|
832
|
+
font-size: ${options.valueFontSize};
|
|
833
|
+
}
|
|
834
|
+
.treemapTitle {
|
|
835
|
+
fill: ${titleColor};
|
|
836
|
+
font-size: ${options.titleFontSize};
|
|
837
|
+
}
|
|
838
|
+
`;
|
|
839
|
+
}, "getStyles");
|
|
840
|
+
var styles_default = getStyles;
|
|
841
|
+
var diagram = {
|
|
842
|
+
parser,
|
|
843
|
+
get db() {
|
|
844
|
+
return new TreeMapDB();
|
|
845
|
+
},
|
|
846
|
+
renderer,
|
|
847
|
+
styles: styles_default
|
|
848
|
+
};
|
|
849
|
+
export {
|
|
850
|
+
diagram
|
|
851
|
+
};
|