@infinilabs/ai-chat 0.0.0 → 0.0.2
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/README.md +310 -56
- package/dist/_baseUniq-BFn6cCm9.js +152 -0
- package/dist/_baseUniq-nfJyj2zU.cjs +151 -0
- package/dist/arc-BWSMkwk2.cjs +130 -0
- package/dist/arc-DODeX7B9.js +131 -0
- package/dist/architecture-U656AL7Q-B4C0nw6C.js +5 -0
- package/dist/architecture-U656AL7Q-CVURQXwt.cjs +5 -0
- package/dist/architectureDiagram-VXUJARFQ-2UbdzpNz.cjs +8681 -0
- package/dist/architectureDiagram-VXUJARFQ-NCVmzKuE.js +8681 -0
- package/dist/blockDiagram-VD42YOAC-B3yCPK1N.cjs +3606 -0
- package/dist/blockDiagram-VD42YOAC-C4FsmQfk.js +3606 -0
- package/dist/c4Diagram-YG6GDRKO-ATyoKzFV.js +2481 -0
- package/dist/c4Diagram-YG6GDRKO-COwVcHWj.cjs +2481 -0
- package/dist/channel-2Y73gsu9.cjs +6 -0
- package/dist/channel-oB8MffQV.js +7 -0
- package/dist/chunk-4BX2VUAB-C3diNHZw.cjs +15 -0
- package/dist/chunk-4BX2VUAB-sd2zFBFz.js +16 -0
- package/dist/chunk-55IACEB6-6ohTnYE3.js +13 -0
- package/dist/chunk-55IACEB6-T-CzlJke.cjs +12 -0
- package/dist/chunk-B4BG7PRW-B1zqG62l.cjs +1825 -0
- package/dist/chunk-B4BG7PRW-E1dti26Y.js +1826 -0
- package/dist/chunk-DI55MBZ5-Dk0kfYBV.cjs +1914 -0
- package/dist/chunk-DI55MBZ5-DpHw-vMw.js +1915 -0
- package/dist/chunk-FMBD7UC4-B1vXpasq.js +19 -0
- package/dist/chunk-FMBD7UC4-CShN9-qf.cjs +18 -0
- package/dist/chunk-QN33PNHL-Cw7FG91D.js +24 -0
- package/dist/chunk-QN33PNHL-DJi1fhak.cjs +23 -0
- package/dist/chunk-QZHKN3VN-BweiBR9P.js +17 -0
- package/dist/chunk-QZHKN3VN-DfUW_gDw.cjs +16 -0
- package/dist/chunk-TZMSLE5B-DY2Kbag4.cjs +107 -0
- package/dist/chunk-TZMSLE5B-ZQ2Esoix.js +108 -0
- package/dist/classDiagram-2ON5EDUG-D2tIbkjc.js +19 -0
- package/dist/classDiagram-2ON5EDUG-DRhRmkUb.cjs +19 -0
- package/dist/classDiagram-v2-WZHVMYZB-D2tIbkjc.js +19 -0
- package/dist/classDiagram-v2-WZHVMYZB-DRhRmkUb.cjs +19 -0
- package/dist/clone-BMkj3yun.cjs +7 -0
- package/dist/clone-ChHXIoR6.js +8 -0
- package/dist/cose-bilkent-S5V4N54A-BXnWH5Od.cjs +4942 -0
- package/dist/cose-bilkent-S5V4N54A-D15BmpCb.js +4942 -0
- package/dist/cytoscape.esm-BfvZ3QT_.js +30239 -0
- package/dist/cytoscape.esm-D8IBYQeQ.cjs +30238 -0
- package/dist/dagre-6UL2VRFP-DGQ6TW_g.cjs +693 -0
- package/dist/dagre-6UL2VRFP-WmhUYWg8.js +693 -0
- package/dist/defaultLocale-DVr69WTU.js +206 -0
- package/dist/defaultLocale-DwYGIg9G.cjs +203 -0
- package/dist/diagram-PSM6KHXK-DSfHBoUT.js +845 -0
- package/dist/diagram-PSM6KHXK-J4qyGeN7.cjs +845 -0
- package/dist/diagram-QEK2KX5R-D96wT5cH.cjs +300 -0
- package/dist/diagram-QEK2KX5R-I_nyexpY.js +300 -0
- package/dist/diagram-S2PKOQOG-BC_WyKEe.cjs +210 -0
- package/dist/diagram-S2PKOQOG-aooXSMNo.js +210 -0
- package/dist/erDiagram-Q2GNP2WA-DQ8Lquay.cjs +1158 -0
- package/dist/erDiagram-Q2GNP2WA-DWF8e6EL.js +1158 -0
- package/dist/flowDiagram-NV44I4VS-CM9c4F1o.js +2331 -0
- package/dist/flowDiagram-NV44I4VS-DpYNkyM2.cjs +2331 -0
- package/dist/ganttDiagram-JELNMOA3-CAsoD6rZ.js +3679 -0
- package/dist/ganttDiagram-JELNMOA3-DfKahpj4.cjs +3679 -0
- package/dist/gitGraph-F6HP7TQM-BX2fz4_i.js +5 -0
- package/dist/gitGraph-F6HP7TQM-DRkGg4T1.cjs +5 -0
- package/dist/gitGraphDiagram-NY62KEGX-PXpI94u6.js +1203 -0
- package/dist/gitGraphDiagram-NY62KEGX-YhnKpooH.cjs +1203 -0
- package/dist/graph-BvxpI7Xc.js +596 -0
- package/dist/graph-CI_TWBSn.cjs +595 -0
- package/dist/index-BctLGjTK.cjs +120500 -0
- package/dist/index-CjSgoo1P.js +120485 -0
- package/dist/index.cjs +19 -0
- package/dist/index.js +12 -19961
- package/dist/info-NVLQJR56-BGbTE7dw.cjs +5 -0
- package/dist/info-NVLQJR56-DRxIh-N8.js +5 -0
- package/dist/infoDiagram-WHAUD3N6-BB2Bnbnh.cjs +31 -0
- package/dist/infoDiagram-WHAUD3N6-D_RrgwxS.js +31 -0
- package/dist/init-DevvdK2U.cjs +15 -0
- package/dist/init-ZxktEp_H.js +16 -0
- package/dist/journeyDiagram-XKPGCS4Q-BJjXlMIj.js +1254 -0
- package/dist/journeyDiagram-XKPGCS4Q-BcBLsfI9.cjs +1254 -0
- package/dist/kanban-definition-3W4ZIXB7-0wwNBZ93.js +1047 -0
- package/dist/kanban-definition-3W4ZIXB7-CaY0q4j9.cjs +1047 -0
- package/dist/katex-BhpYeT3b.cjs +14523 -0
- package/dist/katex-ei8sH3Uy.js +14524 -0
- package/dist/layout-CcghncRv.js +2183 -0
- package/dist/layout-CvwzED_C.cjs +2182 -0
- package/dist/linear-CYow-mAK.cjs +339 -0
- package/dist/linear-D_gKQzVp.js +340 -0
- package/dist/mermaid-parser.core-CzmkR-3i.cjs +18703 -0
- package/dist/mermaid-parser.core-DCMDT-Cp.js +18704 -0
- package/dist/min-BBp7Smma.js +41 -0
- package/dist/min-Gu1I_bJ9.cjs +40 -0
- package/dist/mindmap-definition-VGOIOE7T-D16Pp1u5.cjs +1126 -0
- package/dist/mindmap-definition-VGOIOE7T-PjSLRtz4.js +1126 -0
- package/dist/ordinal-CxptdPJm.js +76 -0
- package/dist/ordinal-D7sQNqXZ.cjs +75 -0
- package/dist/packet-BFZMPI3H-BvdogPiS.js +5 -0
- package/dist/packet-BFZMPI3H-C7pOHUWY.cjs +5 -0
- package/dist/pie-7BOR55EZ-D-DxSHbP.cjs +5 -0
- package/dist/pie-7BOR55EZ-DEWJe4Xn.js +5 -0
- package/dist/pieDiagram-ADFJNKIX-CoDddKZl.js +237 -0
- package/dist/pieDiagram-ADFJNKIX-DjN4DU9l.cjs +237 -0
- package/dist/quadrantDiagram-AYHSOK5B-BZOg0JMm.js +1335 -0
- package/dist/quadrantDiagram-AYHSOK5B-DXjTSOL4.cjs +1335 -0
- package/dist/radar-NHE76QYJ-BrnDXy9q.cjs +5 -0
- package/dist/radar-NHE76QYJ-C2WmPmJ4.js +5 -0
- package/dist/requirementDiagram-UZGBJVZJ-CCW1O1xH.js +1161 -0
- package/dist/requirementDiagram-UZGBJVZJ-e5F3-dDI.cjs +1161 -0
- package/dist/sankeyDiagram-TZEHDZUN-BaGzCxTp.js +1193 -0
- package/dist/sankeyDiagram-TZEHDZUN-DtIvOvVI.cjs +1193 -0
- package/dist/sequenceDiagram-WL72ISMW-0vFhYnxn.cjs +3874 -0
- package/dist/sequenceDiagram-WL72ISMW-DL3B7U56.js +3874 -0
- package/dist/stateDiagram-FKZM4ZOC-CXW608BR.cjs +447 -0
- package/dist/stateDiagram-FKZM4ZOC-Ddw6HxPD.js +447 -0
- package/dist/stateDiagram-v2-4FDKWEC3-DZCkQKmp.js +19 -0
- package/dist/stateDiagram-v2-4FDKWEC3-DefWUbvq.cjs +19 -0
- package/dist/timeline-definition-IT6M3QCI-C3TfA9lE.cjs +1222 -0
- package/dist/timeline-definition-IT6M3QCI-DiS88lUo.js +1222 -0
- package/dist/treemap-KMMF4GRG-Bl-H6j2c.cjs +5 -0
- package/dist/treemap-KMMF4GRG-DGGr_R9A.js +5 -0
- package/dist/xychartDiagram-PRI3JC2R-BrOwRjfF.js +1886 -0
- package/dist/xychartDiagram-PRI3JC2R-CM06DttH.cjs +1886 -0
- package/package.json +22 -11
- package/dist/index.css +0 -1582
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const index = require("./index-BctLGjTK.cjs");
|
|
4
|
+
const chunk4BX2VUAB = require("./chunk-4BX2VUAB-C3diNHZw.cjs");
|
|
5
|
+
const mermaidParser_core = require("./mermaid-parser.core-CzmkR-3i.cjs");
|
|
6
|
+
var defaultOptions = {
|
|
7
|
+
showLegend: true,
|
|
8
|
+
ticks: 5,
|
|
9
|
+
max: null,
|
|
10
|
+
min: 0,
|
|
11
|
+
graticule: "circle"
|
|
12
|
+
};
|
|
13
|
+
var defaultRadarData = {
|
|
14
|
+
axes: [],
|
|
15
|
+
curves: [],
|
|
16
|
+
options: defaultOptions
|
|
17
|
+
};
|
|
18
|
+
var data = structuredClone(defaultRadarData);
|
|
19
|
+
var DEFAULT_RADAR_CONFIG = index.defaultConfig_default.radar;
|
|
20
|
+
var getConfig2 = /* @__PURE__ */ index.__name(() => {
|
|
21
|
+
const config = index.cleanAndMerge({
|
|
22
|
+
...DEFAULT_RADAR_CONFIG,
|
|
23
|
+
...index.getConfig().radar
|
|
24
|
+
});
|
|
25
|
+
return config;
|
|
26
|
+
}, "getConfig");
|
|
27
|
+
var getAxes = /* @__PURE__ */ index.__name(() => data.axes, "getAxes");
|
|
28
|
+
var getCurves = /* @__PURE__ */ index.__name(() => data.curves, "getCurves");
|
|
29
|
+
var getOptions = /* @__PURE__ */ index.__name(() => data.options, "getOptions");
|
|
30
|
+
var setAxes = /* @__PURE__ */ index.__name((axes) => {
|
|
31
|
+
data.axes = axes.map((axis) => {
|
|
32
|
+
return {
|
|
33
|
+
name: axis.name,
|
|
34
|
+
label: axis.label ?? axis.name
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}, "setAxes");
|
|
38
|
+
var setCurves = /* @__PURE__ */ index.__name((curves) => {
|
|
39
|
+
data.curves = curves.map((curve) => {
|
|
40
|
+
return {
|
|
41
|
+
name: curve.name,
|
|
42
|
+
label: curve.label ?? curve.name,
|
|
43
|
+
entries: computeCurveEntries(curve.entries)
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}, "setCurves");
|
|
47
|
+
var computeCurveEntries = /* @__PURE__ */ index.__name((entries) => {
|
|
48
|
+
if (entries[0].axis == void 0) {
|
|
49
|
+
return entries.map((entry) => entry.value);
|
|
50
|
+
}
|
|
51
|
+
const axes = getAxes();
|
|
52
|
+
if (axes.length === 0) {
|
|
53
|
+
throw new Error("Axes must be populated before curves for reference entries");
|
|
54
|
+
}
|
|
55
|
+
return axes.map((axis) => {
|
|
56
|
+
const entry = entries.find((entry2) => entry2.axis?.$refText === axis.name);
|
|
57
|
+
if (entry === void 0) {
|
|
58
|
+
throw new Error("Missing entry for axis " + axis.label);
|
|
59
|
+
}
|
|
60
|
+
return entry.value;
|
|
61
|
+
});
|
|
62
|
+
}, "computeCurveEntries");
|
|
63
|
+
var setOptions = /* @__PURE__ */ index.__name((options) => {
|
|
64
|
+
const optionMap = options.reduce(
|
|
65
|
+
(acc, option) => {
|
|
66
|
+
acc[option.name] = option;
|
|
67
|
+
return acc;
|
|
68
|
+
},
|
|
69
|
+
{}
|
|
70
|
+
);
|
|
71
|
+
data.options = {
|
|
72
|
+
showLegend: optionMap.showLegend?.value ?? defaultOptions.showLegend,
|
|
73
|
+
ticks: optionMap.ticks?.value ?? defaultOptions.ticks,
|
|
74
|
+
max: optionMap.max?.value ?? defaultOptions.max,
|
|
75
|
+
min: optionMap.min?.value ?? defaultOptions.min,
|
|
76
|
+
graticule: optionMap.graticule?.value ?? defaultOptions.graticule
|
|
77
|
+
};
|
|
78
|
+
}, "setOptions");
|
|
79
|
+
var clear2 = /* @__PURE__ */ index.__name(() => {
|
|
80
|
+
index.clear();
|
|
81
|
+
data = structuredClone(defaultRadarData);
|
|
82
|
+
}, "clear");
|
|
83
|
+
var db = {
|
|
84
|
+
getAxes,
|
|
85
|
+
getCurves,
|
|
86
|
+
getOptions,
|
|
87
|
+
setAxes,
|
|
88
|
+
setCurves,
|
|
89
|
+
setOptions,
|
|
90
|
+
getConfig: getConfig2,
|
|
91
|
+
clear: clear2,
|
|
92
|
+
setAccTitle: index.setAccTitle,
|
|
93
|
+
getAccTitle: index.getAccTitle,
|
|
94
|
+
setDiagramTitle: index.setDiagramTitle,
|
|
95
|
+
getDiagramTitle: index.getDiagramTitle,
|
|
96
|
+
getAccDescription: index.getAccDescription,
|
|
97
|
+
setAccDescription: index.setAccDescription
|
|
98
|
+
};
|
|
99
|
+
var populate = /* @__PURE__ */ index.__name((ast) => {
|
|
100
|
+
chunk4BX2VUAB.populateCommonDb(ast, db);
|
|
101
|
+
const { axes, curves, options } = ast;
|
|
102
|
+
db.setAxes(axes);
|
|
103
|
+
db.setCurves(curves);
|
|
104
|
+
db.setOptions(options);
|
|
105
|
+
}, "populate");
|
|
106
|
+
var parser = {
|
|
107
|
+
parse: /* @__PURE__ */ index.__name(async (input) => {
|
|
108
|
+
const ast = await mermaidParser_core.parse("radar", input);
|
|
109
|
+
index.log.debug(ast);
|
|
110
|
+
populate(ast);
|
|
111
|
+
}, "parse")
|
|
112
|
+
};
|
|
113
|
+
var draw = /* @__PURE__ */ index.__name((_text, id, _version, diagram2) => {
|
|
114
|
+
const db2 = diagram2.db;
|
|
115
|
+
const axes = db2.getAxes();
|
|
116
|
+
const curves = db2.getCurves();
|
|
117
|
+
const options = db2.getOptions();
|
|
118
|
+
const config = db2.getConfig();
|
|
119
|
+
const title = db2.getDiagramTitle();
|
|
120
|
+
const svg = index.selectSvgElement(id);
|
|
121
|
+
const g = drawFrame(svg, config);
|
|
122
|
+
const maxValue = options.max ?? Math.max(...curves.map((curve) => Math.max(...curve.entries)));
|
|
123
|
+
const minValue = options.min;
|
|
124
|
+
const radius = Math.min(config.width, config.height) / 2;
|
|
125
|
+
drawGraticule(g, axes, radius, options.ticks, options.graticule);
|
|
126
|
+
drawAxes(g, axes, radius, config);
|
|
127
|
+
drawCurves(g, axes, curves, minValue, maxValue, options.graticule, config);
|
|
128
|
+
drawLegend(g, curves, options.showLegend, config);
|
|
129
|
+
g.append("text").attr("class", "radarTitle").text(title).attr("x", 0).attr("y", -config.height / 2 - config.marginTop);
|
|
130
|
+
}, "draw");
|
|
131
|
+
var drawFrame = /* @__PURE__ */ index.__name((svg, config) => {
|
|
132
|
+
const totalWidth = config.width + config.marginLeft + config.marginRight;
|
|
133
|
+
const totalHeight = config.height + config.marginTop + config.marginBottom;
|
|
134
|
+
const center = {
|
|
135
|
+
x: config.marginLeft + config.width / 2,
|
|
136
|
+
y: config.marginTop + config.height / 2
|
|
137
|
+
};
|
|
138
|
+
svg.attr("viewbox", `0 0 ${totalWidth} ${totalHeight}`).attr("width", totalWidth).attr("height", totalHeight);
|
|
139
|
+
return svg.append("g").attr("transform", `translate(${center.x}, ${center.y})`);
|
|
140
|
+
}, "drawFrame");
|
|
141
|
+
var drawGraticule = /* @__PURE__ */ index.__name((g, axes, radius, ticks, graticule) => {
|
|
142
|
+
if (graticule === "circle") {
|
|
143
|
+
for (let i = 0; i < ticks; i++) {
|
|
144
|
+
const r = radius * (i + 1) / ticks;
|
|
145
|
+
g.append("circle").attr("r", r).attr("class", "radarGraticule");
|
|
146
|
+
}
|
|
147
|
+
} else if (graticule === "polygon") {
|
|
148
|
+
const numAxes = axes.length;
|
|
149
|
+
for (let i = 0; i < ticks; i++) {
|
|
150
|
+
const r = radius * (i + 1) / ticks;
|
|
151
|
+
const points = axes.map((_, j) => {
|
|
152
|
+
const angle = 2 * j * Math.PI / numAxes - Math.PI / 2;
|
|
153
|
+
const x = r * Math.cos(angle);
|
|
154
|
+
const y = r * Math.sin(angle);
|
|
155
|
+
return `${x},${y}`;
|
|
156
|
+
}).join(" ");
|
|
157
|
+
g.append("polygon").attr("points", points).attr("class", "radarGraticule");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}, "drawGraticule");
|
|
161
|
+
var drawAxes = /* @__PURE__ */ index.__name((g, axes, radius, config) => {
|
|
162
|
+
const numAxes = axes.length;
|
|
163
|
+
for (let i = 0; i < numAxes; i++) {
|
|
164
|
+
const label = axes[i].label;
|
|
165
|
+
const angle = 2 * i * Math.PI / numAxes - Math.PI / 2;
|
|
166
|
+
g.append("line").attr("x1", 0).attr("y1", 0).attr("x2", radius * config.axisScaleFactor * Math.cos(angle)).attr("y2", radius * config.axisScaleFactor * Math.sin(angle)).attr("class", "radarAxisLine");
|
|
167
|
+
g.append("text").text(label).attr("x", radius * config.axisLabelFactor * Math.cos(angle)).attr("y", radius * config.axisLabelFactor * Math.sin(angle)).attr("class", "radarAxisLabel");
|
|
168
|
+
}
|
|
169
|
+
}, "drawAxes");
|
|
170
|
+
function drawCurves(g, axes, curves, minValue, maxValue, graticule, config) {
|
|
171
|
+
const numAxes = axes.length;
|
|
172
|
+
const radius = Math.min(config.width, config.height) / 2;
|
|
173
|
+
curves.forEach((curve, index2) => {
|
|
174
|
+
if (curve.entries.length !== numAxes) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const points = curve.entries.map((entry, i) => {
|
|
178
|
+
const angle = 2 * Math.PI * i / numAxes - Math.PI / 2;
|
|
179
|
+
const r = relativeRadius(entry, minValue, maxValue, radius);
|
|
180
|
+
const x = r * Math.cos(angle);
|
|
181
|
+
const y = r * Math.sin(angle);
|
|
182
|
+
return { x, y };
|
|
183
|
+
});
|
|
184
|
+
if (graticule === "circle") {
|
|
185
|
+
g.append("path").attr("d", closedRoundCurve(points, config.curveTension)).attr("class", `radarCurve-${index2}`);
|
|
186
|
+
} else if (graticule === "polygon") {
|
|
187
|
+
g.append("polygon").attr("points", points.map((p) => `${p.x},${p.y}`).join(" ")).attr("class", `radarCurve-${index2}`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
index.__name(drawCurves, "drawCurves");
|
|
192
|
+
function relativeRadius(value, minValue, maxValue, radius) {
|
|
193
|
+
const clippedValue = Math.min(Math.max(value, minValue), maxValue);
|
|
194
|
+
return radius * (clippedValue - minValue) / (maxValue - minValue);
|
|
195
|
+
}
|
|
196
|
+
index.__name(relativeRadius, "relativeRadius");
|
|
197
|
+
function closedRoundCurve(points, tension) {
|
|
198
|
+
const numPoints = points.length;
|
|
199
|
+
let d = `M${points[0].x},${points[0].y}`;
|
|
200
|
+
for (let i = 0; i < numPoints; i++) {
|
|
201
|
+
const p0 = points[(i - 1 + numPoints) % numPoints];
|
|
202
|
+
const p1 = points[i];
|
|
203
|
+
const p2 = points[(i + 1) % numPoints];
|
|
204
|
+
const p3 = points[(i + 2) % numPoints];
|
|
205
|
+
const cp1 = {
|
|
206
|
+
x: p1.x + (p2.x - p0.x) * tension,
|
|
207
|
+
y: p1.y + (p2.y - p0.y) * tension
|
|
208
|
+
};
|
|
209
|
+
const cp2 = {
|
|
210
|
+
x: p2.x - (p3.x - p1.x) * tension,
|
|
211
|
+
y: p2.y - (p3.y - p1.y) * tension
|
|
212
|
+
};
|
|
213
|
+
d += ` C${cp1.x},${cp1.y} ${cp2.x},${cp2.y} ${p2.x},${p2.y}`;
|
|
214
|
+
}
|
|
215
|
+
return `${d} Z`;
|
|
216
|
+
}
|
|
217
|
+
index.__name(closedRoundCurve, "closedRoundCurve");
|
|
218
|
+
function drawLegend(g, curves, showLegend, config) {
|
|
219
|
+
if (!showLegend) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const legendX = (config.width / 2 + config.marginRight) * 3 / 4;
|
|
223
|
+
const legendY = -(config.height / 2 + config.marginTop) * 3 / 4;
|
|
224
|
+
const lineHeight = 20;
|
|
225
|
+
curves.forEach((curve, index2) => {
|
|
226
|
+
const itemGroup = g.append("g").attr("transform", `translate(${legendX}, ${legendY + index2 * lineHeight})`);
|
|
227
|
+
itemGroup.append("rect").attr("width", 12).attr("height", 12).attr("class", `radarLegendBox-${index2}`);
|
|
228
|
+
itemGroup.append("text").attr("x", 16).attr("y", 0).attr("class", "radarLegendText").text(curve.label);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
index.__name(drawLegend, "drawLegend");
|
|
232
|
+
var renderer = { draw };
|
|
233
|
+
var genIndexStyles = /* @__PURE__ */ index.__name((themeVariables, radarOptions) => {
|
|
234
|
+
let sections = "";
|
|
235
|
+
for (let i = 0; i < themeVariables.THEME_COLOR_LIMIT; i++) {
|
|
236
|
+
const indexColor = themeVariables[`cScale${i}`];
|
|
237
|
+
sections += `
|
|
238
|
+
.radarCurve-${i} {
|
|
239
|
+
color: ${indexColor};
|
|
240
|
+
fill: ${indexColor};
|
|
241
|
+
fill-opacity: ${radarOptions.curveOpacity};
|
|
242
|
+
stroke: ${indexColor};
|
|
243
|
+
stroke-width: ${radarOptions.curveStrokeWidth};
|
|
244
|
+
}
|
|
245
|
+
.radarLegendBox-${i} {
|
|
246
|
+
fill: ${indexColor};
|
|
247
|
+
fill-opacity: ${radarOptions.curveOpacity};
|
|
248
|
+
stroke: ${indexColor};
|
|
249
|
+
}
|
|
250
|
+
`;
|
|
251
|
+
}
|
|
252
|
+
return sections;
|
|
253
|
+
}, "genIndexStyles");
|
|
254
|
+
var buildRadarStyleOptions = /* @__PURE__ */ index.__name((radar) => {
|
|
255
|
+
const defaultThemeVariables = index.getThemeVariables3();
|
|
256
|
+
const currentConfig = index.getConfig();
|
|
257
|
+
const themeVariables = index.cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
|
|
258
|
+
const radarOptions = index.cleanAndMerge(themeVariables.radar, radar);
|
|
259
|
+
return { themeVariables, radarOptions };
|
|
260
|
+
}, "buildRadarStyleOptions");
|
|
261
|
+
var styles = /* @__PURE__ */ index.__name(({ radar } = {}) => {
|
|
262
|
+
const { themeVariables, radarOptions } = buildRadarStyleOptions(radar);
|
|
263
|
+
return `
|
|
264
|
+
.radarTitle {
|
|
265
|
+
font-size: ${themeVariables.fontSize};
|
|
266
|
+
color: ${themeVariables.titleColor};
|
|
267
|
+
dominant-baseline: hanging;
|
|
268
|
+
text-anchor: middle;
|
|
269
|
+
}
|
|
270
|
+
.radarAxisLine {
|
|
271
|
+
stroke: ${radarOptions.axisColor};
|
|
272
|
+
stroke-width: ${radarOptions.axisStrokeWidth};
|
|
273
|
+
}
|
|
274
|
+
.radarAxisLabel {
|
|
275
|
+
dominant-baseline: middle;
|
|
276
|
+
text-anchor: middle;
|
|
277
|
+
font-size: ${radarOptions.axisLabelFontSize}px;
|
|
278
|
+
color: ${radarOptions.axisColor};
|
|
279
|
+
}
|
|
280
|
+
.radarGraticule {
|
|
281
|
+
fill: ${radarOptions.graticuleColor};
|
|
282
|
+
fill-opacity: ${radarOptions.graticuleOpacity};
|
|
283
|
+
stroke: ${radarOptions.graticuleColor};
|
|
284
|
+
stroke-width: ${radarOptions.graticuleStrokeWidth};
|
|
285
|
+
}
|
|
286
|
+
.radarLegendText {
|
|
287
|
+
text-anchor: start;
|
|
288
|
+
font-size: ${radarOptions.legendFontSize}px;
|
|
289
|
+
dominant-baseline: hanging;
|
|
290
|
+
}
|
|
291
|
+
${genIndexStyles(themeVariables, radarOptions)}
|
|
292
|
+
`;
|
|
293
|
+
}, "styles");
|
|
294
|
+
var diagram = {
|
|
295
|
+
parser,
|
|
296
|
+
db,
|
|
297
|
+
renderer,
|
|
298
|
+
styles
|
|
299
|
+
};
|
|
300
|
+
exports.diagram = diagram;
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { _ as __name, s as setAccDescription, g as getAccDescription, q as getDiagramTitle, p as setDiagramTitle, a as getAccTitle, b as setAccTitle, H as selectSvgElement, y as clear, D as cleanAndMerge, E as getConfig, F as defaultConfig_default, l as log, K as getThemeVariables3 } from "./index-CjSgoo1P.js";
|
|
2
|
+
import { p as populateCommonDb } from "./chunk-4BX2VUAB-sd2zFBFz.js";
|
|
3
|
+
import { p as parse } from "./mermaid-parser.core-DCMDT-Cp.js";
|
|
4
|
+
var defaultOptions = {
|
|
5
|
+
showLegend: true,
|
|
6
|
+
ticks: 5,
|
|
7
|
+
max: null,
|
|
8
|
+
min: 0,
|
|
9
|
+
graticule: "circle"
|
|
10
|
+
};
|
|
11
|
+
var defaultRadarData = {
|
|
12
|
+
axes: [],
|
|
13
|
+
curves: [],
|
|
14
|
+
options: defaultOptions
|
|
15
|
+
};
|
|
16
|
+
var data = structuredClone(defaultRadarData);
|
|
17
|
+
var DEFAULT_RADAR_CONFIG = defaultConfig_default.radar;
|
|
18
|
+
var getConfig2 = /* @__PURE__ */ __name(() => {
|
|
19
|
+
const config = cleanAndMerge({
|
|
20
|
+
...DEFAULT_RADAR_CONFIG,
|
|
21
|
+
...getConfig().radar
|
|
22
|
+
});
|
|
23
|
+
return config;
|
|
24
|
+
}, "getConfig");
|
|
25
|
+
var getAxes = /* @__PURE__ */ __name(() => data.axes, "getAxes");
|
|
26
|
+
var getCurves = /* @__PURE__ */ __name(() => data.curves, "getCurves");
|
|
27
|
+
var getOptions = /* @__PURE__ */ __name(() => data.options, "getOptions");
|
|
28
|
+
var setAxes = /* @__PURE__ */ __name((axes) => {
|
|
29
|
+
data.axes = axes.map((axis) => {
|
|
30
|
+
return {
|
|
31
|
+
name: axis.name,
|
|
32
|
+
label: axis.label ?? axis.name
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}, "setAxes");
|
|
36
|
+
var setCurves = /* @__PURE__ */ __name((curves) => {
|
|
37
|
+
data.curves = curves.map((curve) => {
|
|
38
|
+
return {
|
|
39
|
+
name: curve.name,
|
|
40
|
+
label: curve.label ?? curve.name,
|
|
41
|
+
entries: computeCurveEntries(curve.entries)
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}, "setCurves");
|
|
45
|
+
var computeCurveEntries = /* @__PURE__ */ __name((entries) => {
|
|
46
|
+
if (entries[0].axis == void 0) {
|
|
47
|
+
return entries.map((entry) => entry.value);
|
|
48
|
+
}
|
|
49
|
+
const axes = getAxes();
|
|
50
|
+
if (axes.length === 0) {
|
|
51
|
+
throw new Error("Axes must be populated before curves for reference entries");
|
|
52
|
+
}
|
|
53
|
+
return axes.map((axis) => {
|
|
54
|
+
const entry = entries.find((entry2) => entry2.axis?.$refText === axis.name);
|
|
55
|
+
if (entry === void 0) {
|
|
56
|
+
throw new Error("Missing entry for axis " + axis.label);
|
|
57
|
+
}
|
|
58
|
+
return entry.value;
|
|
59
|
+
});
|
|
60
|
+
}, "computeCurveEntries");
|
|
61
|
+
var setOptions = /* @__PURE__ */ __name((options) => {
|
|
62
|
+
const optionMap = options.reduce(
|
|
63
|
+
(acc, option) => {
|
|
64
|
+
acc[option.name] = option;
|
|
65
|
+
return acc;
|
|
66
|
+
},
|
|
67
|
+
{}
|
|
68
|
+
);
|
|
69
|
+
data.options = {
|
|
70
|
+
showLegend: optionMap.showLegend?.value ?? defaultOptions.showLegend,
|
|
71
|
+
ticks: optionMap.ticks?.value ?? defaultOptions.ticks,
|
|
72
|
+
max: optionMap.max?.value ?? defaultOptions.max,
|
|
73
|
+
min: optionMap.min?.value ?? defaultOptions.min,
|
|
74
|
+
graticule: optionMap.graticule?.value ?? defaultOptions.graticule
|
|
75
|
+
};
|
|
76
|
+
}, "setOptions");
|
|
77
|
+
var clear2 = /* @__PURE__ */ __name(() => {
|
|
78
|
+
clear();
|
|
79
|
+
data = structuredClone(defaultRadarData);
|
|
80
|
+
}, "clear");
|
|
81
|
+
var db = {
|
|
82
|
+
getAxes,
|
|
83
|
+
getCurves,
|
|
84
|
+
getOptions,
|
|
85
|
+
setAxes,
|
|
86
|
+
setCurves,
|
|
87
|
+
setOptions,
|
|
88
|
+
getConfig: getConfig2,
|
|
89
|
+
clear: clear2,
|
|
90
|
+
setAccTitle,
|
|
91
|
+
getAccTitle,
|
|
92
|
+
setDiagramTitle,
|
|
93
|
+
getDiagramTitle,
|
|
94
|
+
getAccDescription,
|
|
95
|
+
setAccDescription
|
|
96
|
+
};
|
|
97
|
+
var populate = /* @__PURE__ */ __name((ast) => {
|
|
98
|
+
populateCommonDb(ast, db);
|
|
99
|
+
const { axes, curves, options } = ast;
|
|
100
|
+
db.setAxes(axes);
|
|
101
|
+
db.setCurves(curves);
|
|
102
|
+
db.setOptions(options);
|
|
103
|
+
}, "populate");
|
|
104
|
+
var parser = {
|
|
105
|
+
parse: /* @__PURE__ */ __name(async (input) => {
|
|
106
|
+
const ast = await parse("radar", input);
|
|
107
|
+
log.debug(ast);
|
|
108
|
+
populate(ast);
|
|
109
|
+
}, "parse")
|
|
110
|
+
};
|
|
111
|
+
var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
|
|
112
|
+
const db2 = diagram2.db;
|
|
113
|
+
const axes = db2.getAxes();
|
|
114
|
+
const curves = db2.getCurves();
|
|
115
|
+
const options = db2.getOptions();
|
|
116
|
+
const config = db2.getConfig();
|
|
117
|
+
const title = db2.getDiagramTitle();
|
|
118
|
+
const svg = selectSvgElement(id);
|
|
119
|
+
const g = drawFrame(svg, config);
|
|
120
|
+
const maxValue = options.max ?? Math.max(...curves.map((curve) => Math.max(...curve.entries)));
|
|
121
|
+
const minValue = options.min;
|
|
122
|
+
const radius = Math.min(config.width, config.height) / 2;
|
|
123
|
+
drawGraticule(g, axes, radius, options.ticks, options.graticule);
|
|
124
|
+
drawAxes(g, axes, radius, config);
|
|
125
|
+
drawCurves(g, axes, curves, minValue, maxValue, options.graticule, config);
|
|
126
|
+
drawLegend(g, curves, options.showLegend, config);
|
|
127
|
+
g.append("text").attr("class", "radarTitle").text(title).attr("x", 0).attr("y", -config.height / 2 - config.marginTop);
|
|
128
|
+
}, "draw");
|
|
129
|
+
var drawFrame = /* @__PURE__ */ __name((svg, config) => {
|
|
130
|
+
const totalWidth = config.width + config.marginLeft + config.marginRight;
|
|
131
|
+
const totalHeight = config.height + config.marginTop + config.marginBottom;
|
|
132
|
+
const center = {
|
|
133
|
+
x: config.marginLeft + config.width / 2,
|
|
134
|
+
y: config.marginTop + config.height / 2
|
|
135
|
+
};
|
|
136
|
+
svg.attr("viewbox", `0 0 ${totalWidth} ${totalHeight}`).attr("width", totalWidth).attr("height", totalHeight);
|
|
137
|
+
return svg.append("g").attr("transform", `translate(${center.x}, ${center.y})`);
|
|
138
|
+
}, "drawFrame");
|
|
139
|
+
var drawGraticule = /* @__PURE__ */ __name((g, axes, radius, ticks, graticule) => {
|
|
140
|
+
if (graticule === "circle") {
|
|
141
|
+
for (let i = 0; i < ticks; i++) {
|
|
142
|
+
const r = radius * (i + 1) / ticks;
|
|
143
|
+
g.append("circle").attr("r", r).attr("class", "radarGraticule");
|
|
144
|
+
}
|
|
145
|
+
} else if (graticule === "polygon") {
|
|
146
|
+
const numAxes = axes.length;
|
|
147
|
+
for (let i = 0; i < ticks; i++) {
|
|
148
|
+
const r = radius * (i + 1) / ticks;
|
|
149
|
+
const points = axes.map((_, j) => {
|
|
150
|
+
const angle = 2 * j * Math.PI / numAxes - Math.PI / 2;
|
|
151
|
+
const x = r * Math.cos(angle);
|
|
152
|
+
const y = r * Math.sin(angle);
|
|
153
|
+
return `${x},${y}`;
|
|
154
|
+
}).join(" ");
|
|
155
|
+
g.append("polygon").attr("points", points).attr("class", "radarGraticule");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, "drawGraticule");
|
|
159
|
+
var drawAxes = /* @__PURE__ */ __name((g, axes, radius, config) => {
|
|
160
|
+
const numAxes = axes.length;
|
|
161
|
+
for (let i = 0; i < numAxes; i++) {
|
|
162
|
+
const label = axes[i].label;
|
|
163
|
+
const angle = 2 * i * Math.PI / numAxes - Math.PI / 2;
|
|
164
|
+
g.append("line").attr("x1", 0).attr("y1", 0).attr("x2", radius * config.axisScaleFactor * Math.cos(angle)).attr("y2", radius * config.axisScaleFactor * Math.sin(angle)).attr("class", "radarAxisLine");
|
|
165
|
+
g.append("text").text(label).attr("x", radius * config.axisLabelFactor * Math.cos(angle)).attr("y", radius * config.axisLabelFactor * Math.sin(angle)).attr("class", "radarAxisLabel");
|
|
166
|
+
}
|
|
167
|
+
}, "drawAxes");
|
|
168
|
+
function drawCurves(g, axes, curves, minValue, maxValue, graticule, config) {
|
|
169
|
+
const numAxes = axes.length;
|
|
170
|
+
const radius = Math.min(config.width, config.height) / 2;
|
|
171
|
+
curves.forEach((curve, index) => {
|
|
172
|
+
if (curve.entries.length !== numAxes) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const points = curve.entries.map((entry, i) => {
|
|
176
|
+
const angle = 2 * Math.PI * i / numAxes - Math.PI / 2;
|
|
177
|
+
const r = relativeRadius(entry, minValue, maxValue, radius);
|
|
178
|
+
const x = r * Math.cos(angle);
|
|
179
|
+
const y = r * Math.sin(angle);
|
|
180
|
+
return { x, y };
|
|
181
|
+
});
|
|
182
|
+
if (graticule === "circle") {
|
|
183
|
+
g.append("path").attr("d", closedRoundCurve(points, config.curveTension)).attr("class", `radarCurve-${index}`);
|
|
184
|
+
} else if (graticule === "polygon") {
|
|
185
|
+
g.append("polygon").attr("points", points.map((p) => `${p.x},${p.y}`).join(" ")).attr("class", `radarCurve-${index}`);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
__name(drawCurves, "drawCurves");
|
|
190
|
+
function relativeRadius(value, minValue, maxValue, radius) {
|
|
191
|
+
const clippedValue = Math.min(Math.max(value, minValue), maxValue);
|
|
192
|
+
return radius * (clippedValue - minValue) / (maxValue - minValue);
|
|
193
|
+
}
|
|
194
|
+
__name(relativeRadius, "relativeRadius");
|
|
195
|
+
function closedRoundCurve(points, tension) {
|
|
196
|
+
const numPoints = points.length;
|
|
197
|
+
let d = `M${points[0].x},${points[0].y}`;
|
|
198
|
+
for (let i = 0; i < numPoints; i++) {
|
|
199
|
+
const p0 = points[(i - 1 + numPoints) % numPoints];
|
|
200
|
+
const p1 = points[i];
|
|
201
|
+
const p2 = points[(i + 1) % numPoints];
|
|
202
|
+
const p3 = points[(i + 2) % numPoints];
|
|
203
|
+
const cp1 = {
|
|
204
|
+
x: p1.x + (p2.x - p0.x) * tension,
|
|
205
|
+
y: p1.y + (p2.y - p0.y) * tension
|
|
206
|
+
};
|
|
207
|
+
const cp2 = {
|
|
208
|
+
x: p2.x - (p3.x - p1.x) * tension,
|
|
209
|
+
y: p2.y - (p3.y - p1.y) * tension
|
|
210
|
+
};
|
|
211
|
+
d += ` C${cp1.x},${cp1.y} ${cp2.x},${cp2.y} ${p2.x},${p2.y}`;
|
|
212
|
+
}
|
|
213
|
+
return `${d} Z`;
|
|
214
|
+
}
|
|
215
|
+
__name(closedRoundCurve, "closedRoundCurve");
|
|
216
|
+
function drawLegend(g, curves, showLegend, config) {
|
|
217
|
+
if (!showLegend) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const legendX = (config.width / 2 + config.marginRight) * 3 / 4;
|
|
221
|
+
const legendY = -(config.height / 2 + config.marginTop) * 3 / 4;
|
|
222
|
+
const lineHeight = 20;
|
|
223
|
+
curves.forEach((curve, index) => {
|
|
224
|
+
const itemGroup = g.append("g").attr("transform", `translate(${legendX}, ${legendY + index * lineHeight})`);
|
|
225
|
+
itemGroup.append("rect").attr("width", 12).attr("height", 12).attr("class", `radarLegendBox-${index}`);
|
|
226
|
+
itemGroup.append("text").attr("x", 16).attr("y", 0).attr("class", "radarLegendText").text(curve.label);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
__name(drawLegend, "drawLegend");
|
|
230
|
+
var renderer = { draw };
|
|
231
|
+
var genIndexStyles = /* @__PURE__ */ __name((themeVariables, radarOptions) => {
|
|
232
|
+
let sections = "";
|
|
233
|
+
for (let i = 0; i < themeVariables.THEME_COLOR_LIMIT; i++) {
|
|
234
|
+
const indexColor = themeVariables[`cScale${i}`];
|
|
235
|
+
sections += `
|
|
236
|
+
.radarCurve-${i} {
|
|
237
|
+
color: ${indexColor};
|
|
238
|
+
fill: ${indexColor};
|
|
239
|
+
fill-opacity: ${radarOptions.curveOpacity};
|
|
240
|
+
stroke: ${indexColor};
|
|
241
|
+
stroke-width: ${radarOptions.curveStrokeWidth};
|
|
242
|
+
}
|
|
243
|
+
.radarLegendBox-${i} {
|
|
244
|
+
fill: ${indexColor};
|
|
245
|
+
fill-opacity: ${radarOptions.curveOpacity};
|
|
246
|
+
stroke: ${indexColor};
|
|
247
|
+
}
|
|
248
|
+
`;
|
|
249
|
+
}
|
|
250
|
+
return sections;
|
|
251
|
+
}, "genIndexStyles");
|
|
252
|
+
var buildRadarStyleOptions = /* @__PURE__ */ __name((radar) => {
|
|
253
|
+
const defaultThemeVariables = getThemeVariables3();
|
|
254
|
+
const currentConfig = getConfig();
|
|
255
|
+
const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
|
|
256
|
+
const radarOptions = cleanAndMerge(themeVariables.radar, radar);
|
|
257
|
+
return { themeVariables, radarOptions };
|
|
258
|
+
}, "buildRadarStyleOptions");
|
|
259
|
+
var styles = /* @__PURE__ */ __name(({ radar } = {}) => {
|
|
260
|
+
const { themeVariables, radarOptions } = buildRadarStyleOptions(radar);
|
|
261
|
+
return `
|
|
262
|
+
.radarTitle {
|
|
263
|
+
font-size: ${themeVariables.fontSize};
|
|
264
|
+
color: ${themeVariables.titleColor};
|
|
265
|
+
dominant-baseline: hanging;
|
|
266
|
+
text-anchor: middle;
|
|
267
|
+
}
|
|
268
|
+
.radarAxisLine {
|
|
269
|
+
stroke: ${radarOptions.axisColor};
|
|
270
|
+
stroke-width: ${radarOptions.axisStrokeWidth};
|
|
271
|
+
}
|
|
272
|
+
.radarAxisLabel {
|
|
273
|
+
dominant-baseline: middle;
|
|
274
|
+
text-anchor: middle;
|
|
275
|
+
font-size: ${radarOptions.axisLabelFontSize}px;
|
|
276
|
+
color: ${radarOptions.axisColor};
|
|
277
|
+
}
|
|
278
|
+
.radarGraticule {
|
|
279
|
+
fill: ${radarOptions.graticuleColor};
|
|
280
|
+
fill-opacity: ${radarOptions.graticuleOpacity};
|
|
281
|
+
stroke: ${radarOptions.graticuleColor};
|
|
282
|
+
stroke-width: ${radarOptions.graticuleStrokeWidth};
|
|
283
|
+
}
|
|
284
|
+
.radarLegendText {
|
|
285
|
+
text-anchor: start;
|
|
286
|
+
font-size: ${radarOptions.legendFontSize}px;
|
|
287
|
+
dominant-baseline: hanging;
|
|
288
|
+
}
|
|
289
|
+
${genIndexStyles(themeVariables, radarOptions)}
|
|
290
|
+
`;
|
|
291
|
+
}, "styles");
|
|
292
|
+
var diagram = {
|
|
293
|
+
parser,
|
|
294
|
+
db,
|
|
295
|
+
renderer,
|
|
296
|
+
styles
|
|
297
|
+
};
|
|
298
|
+
export {
|
|
299
|
+
diagram
|
|
300
|
+
};
|