@diagrammo/dgmo 0.6.3 → 0.7.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.
@@ -16,6 +16,7 @@ import { parseC4 } from './c4/parser';
16
16
  import { looksLikeInitiativeStatus, parseInitiativeStatus } from './initiative-status/parser';
17
17
  import { looksLikeSitemap, parseSitemap } from './sitemap/parser';
18
18
  import { parseInfra } from './infra/parser';
19
+ import { parseGantt } from './gantt/parser';
19
20
  import type { DgmoError } from './diagnostics';
20
21
 
21
22
  /**
@@ -65,7 +66,7 @@ const VISUALIZATION_TYPES = new Set([
65
66
  ]);
66
67
  const DIAGRAM_TYPES = new Set([
67
68
  'sequence', 'flowchart', 'class', 'er', 'org', 'kanban', 'c4',
68
- 'initiative-status', 'state', 'sitemap', 'infra',
69
+ 'initiative-status', 'state', 'sitemap', 'infra', 'gantt',
69
70
  ]);
70
71
  const EXTENDED_CHART_TYPES = new Set([
71
72
  'scatter', 'sankey', 'chord', 'function', 'heatmap', 'funnel',
@@ -128,6 +129,7 @@ const PARSE_DISPATCH = new Map<string, (content: string) => { diagnostics: DgmoE
128
129
  ['state', (c) => parseState(c)],
129
130
  ['sitemap', (c) => parseSitemap(c)],
130
131
  ['infra', (c) => parseInfra(c)],
132
+ ['gantt', (c) => parseGantt(c)],
131
133
  ]);
132
134
 
133
135
  /**
@@ -224,7 +224,13 @@ export function renderERDiagram(
224
224
 
225
225
  const useSemanticColors =
226
226
  parsed.tagGroups.length === 0 && layout.nodes.every((n) => !n.color);
227
- const legendReserveH = useSemanticColors ? LEGEND_HEIGHT + DIAGRAM_PADDING : 0;
227
+ const LEGEND_FIXED_GAP = 8;
228
+ const hasTagLegend = parsed.tagGroups.length > 0;
229
+ const legendReserveH = useSemanticColors
230
+ ? LEGEND_HEIGHT + LEGEND_FIXED_GAP
231
+ : hasTagLegend
232
+ ? LEGEND_HEIGHT + LEGEND_FIXED_GAP
233
+ : 0;
228
234
 
229
235
  const titleHeight = parsed.title ? 40 : 0;
230
236
  const diagramW = layout.width;
@@ -254,13 +260,13 @@ export function renderERDiagram(
254
260
  scale = Math.min(MAX_SCALE, scaleX, scaleY);
255
261
  const scaledW = diagramW * scale;
256
262
  offsetX = (viewW - scaledW) / 2;
257
- offsetY = titleHeight + DIAGRAM_PADDING;
263
+ offsetY = titleHeight + legendReserveH + DIAGRAM_PADDING;
258
264
  } else {
259
265
  viewW = naturalW;
260
266
  viewH = naturalH;
261
267
  scale = 1;
262
268
  offsetX = DIAGRAM_PADDING;
263
- offsetY = titleHeight + DIAGRAM_PADDING;
269
+ offsetY = titleHeight + legendReserveH + DIAGRAM_PADDING;
264
270
  }
265
271
 
266
272
  if (viewW <= 0 || viewH <= 0) return;
@@ -521,7 +527,7 @@ export function renderERDiagram(
521
527
  }
522
528
 
523
529
  let legendX = DIAGRAM_PADDING;
524
- let legendY = viewH - DIAGRAM_PADDING;
530
+ let legendY = DIAGRAM_PADDING + titleHeight;
525
531
 
526
532
  for (const group of parsed.tagGroups) {
527
533
  const groupG = legendG.append('g')
@@ -639,7 +645,7 @@ export function renderERDiagram(
639
645
  }
640
646
 
641
647
  const legendX = (viewW - totalWidth) / 2;
642
- const legendY = viewH - DIAGRAM_PADDING - LEGEND_HEIGHT;
648
+ const legendY = DIAGRAM_PADDING + titleHeight;
643
649
 
644
650
  const semanticLegendG = svg
645
651
  .append('g')