@diagrammo/dgmo 0.8.0 → 0.8.2
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/cli.cjs +73 -73
- package/dist/index.cjs +20 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/d3.ts +14 -5
- package/src/echarts.ts +10 -11
package/package.json
CHANGED
package/src/d3.ts
CHANGED
|
@@ -1116,8 +1116,17 @@ export function parseVisualization(content: string, palette?: PaletteColors): Pa
|
|
|
1116
1116
|
if (colonIndex === -1 && !line.includes(' ')) {
|
|
1117
1117
|
// Single bare word — structured mode
|
|
1118
1118
|
result.words.push({ text: line, weight: 10, lineNumber });
|
|
1119
|
+
} else if (colonIndex === -1) {
|
|
1120
|
+
// Try "word weight" or "multi-word-label weight" space-separated format
|
|
1121
|
+
const lastSpace = line.lastIndexOf(' ');
|
|
1122
|
+
const maybeWeight = lastSpace >= 0 ? parseFloat(line.substring(lastSpace + 1)) : NaN;
|
|
1123
|
+
if (lastSpace >= 0 && !isNaN(maybeWeight) && maybeWeight > 0) {
|
|
1124
|
+
result.words.push({ text: line.substring(0, lastSpace).trim(), weight: maybeWeight, lineNumber });
|
|
1125
|
+
} else {
|
|
1126
|
+
freeformLines.push(line);
|
|
1127
|
+
}
|
|
1119
1128
|
} else {
|
|
1120
|
-
//
|
|
1129
|
+
// Non-numeric colon line — freeform text
|
|
1121
1130
|
freeformLines.push(line);
|
|
1122
1131
|
}
|
|
1123
1132
|
continue;
|
|
@@ -4820,7 +4829,7 @@ export function renderWordCloud(
|
|
|
4820
4829
|
|
|
4821
4830
|
const fontSize = (weight: number): number => {
|
|
4822
4831
|
const t = (weight - minWeight) / range;
|
|
4823
|
-
return minSize + t * (maxSize - minSize);
|
|
4832
|
+
return minSize + Math.sqrt(t) * (maxSize - minSize);
|
|
4824
4833
|
};
|
|
4825
4834
|
|
|
4826
4835
|
const rotateFn = getRotateFn(cloudOptions.rotate);
|
|
@@ -4837,7 +4846,7 @@ export function renderWordCloud(
|
|
|
4837
4846
|
cloud<WordCloudWord & cloud.Word>()
|
|
4838
4847
|
.size([width, cloudHeight])
|
|
4839
4848
|
.words(words.map((w) => ({ ...w, size: fontSize(w.weight) })))
|
|
4840
|
-
.padding(
|
|
4849
|
+
.padding(2)
|
|
4841
4850
|
.rotate(rotateFn)
|
|
4842
4851
|
.fontSize((d) => d.size!)
|
|
4843
4852
|
.font(FONT_FAMILY)
|
|
@@ -4912,7 +4921,7 @@ function renderWordCloudAsync(
|
|
|
4912
4921
|
|
|
4913
4922
|
const fontSize = (weight: number): number => {
|
|
4914
4923
|
const t = (weight - minWeight) / range;
|
|
4915
|
-
return minSize + t * (maxSize - minSize);
|
|
4924
|
+
return minSize + Math.sqrt(t) * (maxSize - minSize);
|
|
4916
4925
|
};
|
|
4917
4926
|
|
|
4918
4927
|
const rotateFn = getRotateFn(cloudOptions.rotate);
|
|
@@ -4936,7 +4945,7 @@ function renderWordCloudAsync(
|
|
|
4936
4945
|
cloud<WordCloudWord & cloud.Word>()
|
|
4937
4946
|
.size([width, cloudHeight])
|
|
4938
4947
|
.words(words.map((w) => ({ ...w, size: fontSize(w.weight) })))
|
|
4939
|
-
.padding(
|
|
4948
|
+
.padding(2)
|
|
4940
4949
|
.rotate(rotateFn)
|
|
4941
4950
|
.fontSize((d) => d.size!)
|
|
4942
4951
|
.font(FONT_FAMILY)
|
package/src/echarts.ts
CHANGED
|
@@ -1401,7 +1401,7 @@ function buildScatterOption(
|
|
|
1401
1401
|
|
|
1402
1402
|
const gridLeft = parsed.ylabel ? 12 : 3;
|
|
1403
1403
|
const gridRight = 4;
|
|
1404
|
-
const gridBottom = parsed.xlabel ? 10 : 3;
|
|
1404
|
+
const gridBottom = hasCategories ? 15 : parsed.xlabel ? 10 : 3;
|
|
1405
1405
|
const gridTop = parsed.title ? 15 : 5;
|
|
1406
1406
|
|
|
1407
1407
|
// Compute custom label graphics for SSR when labels are enabled
|
|
@@ -1450,9 +1450,18 @@ function buildScatterOption(
|
|
|
1450
1450
|
);
|
|
1451
1451
|
}
|
|
1452
1452
|
|
|
1453
|
+
// Build legend for categorized scatter charts
|
|
1454
|
+
const categories = hasCategories
|
|
1455
|
+
? [...new Set(points.map((p) => p.category).filter(Boolean))] as string[]
|
|
1456
|
+
: [];
|
|
1457
|
+
const legendConfig = categories.length > 0
|
|
1458
|
+
? { data: categories, bottom: 10, textStyle: { color: textColor } }
|
|
1459
|
+
: undefined;
|
|
1460
|
+
|
|
1453
1461
|
return {
|
|
1454
1462
|
...CHART_BASE,
|
|
1455
1463
|
title: titleConfig,
|
|
1464
|
+
...(legendConfig && { legend: legendConfig }),
|
|
1456
1465
|
tooltip,
|
|
1457
1466
|
grid: {
|
|
1458
1467
|
left: `${gridLeft}%`,
|
|
@@ -1939,11 +1948,6 @@ function buildBarOption(
|
|
|
1939
1948
|
return {
|
|
1940
1949
|
...CHART_BASE,
|
|
1941
1950
|
title: titleConfig,
|
|
1942
|
-
tooltip: {
|
|
1943
|
-
trigger: 'axis',
|
|
1944
|
-
...tooltipTheme,
|
|
1945
|
-
axisPointer: { type: 'shadow' },
|
|
1946
|
-
},
|
|
1947
1951
|
grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
|
|
1948
1952
|
xAxis: isHorizontal ? valueAxis : categoryAxis,
|
|
1949
1953
|
yAxis: isHorizontal ? categoryAxis : valueAxis,
|
|
@@ -2391,11 +2395,6 @@ function buildBarStackedOption(
|
|
|
2391
2395
|
return {
|
|
2392
2396
|
...CHART_BASE,
|
|
2393
2397
|
title: titleConfig,
|
|
2394
|
-
tooltip: {
|
|
2395
|
-
trigger: 'axis',
|
|
2396
|
-
...tooltipTheme,
|
|
2397
|
-
axisPointer: { type: 'shadow' },
|
|
2398
|
-
},
|
|
2399
2398
|
legend: {
|
|
2400
2399
|
data: seriesNames,
|
|
2401
2400
|
bottom: 10,
|