@diagrammo/dgmo 0.1.7 → 0.2.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.
- package/README.md +19 -19
- package/dist/cli.cjs +1498 -3
- package/dist/index.cjs +453 -475
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -16
- package/dist/index.d.ts +20 -16
- package/dist/index.js +450 -473
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/src/chart.ts +231 -0
- package/src/cli.ts +19 -5
- package/src/dgmo-router.ts +12 -13
- package/src/echarts.ts +590 -0
- package/src/index.ts +6 -7
- package/src/chartjs.ts +0 -784
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A unified diagram markup language — parser, config builder, renderer, and color system.
|
|
4
4
|
|
|
5
|
-
Write simple, readable `.dgmo` text files and render them as charts, diagrams, and visualizations using
|
|
5
|
+
Write simple, readable `.dgmo` text files and render them as charts, diagrams, and visualizations using ECharts, D3, or Mermaid.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -57,7 +57,7 @@ dgmo diagram.dgmo --theme dark --palette catppuccin
|
|
|
57
57
|
|
|
58
58
|
Every `.dgmo` file is plain text with a `chart: <type>` header followed by metadata and data. The library routes each chart type to the right framework and gives you either:
|
|
59
59
|
|
|
60
|
-
- A **framework config object** you render yourself (
|
|
60
|
+
- A **framework config object** you render yourself (ECharts, Mermaid)
|
|
61
61
|
- A **rendered SVG** via D3 or the built-in sequence renderer
|
|
62
62
|
|
|
63
63
|
```
|
|
@@ -70,14 +70,14 @@ All parsers are pure functions with no DOM dependency. Renderers that produce SV
|
|
|
70
70
|
|
|
71
71
|
| Type | Framework | Description |
|
|
72
72
|
|------|-----------|-------------|
|
|
73
|
-
| `bar` |
|
|
74
|
-
| `bar-stacked` |
|
|
75
|
-
| `line` |
|
|
76
|
-
| `area` |
|
|
77
|
-
| `pie` |
|
|
78
|
-
| `doughnut` |
|
|
79
|
-
| `radar` |
|
|
80
|
-
| `polar-area` |
|
|
73
|
+
| `bar` | ECharts | Vertical/horizontal bar charts |
|
|
74
|
+
| `bar-stacked` | ECharts | Stacked bar charts |
|
|
75
|
+
| `line` | ECharts | Line charts with crosshair |
|
|
76
|
+
| `area` | ECharts | Filled area charts |
|
|
77
|
+
| `pie` | ECharts | Pie charts with connector labels |
|
|
78
|
+
| `doughnut` | ECharts | Doughnut charts |
|
|
79
|
+
| `radar` | ECharts | Radar/spider charts |
|
|
80
|
+
| `polar-area` | ECharts | Polar area charts |
|
|
81
81
|
| `scatter` | ECharts | XY scatter with categories and sizing |
|
|
82
82
|
| `sankey` | ECharts | Flow diagrams |
|
|
83
83
|
| `chord` | ECharts | Circular relationship diagrams |
|
|
@@ -94,11 +94,11 @@ All parsers are pure functions with no DOM dependency. Renderers that produce SV
|
|
|
94
94
|
|
|
95
95
|
## Usage
|
|
96
96
|
|
|
97
|
-
###
|
|
97
|
+
### Standard charts (bar, line, pie, radar, etc.)
|
|
98
98
|
|
|
99
99
|
```typescript
|
|
100
|
-
import {
|
|
101
|
-
import
|
|
100
|
+
import { parseChart, buildEChartsOptionFromChart } from '@diagrammo/dgmo';
|
|
101
|
+
import * as echarts from 'echarts';
|
|
102
102
|
|
|
103
103
|
const content = `
|
|
104
104
|
chart: bar
|
|
@@ -112,9 +112,9 @@ Q3: 15
|
|
|
112
112
|
Q4: 22
|
|
113
113
|
`;
|
|
114
114
|
|
|
115
|
-
const parsed =
|
|
116
|
-
const
|
|
117
|
-
|
|
115
|
+
const parsed = parseChart(content, palette.light);
|
|
116
|
+
const option = buildEChartsOptionFromChart(parsed, palette.light, false);
|
|
117
|
+
echarts.init(container).setOption(option);
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### ECharts (scatter, sankey, heatmap, etc.)
|
|
@@ -212,7 +212,7 @@ If you don't know the chart type ahead of time, use the router:
|
|
|
212
212
|
import { parseDgmoChartType, getDgmoFramework } from '@diagrammo/dgmo';
|
|
213
213
|
|
|
214
214
|
const chartType = parseDgmoChartType(content); // e.g. 'bar'
|
|
215
|
-
const framework = getDgmoFramework(chartType); // e.g. '
|
|
215
|
+
const framework = getDgmoFramework(chartType); // e.g. 'echart'
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
Content with `->` arrows and no `chart:` header is automatically detected as a sequence diagram.
|
|
@@ -323,7 +323,7 @@ const svgString = await renderD3ForExport(content, 'light');
|
|
|
323
323
|
|
|
324
324
|
| Export | Description |
|
|
325
325
|
|--------|-------------|
|
|
326
|
-
| `
|
|
326
|
+
| `parseChart(content, colors)` | Parse standard chart types |
|
|
327
327
|
| `parseEChart(content)` | Parse ECharts chart types |
|
|
328
328
|
| `parseD3(content, colors)` | Parse D3 chart types |
|
|
329
329
|
| `parseSequenceDgmo(content)` | Parse sequence diagrams |
|
|
@@ -333,7 +333,7 @@ const svgString = await renderD3ForExport(content, 'light');
|
|
|
333
333
|
|
|
334
334
|
| Export | Description |
|
|
335
335
|
|--------|-------------|
|
|
336
|
-
| `
|
|
336
|
+
| `buildEChartsOptionFromChart(parsed, colors, dark)` | ECharts option object |
|
|
337
337
|
| `buildEChartsOption(parsed, colors, dark)` | ECharts option object |
|
|
338
338
|
| `buildMermaidQuadrant(parsed, colors)` | Mermaid quadrant syntax string |
|
|
339
339
|
|