@diagrammo/dgmo 0.5.5 → 0.6.1
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 +75 -44
- package/dist/cli.cjs +163 -162
- package/dist/index.cjs +556 -589
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -63
- package/dist/index.d.ts +53 -63
- package/dist/index.js +548 -580
- package/dist/index.js.map +1 -1
- package/docs/language-reference.md +27 -1
- package/package.json +1 -1
- package/src/c4/layout.ts +7 -67
- package/src/c4/renderer.ts +122 -119
- package/src/chart.ts +27 -0
- package/src/cli.ts +8 -40
- package/src/d3.ts +72 -52
- package/src/dgmo-router.ts +74 -20
- package/src/echarts.ts +114 -38
- package/src/er/renderer.ts +15 -9
- package/src/index.ts +12 -12
- package/src/infra/compute.ts +1 -21
- package/src/infra/parser.ts +5 -32
- package/src/infra/renderer.ts +28 -164
- package/src/infra/types.ts +1 -11
- package/src/initiative-status/layout.ts +9 -6
- package/src/kanban/renderer.ts +28 -24
- package/src/org/renderer.ts +24 -23
- package/src/render.ts +10 -10
- package/src/sequence/renderer.ts +24 -19
- package/src/sitemap/layout.ts +7 -14
- package/src/sitemap/renderer.ts +30 -29
- package/src/utils/legend-constants.ts +25 -0
package/README.md
CHANGED
|
@@ -58,34 +58,57 @@ dgmo diagram.dgmo --theme dark --palette catppuccin
|
|
|
58
58
|
|
|
59
59
|
## Supported chart types
|
|
60
60
|
|
|
61
|
+
### Data Charts
|
|
62
|
+
|
|
61
63
|
| Type | Description |
|
|
62
64
|
|------|-------------|
|
|
63
|
-
| `arc` | Arc/network diagrams |
|
|
64
|
-
| `area` | Filled area charts |
|
|
65
65
|
| `bar` | Vertical/horizontal bar charts |
|
|
66
|
-
| `bar-stacked` | Stacked bar charts |
|
|
67
|
-
| `chord` | Circular relationship diagrams |
|
|
68
|
-
| `class` | UML class diagrams with inheritance, composition, and visibility |
|
|
69
|
-
| `doughnut` | Doughnut charts |
|
|
70
|
-
| `er` | Entity-relationship diagrams with crow's foot notation |
|
|
71
|
-
| `flowchart` | Directed graph flowcharts with branching and 6 node shapes |
|
|
72
|
-
| `function` | Mathematical function plots |
|
|
73
|
-
| `funnel` | Conversion funnels |
|
|
74
|
-
| `heatmap` | Matrix heatmaps |
|
|
75
66
|
| `line` | Line charts with crosshair |
|
|
76
|
-
| `
|
|
77
|
-
| `org` | Org charts with hierarchy, team containers, and tag group color-coding |
|
|
67
|
+
| `area` | Filled area charts |
|
|
78
68
|
| `pie` | Pie charts with connector labels |
|
|
79
|
-
| `
|
|
80
|
-
| `quadrant` | 2D quadrant scatter |
|
|
69
|
+
| `doughnut` | Doughnut charts |
|
|
81
70
|
| `radar` | Radar/spider charts |
|
|
82
|
-
| `
|
|
71
|
+
| `polar-area` | Polar area charts |
|
|
72
|
+
| `bar-stacked` | Stacked bar charts |
|
|
73
|
+
| `multi-line` | Multi-series line charts |
|
|
83
74
|
| `scatter` | XY scatter with categories and sizing |
|
|
84
|
-
| `
|
|
75
|
+
| `heatmap` | Matrix heatmaps |
|
|
76
|
+
| `funnel` | Conversion funnels |
|
|
77
|
+
| `sankey` | Flow diagrams |
|
|
78
|
+
| `chord` | Circular relationship diagrams |
|
|
79
|
+
|
|
80
|
+
### Visualizations
|
|
81
|
+
|
|
82
|
+
| Type | Description |
|
|
83
|
+
|------|-------------|
|
|
85
84
|
| `slope` | Before/after comparison |
|
|
85
|
+
| `wordcloud` | Weighted text clouds |
|
|
86
|
+
| `arc` | Arc/network diagrams |
|
|
86
87
|
| `timeline` | Timelines with eras and markers |
|
|
87
88
|
| `venn` | Set intersection diagrams |
|
|
88
|
-
| `
|
|
89
|
+
| `quadrant` | 2D quadrant scatter |
|
|
90
|
+
|
|
91
|
+
### Structural Diagrams
|
|
92
|
+
|
|
93
|
+
| Type | Description |
|
|
94
|
+
|------|-------------|
|
|
95
|
+
| `sequence` | Sequence diagrams with type inference |
|
|
96
|
+
| `flowchart` | Directed graph flowcharts with branching and 6 node shapes |
|
|
97
|
+
| `class` | UML class diagrams with inheritance, composition, and visibility |
|
|
98
|
+
| `er` | Entity-relationship diagrams with crow's foot notation |
|
|
99
|
+
| `org` | Org charts with hierarchy, team containers, and tag group color-coding |
|
|
100
|
+
| `c4` | C4 architecture diagrams (context, containers, components, deployment) |
|
|
101
|
+
| `state` | State machine diagrams |
|
|
102
|
+
| `infra` | Infrastructure capacity and latency diagrams |
|
|
103
|
+
| `kanban` | Kanban boards |
|
|
104
|
+
| `initiative-status` | Initiative status and dependency graphs |
|
|
105
|
+
| `sitemap` | Site structure and navigation maps |
|
|
106
|
+
|
|
107
|
+
### Other
|
|
108
|
+
|
|
109
|
+
| Type | Description |
|
|
110
|
+
|------|-------------|
|
|
111
|
+
| `function` | Mathematical function plots |
|
|
89
112
|
|
|
90
113
|
## How it works
|
|
91
114
|
|
|
@@ -102,10 +125,10 @@ All parsers are pure functions with no DOM dependency. The CLI sets up jsdom int
|
|
|
102
125
|
|
|
103
126
|
## Usage
|
|
104
127
|
|
|
105
|
-
###
|
|
128
|
+
### Data charts — standard (bar, line, pie, radar, etc.)
|
|
106
129
|
|
|
107
130
|
```typescript
|
|
108
|
-
import { parseChart,
|
|
131
|
+
import { parseChart, buildSimpleChartOption, getPalette } from '@diagrammo/dgmo';
|
|
109
132
|
import * as echarts from 'echarts';
|
|
110
133
|
|
|
111
134
|
const colors = getPalette('nord').light;
|
|
@@ -123,14 +146,14 @@ Q4: 22
|
|
|
123
146
|
`;
|
|
124
147
|
|
|
125
148
|
const parsed = parseChart(content, colors);
|
|
126
|
-
const option =
|
|
149
|
+
const option = buildSimpleChartOption(parsed, colors, false);
|
|
127
150
|
echarts.init(container).setOption(option);
|
|
128
151
|
```
|
|
129
152
|
|
|
130
|
-
###
|
|
153
|
+
### Data charts — extended (scatter, sankey, heatmap, etc.)
|
|
131
154
|
|
|
132
155
|
```typescript
|
|
133
|
-
import {
|
|
156
|
+
import { parseExtendedChart, buildExtendedChartOption, getPalette } from '@diagrammo/dgmo';
|
|
134
157
|
import * as echarts from 'echarts';
|
|
135
158
|
|
|
136
159
|
const colors = getPalette('nord').light;
|
|
@@ -147,15 +170,15 @@ Electricity -> Industry: 45
|
|
|
147
170
|
Electricity -> Homes: 35
|
|
148
171
|
`;
|
|
149
172
|
|
|
150
|
-
const parsed =
|
|
151
|
-
const option =
|
|
173
|
+
const parsed = parseExtendedChart(content);
|
|
174
|
+
const option = buildExtendedChartOption(parsed, colors, false);
|
|
152
175
|
echarts.init(container).setOption(option);
|
|
153
176
|
```
|
|
154
177
|
|
|
155
|
-
###
|
|
178
|
+
### Visualizations (slope, timeline, wordcloud, etc.)
|
|
156
179
|
|
|
157
180
|
```typescript
|
|
158
|
-
import {
|
|
181
|
+
import { parseVisualization, renderTimeline, getPalette } from '@diagrammo/dgmo';
|
|
159
182
|
|
|
160
183
|
const colors = getPalette('nord').light;
|
|
161
184
|
|
|
@@ -168,7 +191,7 @@ title: Project Milestones
|
|
|
168
191
|
2024-07: Launch
|
|
169
192
|
`;
|
|
170
193
|
|
|
171
|
-
const parsed =
|
|
194
|
+
const parsed = parseVisualization(content, colors);
|
|
172
195
|
renderTimeline(container, parsed, colors, false);
|
|
173
196
|
```
|
|
174
197
|
|
|
@@ -397,10 +420,17 @@ tag: Location alias l
|
|
|
397
420
|
If you don't know the chart type ahead of time, use the router:
|
|
398
421
|
|
|
399
422
|
```typescript
|
|
400
|
-
import { parseDgmoChartType,
|
|
423
|
+
import { parseDgmoChartType, getRenderCategory, isExtendedChartType, parseChart, parseExtendedChart } from '@diagrammo/dgmo';
|
|
401
424
|
|
|
402
425
|
const chartType = parseDgmoChartType(content); // e.g. 'bar'
|
|
403
|
-
const
|
|
426
|
+
const category = getRenderCategory(chartType); // 'data-chart' | 'visualization' | 'diagram' | null
|
|
427
|
+
|
|
428
|
+
// Dispatch within data-chart: standard vs extended parser
|
|
429
|
+
if (isExtendedChartType(chartType)) {
|
|
430
|
+
const parsed = parseExtendedChart(content); // scatter, sankey, heatmap, funnel, chord, function
|
|
431
|
+
} else {
|
|
432
|
+
const parsed = parseChart(content); // bar, line, pie, etc.
|
|
433
|
+
}
|
|
404
434
|
```
|
|
405
435
|
|
|
406
436
|
Content with `->` arrows and no `chart:` header is automatically detected as a sequence diagram.
|
|
@@ -502,13 +532,13 @@ const css = buildThemeCSS(palette.light); // complete CSS string
|
|
|
502
532
|
Render any chart to an SVG string without a visible DOM:
|
|
503
533
|
|
|
504
534
|
```typescript
|
|
505
|
-
import {
|
|
535
|
+
import { renderForExport, renderExtendedChartForExport } from '@diagrammo/dgmo';
|
|
506
536
|
|
|
507
|
-
//
|
|
508
|
-
const svg = await
|
|
537
|
+
// Diagrams, visualizations, and sequence charts
|
|
538
|
+
const svg = await renderForExport(content, 'light');
|
|
509
539
|
|
|
510
|
-
//
|
|
511
|
-
const svg = await
|
|
540
|
+
// Data charts (bar, line, scatter, sankey, etc.)
|
|
541
|
+
const svg = await renderExtendedChartForExport(content, 'light');
|
|
512
542
|
```
|
|
513
543
|
|
|
514
544
|
Both accept an optional third argument for a custom `PaletteColors` object (defaults to Nord).
|
|
@@ -520,16 +550,17 @@ Both accept an optional third argument for a custom `PaletteColors` object (defa
|
|
|
520
550
|
| Export | Description |
|
|
521
551
|
|--------|-------------|
|
|
522
552
|
| `parseDgmoChartType(content)` | Extract chart type from content (infers `sequence` from arrow syntax) |
|
|
523
|
-
| `
|
|
524
|
-
| `
|
|
553
|
+
| `getRenderCategory(type)` | Map chart type → `'data-chart'` \| `'visualization'` \| `'diagram'` \| `null` |
|
|
554
|
+
| `isExtendedChartType(type)` | Returns `true` for extended data-chart types (scatter, sankey, chord, function, heatmap, funnel) |
|
|
555
|
+
| `RenderCategory` | Type alias for `'data-chart' \| 'visualization' \| 'diagram'` |
|
|
525
556
|
|
|
526
557
|
### Parsers
|
|
527
558
|
|
|
528
559
|
| Export | Description |
|
|
529
560
|
|--------|-------------|
|
|
530
|
-
| `parseChart(content, colors)` | Parse standard chart types (bar, line, pie, radar, etc.) |
|
|
531
|
-
| `
|
|
532
|
-
| `
|
|
561
|
+
| `parseChart(content, colors)` | Parse standard data-chart types (bar, line, pie, radar, etc.) |
|
|
562
|
+
| `parseExtendedChart(content)` | Parse extended data-chart types (scatter, sankey, heatmap, etc.) |
|
|
563
|
+
| `parseVisualization(content, colors)` | Parse visualization types (slope, arc, timeline, etc.) |
|
|
533
564
|
| `parseSequenceDgmo(content)` | Parse sequence diagrams |
|
|
534
565
|
| `parseFlowchart(content, colors)` | Parse flowchart diagrams |
|
|
535
566
|
| `parseClassDiagram(content, colors)` | Parse class diagrams |
|
|
@@ -541,8 +572,8 @@ Both accept an optional third argument for a custom `PaletteColors` object (defa
|
|
|
541
572
|
|
|
542
573
|
| Export | Description |
|
|
543
574
|
|--------|-------------|
|
|
544
|
-
| `
|
|
545
|
-
| `
|
|
575
|
+
| `buildSimpleChartOption(parsed, colors, dark)` | ECharts option from `parseChart` result (bar, line, pie, etc.) |
|
|
576
|
+
| `buildExtendedChartOption(parsed, colors, dark)` | ECharts option from `parseExtendedChart` result (scatter, sankey, etc.) |
|
|
546
577
|
| `buildMermaidQuadrant(parsed, colors)` | Mermaid quadrantChart syntax string |
|
|
547
578
|
|
|
548
579
|
### Renderers
|
|
@@ -563,8 +594,8 @@ Both accept an optional third argument for a custom `PaletteColors` object (defa
|
|
|
563
594
|
| `layoutERDiagram(parsed)` | Compute ER diagram node positions |
|
|
564
595
|
| `layoutGraph(parsed)` | Compute flowchart node positions |
|
|
565
596
|
| `renderSequenceDiagram(el, parsed, colors, dark, onClick)` | Sequence diagram SVG |
|
|
566
|
-
| `
|
|
567
|
-
| `
|
|
597
|
+
| `renderForExport(content, theme, palette?)` | Any diagram or visualization → SVG string |
|
|
598
|
+
| `renderExtendedChartForExport(content, theme, palette?)` | Any data-chart → SVG string |
|
|
568
599
|
|
|
569
600
|
### Sequence internals
|
|
570
601
|
|