@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/index.cjs CHANGED
@@ -3977,16 +3977,15 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
3977
3977
  const val = p.value;
3978
3978
  const prev = prevValueMap.get(p.name) ?? val;
3979
3979
  const isFirst = p.dataIndex === 0;
3980
- let html = `<strong>${p.name}</strong>: ${val}`;
3981
- if (!isFirst) {
3982
- const stepDrop = ((1 - val / prev) * 100).toFixed(1);
3983
- html += `<br/>Step drop-off: ${stepDrop}%`;
3984
- }
3985
- if (!isFirst && topValue > 0) {
3980
+ if (isFirst) return "";
3981
+ const parts = [];
3982
+ const stepDrop = ((1 - val / prev) * 100).toFixed(1);
3983
+ parts.push(`Step drop-off: ${stepDrop}%`);
3984
+ if (topValue > 0) {
3986
3985
  const totalDrop = ((1 - val / topValue) * 100).toFixed(1);
3987
- html += `<br/>Overall drop-off: ${totalDrop}%`;
3986
+ parts.push(`Overall drop-off: ${totalDrop}%`);
3988
3987
  }
3989
- return html;
3988
+ return parts.join("<br/>");
3990
3989
  }
3991
3990
  },
3992
3991
  series: [
@@ -5331,20 +5330,29 @@ function computeLegendGroups(tagGroups, _showEyeIcons) {
5331
5330
  const groups = [];
5332
5331
  for (const group of tagGroups) {
5333
5332
  if (group.entries.length === 0) continue;
5334
- const pillWidth = group.name.length * LEGEND_PILL_FONT_W + LEGEND_PILL_PAD;
5333
+ const pillLabel = group.alias ? `${group.name} (${group.alias})` : group.name;
5334
+ const pillWidth = pillLabel.length * LEGEND_PILL_FONT_W + LEGEND_PILL_PAD;
5335
+ const minPillWidth = group.name.length * LEGEND_PILL_FONT_W + LEGEND_PILL_PAD;
5336
+ const isDefaultValue = group.defaultValue?.toLowerCase();
5335
5337
  let entriesWidth = 0;
5336
5338
  for (const entry of group.entries) {
5337
- entriesWidth += LEGEND_DOT_R * 2 + LEGEND_ENTRY_DOT_GAP + entry.value.length * LEGEND_ENTRY_FONT_W + LEGEND_ENTRY_TRAIL;
5339
+ const entryLabel = isDefaultValue === entry.value.toLowerCase() ? `${entry.value} (default)` : entry.value;
5340
+ entriesWidth += LEGEND_DOT_R * 2 + LEGEND_ENTRY_DOT_GAP + entryLabel.length * LEGEND_ENTRY_FONT_W + LEGEND_ENTRY_TRAIL;
5338
5341
  }
5339
5342
  const capsuleWidth = LEGEND_CAPSULE_PAD * 2 + pillWidth + 4 + entriesWidth;
5340
5343
  groups.push({
5341
5344
  name: group.name,
5342
- entries: group.entries.map((e) => ({ value: e.value, color: e.color })),
5345
+ alias: group.alias,
5346
+ entries: group.entries.map((e) => ({
5347
+ value: e.value,
5348
+ color: e.color,
5349
+ isDefault: group.defaultValue?.toLowerCase() === e.value.toLowerCase() || void 0
5350
+ })),
5343
5351
  x: 0,
5344
5352
  y: 0,
5345
5353
  width: capsuleWidth,
5346
5354
  height: LEGEND_HEIGHT,
5347
- minifiedWidth: pillWidth,
5355
+ minifiedWidth: minPillWidth,
5348
5356
  minifiedHeight: LEGEND_HEIGHT
5349
5357
  });
5350
5358
  }
@@ -5377,19 +5385,21 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes) {
5377
5385
  if (legendGroups2.length === 0) {
5378
5386
  return { nodes: [], edges: [], containers: [], legend: [], width: 0, height: 0 };
5379
5387
  }
5380
- let cx = MARGIN;
5388
+ let cy = MARGIN;
5389
+ let maxWidth2 = 0;
5381
5390
  for (const g of legendGroups2) {
5382
- g.x = cx;
5383
- g.y = MARGIN;
5384
- cx += g.minifiedWidth + LEGEND_GROUP_GAP;
5391
+ g.x = MARGIN;
5392
+ g.y = cy;
5393
+ cy += LEGEND_HEIGHT + LEGEND_GROUP_GAP;
5394
+ if (g.width > maxWidth2) maxWidth2 = g.width;
5385
5395
  }
5386
5396
  return {
5387
5397
  nodes: [],
5388
5398
  edges: [],
5389
5399
  containers: [],
5390
5400
  legend: legendGroups2,
5391
- width: cx - LEGEND_GROUP_GAP + MARGIN,
5392
- height: LEGEND_HEIGHT + MARGIN * 2
5401
+ width: maxWidth2 + MARGIN * 2,
5402
+ height: cy - LEGEND_GROUP_GAP + MARGIN
5393
5403
  };
5394
5404
  }
5395
5405
  injectDefaultMetadata(parsed.roots, parsed.tagGroups);
@@ -5898,7 +5908,7 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes) {
5898
5908
  const legendGroups = computeLegendGroups(parsed.tagGroups, showEyeIcons);
5899
5909
  let finalWidth = totalWidth;
5900
5910
  let finalHeight = totalHeight;
5901
- const legendPosition = parsed.options?.["legend-position"] ?? "bottom";
5911
+ const legendPosition = parsed.options?.["legend-position"] ?? "top";
5902
5912
  const visibleGroups = activeTagGroup != null ? legendGroups.filter((g) => g.name.toLowerCase() === activeTagGroup.toLowerCase()) : legendGroups;
5903
5913
  const effectiveW = (g) => activeTagGroup != null ? g.width : g.minifiedWidth;
5904
5914
  const effectiveH = (g) => activeTagGroup != null ? g.height : g.minifiedHeight;
@@ -5926,22 +5936,23 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes) {
5926
5936
  }
