@diagrammo/dgmo 0.5.4 → 0.6.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 +75 -44
- package/dist/cli.cjs +141 -141
- package/dist/index.cjs +197 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -44
- package/dist/index.d.ts +49 -44
- package/dist/index.js +189 -90
- package/dist/index.js.map +1 -1
- package/docs/language-reference.md +27 -1
- package/package.json +1 -1
- package/src/chart.ts +27 -0
- package/src/cli.ts +2 -2
- package/src/d3.ts +19 -24
- package/src/dgmo-router.ts +74 -20
- package/src/echarts.ts +110 -34
- package/src/index.ts +10 -10
- package/src/render.ts +8 -8
package/dist/index.js
CHANGED
|
@@ -3640,9 +3640,11 @@ var init_parser3 = __esm({
|
|
|
3640
3640
|
// src/chart.ts
|
|
3641
3641
|
function parseChart(content, palette) {
|
|
3642
3642
|
const lines = content.split("\n");
|
|
3643
|
+
const parsedEras = [];
|
|
3643
3644
|
const result = {
|
|
3644
3645
|
type: "bar",
|
|
3645
3646
|
data: [],
|
|
3647
|
+
eras: parsedEras,
|
|
3646
3648
|
diagnostics: [],
|
|
3647
3649
|
error: null
|
|
3648
3650
|
};
|
|
@@ -3661,6 +3663,16 @@ function parseChart(content, palette) {
|
|
|
3661
3663
|
continue;
|
|
3662
3664
|
}
|
|
3663
3665
|
if (trimmed.startsWith("//")) continue;
|
|
3666
|
+
const eraMatch = trimmed.match(/^era\s+(.+?)\s*->\s*(.+?)\s*:\s*(.+?)(?:\s*\(([^)]+)\))?\s*$/);
|
|
3667
|
+
if (eraMatch) {
|
|
3668
|
+
parsedEras.push({
|
|
3669
|
+
start: eraMatch[1].trim(),
|
|
3670
|
+
end: eraMatch[2].trim(),
|
|
3671
|
+
label: eraMatch[3].trim(),
|
|
3672
|
+
color: eraMatch[4] ? resolveColor(eraMatch[4].trim(), palette) : null
|
|
3673
|
+
});
|
|
3674
|
+
continue;
|
|
3675
|
+
}
|
|
3664
3676
|
const colonIndex = trimmed.indexOf(":");
|
|
3665
3677
|
if (colonIndex === -1) continue;
|
|
3666
3678
|
const key = trimmed.substring(0, colonIndex).trim().toLowerCase();
|
|
@@ -3739,6 +3751,9 @@ function parseChart(content, palette) {
|
|
|
3739
3751
|
});
|
|
3740
3752
|
}
|
|
3741
3753
|
}
|
|
3754
|
+
if (result.type !== "line" && result.type !== "area") {
|
|
3755
|
+
result.eras = void 0;
|
|
3756
|
+
}
|
|
3742
3757
|
const setChartError = (line10, message) => {
|
|
3743
3758
|
const diag = makeDgmoError(line10, message);
|
|
3744
3759
|
result.diagnostics.push(diag);
|
|
@@ -3793,7 +3808,7 @@ var init_chart = __esm({
|
|
|
3793
3808
|
|
|
3794
3809
|
// src/echarts.ts
|
|
3795
3810
|
import * as echarts from "echarts";
|
|
3796
|
-
function
|
|
3811
|
+
function parseExtendedChart(content, palette) {
|
|
3797
3812
|
const lines = content.split("\n");
|
|
3798
3813
|
const result = {
|
|
3799
3814
|
type: "scatter",
|
|
@@ -4062,7 +4077,7 @@ function buildChartCommons(parsed, palette, isDark) {
|
|
|
4062
4077
|
const tooltipTheme = { backgroundColor: palette.surface, borderColor: palette.border, textStyle: { color: palette.text } };
|
|
4063
4078
|
return { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme };
|
|
4064
4079
|
}
|
|
4065
|
-
function
|
|
4080
|
+
function buildExtendedChartOption(parsed, palette, isDark) {
|
|
4066
4081
|
if (parsed.error) {
|
|
4067
4082
|
return {};
|
|
4068
4083
|
}
|
|
@@ -4734,7 +4749,7 @@ function resolveAxisLabels(parsed) {
|
|
|
4734
4749
|
yLabel: parsed.ylabel ?? (isHorizontal ? void 0 : parsed.label)
|
|
4735
4750
|
};
|
|
4736
4751
|
}
|
|
4737
|
-
function makeGridAxis(type, textColor, axisLineColor, splitLineColor, gridOpacity, label, data, nameGapOverride, chartWidthHint) {
|
|
4752
|
+
function makeGridAxis(type, textColor, axisLineColor, splitLineColor, gridOpacity, label, data, nameGapOverride, chartWidthHint, intervalOverride) {
|
|
4738
4753
|
const defaultGap = type === "value" ? 75 : 40;
|
|
4739
4754
|
let catFontSize = 16;
|
|
4740
4755
|
let catLabelExtras = {};
|
|
@@ -4761,7 +4776,7 @@ function makeGridAxis(type, textColor, axisLineColor, splitLineColor, gridOpacit
|
|
|
4761
4776
|
fontSize: type === "category" && data ? catFontSize : 16,
|
|
4762
4777
|
fontFamily: FONT_FAMILY,
|
|
4763
4778
|
...type === "category" && {
|
|
4764
|
-
interval: 0,
|
|
4779
|
+
interval: intervalOverride ?? 0,
|
|
4765
4780
|
formatter: (value) => value.replace(/([a-z])([A-Z])/g, "$1\n$2"),
|
|
4766
4781
|
...catLabelExtras
|
|
4767
4782
|
}
|
|
@@ -4775,7 +4790,7 @@ function makeGridAxis(type, textColor, axisLineColor, splitLineColor, gridOpacit
|
|
|
4775
4790
|
}
|
|
4776
4791
|
};
|
|
4777
4792
|
}
|
|
4778
|
-
function
|
|
4793
|
+
function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
4779
4794
|
if (parsed.error) return {};
|
|
4780
4795
|
const { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme } = buildChartCommons(parsed, palette, isDark);
|
|
4781
4796
|
switch (parsed.type) {
|
|
@@ -4784,7 +4799,7 @@ function buildEChartsOptionFromChart(parsed, palette, isDark, chartWidth) {
|
|
|
4784
4799
|
case "bar-stacked":
|
|
4785
4800
|
return buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth);
|
|
4786
4801
|
case "line":
|
|
4787
|
-
return parsed.seriesNames ? buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth) : buildLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig, tooltipTheme, chartWidth);
|
|
4802
|
+
return parsed.seriesNames ? buildMultiLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth) : buildLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig, tooltipTheme, chartWidth);
|
|
4788
4803
|
case "area":
|
|
4789
4804
|
return buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig, tooltipTheme, chartWidth);
|
|
4790
4805
|
case "pie":
|
|
@@ -4837,11 +4852,57 @@ function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOp
|
|
|
4837
4852
|
]
|
|
4838
4853
|
};
|
|
4839
4854
|
}
|
|
4855
|
+
function buildIntervalCallback(labels, eras) {
|
|
4856
|
+
const count = labels.length;
|
|
4857
|
+
if (count <= 8) return () => true;
|
|
4858
|
+
const snapSteps = [1, 2, 4, 5, 10, 20, 25, 50];
|
|
4859
|
+
const raw = Math.ceil(count / 8);
|
|
4860
|
+
const N = [...snapSteps].reverse().find((s) => s <= raw) ?? 1;
|
|
4861
|
+
const pinned = /* @__PURE__ */ new Set();
|
|
4862
|
+
for (let i = 0; i < count; i += N) pinned.add(i);
|
|
4863
|
+
for (const era of eras) {
|
|
4864
|
+
const si = labels.indexOf(era.start);
|
|
4865
|
+
const ei = labels.indexOf(era.end);
|
|
4866
|
+
if (si >= 0) pinned.add(si);
|
|
4867
|
+
if (ei >= 0) pinned.add(ei);
|
|
4868
|
+
}
|
|
4869
|
+
return (index) => pinned.has(index);
|
|
4870
|
+
}
|
|
4871
|
+
function buildMarkArea(eras, labels, textColor, defaultColor) {
|
|
4872
|
+
if (eras.length === 0) return void 0;
|
|
4873
|
+
return {
|
|
4874
|
+
silent: false,
|
|
4875
|
+
tooltip: { show: true },
|
|
4876
|
+
data: eras.map((era) => {
|
|
4877
|
+
const startIdx = labels.indexOf(era.start);
|
|
4878
|
+
const endIdx = labels.indexOf(era.end);
|
|
4879
|
+
const bandSlots = startIdx >= 0 && endIdx >= 0 ? endIdx - startIdx : Infinity;
|
|
4880
|
+
const color = era.color ?? defaultColor;
|
|
4881
|
+
return [
|
|
4882
|
+
{
|
|
4883
|
+
name: era.label,
|
|
4884
|
+
xAxis: era.start,
|
|
4885
|
+
itemStyle: { color, opacity: 0.15 },
|
|
4886
|
+
label: {
|
|
4887
|
+
show: bandSlots >= 3,
|
|
4888
|
+
position: "insideTop",
|
|
4889
|
+
fontSize: 11,
|
|
4890
|
+
color: textColor
|
|
4891
|
+
}
|
|
4892
|
+
},
|
|
4893
|
+
{ xAxis: era.end }
|
|
4894
|
+
];
|
|
4895
|
+
})
|
|
4896
|
+
};
|
|
4897
|
+
}
|
|
4840
4898
|
function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig, tooltipTheme, chartWidth) {
|
|
4841
4899
|
const { xLabel, yLabel } = resolveAxisLabels(parsed);
|
|
4842
4900
|
const lineColor = parsed.color ?? parsed.seriesNameColors?.[0] ?? palette.primary;
|
|
4843
4901
|
const labels = parsed.data.map((d) => d.label);
|
|
4844
4902
|
const values = parsed.data.map((d) => d.value);
|
|
4903
|
+
const eras = parsed.eras ?? [];
|
|
4904
|
+
const interval = buildIntervalCallback(labels, eras);
|
|
4905
|
+
const markArea = buildMarkArea(eras, labels, textColor, palette.colors.blue);
|
|
4845
4906
|
return {
|
|
4846
4907
|
...CHART_BASE,
|
|
4847
4908
|
title: titleConfig,
|
|
@@ -4851,7 +4912,7 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
4851
4912
|
axisPointer: { type: "line" }
|
|
4852
4913
|
},
|
|
4853
4914
|
grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
|
|
4854
|
-
xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
|
|
4915
|
+
xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth, interval),
|
|
4855
4916
|
yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
|
|
4856
4917
|
series: [
|
|
4857
4918
|
{
|
|
@@ -4861,15 +4922,19 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
4861
4922
|
symbolSize: 8,
|
|
4862
4923
|
lineStyle: { color: lineColor, width: 3 },
|
|
4863
4924
|
itemStyle: { color: lineColor },
|
|
4864
|
-
emphasis: EMPHASIS_SELF
|
|
4925
|
+
emphasis: EMPHASIS_SELF,
|
|
4926
|
+
...markArea && { markArea }
|
|
4865
4927
|
}
|
|
4866
4928
|
]
|
|
4867
4929
|
};
|
|
4868
4930
|
}
|
|
4869
|
-
function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth) {
|
|
4931
|
+
function buildMultiLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth) {
|
|
4870
4932
|
const { xLabel, yLabel } = resolveAxisLabels(parsed);
|
|
4871
4933
|
const seriesNames = parsed.seriesNames ?? [];
|
|
4872
4934
|
const labels = parsed.data.map((d) => d.label);
|
|
4935
|
+
const eras = parsed.eras ?? [];
|
|
4936
|
+
const interval = buildIntervalCallback(labels, eras);
|
|
4937
|
+
const markArea = buildMarkArea(eras, labels, textColor, palette.colors.blue);
|
|
4873
4938
|
const series = seriesNames.map((name, idx) => {
|
|
4874
4939
|
const color = parsed.seriesNameColors?.[idx] ?? colors[idx % colors.length];
|
|
4875
4940
|
const data = parsed.data.map(
|
|
@@ -4883,7 +4948,8 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
|
|
|
4883
4948
|
symbolSize: 8,
|
|
4884
4949
|
lineStyle: { color, width: 3 },
|
|
4885
4950
|
itemStyle: { color },
|
|
4886
|
-
emphasis: EMPHASIS_SELF
|
|
4951
|
+
emphasis: EMPHASIS_SELF,
|
|
4952
|
+
...idx === 0 && markArea && { markArea }
|
|
4887
4953
|
};
|
|
4888
4954
|
});
|
|
4889
4955
|
return {
|
|
@@ -4900,7 +4966,7 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
|
|
|
4900
4966
|
textStyle: { color: textColor }
|
|
4901
4967
|
},
|
|
4902
4968
|
grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title, hasLegend: true }),
|
|
4903
|
-
xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
|
|
4969
|
+
xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth, interval),
|
|
4904
4970
|
yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
|
|
4905
4971
|
series
|
|
4906
4972
|
};
|
|
@@ -4910,6 +4976,9 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
4910
4976
|
const lineColor = parsed.color ?? parsed.seriesNameColors?.[0] ?? palette.primary;
|
|
4911
4977
|
const labels = parsed.data.map((d) => d.label);
|
|
4912
4978
|
const values = parsed.data.map((d) => d.value);
|
|
4979
|
+
const eras = parsed.eras ?? [];
|
|
4980
|
+
const interval = buildIntervalCallback(labels, eras);
|
|
4981
|
+
const markArea = buildMarkArea(eras, labels, textColor, palette.colors.blue);
|
|
4913
4982
|
return {
|
|
4914
4983
|
...CHART_BASE,
|
|
4915
4984
|
title: titleConfig,
|
|
@@ -4919,7 +4988,7 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
4919
4988
|
axisPointer: { type: "line" }
|
|
4920
4989
|
},
|
|
4921
4990
|
grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
|
|
4922
|
-
xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
|
|
4991
|
+
xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth, interval),
|
|
4923
4992
|
yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
|
|
4924
4993
|
series: [
|
|
4925
4994
|
{
|
|
@@ -4930,7 +4999,8 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
4930
4999
|
lineStyle: { color: lineColor, width: 3 },
|
|
4931
5000
|
itemStyle: { color: lineColor },
|
|
4932
5001
|
areaStyle: { opacity: 0.25 },
|
|
4933
|
-
emphasis: EMPHASIS_SELF
|
|
5002
|
+
emphasis: EMPHASIS_SELF,
|
|
5003
|
+
...markArea && { markArea }
|
|
4934
5004
|
}
|
|
4935
5005
|
]
|
|
4936
5006
|
};
|
|
@@ -5115,7 +5185,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
|
|
|
5115
5185
|
series
|
|
5116
5186
|
};
|
|
5117
5187
|
}
|
|
5118
|
-
async function
|
|
5188
|
+
async function renderExtendedChartForExport(content, theme, palette, options) {
|
|
5119
5189
|
const isDark = theme === "dark";
|
|
5120
5190
|
const { getPalette: getPalette2 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
|
|
5121
5191
|
const effectivePalette = palette ?? (isDark ? getPalette2("nord").dark : getPalette2("nord").light);
|
|
@@ -5125,11 +5195,11 @@ async function renderEChartsForExport(content, theme, palette, options) {
|
|
|
5125
5195
|
if (chartType && STANDARD_CHART_TYPES.has(chartType)) {
|
|
5126
5196
|
const parsed = parseChart(content, effectivePalette);
|
|
5127
5197
|
if (parsed.error) return "";
|
|
5128
|
-
option =
|
|
5198
|
+
option = buildSimpleChartOption(parsed, effectivePalette, isDark, ECHART_EXPORT_WIDTH);
|
|
5129
5199
|
} else {
|
|
5130
|
-
const parsed =
|
|
5200
|
+
const parsed = parseExtendedChart(content, effectivePalette);
|
|
5131
5201
|
if (parsed.error) return "";
|
|
5132
|
-
option =
|
|
5202
|
+
option = buildExtendedChartOption(parsed, effectivePalette, isDark);
|
|
5133
5203
|
}
|
|
5134
5204
|
if (!option || Object.keys(option).length === 0) return "";
|
|
5135
5205
|
const chart = echarts.init(null, null, {
|
|
@@ -5156,7 +5226,7 @@ async function renderEChartsForExport(content, theme, palette, options) {
|
|
|
5156
5226
|
chart.dispose();
|
|
5157
5227
|
}
|
|
5158
5228
|
}
|
|
5159
|
-
var EMPHASIS_SELF, CHART_BASE, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT;
|
|
5229
|
+
var EMPHASIS_SELF, CHART_BASE, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT, STANDARD_CHART_TYPES;
|
|
5160
5230
|
var init_echarts = __esm({
|
|
5161
5231
|
"src/echarts.ts"() {
|
|
5162
5232
|
"use strict";
|
|
@@ -5167,11 +5237,21 @@ var init_echarts = __esm({
|
|
|
5167
5237
|
init_diagnostics();
|
|
5168
5238
|
init_colors();
|
|
5169
5239
|
init_parsing();
|
|
5170
|
-
init_dgmo_router();
|
|
5171
5240
|
EMPHASIS_SELF = { focus: "self", blurScope: "global" };
|
|
5172
5241
|
CHART_BASE = { backgroundColor: "transparent", animation: false };
|
|
5173
5242
|
ECHART_EXPORT_WIDTH = 1200;
|
|
5174
5243
|
ECHART_EXPORT_HEIGHT = 800;
|
|
5244
|
+
STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
5245
|
+
"bar",
|
|
5246
|
+
"line",
|
|
5247
|
+
"multi-line",
|
|
5248
|
+
"area",
|
|
5249
|
+
"pie",
|
|
5250
|
+
"doughnut",
|
|
5251
|
+
"radar",
|
|
5252
|
+
"polar-area",
|
|
5253
|
+
"bar-stacked"
|
|
5254
|
+
]);
|
|
5175
5255
|
}
|
|
5176
5256
|
});
|
|
5177
5257
|
|
|
@@ -7329,15 +7409,12 @@ var init_parser9 = __esm({
|
|
|
7329
7409
|
// src/dgmo-router.ts
|
|
7330
7410
|
var dgmo_router_exports = {};
|
|
7331
7411
|
__export(dgmo_router_exports, {
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7412
|
+
getAllChartTypes: () => getAllChartTypes,
|
|
7413
|
+
getRenderCategory: () => getRenderCategory,
|
|
7414
|
+
isExtendedChartType: () => isExtendedChartType,
|
|
7335
7415
|
parseDgmo: () => parseDgmo,
|
|
7336
7416
|
parseDgmoChartType: () => parseDgmoChartType
|
|
7337
7417
|
});
|
|
7338
|
-
function getDgmoFramework(chartType) {
|
|
7339
|
-
return DGMO_CHART_TYPE_MAP[chartType.toLowerCase()] ?? null;
|
|
7340
|
-
}
|
|
7341
7418
|
function parseDgmoChartType(content) {
|
|
7342
7419
|
const lines = content.split("\n");
|
|
7343
7420
|
for (const line10 of lines) {
|
|
@@ -7357,22 +7434,39 @@ function parseDgmoChartType(content) {
|
|
|
7357
7434
|
if (looksLikeOrg(content)) return "org";
|
|
7358
7435
|
return null;
|
|
7359
7436
|
}
|
|
7437
|
+
function getRenderCategory(chartType) {
|
|
7438
|
+
const type = chartType.toLowerCase();
|
|
7439
|
+
if (DATA_CHART_TYPES.has(type)) return "data-chart";
|
|
7440
|
+
if (VISUALIZATION_TYPES.has(type)) return "visualization";
|
|
7441
|
+
if (DIAGRAM_TYPES.has(type)) return "diagram";
|
|
7442
|
+
return null;
|
|
7443
|
+
}
|
|
7444
|
+
function isExtendedChartType(chartType) {
|
|
7445
|
+
return EXTENDED_CHART_TYPES.has(chartType.toLowerCase());
|
|
7446
|
+
}
|
|
7447
|
+
function getAllChartTypes() {
|
|
7448
|
+
return [
|
|
7449
|
+
...DATA_CHART_TYPES,
|
|
7450
|
+
...VISUALIZATION_TYPES,
|
|
7451
|
+
...DIAGRAM_TYPES
|
|
7452
|
+
];
|
|
7453
|
+
}
|
|
7360
7454
|
function parseDgmo(content) {
|
|
7361
7455
|
const chartType = parseDgmoChartType(content);
|
|
7362
7456
|
if (!chartType) {
|
|
7363
|
-
return { diagnostics:
|
|
7457
|
+
return { diagnostics: parseVisualization(content).diagnostics };
|
|
7364
7458
|
}
|
|
7365
7459
|
const directParser = PARSE_DISPATCH.get(chartType);
|
|
7366
7460
|
if (directParser) return { diagnostics: directParser(content).diagnostics };
|
|
7367
|
-
if (
|
|
7461
|
+
if (STANDARD_CHART_TYPES2.has(chartType)) {
|
|
7368
7462
|
return { diagnostics: parseChart(content).diagnostics };
|
|
7369
7463
|
}
|
|
7370
7464
|
if (ECHART_TYPES.has(chartType)) {
|
|
7371
|
-
return { diagnostics:
|
|
7465
|
+
return { diagnostics: parseExtendedChart(content).diagnostics };
|
|
7372
7466
|
}
|
|
7373
|
-
return { diagnostics:
|
|
7467
|
+
return { diagnostics: parseVisualization(content).diagnostics };
|
|
7374
7468
|
}
|
|
7375
|
-
var
|
|
7469
|
+
var DATA_CHART_TYPES, VISUALIZATION_TYPES, DIAGRAM_TYPES, EXTENDED_CHART_TYPES, STANDARD_CHART_TYPES2, ECHART_TYPES, PARSE_DISPATCH;
|
|
7376
7470
|
var init_dgmo_router = __esm({
|
|
7377
7471
|
"src/dgmo-router.ts"() {
|
|
7378
7472
|
"use strict";
|
|
@@ -7390,44 +7484,53 @@ var init_dgmo_router = __esm({
|
|
|
7390
7484
|
init_parser7();
|
|
7391
7485
|
init_parser8();
|
|
7392
7486
|
init_parser9();
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
"
|
|
7398
|
-
area
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
"
|
|
7403
|
-
"
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
"
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7487
|
+
DATA_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
7488
|
+
"bar",
|
|
7489
|
+
"line",
|
|
7490
|
+
"pie",
|
|
7491
|
+
"doughnut",
|
|
7492
|
+
"area",
|
|
7493
|
+
"polar-area",
|
|
7494
|
+
"radar",
|
|
7495
|
+
"bar-stacked",
|
|
7496
|
+
"multi-line",
|
|
7497
|
+
"scatter",
|
|
7498
|
+
"sankey",
|
|
7499
|
+
"chord",
|
|
7500
|
+
"function",
|
|
7501
|
+
"heatmap",
|
|
7502
|
+
"funnel"
|
|
7503
|
+
]);
|
|
7504
|
+
VISUALIZATION_TYPES = /* @__PURE__ */ new Set([
|
|
7505
|
+
"slope",
|
|
7506
|
+
"wordcloud",
|
|
7507
|
+
"arc",
|
|
7508
|
+
"timeline",
|
|
7509
|
+
"venn",
|
|
7510
|
+
"quadrant"
|
|
7511
|
+
]);
|
|
7512
|
+
DIAGRAM_TYPES = /* @__PURE__ */ new Set([
|
|
7513
|
+
"sequence",
|
|
7514
|
+
"flowchart",
|
|
7515
|
+
"class",
|
|
7516
|
+
"er",
|
|
7517
|
+
"org",
|
|
7518
|
+
"kanban",
|
|
7519
|
+
"c4",
|
|
7520
|
+
"initiative-status",
|
|
7521
|
+
"state",
|
|
7522
|
+
"sitemap",
|
|
7523
|
+
"infra"
|
|
7524
|
+
]);
|
|
7525
|
+
EXTENDED_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
7526
|
+
"scatter",
|
|
7527
|
+
"sankey",
|
|
7528
|
+
"chord",
|
|
7529
|
+
"function",
|
|
7530
|
+
"heatmap",
|
|
7531
|
+
"funnel"
|
|
7532
|
+
]);
|
|
7533
|
+
STANDARD_CHART_TYPES2 = /* @__PURE__ */ new Set([
|
|
7431
7534
|
"bar",
|
|
7432
7535
|
"line",
|
|
7433
7536
|
"multi-line",
|
|
@@ -18505,7 +18608,7 @@ function addDurationToDate(startDate, amount, unit) {
|
|
|
18505
18608
|
return `${endYear}-${endMonth}-${endDay}`;
|
|
18506
18609
|
}
|
|
18507
18610
|
}
|
|
18508
|
-
function
|
|
18611
|
+
function parseVisualization(content, palette) {
|
|
18509
18612
|
const result = {
|
|
18510
18613
|
type: null,
|
|
18511
18614
|
title: null,
|
|
@@ -20951,7 +21054,7 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
|
|
|
20951
21054
|
const circleEls = [];
|
|
20952
21055
|
const circleGroup = svg.append("g");
|
|
20953
21056
|
circles.forEach((c, i) => {
|
|
20954
|
-
const el = circleGroup.append("circle").attr("cx", c.x).attr("cy", c.y).attr("r", c.r).attr("fill", setColors[i]).attr("fill-opacity", 0.35).attr("stroke", setColors[i]).attr("stroke-width", 2).
|
|
21057
|
+
const el = circleGroup.append("circle").attr("cx", c.x).attr("cy", c.y).attr("r", c.r).attr("fill", setColors[i]).attr("fill-opacity", 0.35).attr("stroke", setColors[i]).attr("stroke-width", 2).style("pointer-events", "none");
|
|
20955
21058
|
circleEls.push(el);
|
|
20956
21059
|
});
|
|
20957
21060
|
const defs = svg.append("defs");
|
|
@@ -20986,10 +21089,7 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
|
|
|
20986
21089
|
);
|
|
20987
21090
|
regionLineNumber = ov?.lineNumber ?? null;
|
|
20988
21091
|
}
|
|
20989
|
-
const el = overlayGroup.append("rect").attr("x", 0).attr("y", 0).attr("width", width).attr("height", height).attr("fill", "white").attr("fill-opacity", 0).attr("class", "venn-region-overlay").attr("clip-path", `url(#${clipId})`);
|
|
20990
|
-
if (regionLineNumber != null) {
|
|
20991
|
-
el.attr("data-line-number", String(regionLineNumber));
|
|
20992
|
-
}
|
|
21092
|
+
const el = overlayGroup.append("rect").attr("x", 0).attr("y", 0).attr("width", width).attr("height", height).attr("fill", "white").attr("fill-opacity", 0).attr("class", "venn-region-overlay").attr("data-line-number", regionLineNumber != null ? String(regionLineNumber) : "0").attr("clip-path", `url(#${clipId})`);
|
|
20993
21093
|
if (excluded.length > 0) {
|
|
20994
21094
|
const maskId = `vvm-${key}`;
|
|
20995
21095
|
const mask = defs.append("mask").attr("id", maskId);
|
|
@@ -21003,7 +21103,7 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
|
|
|
21003
21103
|
}
|
|
21004
21104
|
const showRegionOverlay = (idxs) => {
|
|
21005
21105
|
const key = [...idxs].sort((a, b) => a - b).join("-");
|
|
21006
|
-
overlayEls.forEach((el, k) => el.attr("fill-opacity", k === key ? 0
|
|
21106
|
+
overlayEls.forEach((el, k) => el.attr("fill-opacity", k === key ? 0 : 0.55));
|
|
21007
21107
|
};
|
|
21008
21108
|
const hideAllOverlays = () => {
|
|
21009
21109
|
overlayEls.forEach((el) => el.attr("fill-opacity", 0));
|
|
@@ -21462,7 +21562,7 @@ function finalizeSvgExport(container, theme, palette, options) {
|
|
|
21462
21562
|
}
|
|
21463
21563
|
return svgHtml;
|
|
21464
21564
|
}
|
|
21465
|
-
async function
|
|
21565
|
+
async function renderForExport(content, theme, palette, orgExportState, options) {
|
|
21466
21566
|
const { parseDgmoChartType: parseDgmoChartType2 } = await Promise.resolve().then(() => (init_dgmo_router(), dgmo_router_exports));
|
|
21467
21567
|
const detectedType = parseDgmoChartType2(content);
|
|
21468
21568
|
if (detectedType === "org") {
|
|
@@ -21653,7 +21753,7 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
|
|
|
21653
21753
|
renderState2(container2, stateParsed, layout, effectivePalette2, theme === "dark", void 0, { width: EXPORT_WIDTH, height: EXPORT_HEIGHT });
|
|
21654
21754
|
return finalizeSvgExport(container2, theme, effectivePalette2, options);
|
|
21655
21755
|
}
|
|
21656
|
-
const parsed =
|
|
21756
|
+
const parsed = parseVisualization(content, palette);
|
|
21657
21757
|
if (parsed.error && parsed.type !== "sequence") {
|
|
21658
21758
|
const looksLikeSequence2 = /->|~>|<-/.test(content);
|
|
21659
21759
|
if (!looksLikeSequence2) return "";
|
|
@@ -21880,12 +21980,12 @@ async function render(content, options) {
|
|
|
21880
21980
|
const branding = options?.branding ?? true;
|
|
21881
21981
|
const paletteColors = getPalette(paletteName)[theme === "dark" ? "dark" : "light"];
|
|
21882
21982
|
const chartType = parseDgmoChartType(content);
|
|
21883
|
-
const
|
|
21884
|
-
if (
|
|
21885
|
-
return
|
|
21983
|
+
const category = chartType ? getRenderCategory(chartType) : null;
|
|
21984
|
+
if (category === "data-chart") {
|
|
21985
|
+
return renderExtendedChartForExport(content, theme, paletteColors, { branding });
|
|
21886
21986
|
}
|
|
21887
21987
|
await ensureDom();
|
|
21888
|
-
return
|
|
21988
|
+
return renderForExport(content, theme, paletteColors, void 0, {
|
|
21889
21989
|
branding,
|
|
21890
21990
|
c4Level: options?.c4Level,
|
|
21891
21991
|
c4System: options?.c4System,
|
|
@@ -22666,20 +22766,18 @@ function decodeDiagramUrl(hash) {
|
|
|
22666
22766
|
// src/index.ts
|
|
22667
22767
|
init_branding();
|
|
22668
22768
|
export {
|
|
22669
|
-
DGMO_CHART_TYPE_MAP,
|
|
22670
22769
|
INFRA_BEHAVIOR_KEYS,
|
|
22671
22770
|
RULE_COUNT,
|
|
22672
|
-
STANDARD_CHART_TYPES,
|
|
22673
22771
|
addDurationToDate,
|
|
22674
22772
|
applyGroupOrdering,
|
|
22675
22773
|
applyPositionOverrides,
|
|
22676
22774
|
boldPalette,
|
|
22677
|
-
|
|
22678
|
-
buildEChartsOptionFromChart,
|
|
22775
|
+
buildExtendedChartOption,
|
|
22679
22776
|
buildMermaidQuadrant,
|
|
22680
22777
|
buildMermaidThemeVars,
|
|
22681
22778
|
buildNoteMessageMap,
|
|
22682
22779
|
buildRenderSequence,
|
|
22780
|
+
buildSimpleChartOption,
|
|
22683
22781
|
buildThemeCSS,
|
|
22684
22782
|
catppuccinPalette,
|
|
22685
22783
|
collapseInitiativeStatus,
|
|
@@ -22699,8 +22797,8 @@ export {
|
|
|
22699
22797
|
formatDateLabel,
|
|
22700
22798
|
formatDgmoError,
|
|
22701
22799
|
getAvailablePalettes,
|
|
22702
|
-
getDgmoFramework,
|
|
22703
22800
|
getPalette,
|
|
22801
|
+
getRenderCategory,
|
|
22704
22802
|
getSeriesColors,
|
|
22705
22803
|
groupMessagesBySection,
|
|
22706
22804
|
gruvboxPalette,
|
|
@@ -22711,6 +22809,7 @@ export {
|
|
|
22711
22809
|
inferRoles,
|
|
22712
22810
|
injectBranding,
|
|
22713
22811
|
isArchiveColumn,
|
|
22812
|
+
isExtendedChartType,
|
|
22714
22813
|
isSequenceBlock,
|
|
22715
22814
|
isSequenceNote,
|
|
22716
22815
|
isValidHex,
|
|
@@ -22742,11 +22841,10 @@ export {
|
|
|
22742
22841
|
parseC4,
|
|
22743
22842
|
parseChart,
|
|
22744
22843
|
parseClassDiagram,
|
|
22745
|
-
parseD3,
|
|
22746
22844
|
parseDgmo,
|
|
22747
22845
|
parseDgmoChartType,
|
|
22748
|
-
parseEChart,
|
|
22749
22846
|
parseERDiagram,
|
|
22847
|
+
parseExtendedChart,
|
|
22750
22848
|
parseFlowchart,
|
|
22751
22849
|
parseInfra,
|
|
22752
22850
|
parseInitiativeStatus,
|
|
@@ -22758,6 +22856,7 @@ export {
|
|
|
22758
22856
|
parseSitemap,
|
|
22759
22857
|
parseState,
|
|
22760
22858
|
parseTimelineDate,
|
|
22859
|
+
parseVisualization,
|
|
22761
22860
|
registerPalette,
|
|
22762
22861
|
render,
|
|
22763
22862
|
renderArcDiagram,
|
|
@@ -22770,12 +22869,12 @@ export {
|
|
|
22770
22869
|
renderC4DeploymentForExport,
|
|
22771
22870
|
renderClassDiagram,
|
|
22772
22871
|
renderClassDiagramForExport,
|
|
22773
|
-
renderD3ForExport,
|
|
22774
|
-
renderEChartsForExport,
|
|
22775
22872
|
renderERDiagram,
|
|
22776
22873
|
renderERDiagramForExport,
|
|
22874
|
+
renderExtendedChartForExport,
|
|
22777
22875
|
renderFlowchart,
|
|
22778
22876
|
renderFlowchartForExport,
|
|
22877
|
+
renderForExport,
|
|
22779
22878
|
renderInfra,
|
|
22780
22879
|
renderInitiativeStatus,
|
|
22781
22880
|
renderInitiativeStatusForExport,
|