@webskill/sdk 0.20.0 → 0.22.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/dist/abnfDiagram-O67JEVCF-DtYFjfqO.js +109 -0
- package/dist/agent.d.ts +3 -3
- package/dist/agent.js +1171 -73
- package/dist/{approval-Bbh_Apwg.js → approval-DWQlDPbY.js} +527 -29
- package/dist/arc-8U_6NQWm.js +130 -0
- package/dist/architecture-7GRP2DOG-RTw1wpAq.js +4 -0
- package/dist/architectureDiagram-NJMV4G6O-XmmXrJAK.js +7473 -0
- package/dist/array-DQfpQNY8.js +8 -0
- package/dist/blockDiagram-BEXU5L5S-D4yjnCD1.js +2582 -0
- package/dist/browser.d.ts +1129 -48
- package/dist/browser.js +3562 -278
- package/dist/c4Diagram-YGBWAQC7-BLmA_JSd.js +3668 -0
- package/dist/channel-CZxxLrG7.js +9 -0
- package/dist/chunk-2Q5K7J3B-Ck03gkFR.js +21 -0
- package/dist/chunk-3FUC2YCW-tr6jmbQf.js +530 -0
- package/dist/chunk-5DYCD2WN-Bt97YGTd.js +58 -0
- package/dist/chunk-5VM5RSS4-BBxa48HL.js +21 -0
- package/dist/chunk-6AEJRKK7-JXK89I-O.js +14 -0
- package/dist/chunk-742MDFTN-CPmgCGwC.js +466 -0
- package/dist/chunk-7INBJB4K-C9jq9o66.js +6552 -0
- package/dist/chunk-7M6MHVWA-BrKCWcR1.js +4894 -0
- package/dist/chunk-7PRAP22T-BHED6GVs.js +95 -0
- package/dist/chunk-DUW6YSOI-DoZj78PO.js +19 -0
- package/dist/chunk-FOHPRMQF-Dkbp819z.js +27189 -0
- package/dist/chunk-GNY47TPC-Bpvq1T49.js +87 -0
- package/dist/chunk-GTNCS2PH-CLmh4I2c.js +686 -0
- package/dist/chunk-GWA4HPMP-B6vN3fkL.js +95 -0
- package/dist/chunk-J5ZVWO5B-Bi_Pcobw.js +26 -0
- package/dist/chunk-JWPE2WC7-D1rC79GS.js +12 -0
- package/dist/chunk-LNGE3PJU-D5OIoe3Z.js +2582 -0
- package/dist/chunk-MBY4JIJT-C34L7a4f.js +2276 -0
- package/dist/chunk-NETBCI7D-Cg84k8N8.js +321 -0
- package/dist/chunk-O7XYJQB3-B6K0KOSL.js +8846 -0
- package/dist/chunk-UA2S7LBM-DxHM29_K.js +612 -0
- package/dist/chunk-WEXAMYUT-Ba6jFWhB.js +33 -0
- package/dist/chunk-XXDRQBXY-DPbSy4kg.js +12 -0
- package/dist/chunk-Y2CYZVJY-U3QOMqrW.js +15 -0
- package/dist/chunk-Z7XXMR3K-oLg1h8F3.js +1038 -0
- package/dist/chunk-ZIGJFQKS-DqEFBuHR.js +2215 -0
- package/dist/classDiagram-v2-NBCMYWYE-BqnOWIUt.js +3845 -0
- package/dist/cose-bilkent-JH36ORCC-C0dTAHVK.js +4270 -0
- package/dist/cynefin-OW5HDTMX-B2QvgEQj.js +4 -0
- package/dist/cynefinDiagram-VND7K2PF-yAWc6Z3W.js +479 -0
- package/dist/cytoscape.esm-C64mRh9B.js +28325 -0
- package/dist/dagre-6A5THRUB-D0w2W27v.js +4816 -0
- package/dist/defaultLocale-B_EoOkSF.js +249 -0
- package/dist/diagram-22UHCM2B-DvgzhUzP.js +6115 -0
- package/dist/diagram-3UASUU5V-DWgUB-ef.js +795 -0
- package/dist/diagram-ATOU4E4O-P1olqwIs.js +553 -0
- package/dist/diagram-CDSNMT55-BUlZuLUe.js +402 -0
- package/dist/diagram-MLGK6HIB-6w5qmkGt.js +186 -0
- package/dist/diagram-MPIPVDR6-DEFiSo8o.js +289 -0
- package/dist/dist-UajCDt3n.js +92 -0
- package/dist/ebnfDiagram-ZINNZB2B-CI8liCfR.js +123 -0
- package/dist/elk-276RUBZZ-3SvW6OAK.js +90034 -0
- package/dist/erDiagram-OPXOYQCR-CPTbKhwP.js +2301 -0
- package/dist/{eventTypes-CwciaqCU.js → eventTypes-DcTQXSV1.js} +7 -1
- package/dist/eventmodeling-NTZA5JFV-BlyuqGp0.js +4 -0
- package/dist/flowDiagram-KWPJA3E3-CcUJ6HbV.js +18 -0
- package/dist/ganttDiagram-FUAMR5RP-31UjY0KK.js +3939 -0
- package/dist/geometry-wx5ZTYzi.js +715 -0
- package/dist/gitGraph-4MIJSDKK-ChdVlrk7.js +4 -0
- package/dist/gitGraphDiagram-X574FWY7-DKuxJymB.js +1153 -0
- package/dist/governance.d.ts +9 -3
- package/dist/governance.js +1 -1
- package/dist/graphlib-tk9gQYuN.js +4194 -0
- package/dist/{index-ad11wflI.d.ts → index-BiO9_XRk.d.ts} +2 -2
- package/dist/{index-DQ3-6GFu.d.ts → index-CjwdZQOS.d.ts} +945 -8
- package/dist/{index-BDyXe-a5.d.ts → index-YPd8ZSEa.d.ts} +413 -7
- package/dist/index.d.ts +4 -4
- package/dist/index.js +47 -41
- package/dist/info-A6RAGUB7-CxRAt9S9.js +4 -0
- package/dist/infoDiagram-VRGFBTTK-pRspGfjZ.js +25 -0
- package/dist/init-CMOIWdg-.js +16 -0
- package/dist/ishikawaDiagram-OU5B5YK6-DKerAPAg.js +975 -0
- package/dist/journeyDiagram-ZHPQQLJL-C4MK-YO5.js +1227 -0
- package/dist/kanban-definition-PNTS6WVX-BqsZpMXx.js +1244 -0
- package/dist/katex-BcRRvyh_.js +26465 -0
- package/dist/kind-Dc8x0HWz.js +110 -0
- package/dist/line-LgV8iVMV.js +48 -0
- package/dist/linear-BWKR0Tqd.js +393 -0
- package/dist/linkedDocument-CIuh_Yp0.js +416 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/{memoryArtifactStore-D6dLeY55.js → memoryArtifactStore-Bs7glPqm.js} +14 -0
- package/dist/mermaid-parser.core-pYR5siSx.js +754 -0
- package/dist/mermaid.core-DMtwGCHy.js +1756 -0
- package/dist/mindmap-definition-NLK3R4M7-CXbD-myG.js +1312 -0
- package/dist/node.d.ts +8 -3
- package/dist/node.js +79 -4
- package/dist/{openUiLibrary-b0i7F_oZ.js → openUiLibrary-B7j3rLrm.js} +1 -1
- package/dist/{openUiSpecLang-CLXJEeRU.js → openUiSpecLang-BSYYnjay.js} +1 -1
- package/dist/ordinal-CxA6GHQS.js +84 -0
- package/dist/packet-AYTQ26CC-BOm08cxl.js +4 -0
- package/dist/path-C27Z2Bjv.js +106 -0
- package/dist/pegDiagram-GJSIUBJH-BLGJOewQ.js +115 -0
- package/dist/pie-WAS4IAKB-Dvg7glpk.js +4 -0
- package/dist/pieDiagram-5QR66LMP-laoaV_PB.js +298 -0
- package/dist/processSandboxEntry.js +5 -0
- package/dist/quadrantDiagram-O4NWA36T-Db_wFBkT.js +2236 -0
- package/dist/radar-RG4KPBEZ-BZDaTu06.js +4 -0
- package/dist/railroad-74A4TZTK-C-UhjkOy.js +4 -0
- package/dist/railroad-abnf-HS5TGJTU-dUKVA4OS.js +4 -0
- package/dist/railroad-ebnf-LZEXJU2U-DzQumk18.js +4 -0
- package/dist/railroad-peg-WCYAUIDC-B3vvTWed.js +4 -0
- package/dist/railroadDiagram-XR7U4H2S-BY0sTM4X.js +89 -0
- package/dist/requirementDiagram-PLB6GJNP-3rkQfEhs.js +2474 -0
- package/dist/rough.cjs-AmDd_NQk.js +1395 -0
- package/dist/sandboxWorkerEntry.js +5 -0
- package/dist/sankeyDiagram-IPEJSGJF-CGAJhyG2.js +3578 -0
- package/dist/sequenceDiagram-PO4LG4MO-9FJjFX06.js +5522 -0
- package/dist/sizeCapture-INFHLROL-D8PWxdOn.js +56 -0
- package/dist/{skillVersionStore-B24Jjjry-v2CCU0Xo.d.ts → skillVersionStore-B24Jjjry-BY1H7Krp.d.ts} +1 -1
- package/dist/src-NkhI3UMl.js +2653 -0
- package/dist/stateDiagram-v2-GCMORJYK-B0O3wc1-.js +2715 -0
- package/dist/swimlanes-2SLR337P-D4EOnrpu.js +6637 -0
- package/dist/swimlanesDiagram-TC7HE7FX-BUx29EJ9.js +30 -0
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +1 -1
- package/dist/timeline-definition-EJHVYXUP-CrgiiB4C.js +1513 -0
- package/dist/treeView-Q6P3EWNA-C1by-Gzc.js +4 -0
- package/dist/treemap-WGGIJYW6-mC2NZ6ad.js +4 -0
- package/dist/{types-Btpdd1y--BcxQ10Fa.d.ts → types-CpDRZ0rA-BM5FI9oN.d.ts} +111 -9
- package/dist/ui-react.d.ts +3 -3
- package/dist/ui-react.js +3718 -77
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +2 -2
- package/dist/untrustedText-BIaRvPZK.js +16 -0
- package/dist/usecaseDiagram-POWQR4AR-BUt_TQOY.js +14397 -0
- package/dist/vennDiagram-UO4OBE2U-CwXr0wjA.js +2808 -0
- package/dist/wardley-WFR3VGLG-CVSYjq_S.js +4 -0
- package/dist/wardleyDiagram-VNRHLVJA-Cpfd47dQ.js +874 -0
- package/dist/{webSkillApi-CsvA69qk.js → webSkillApi-Dy-Zjv0y.js} +1 -1
- package/dist/{webskillLitCatalog-W06npwej.js → webskillLitCatalog-D5BCiMCU.js} +1 -1
- package/dist/xychartDiagram-PMCCYNJV-e1TeVoc6.js +2704 -0
- package/package.json +6 -5
- package/dist/kind-DxgS8LM-.js +0 -77
- package/dist/linkedDocument-xNXF-z8n.js +0 -94
- package/dist/types-DOJI5YC3.js +0 -90
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { n as parse } from "./mermaid-parser.core-pYR5siSx.js";
|
|
2
|
+
import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
|
|
3
|
+
import { m as log } from "./src-NkhI3UMl.js";
|
|
4
|
+
import { H as setAccDescription, U as setAccTitle, a as clear, c as configureSvgSize, f as defaultConfig_default, q as setDiagramTitle, v as getAccDescription, w as getDiagramTitle, x as getConfig2, y as getAccTitle } from "./chunk-O7XYJQB3-B6K0KOSL.js";
|
|
5
|
+
import { t as ordinal } from "./ordinal-CxA6GHQS.js";
|
|
6
|
+
import { n as constant_default } from "./path-C27Z2Bjv.js";
|
|
7
|
+
import { m as tau } from "./dist-UajCDt3n.js";
|
|
8
|
+
import { t as arc_default } from "./arc-8U_6NQWm.js";
|
|
9
|
+
import { t as array_default } from "./array-DQfpQNY8.js";
|
|
10
|
+
import { i as cleanAndMerge, p as parseFontSize } from "./chunk-ZIGJFQKS-DqEFBuHR.js";
|
|
11
|
+
import { t as selectSvgElement } from "./chunk-6AEJRKK7-JXK89I-O.js";
|
|
12
|
+
import { t as populateCommonDb } from "./chunk-JWPE2WC7-D1rC79GS.js";
|
|
13
|
+
|
|
14
|
+
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/descending.js
|
|
15
|
+
function descending_default(a, b) {
|
|
16
|
+
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/identity.js
|
|
21
|
+
function identity_default(d) {
|
|
22
|
+
return d;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/pie.js
|
|
27
|
+
function pie_default() {
|
|
28
|
+
var value = identity_default, sortValues = descending_default, sort = null, startAngle = constant_default(0), endAngle = constant_default(tau), padAngle = constant_default(0);
|
|
29
|
+
function pie(data) {
|
|
30
|
+
var i, n = (data = array_default(data)).length, j, k, sum = 0, index = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), a1, p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), pa = p * (da < 0 ? -1 : 1), v;
|
|
31
|
+
for (i = 0; i < n; ++i) if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) sum += v;
|
|
32
|
+
if (sortValues != null) index.sort(function(i, j) {
|
|
33
|
+
return sortValues(arcs[i], arcs[j]);
|
|
34
|
+
});
|
|
35
|
+
else if (sort != null) index.sort(function(i, j) {
|
|
36
|
+
return sort(data[i], data[j]);
|
|
37
|
+
});
|
|
38
|
+
for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
|
|
39
|
+
data: data[j],
|
|
40
|
+
index: i,
|
|
41
|
+
value: v,
|
|
42
|
+
startAngle: a0,
|
|
43
|
+
endAngle: a1,
|
|
44
|
+
padAngle: p
|
|
45
|
+
};
|
|
46
|
+
return arcs;
|
|
47
|
+
}
|
|
48
|
+
pie.value = function(_) {
|
|
49
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant_default(+_), pie) : value;
|
|
50
|
+
};
|
|
51
|
+
pie.sortValues = function(_) {
|
|
52
|
+
return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
|
|
53
|
+
};
|
|
54
|
+
pie.sort = function(_) {
|
|
55
|
+
return arguments.length ? (sort = _, sortValues = null, pie) : sort;
|
|
56
|
+
};
|
|
57
|
+
pie.startAngle = function(_) {
|
|
58
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant_default(+_), pie) : startAngle;
|
|
59
|
+
};
|
|
60
|
+
pie.endAngle = function(_) {
|
|
61
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant_default(+_), pie) : endAngle;
|
|
62
|
+
};
|
|
63
|
+
pie.padAngle = function(_) {
|
|
64
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant_default(+_), pie) : padAngle;
|
|
65
|
+
};
|
|
66
|
+
return pie;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/pieDiagram-5QR66LMP.mjs
|
|
71
|
+
var DEFAULT_PIE_CONFIG = defaultConfig_default.pie;
|
|
72
|
+
var DEFAULT_PIE_DB = {
|
|
73
|
+
sections: /* @__PURE__ */ new Map(),
|
|
74
|
+
showData: false,
|
|
75
|
+
config: DEFAULT_PIE_CONFIG
|
|
76
|
+
};
|
|
77
|
+
var sections = DEFAULT_PIE_DB.sections;
|
|
78
|
+
var showData = DEFAULT_PIE_DB.showData;
|
|
79
|
+
var config = structuredClone(DEFAULT_PIE_CONFIG);
|
|
80
|
+
var db = {
|
|
81
|
+
getConfig: /* @__PURE__ */ __name(() => structuredClone(config), "getConfig"),
|
|
82
|
+
clear: /* @__PURE__ */ __name(() => {
|
|
83
|
+
sections = /* @__PURE__ */ new Map();
|
|
84
|
+
showData = DEFAULT_PIE_DB.showData;
|
|
85
|
+
clear();
|
|
86
|
+
}, "clear"),
|
|
87
|
+
setDiagramTitle,
|
|
88
|
+
getDiagramTitle,
|
|
89
|
+
setAccTitle,
|
|
90
|
+
getAccTitle,
|
|
91
|
+
setAccDescription,
|
|
92
|
+
getAccDescription,
|
|
93
|
+
addSection: /* @__PURE__ */ __name(({ label, value }) => {
|
|
94
|
+
if (value < 0) throw new Error(`"${label}" has invalid value: ${value}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);
|
|
95
|
+
if (!sections.has(label)) {
|
|
96
|
+
sections.set(label, value);
|
|
97
|
+
log.debug(`added new section: ${label}, with value: ${value}`);
|
|
98
|
+
}
|
|
99
|
+
}, "addSection"),
|
|
100
|
+
getSections: /* @__PURE__ */ __name(() => sections, "getSections"),
|
|
101
|
+
setShowData: /* @__PURE__ */ __name((toggle) => {
|
|
102
|
+
showData = toggle;
|
|
103
|
+
}, "setShowData"),
|
|
104
|
+
getShowData: /* @__PURE__ */ __name(() => showData, "getShowData")
|
|
105
|
+
};
|
|
106
|
+
var populateDb = /* @__PURE__ */ __name((ast, db2) => {
|
|
107
|
+
populateCommonDb(ast, db2);
|
|
108
|
+
db2.setShowData(ast.showData);
|
|
109
|
+
ast.sections.map(db2.addSection);
|
|
110
|
+
}, "populateDb");
|
|
111
|
+
var parser = { parse: /* @__PURE__ */ __name(async (input) => {
|
|
112
|
+
const ast = await parse("pie", input);
|
|
113
|
+
log.debug(ast);
|
|
114
|
+
populateDb(ast, db);
|
|
115
|
+
}, "parse") };
|
|
116
|
+
var pieStyles_default = /* @__PURE__ */ __name((options) => `
|
|
117
|
+
.pieCircle{
|
|
118
|
+
stroke: ${options.pieStrokeColor};
|
|
119
|
+
stroke-width : ${options.pieStrokeWidth};
|
|
120
|
+
opacity : ${options.pieOpacity};
|
|
121
|
+
}
|
|
122
|
+
.pieCircle.highlighted{
|
|
123
|
+
scale: 1.05;
|
|
124
|
+
opacity: 1;
|
|
125
|
+
}
|
|
126
|
+
.pieCircle.highlightedOnHover:hover{
|
|
127
|
+
transition-duration: 250ms;
|
|
128
|
+
scale: 1.05;
|
|
129
|
+
opacity: 1;
|
|
130
|
+
}
|
|
131
|
+
.pieOuterCircle{
|
|
132
|
+
stroke: ${options.pieOuterStrokeColor};
|
|
133
|
+
stroke-width: ${options.pieOuterStrokeWidth};
|
|
134
|
+
fill: none;
|
|
135
|
+
}
|
|
136
|
+
.pieTitleText {
|
|
137
|
+
text-anchor: middle;
|
|
138
|
+
font-size: ${options.pieTitleTextSize};
|
|
139
|
+
fill: ${options.pieTitleTextColor};
|
|
140
|
+
font-family: ${options.fontFamily};
|
|
141
|
+
}
|
|
142
|
+
.slice {
|
|
143
|
+
font-family: ${options.fontFamily};
|
|
144
|
+
fill: ${options.pieSectionTextColor};
|
|
145
|
+
font-size:${options.pieSectionTextSize};
|
|
146
|
+
// fill: white;
|
|
147
|
+
}
|
|
148
|
+
.legend text {
|
|
149
|
+
fill: ${options.pieLegendTextColor};
|
|
150
|
+
font-family: ${options.fontFamily};
|
|
151
|
+
font-size: ${options.pieLegendTextSize};
|
|
152
|
+
}
|
|
153
|
+
`, "getStyles");
|
|
154
|
+
var createPieArcs = /* @__PURE__ */ __name((sections2) => {
|
|
155
|
+
const sum = [...sections2.values()].reduce((acc, val) => acc + val, 0);
|
|
156
|
+
const pieData = [...sections2.entries()].map(([label, value]) => ({
|
|
157
|
+
label,
|
|
158
|
+
value
|
|
159
|
+
})).filter((d) => d.value / sum * 100 >= 1);
|
|
160
|
+
return pie_default().value((d) => d.value).sort(null)(pieData);
|
|
161
|
+
}, "createPieArcs");
|
|
162
|
+
var diagram = {
|
|
163
|
+
parser,
|
|
164
|
+
db,
|
|
165
|
+
renderer: { draw: /* @__PURE__ */ __name((text, id, _version, diagObj) => {
|
|
166
|
+
log.debug("rendering pie chart\n" + text);
|
|
167
|
+
const db2 = diagObj.db;
|
|
168
|
+
const globalConfig = getConfig2();
|
|
169
|
+
const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie);
|
|
170
|
+
const MARGIN = 40;
|
|
171
|
+
const LEGEND_RECT_SIZE = 18;
|
|
172
|
+
const LEGEND_SPACING = 4;
|
|
173
|
+
const height = 450;
|
|
174
|
+
const pieWidth = height;
|
|
175
|
+
const svg = selectSvgElement(id);
|
|
176
|
+
const group = svg.append("g");
|
|
177
|
+
group.attr("transform", "translate(225,225)");
|
|
178
|
+
const { themeVariables } = globalConfig;
|
|
179
|
+
let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
|
|
180
|
+
outerStrokeWidth ??= 2;
|
|
181
|
+
const legendPosition = pieConfig.legendPosition;
|
|
182
|
+
const textPosition = pieConfig.textPosition;
|
|
183
|
+
const innerHole = pieConfig.donutHole > 0 && pieConfig.donutHole <= .9 ? pieConfig.donutHole : 0;
|
|
184
|
+
const radius = Math.min(pieWidth, height) / 2 - MARGIN;
|
|
185
|
+
const arcGenerator = arc_default().innerRadius(innerHole * radius).outerRadius(radius);
|
|
186
|
+
const labelArcGenerator = arc_default().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
|
|
187
|
+
const pie = group.append("g");
|
|
188
|
+
pie.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
|
|
189
|
+
const sections2 = db2.getSections();
|
|
190
|
+
const arcs = createPieArcs(sections2);
|
|
191
|
+
const myGeneratedColors = [
|
|
192
|
+
themeVariables.pie1,
|
|
193
|
+
themeVariables.pie2,
|
|
194
|
+
themeVariables.pie3,
|
|
195
|
+
themeVariables.pie4,
|
|
196
|
+
themeVariables.pie5,
|
|
197
|
+
themeVariables.pie6,
|
|
198
|
+
themeVariables.pie7,
|
|
199
|
+
themeVariables.pie8,
|
|
200
|
+
themeVariables.pie9,
|
|
201
|
+
themeVariables.pie10,
|
|
202
|
+
themeVariables.pie11,
|
|
203
|
+
themeVariables.pie12
|
|
204
|
+
];
|
|
205
|
+
let sum = 0;
|
|
206
|
+
sections2.forEach((section) => {
|
|
207
|
+
sum += section;
|
|
208
|
+
});
|
|
209
|
+
const filteredArcs = arcs.filter((datum) => (datum.data.value / sum * 100).toFixed(0) !== "0");
|
|
210
|
+
const color = ordinal(myGeneratedColors).domain([...sections2.keys()]);
|
|
211
|
+
pie.selectAll("mySlices").data(filteredArcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => {
|
|
212
|
+
return color(datum.data.label);
|
|
213
|
+
}).attr("class", (datum) => {
|
|
214
|
+
let className = "pieCircle";
|
|
215
|
+
if (pieConfig.highlightSlice === "hover") className += " highlightedOnHover";
|
|
216
|
+
else if (pieConfig.highlightSlice === datum.data.label) className += " highlighted";
|
|
217
|
+
return className;
|
|
218
|
+
});
|
|
219
|
+
pie.selectAll("mySlices").data(filteredArcs).enter().append("text").text((datum) => {
|
|
220
|
+
return (datum.data.value / sum * 100).toFixed(0) + "%";
|
|
221
|
+
}).attr("transform", (datum) => {
|
|
222
|
+
return "translate(" + labelArcGenerator.centroid(datum) + ")";
|
|
223
|
+
}).style("text-anchor", "middle").attr("class", "slice");
|
|
224
|
+
const titleText = group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -400 / 2).attr("class", "pieTitleText");
|
|
225
|
+
const allSectionData = [...sections2.entries()].map(([label, value]) => ({
|
|
226
|
+
label,
|
|
227
|
+
value
|
|
228
|
+
}));
|
|
229
|
+
const legend = group.selectAll(".legend").data(allSectionData).enter().append("g").attr("class", "legend");
|
|
230
|
+
legend.append("rect").attr("width", LEGEND_RECT_SIZE).attr("height", LEGEND_RECT_SIZE).style("fill", (d) => color(d.label)).style("stroke", (d) => color(d.label));
|
|
231
|
+
legend.append("text").attr("x", 22).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((d) => {
|
|
232
|
+
if (db2.getShowData()) return `${d.label} [${d.value}]`;
|
|
233
|
+
return d.label;
|
|
234
|
+
});
|
|
235
|
+
const longestTextWidth = Math.max(...legend.selectAll("text").nodes().map((node) => node?.getBoundingClientRect().width ?? 0));
|
|
236
|
+
let chartAndLegendHeight = height;
|
|
237
|
+
let chartAndLegendWidth = 490;
|
|
238
|
+
const legendHeight = 22;
|
|
239
|
+
const totalLegendHeight = allSectionData.length * legendHeight;
|
|
240
|
+
switch (legendPosition) {
|
|
241
|
+
case "center":
|
|
242
|
+
legend.attr("transform", (_datum, index) => {
|
|
243
|
+
const offset = legendHeight * allSectionData.length / 2;
|
|
244
|
+
const horizontal = -longestTextWidth / 2 - 22;
|
|
245
|
+
const vertical = index * legendHeight - offset;
|
|
246
|
+
return "translate(" + horizontal + "," + vertical + ")";
|
|
247
|
+
});
|
|
248
|
+
break;
|
|
249
|
+
case "top":
|
|
250
|
+
chartAndLegendHeight += totalLegendHeight;
|
|
251
|
+
legend.attr("transform", (_datum, index) => {
|
|
252
|
+
const offset = radius;
|
|
253
|
+
return `translate(${-longestTextWidth / 2 - 22}, ${index * legendHeight - offset})`;
|
|
254
|
+
});
|
|
255
|
+
pie.attr("transform", () => {
|
|
256
|
+
return `translate(0, ${totalLegendHeight + legendHeight})`;
|
|
257
|
+
});
|
|
258
|
+
break;
|
|
259
|
+
case "bottom":
|
|
260
|
+
chartAndLegendHeight += totalLegendHeight;
|
|
261
|
+
legend.attr("transform", (_datum, index) => {
|
|
262
|
+
const offset = -185 - legendHeight;
|
|
263
|
+
const horizontal = -longestTextWidth / 2 - 22;
|
|
264
|
+
const vertical = index * legendHeight - offset;
|
|
265
|
+
return "translate(" + horizontal + "," + vertical + ")";
|
|
266
|
+
});
|
|
267
|
+
break;
|
|
268
|
+
case "left":
|
|
269
|
+
chartAndLegendWidth += 22 + longestTextWidth;
|
|
270
|
+
legend.attr("transform", (_datum, index) => {
|
|
271
|
+
const offset = legendHeight * allSectionData.length / 2;
|
|
272
|
+
return "translate(-207," + (index * legendHeight - offset) + ")";
|
|
273
|
+
});
|
|
274
|
+
pie.attr("transform", () => {
|
|
275
|
+
return `translate(${longestTextWidth + LEGEND_RECT_SIZE + LEGEND_SPACING}, 0)`;
|
|
276
|
+
});
|
|
277
|
+
break;
|
|
278
|
+
default:
|
|
279
|
+
chartAndLegendWidth += 22 + longestTextWidth;
|
|
280
|
+
legend.attr("transform", (_datum, index) => {
|
|
281
|
+
const offset = legendHeight * allSectionData.length / 2;
|
|
282
|
+
return "translate(216," + (index * legendHeight - offset) + ")";
|
|
283
|
+
});
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
const titleWidth = titleText.node()?.getBoundingClientRect().width ?? 0;
|
|
287
|
+
const titleLeft = pieWidth / 2 - titleWidth / 2;
|
|
288
|
+
const titleRight = pieWidth / 2 + titleWidth / 2;
|
|
289
|
+
const viewBoxX = Math.min(0, titleLeft);
|
|
290
|
+
const totalWidth = Math.max(chartAndLegendWidth, titleRight) - viewBoxX;
|
|
291
|
+
svg.attr("viewBox", `${viewBoxX} 0 ${totalWidth} ${chartAndLegendHeight}`);
|
|
292
|
+
configureSvgSize(svg, chartAndLegendHeight, totalWidth, pieConfig.useMaxWidth);
|
|
293
|
+
}, "draw") },
|
|
294
|
+
styles: pieStyles_default
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
//#endregion
|
|
298
|
+
export { diagram };
|
|
@@ -178,6 +178,11 @@ async function main(task) {
|
|
|
178
178
|
metadata: options?.metadata
|
|
179
179
|
}),
|
|
180
180
|
confirm: (message) => callCapability("confirm", { message }),
|
|
181
|
+
...task.writeSpreadsheet ? { writeSpreadsheet: (path, spec, options) => callCapability("writeSpreadsheet", {
|
|
182
|
+
path,
|
|
183
|
+
spec,
|
|
184
|
+
metadata: options?.metadata
|
|
185
|
+
}) } : {},
|
|
181
186
|
...task.uploadFiles ? {
|
|
182
187
|
listUploadFiles: () => callCapability("listUploadFiles", {}),
|
|
183
188
|
readUploadFile: async (fileId) => new Uint8Array(await callCapability("readUploadFile", { fileId }))
|