5927
5937
  finalHeight = totalHeight + LEGEND_GAP + LEGEND_HEIGHT;
5928
5938
  } else {
5939
+ const legendShift = LEGEND_HEIGHT + LEGEND_GROUP_GAP;
5940
+ for (const n of layoutNodes) n.y += legendShift;
5941
+ for (const c of containers) c.y += legendShift;
5942
+ for (const e of layoutEdges) {
5943
+ for (const p of e.points) p.y += legendShift;
5944
+ }
5929
5945
  const totalGroupsWidth = visibleGroups.reduce((s, g) => s + effectiveW(g), 0) + (visibleGroups.length - 1) * LEGEND_GROUP_GAP;
5930
- const legendStartX = totalWidth - MARGIN + LEGEND_GAP;
5931
- const legendY = MARGIN;
5932
- let cx = legendStartX;
5946
+ let cx = MARGIN;
5933
5947
  for (const g of visibleGroups) {
5934
5948
  g.x = cx;
5935
- g.y = legendY;
5949
+ g.y = MARGIN;
5936
5950
  cx += effectiveW(g) + LEGEND_GROUP_GAP;
5937
5951
  }
5938
- const legendRight = legendStartX + totalGroupsWidth + MARGIN;
5939
- if (legendRight > finalWidth) {
5940
- finalWidth = legendRight;
5941
- }
5942
- const legendBottom = legendY + LEGEND_HEIGHT + MARGIN;
5943
- if (legendBottom > finalHeight) {
5944
- finalHeight = legendBottom;
5952
+ finalHeight += legendShift;
5953
+ const neededWidth = totalGroupsWidth + MARGIN * 2;
5954
+ if (neededWidth > finalWidth) {
5955
+ finalWidth = neededWidth;
5945
5956
  }
5946
5957
  }
5947
5958
  }
