@diagrammo/dgmo 0.2.21 → 0.2.22
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/cli.cjs +90 -90
- package/dist/index.cjs +54 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +54 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/echarts.ts +7 -8
- package/src/kanban/renderer.ts +3 -1
- package/src/org/layout.ts +45 -25
- package/src/org/renderer.ts +19 -11
package/dist/index.d.cts
CHANGED
|
@@ -982,9 +982,11 @@ interface OrgContainerBounds {
|
|
|
982
982
|
interface OrgLegendEntry {
|
|
983
983
|
value: string;
|
|
984
984
|
color: string;
|
|
985
|
+
isDefault?: boolean;
|
|
985
986
|
}
|
|
986
987
|
interface OrgLegendGroup {
|
|
987
988
|
name: string;
|
|
989
|
+
alias?: string;
|
|
988
990
|
entries: OrgLegendEntry[];
|
|
989
991
|
x: number;
|
|
990
992
|
y: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -982,9 +982,11 @@ interface OrgContainerBounds {
|
|
|
982
982
|
interface OrgLegendEntry {
|
|
983
983
|
value: string;
|
|
984
984
|
color: string;
|
|
985
|
+
isDefault?: boolean;
|
|
985
986
|
}
|
|
986
987
|
interface OrgLegendGroup {
|
|
987
988
|
name: string;
|
|
989
|
+
alias?: string;
|
|
988
990
|
entries: OrgLegendEntry[];
|
|
989
991
|
x: number;
|
|
990
992
|
y: number;
|
package/dist/index.js
CHANGED
|
@@ -3956,16 +3956,15 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
|
|
|
3956
3956
|
const val = p.value;
|
|
3957
3957
|
const prev = prevValueMap.get(p.name) ?? val;
|
|
3958
3958
|
const isFirst = p.dataIndex === 0;
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
if (!isFirst && topValue > 0) {
|
|
3959
|
+
if (isFirst) return "";
|
|
3960
|
+
const parts = [];
|
|
3961
|
+
const stepDrop = ((1 - val / prev) * 100).toFixed(1);
|
|
3962
|
+
parts.push(`Step drop-off: ${stepDrop}%`);
|
|
3963
|
+
if (topValue > 0) {
|
|
3965
3964
|
const totalDrop = ((1 - val / topValue) * 100).toFixed(1);
|
|
3966
|
-
|
|
3965
|
+
parts.push(`Overall drop-off: ${totalDrop}%`);
|
|
3967
3966
|
}
|
|
3968
|
-
return
|
|
3967
|
+
return parts.join("<br/>");
|
|
3969
3968
|
}
|
|
3970
3969
|
},
|
|
3971
3970
|
series: [
|
|
@@ -5310,20 +5309,29 @@ function computeLegendGroups(tagGroups, _showEyeIcons) {
|
|
|
5310
5309
|
const groups = [];
|
|
5311
5310
|
for (const group of tagGroups) {
|
|
5312
5311
|
if (group.entries.length === 0) continue;
|
|
5313
|
-
const
|
|
5312
|
+
const pillLabel = group.alias ? `${group.name} (${group.alias})` : group.name;
|
|
5313
|
+
const pillWidth = pillLabel.length * LEGEND_PILL_FONT_W + LEGEND_PILL_PAD;
|
|
5314
|
+
const minPillWidth = group.name.length * LEGEND_PILL_FONT_W + LEGEND_PILL_PAD;
|
|
5315
|
+
const isDefaultValue = group.defaultValue?.toLowerCase();
|
|
5314
5316
|
let entriesWidth = 0;
|
|
5315
5317
|
for (const entry of group.entries) {
|
|
5316
|
-
|
|
5318
|
+
const entryLabel = isDefaultValue === entry.value.toLowerCase() ? `${entry.value} (default)` : entry.value;
|
|
5319
|
+
entriesWidth += LEGEND_DOT_R * 2 + LEGEND_ENTRY_DOT_GAP + entryLabel.length * LEGEND_ENTRY_FONT_W + LEGEND_ENTRY_TRAIL;
|
|
5317
5320
|
}
|
|
5318
5321
|
const capsuleWidth = LEGEND_CAPSULE_PAD * 2 + pillWidth + 4 + entriesWidth;
|
|
5319
5322
|
groups.push({
|
|
5320
5323
|
name: group.name,
|
|
5321
|
-
|
|
5324
|
+
alias: group.alias,
|
|
5325
|
+
entries: group.entries.map((e) => ({
|
|
5326
|
+
value: e.value,
|
|
5327
|
+
color: e.color,
|
|
5328
|
+
isDefault: group.defaultValue?.toLowerCase() === e.value.toLowerCase() || void 0
|
|
5329
|
+
})),
|
|
5322
5330
|
x: 0,
|
|
5323
5331
|
y: 0,
|
|
5324
5332
|
width: capsuleWidth,
|
|
5325
5333
|
height: LEGEND_HEIGHT,
|
|
5326
|
-
minifiedWidth:
|
|
5334
|
+
minifiedWidth: minPillWidth,
|
|
5327
5335
|
minifiedHeight: LEGEND_HEIGHT
|
|
5328
5336
|
});
|
|
5329
5337
|
}
|
|
@@ -5356,19 +5364,21 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes) {
|
|
|
5356
5364
|
if (legendGroups2.length === 0) {
|
|
5357
5365
|
return { nodes: [], edges: [], containers: [], legend: [], width: 0, height: 0 };
|
|
5358
5366
|
}
|
|
5359
|
-
let
|
|
5367
|
+
let cy = MARGIN;
|
|
5368
|
+
let maxWidth2 = 0;
|
|
5360
5369
|
for (const g of legendGroups2) {
|
|
5361
|
-
g.x =
|
|
5362
|
-
g.y =
|
|
5363
|
-
|
|
5370
|
+
g.x = MARGIN;
|
|
5371
|
+
g.y = cy;
|
|
5372
|
+
cy += LEGEND_HEIGHT + LEGEND_GROUP_GAP;
|
|
5373
|
+
if (g.width > maxWidth2) maxWidth2 = g.width;
|
|
5364
5374
|
}
|
|
5365
5375
|
return {
|
|
5366
5376
|
nodes: [],
|
|
5367
5377
|
edges: [],
|
|
5368
5378
|
containers: [],
|
|
5369
5379
|
legend: legendGroups2,
|
|
5370
|
-
width:
|
|
5371
|
-
height:
|
|
5380
|
+
width: maxWidth2 + MARGIN * 2,
|
|
5381
|
+
height: cy - LEGEND_GROUP_GAP + MARGIN
|
|
5372
5382
|
};
|
|
5373
5383
|
}
|
|
5374
5384
|
injectDefaultMetadata(parsed.roots, parsed.tagGroups);
|
|
@@ -5877,7 +5887,7 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes) {
|
|
|
5877
5887
|
const legendGroups = computeLegendGroups(parsed.tagGroups, showEyeIcons);
|
|
5878
5888
|
let finalWidth = totalWidth;
|
|
5879
5889
|
let finalHeight = totalHeight;
|
|
5880
|
-
const legendPosition = parsed.options?.["legend-position"] ?? "
|
|
5890
|
+
const legendPosition = parsed.options?.["legend-position"] ?? "top";
|
|
5881
5891
|
const visibleGroups = activeTagGroup != null ? legendGroups.filter((g) => g.name.toLowerCase() === activeTagGroup.toLowerCase()) : legendGroups;
|
|
5882
5892
|
const effectiveW = (g) => activeTagGroup != null ? g.width : g.minifiedWidth;
|
|
5883
5893
|
const effectiveH = (g) => activeTagGroup != null ? g.height : g.minifiedHeight;
|
|
@@ -5905,22 +5915,23 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes) {
|
|
|
5905
5915
|
}
|
|
5906
5916
|
finalHeight = totalHeight + LEGEND_GAP + LEGEND_HEIGHT;
|
|
5907
5917
|
} else {
|
|
5918
|
+
const legendShift = LEGEND_HEIGHT + LEGEND_GROUP_GAP;
|
|
5919
|
+
for (const n of layoutNodes) n.y += legendShift;
|
|
5920
|
+
for (const c of containers) c.y += legendShift;
|
|
5921
|
+
for (const e of layoutEdges) {
|
|
5922
|
+
for (const p of e.points) p.y += legendShift;
|
|
5923
|
+
}
|
|
5908
5924
|
const totalGroupsWidth = visibleGroups.reduce((s, g) => s + effectiveW(g), 0) + (visibleGroups.length - 1) * LEGEND_GROUP_GAP;
|
|
5909
|
-
|
|
5910
|
-
const legendY = MARGIN;
|
|
5911
|
-
let cx = legendStartX;
|
|
5925
|
+
let cx = MARGIN;
|
|
5912
5926
|
for (const g of visibleGroups) {
|
|
5913
5927
|
g.x = cx;
|
|
5914
|
-
g.y =
|
|
5928
|
+
g.y = MARGIN;
|
|
5915
5929
|
cx += effectiveW(g) + LEGEND_GROUP_GAP;
|
|
5916
5930
|
}
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
const legendBottom = legendY + LEGEND_HEIGHT + MARGIN;
|
|
5922
|
-
if (legendBottom > finalHeight) {
|
|
5923
|
-
finalHeight = legendBottom;
|
|
5931
|
+
finalHeight += legendShift;
|
|
5932
|
+
const neededWidth = totalGroupsWidth + MARGIN * 2;
|
|
5933
|
+
if (neededWidth > finalWidth) {
|
|
5934
|
+
finalWidth = neededWidth;
|
|
5924
5935
|
}
|
|
5925
5936
|
}
|
|
5926
5937
|
}
|
|
@@ -6196,12 +6207,14 @@ function renderOrg(container, parsed, layout, palette, isDark, onClickItem, expo
|
|
|
6196
6207
|
nodeG.append("rect").attr("x", COLLAPSE_BAR_INSET).attr("y", node.height - COLLAPSE_BAR_HEIGHT).attr("width", node.width - COLLAPSE_BAR_INSET * 2).attr("height", COLLAPSE_BAR_HEIGHT).attr("fill", nodeStroke(palette, colorOff ? void 0 : node.color)).attr("clip-path", `url(#${clipId})`).attr("class", "org-collapse-bar");
|
|
6197
6208
|
}
|
|
6198
6209
|
}
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
const
|
|
6204
|
-
const
|
|
6210
|
+
const legendOnly = layout.nodes.length === 0;
|
|
6211
|
+
if (!exportDims || legendOnly) for (const group of layout.legend) {
|
|
6212
|
+
const isActive = legendOnly || activeTagGroup != null && group.name.toLowerCase() === activeTagGroup.toLowerCase();
|
|
6213
|
+
if (!legendOnly && activeTagGroup != null && !isActive) continue;
|
|
6214
|
+
const groupBg = isDark ? mix(palette.surface, palette.bg, 50) : mix(palette.surface, palette.bg, 30);
|
|
6215
|
+
const pillLabel = isActive && group.alias ? `${group.name} (${group.alias})` : group.name;
|
|
6216
|
+
const pillWidth = pillLabel.length * LEGEND_PILL_FONT_W2 + LEGEND_PILL_PAD2;
|
|
6217
|
+
const gEl = contentG.append("g").attr("transform", `translate(${group.x}, ${group.y})`).attr("class", "org-legend-group").attr("data-legend-group", group.name.toLowerCase()).style("cursor", legendOnly ? "default" : "pointer");
|
|
6205
6218
|
if (isActive) {
|
|
6206
6219
|
gEl.append("rect").attr("width", group.width).attr("height", LEGEND_HEIGHT2).attr("rx", LEGEND_HEIGHT2 / 2).attr("fill", groupBg);
|
|
6207
6220
|
}
|
|
@@ -6212,14 +6225,15 @@ function renderOrg(container, parsed, layout, palette, isDark, onClickItem, expo
|
|
|
6212
6225
|
if (isActive) {
|
|
6213
6226
|
gEl.append("rect").attr("x", pillX).attr("y", pillY).attr("width", pillWidth).attr("height", pillH).attr("rx", pillH / 2).attr("fill", "none").attr("stroke", mix(palette.textMuted, palette.bg, 50)).attr("stroke-width", 0.75);
|
|
6214
6227
|
}
|
|
6215
|
-
gEl.append("text").attr("x", pillX + pillWidth / 2).attr("y", LEGEND_HEIGHT2 / 2 + LEGEND_PILL_FONT_SIZE / 2 - 2).attr("font-size", LEGEND_PILL_FONT_SIZE).attr("font-weight", "500").attr("fill", isActive ? palette.text : palette.textMuted).attr("text-anchor", "middle").text(
|
|
6228
|
+
gEl.append("text").attr("x", pillX + pillWidth / 2).attr("y", LEGEND_HEIGHT2 / 2 + LEGEND_PILL_FONT_SIZE / 2 - 2).attr("font-size", LEGEND_PILL_FONT_SIZE).attr("font-weight", "500").attr("fill", isActive ? palette.text : palette.textMuted).attr("text-anchor", "middle").text(pillLabel);
|
|
6216
6229
|
if (isActive) {
|
|
6217
6230
|
let entryX = pillX + pillWidth + 4;
|
|
6218
6231
|
for (const entry of group.entries) {
|
|
6219
6232
|
gEl.append("circle").attr("cx", entryX + LEGEND_DOT_R2).attr("cy", LEGEND_HEIGHT2 / 2).attr("r", LEGEND_DOT_R2).attr("fill", entry.color);
|
|
6220
6233
|
const textX = entryX + LEGEND_DOT_R2 * 2 + LEGEND_ENTRY_DOT_GAP2;
|
|
6221
|
-
|
|
6222
|
-
|
|
6234
|
+
const entryLabel = entry.isDefault ? `${entry.value} (default)` : entry.value;
|
|
6235
|
+
gEl.append("text").attr("x", textX).attr("y", LEGEND_HEIGHT2 / 2 + LEGEND_ENTRY_FONT_SIZE / 2 - 1).attr("font-size", LEGEND_ENTRY_FONT_SIZE).attr("fill", palette.textMuted).text(entryLabel);
|
|
6236
|
+
entryX = textX + entryLabel.length * LEGEND_ENTRY_FONT_W2 + LEGEND_ENTRY_TRAIL2;
|
|
6223
6237
|
}
|
|
6224
6238
|
}
|
|
6225
6239
|
}
|
|
@@ -6533,7 +6547,7 @@ function renderKanban(container, parsed, palette, isDark, _onNavigateToLine, exp
|
|
|
6533
6547
|
const legendY = DIAGRAM_PADDING2;
|
|
6534
6548
|
const titleTextWidth = parsed.title ? parsed.title.length * TITLE_FONT_SIZE2 * 0.6 + 16 : 0;
|
|
6535
6549
|
let legendX = DIAGRAM_PADDING2 + titleTextWidth;
|
|
6536
|
-
const groupBg = mix2(palette.surface, palette.bg,
|
|
6550
|
+
const groupBg = isDark ? mix2(palette.surface, palette.bg, 50) : mix2(palette.surface, palette.bg, 30);
|
|
6537
6551
|
const capsulePad = 4;
|
|
6538
6552
|
for (const group of parsed.tagGroups) {
|
|
6539
6553
|
const isActive = activeTagGroup?.toLowerCase() === group.name.toLowerCase();
|