@@ -6217,12 +6228,14 @@ function renderOrg(container, parsed, layout, palette, isDark, onClickItem, expo
6217
6228
  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");
6218
6229
  }
6219
6230
  }
6220
- if (!exportDims || layout.nodes.length === 0) for (const group of layout.legend) {
6221
- const isActive = activeTagGroup != null && group.name.toLowerCase() === activeTagGroup.toLowerCase();
6222
- if (activeTagGroup != null && !isActive) continue;
6223
- const groupBg = mix(palette.surface, palette.bg, isDark ? 35 : 20);
6224
- const pillWidth = group.name.length * LEGEND_PILL_FONT_W2 + LEGEND_PILL_PAD2;
6225
- 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", "pointer");
6231
+ const legendOnly = layout.nodes.length === 0;
6232
+ if (!exportDims || legendOnly) for (const group of layout.legend) {
6233
+ const isActive = legendOnly || activeTagGroup != null && group.name.toLowerCase() === activeTagGroup.toLowerCase();
6234
+ if (!legendOnly && activeTagGroup != null && !isActive) continue;
6235
+ const groupBg = isDark ? mix(palette.surface, palette.bg, 50) : mix(palette.surface, palette.bg, 30);
6236
+ const pillLabel = isActive && group.alias ? `${group.name} (${group.alias})` : group.name;
6237
+ const pillWidth = pillLabel.length * LEGEND_PILL_FONT_W2 + LEGEND_PILL_PAD2;
6238
+ 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");
6226
6239
  if (isActive) {
6227
6240
  gEl.append("rect").attr("width", group.width).attr("height", LEGEND_HEIGHT2).attr("rx", LEGEND_HEIGHT2 / 2).attr("fill", groupBg);
6228
6241
  }
@@ -6233,14 +6246,15 @@ function renderOrg(container, parsed, layout, palette, isDark, onClickItem, expo
6233
6246
  if (isActive) {
6234
6247
  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);
6235
6248
  }
6236
- 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(group.name);
6249
+ 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);
6237
6250
  if (isActive) {
6238
6251
  let entryX = pillX + pillWidth + 4;
6239
6252
  for (const entry of group.entries) {
6240
6253
  gEl.append("circle").attr("cx", entryX + LEGEND_DOT_R2).attr("cy", LEGEND_HEIGHT2 / 2).attr("r", LEGEND_DOT_R2).attr("fill", entry.color);
6241
6254
  const textX = entryX + LEGEND_DOT_R2 * 2 + LEGEND_ENTRY_DOT_GAP2;
6242
- 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(entry.value);
6243
- entryX = textX + entry.value.length * LEGEND_ENTRY_FONT_W2 + LEGEND_ENTRY_TRAIL2;
6255
+ const entryLabel = entry.isDefault ? `${entry.value} (default)` : entry.value;
6256
+ 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);
6257
+ entryX = textX + entryLabel.length * LEGEND_ENTRY_FONT_W2 + LEGEND_ENTRY_TRAIL2;
6244
6258
  }
6245
6259
  }
6246
6260
  }
@@ -6554,7 +6568,7 @@ function renderKanban(container, parsed, palette, isDark, _onNavigateToLine, exp
6554
6568
  const legendY = DIAGRAM_PADDING2;
6555
6569
  const titleTextWidth = parsed.title ? parsed.title.length * TITLE_FONT_SIZE2 * 0.6 + 16 : 0;
6556
6570
  let legendX = DIAGRAM_PADDING2 + titleTextWidth;
6557
- const groupBg = mix2(palette.surface, palette.bg, isDark ? 35 : 20);
6571
+ const groupBg = isDark ? mix2(palette.surface, palette.bg, 50) : mix2(palette.surface, palette.bg, 30);
6558
6572
  const capsulePad = 4;
6559
6573
  for (const group of parsed.tagGroups) {
6560
6574
  const isActive = activeTagGroup?.toLowerCase() === group.name.toLowerCase();