@diagrammo/dgmo 0.8.8 → 0.8.9
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 +177 -175
- package/dist/index.cjs +107 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +107 -209
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/echarts.ts +99 -214
package/dist/index.js
CHANGED
|
@@ -5334,52 +5334,26 @@ function buildChartCommons(parsed, palette, isDark) {
|
|
|
5334
5334
|
fontFamily: FONT_FAMILY
|
|
5335
5335
|
}
|
|
5336
5336
|
} : void 0;
|
|
5337
|
-
const tooltipTheme = {
|
|
5338
|
-
backgroundColor: palette.surface,
|
|
5339
|
-
borderColor: palette.border,
|
|
5340
|
-
textStyle: { color: palette.text }
|
|
5341
|
-
};
|
|
5342
5337
|
return {
|
|
5343
5338
|
textColor,
|
|
5344
5339
|
axisLineColor,
|
|
5345
5340
|
splitLineColor,
|
|
5346
5341
|
gridOpacity,
|
|
5347
5342
|
colors,
|
|
5348
|
-
titleConfig
|
|
5349
|
-
tooltipTheme
|
|
5343
|
+
titleConfig
|
|
5350
5344
|
};
|
|
5351
5345
|
}
|
|
5352
5346
|
function buildExtendedChartOption(parsed, palette, isDark) {
|
|
5353
5347
|
if (parsed.error) {
|
|
5354
5348
|
return {};
|
|
5355
5349
|
}
|
|
5356
|
-
const {
|
|
5357
|
-
textColor,
|
|
5358
|
-
axisLineColor,
|
|
5359
|
-
gridOpacity,
|
|
5360
|
-
colors,
|
|
5361
|
-
titleConfig,
|
|
5362
|
-
tooltipTheme
|
|
5363
|
-
} = buildChartCommons(parsed, palette, isDark);
|
|
5350
|
+
const { textColor, axisLineColor, gridOpacity, colors, titleConfig } = buildChartCommons(parsed, palette, isDark);
|
|
5364
5351
|
if (parsed.type === "sankey") {
|
|
5365
|
-
return buildSankeyOption(
|
|
5366
|
-
parsed,
|
|
5367
|
-
textColor,
|
|
5368
|
-
colors,
|
|
5369
|
-
titleConfig,
|
|
5370
|
-
tooltipTheme
|
|
5371
|
-
);
|
|
5352
|
+
return buildSankeyOption(parsed, textColor, colors, titleConfig);
|
|
5372
5353
|
}
|
|
5373
5354
|
if (parsed.type === "chord") {
|
|
5374
5355
|
const bg = isDark ? palette.surface : palette.bg;
|
|
5375
|
-
return buildChordOption(
|
|
5376
|
-
parsed,
|
|
5377
|
-
textColor,
|
|
5378
|
-
colors,
|
|
5379
|
-
bg,
|
|
5380
|
-
titleConfig,
|
|
5381
|
-
tooltipTheme
|
|
5382
|
-
);
|
|
5356
|
+
return buildChordOption(parsed, textColor, colors, bg, titleConfig);
|
|
5383
5357
|
}
|
|
5384
5358
|
if (parsed.type === "function") {
|
|
5385
5359
|
return buildFunctionOption(
|
|
@@ -5389,8 +5363,7 @@ function buildExtendedChartOption(parsed, palette, isDark) {
|
|
|
5389
5363
|
axisLineColor,
|
|
5390
5364
|
gridOpacity,
|
|
5391
5365
|
colors,
|
|
5392
|
-
titleConfig
|
|
5393
|
-
tooltipTheme
|
|
5366
|
+
titleConfig
|
|
5394
5367
|
);
|
|
5395
5368
|
}
|
|
5396
5369
|
if (parsed.type === "scatter") {
|
|
@@ -5403,20 +5376,12 @@ function buildExtendedChartOption(parsed, palette, isDark) {
|
|
|
5403
5376
|
gridOpacity,
|
|
5404
5377
|
colors,
|
|
5405
5378
|
bg,
|
|
5406
|
-
titleConfig
|
|
5407
|
-
tooltipTheme
|
|
5379
|
+
titleConfig
|
|
5408
5380
|
);
|
|
5409
5381
|
}
|
|
5410
5382
|
if (parsed.type === "funnel") {
|
|
5411
5383
|
const bg = isDark ? palette.surface : palette.bg;
|
|
5412
|
-
return buildFunnelOption(
|
|
5413
|
-
parsed,
|
|
5414
|
-
textColor,
|
|
5415
|
-
colors,
|
|
5416
|
-
bg,
|
|
5417
|
-
titleConfig,
|
|
5418
|
-
tooltipTheme
|
|
5419
|
-
);
|
|
5384
|
+
return buildFunnelOption(parsed, textColor, colors, bg, titleConfig);
|
|
5420
5385
|
}
|
|
5421
5386
|
return buildHeatmapOption(
|
|
5422
5387
|
parsed,
|
|
@@ -5424,11 +5389,10 @@ function buildExtendedChartOption(parsed, palette, isDark) {
|
|
|
5424
5389
|
isDark,
|
|
5425
5390
|
textColor,
|
|
5426
5391
|
axisLineColor,
|
|
5427
|
-
titleConfig
|
|
5428
|
-
tooltipTheme
|
|
5392
|
+
titleConfig
|
|
5429
5393
|
);
|
|
5430
5394
|
}
|
|
5431
|
-
function buildSankeyOption(parsed, textColor, colors, titleConfig
|
|
5395
|
+
function buildSankeyOption(parsed, textColor, colors, titleConfig) {
|
|
5432
5396
|
const nodeSet = /* @__PURE__ */ new Set();
|
|
5433
5397
|
if (parsed.links) {
|
|
5434
5398
|
for (const link of parsed.links) {
|
|
@@ -5447,17 +5411,15 @@ function buildSankeyOption(parsed, textColor, colors, titleConfig, tooltipTheme)
|
|
|
5447
5411
|
title: titleConfig,
|
|
5448
5412
|
xAxis: { show: false },
|
|
5449
5413
|
yAxis: { show: false },
|
|
5450
|
-
tooltip: {
|
|
5451
|
-
show: false,
|
|
5452
|
-
...tooltipTheme
|
|
5453
|
-
},
|
|
5454
5414
|
series: [
|
|
5455
5415
|
{
|
|
5456
5416
|
type: "sankey",
|
|
5457
5417
|
emphasis: {
|
|
5458
5418
|
focus: "adjacency",
|
|
5459
|
-
blurScope: "global"
|
|
5419
|
+
blurScope: "global",
|
|
5420
|
+
itemStyle: { opacity: 1 }
|
|
5460
5421
|
},
|
|
5422
|
+
blur: BLUR_DIM,
|
|
5461
5423
|
nodeAlign: "left",
|
|
5462
5424
|
nodeGap: 12,
|
|
5463
5425
|
nodeWidth: 20,
|
|
@@ -5480,7 +5442,7 @@ function buildSankeyOption(parsed, textColor, colors, titleConfig, tooltipTheme)
|
|
|
5480
5442
|
]
|
|
5481
5443
|
};
|
|
5482
5444
|
}
|
|
5483
|
-
function buildChordOption(parsed, textColor, colors, bg, titleConfig
|
|
5445
|
+
function buildChordOption(parsed, textColor, colors, bg, titleConfig) {
|
|
5484
5446
|
const nodeSet = /* @__PURE__ */ new Set();
|
|
5485
5447
|
if (parsed.links) {
|
|
5486
5448
|
for (const link of parsed.links) {
|
|
@@ -5514,17 +5476,6 @@ function buildChordOption(parsed, textColor, colors, bg, titleConfig, tooltipThe
|
|
|
5514
5476
|
return {
|
|
5515
5477
|
...CHART_BASE,
|
|
5516
5478
|
title: titleConfig,
|
|
5517
|
-
tooltip: {
|
|
5518
|
-
trigger: "item",
|
|
5519
|
-
...tooltipTheme,
|
|
5520
|
-
formatter: (params) => {
|
|
5521
|
-
const p = params;
|
|
5522
|
-
if (p.data && p.data.source && p.data.target) {
|
|
5523
|
-
return `${p.data.source} \u2192 ${p.data.target}: ${p.data.value}`;
|
|
5524
|
-
}
|
|
5525
|
-
return "";
|
|
5526
|
-
}
|
|
5527
|
-
},
|
|
5528
5479
|
xAxis: { show: false },
|
|
5529
5480
|
yAxis: { show: false },
|
|
5530
5481
|
series: [
|
|
@@ -5583,11 +5534,13 @@ function buildChordOption(parsed, textColor, colors, bg, titleConfig, tooltipThe
|
|
|
5583
5534
|
},
|
|
5584
5535
|
emphasis: {
|
|
5585
5536
|
focus: "adjacency",
|
|
5537
|
+
itemStyle: { opacity: 1 },
|
|
5586
5538
|
lineStyle: {
|
|
5587
5539
|
width: 5,
|
|
5588
5540
|
opacity: 1
|
|
5589
5541
|
}
|
|
5590
|
-
}
|
|
5542
|
+
},
|
|
5543
|
+
blur: BLUR_DIM
|
|
5591
5544
|
}
|
|
5592
5545
|
]
|
|
5593
5546
|
};
|
|
@@ -5601,7 +5554,7 @@ function evaluateExpression(expr, x) {
|
|
|
5601
5554
|
return NaN;
|
|
5602
5555
|
}
|
|
5603
5556
|
}
|
|
5604
|
-
function buildFunctionOption(parsed, palette, textColor, axisLineColor, gridOpacity, colors, titleConfig
|
|
5557
|
+
function buildFunctionOption(parsed, palette, textColor, axisLineColor, gridOpacity, colors, titleConfig) {
|
|
5605
5558
|
const xRange = parsed.xRange ?? { min: -10, max: 10 };
|
|
5606
5559
|
const samples = 200;
|
|
5607
5560
|
const step = (xRange.max - xRange.min) / samples;
|
|
@@ -5634,19 +5587,13 @@ function buildFunctionOption(parsed, palette, textColor, axisLineColor, gridOpac
|
|
|
5634
5587
|
opacity: 0.15
|
|
5635
5588
|
}
|
|
5636
5589
|
},
|
|
5637
|
-
emphasis: EMPHASIS_SELF
|
|
5590
|
+
emphasis: EMPHASIS_SELF,
|
|
5591
|
+
blur: BLUR_DIM
|
|
5638
5592
|
};
|
|
5639
5593
|
});
|
|
5640
5594
|
return {
|
|
5641
5595
|
...CHART_BASE,
|
|
5642
5596
|
title: titleConfig,
|
|
5643
|
-
tooltip: {
|
|
5644
|
-
trigger: "axis",
|
|
5645
|
-
...tooltipTheme,
|
|
5646
|
-
axisPointer: {
|
|
5647
|
-
type: "cross"
|
|
5648
|
-
}
|
|
5649
|
-
},
|
|
5650
5597
|
legend: {
|
|
5651
5598
|
data: (parsed.functions ?? []).map((fn) => fn.name),
|
|
5652
5599
|
bottom: 10,
|
|
@@ -5895,7 +5842,7 @@ function dataToPixel(dataX, dataY, xMin, xMax, yMin, yMax, gridLeftPct, gridRigh
|
|
|
5895
5842
|
const py = gridTopPx + (yMax - dataY) / (yMax - yMin) * plotHeight;
|
|
5896
5843
|
return { px, py };
|
|
5897
5844
|
}
|
|
5898
|
-
function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpacity, colors, bg, titleConfig
|
|
5845
|
+
function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpacity, colors, bg, titleConfig) {
|
|
5899
5846
|
const points = parsed.scatterPoints ?? [];
|
|
5900
5847
|
const defaultSize = 15;
|
|
5901
5848
|
const hasCategories = points.some((p) => p.category !== void 0);
|
|
@@ -5911,11 +5858,9 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
|
|
|
5911
5858
|
};
|
|
5912
5859
|
const emphasisConfig = {
|
|
5913
5860
|
focus: "self",
|
|
5914
|
-
itemStyle: {
|
|
5915
|
-
shadowBlur: 10,
|
|
5916
|
-
shadowColor: "rgba(0, 0, 0, 0.3)"
|
|
5917
|
-
}
|
|
5861
|
+
itemStyle: { opacity: 1 }
|
|
5918
5862
|
};
|
|
5863
|
+
const blurConfig = BLUR_DIM;
|
|
5919
5864
|
let series;
|
|
5920
5865
|
if (hasCategories) {
|
|
5921
5866
|
const categories2 = [
|
|
@@ -5946,7 +5891,8 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
|
|
|
5946
5891
|
borderWidth: CHART_BORDER_WIDTH
|
|
5947
5892
|
},
|
|
5948
5893
|
label: labelConfig,
|
|
5949
|
-
emphasis: emphasisConfig
|
|
5894
|
+
emphasis: emphasisConfig,
|
|
5895
|
+
blur: blurConfig
|
|
5950
5896
|
};
|
|
5951
5897
|
});
|
|
5952
5898
|
} else {
|
|
@@ -5968,24 +5914,11 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
|
|
|
5968
5914
|
type: "scatter",
|
|
5969
5915
|
data,
|
|
5970
5916
|
label: labelConfig,
|
|
5971
|
-
emphasis: emphasisConfig
|
|
5917
|
+
emphasis: emphasisConfig,
|
|
5918
|
+
blur: blurConfig
|
|
5972
5919
|
}
|
|
5973
5920
|
];
|
|
5974
5921
|
}
|
|
5975
|
-
const tooltip = {
|
|
5976
|
-
trigger: "item",
|
|
5977
|
-
...tooltipTheme,
|
|
5978
|
-
formatter: (params) => {
|
|
5979
|
-
const p = params;
|
|
5980
|
-
const xLabel = parsed.xlabel || "x";
|
|
5981
|
-
const yLabel = parsed.ylabel || "y";
|
|
5982
|
-
let html = `<strong>${p.name}</strong>`;
|
|
5983
|
-
if (hasCategories) html += `<br/>${p.seriesName}`;
|
|
5984
|
-
html += `<br/>${xLabel}: ${p.value[0]}<br/>${yLabel}: ${p.value[1]}`;
|
|
5985
|
-
if (hasSize) html += `<br/>${parsed.sizelabel || "size"}: ${p.value[2]}`;
|
|
5986
|
-
return html;
|
|
5987
|
-
}
|
|
5988
|
-
};
|
|
5989
5922
|
const xValues = points.map((p) => p.x);
|
|
5990
5923
|
const yValues = points.map((p) => p.y);
|
|
5991
5924
|
const xMin = Math.min(...xValues);
|
|
@@ -6066,7 +5999,6 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
|
|
|
6066
5999
|
...CHART_BASE,
|
|
6067
6000
|
title: titleConfig,
|
|
6068
6001
|
...legendConfig && { legend: legendConfig },
|
|
6069
|
-
tooltip,
|
|
6070
6002
|
grid: {
|
|
6071
6003
|
left: `${gridLeft}%`,
|
|
6072
6004
|
right: `${gridRight}%`,
|
|
@@ -6128,7 +6060,7 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
|
|
|
6128
6060
|
...graphic && { graphic }
|
|
6129
6061
|
};
|
|
6130
6062
|
}
|
|
6131
|
-
function buildHeatmapOption(parsed, palette, isDark, textColor, axisLineColor, titleConfig
|
|
6063
|
+
function buildHeatmapOption(parsed, palette, isDark, textColor, axisLineColor, titleConfig) {
|
|
6132
6064
|
const bg = isDark ? palette.surface : palette.bg;
|
|
6133
6065
|
const heatmapRows = parsed.heatmapRows ?? [];
|
|
6134
6066
|
const columns = parsed.columns ?? [];
|
|
@@ -6146,16 +6078,6 @@ function buildHeatmapOption(parsed, palette, isDark, textColor, axisLineColor, t
|
|
|
6146
6078
|
return {
|
|
6147
6079
|
...CHART_BASE,
|
|
6148
6080
|
title: titleConfig,
|
|
6149
|
-
tooltip: {
|
|
6150
|
-
trigger: "item",
|
|
6151
|
-
...tooltipTheme,
|
|
6152
|
-
formatter: (params) => {
|
|
6153
|
-
const p = params;
|
|
6154
|
-
const colName = columns[p.data[0]] ?? p.data[0];
|
|
6155
|
-
const rowName = rowLabels[p.data[1]] ?? p.data[1];
|
|
6156
|
-
return `${rowName} / ${colName}: <strong>${p.data[2]}</strong>`;
|
|
6157
|
-
}
|
|
6158
|
-
},
|
|
6159
6081
|
grid: {
|
|
6160
6082
|
left: "3%",
|
|
6161
6083
|
right: "10%",
|
|
@@ -6225,19 +6147,15 @@ function buildHeatmapOption(parsed, palette, isDark, textColor, axisLineColor, t
|
|
|
6225
6147
|
fontWeight: "bold"
|
|
6226
6148
|
},
|
|
6227
6149
|
emphasis: {
|
|
6228
|
-
...EMPHASIS_SELF
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
shadowColor: "rgba(0, 0, 0, 0.5)"
|
|
6232
|
-
}
|
|
6233
|
-
}
|
|
6150
|
+
...EMPHASIS_SELF
|
|
6151
|
+
},
|
|
6152
|
+
blur: BLUR_DIM
|
|
6234
6153
|
}
|
|
6235
6154
|
]
|
|
6236
6155
|
};
|
|
6237
6156
|
}
|
|
6238
|
-
function buildFunnelOption(parsed, textColor, colors, bg, titleConfig
|
|
6157
|
+
function buildFunnelOption(parsed, textColor, colors, bg, titleConfig) {
|
|
6239
6158
|
const sorted = [...parsed.data].sort((a, b) => b.value - a.value);
|
|
6240
|
-
const topValue = sorted.length > 0 ? sorted[0].value : 1;
|
|
6241
6159
|
const data = sorted.map((d) => {
|
|
6242
6160
|
const stroke2 = d.color ?? colors[parsed.data.indexOf(d) % colors.length];
|
|
6243
6161
|
return {
|
|
@@ -6272,25 +6190,6 @@ function buildFunnelOption(parsed, textColor, colors, bg, titleConfig, tooltipTh
|
|
|
6272
6190
|
title: titleConfig,
|
|
6273
6191
|
xAxis: { show: false },
|
|
6274
6192
|
yAxis: { show: false },
|
|
6275
|
-
tooltip: {
|
|
6276
|
-
trigger: "item",
|
|
6277
|
-
...tooltipTheme,
|
|
6278
|
-
formatter: (params) => {
|
|
6279
|
-
const p = params;
|
|
6280
|
-
const val = p.value;
|
|
6281
|
-
const prev = prevValueMap.get(p.name) ?? val;
|
|
6282
|
-
const isFirst = p.dataIndex === 0;
|
|
6283
|
-
if (isFirst) return "";
|
|
6284
|
-
const parts = [];
|
|
6285
|
-
const stepDrop = ((1 - val / prev) * 100).toFixed(1);
|
|
6286
|
-
parts.push(`Step drop-off: ${stepDrop}%`);
|
|
6287
|
-
if (topValue > 0) {
|
|
6288
|
-
const totalDrop = ((1 - val / topValue) * 100).toFixed(1);
|
|
6289
|
-
parts.push(`Overall drop-off: ${totalDrop}%`);
|
|
6290
|
-
}
|
|
6291
|
-
return parts.join("<br/>");
|
|
6292
|
-
}
|
|
6293
|
-
},
|
|
6294
6193
|
series: [
|
|
6295
6194
|
{
|
|
6296
6195
|
type: "funnel",
|
|
@@ -6308,11 +6207,9 @@ function buildFunnelOption(parsed, textColor, colors, bg, titleConfig, tooltipTh
|
|
|
6308
6207
|
lineStyle: { color: textColor, opacity: 0.3 }
|
|
6309
6208
|
},
|
|
6310
6209
|
emphasis: {
|
|
6311
|
-
...EMPHASIS_SELF
|
|
6312
|
-
label: {
|
|
6313
|
-
fontSize: 15
|
|
6314
|
-
}
|
|
6210
|
+
...EMPHASIS_SELF
|
|
6315
6211
|
},
|
|
6212
|
+
blur: BLUR_DIM,
|
|
6316
6213
|
data
|
|
6317
6214
|
},
|
|
6318
6215
|
{
|
|
@@ -6406,8 +6303,7 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6406
6303
|
splitLineColor,
|
|
6407
6304
|
gridOpacity,
|
|
6408
6305
|
colors,
|
|
6409
|
-
titleConfig
|
|
6410
|
-
tooltipTheme
|
|
6306
|
+
titleConfig
|
|
6411
6307
|
} = buildChartCommons(parsed, palette, isDark);
|
|
6412
6308
|
const bg = isDark ? palette.surface : palette.bg;
|
|
6413
6309
|
switch (parsed.type) {
|
|
@@ -6421,7 +6317,6 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6421
6317
|
colors,
|
|
6422
6318
|
bg,
|
|
6423
6319
|
titleConfig,
|
|
6424
|
-
tooltipTheme,
|
|
6425
6320
|
chartWidth
|
|
6426
6321
|
);
|
|
6427
6322
|
case "bar-stacked":
|
|
@@ -6434,7 +6329,6 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6434
6329
|
colors,
|
|
6435
6330
|
bg,
|
|
6436
6331
|
titleConfig,
|
|
6437
|
-
tooltipTheme,
|
|
6438
6332
|
chartWidth
|
|
6439
6333
|
);
|
|
6440
6334
|
case "line":
|
|
@@ -6447,7 +6341,6 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6447
6341
|
gridOpacity,
|
|
6448
6342
|
colors,
|
|
6449
6343
|
titleConfig,
|
|
6450
|
-
tooltipTheme,
|
|
6451
6344
|
chartWidth
|
|
6452
6345
|
) : buildLineOption(
|
|
6453
6346
|
parsed,
|
|
@@ -6457,7 +6350,6 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6457
6350
|
splitLineColor,
|
|
6458
6351
|
gridOpacity,
|
|
6459
6352
|
titleConfig,
|
|
6460
|
-
tooltipTheme,
|
|
6461
6353
|
chartWidth
|
|
6462
6354
|
);
|
|
6463
6355
|
case "area":
|
|
@@ -6469,7 +6361,6 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6469
6361
|
splitLineColor,
|
|
6470
6362
|
gridOpacity,
|
|
6471
6363
|
titleConfig,
|
|
6472
|
-
tooltipTheme,
|
|
6473
6364
|
chartWidth
|
|
6474
6365
|
);
|
|
6475
6366
|
case "pie":
|
|
@@ -6479,7 +6370,6 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6479
6370
|
getSegmentColors(palette, parsed.data.length),
|
|
6480
6371
|
bg,
|
|
6481
6372
|
titleConfig,
|
|
6482
|
-
tooltipTheme,
|
|
6483
6373
|
false
|
|
6484
6374
|
);
|
|
6485
6375
|
case "doughnut":
|
|
@@ -6489,7 +6379,6 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6489
6379
|
getSegmentColors(palette, parsed.data.length),
|
|
6490
6380
|
bg,
|
|
6491
6381
|
titleConfig,
|
|
6492
|
-
tooltipTheme,
|
|
6493
6382
|
true
|
|
6494
6383
|
);
|
|
6495
6384
|
case "radar":
|
|
@@ -6499,8 +6388,7 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6499
6388
|
isDark,
|
|
6500
6389
|
textColor,
|
|
6501
6390
|
gridOpacity,
|
|
6502
|
-
titleConfig
|
|
6503
|
-
tooltipTheme
|
|
6391
|
+
titleConfig
|
|
6504
6392
|
);
|
|
6505
6393
|
case "polar-area":
|
|
6506
6394
|
return buildPolarAreaOption(
|
|
@@ -6508,21 +6396,36 @@ function buildSimpleChartOption(parsed, palette, isDark, chartWidth) {
|
|
|
6508
6396
|
textColor,
|
|
6509
6397
|
getSegmentColors(palette, parsed.data.length),
|
|
6510
6398
|
bg,
|
|
6511
|
-
titleConfig
|
|
6512
|
-
tooltipTheme
|
|
6399
|
+
titleConfig
|
|
6513
6400
|
);
|
|
6514
6401
|
}
|
|
6515
6402
|
}
|
|
6516
6403
|
function makeChartGrid(options) {
|
|
6404
|
+
const left = options.yLabel ? "12%" : "3%";
|
|
6517
6405
|
return {
|
|
6518
|
-
left
|
|
6406
|
+
left,
|
|
6519
6407
|
right: "4%",
|
|
6520
6408
|
bottom: options.hasLegend ? "15%" : options.xLabel ? "10%" : "3%",
|
|
6521
6409
|
top: options.hasTitle ? "15%" : "5%",
|
|
6522
6410
|
containLabel: true
|
|
6523
6411
|
};
|
|
6524
6412
|
}
|
|
6525
|
-
function
|
|
6413
|
+
function wrapLabel(text, maxChars) {
|
|
6414
|
+
const words = text.split(" ");
|
|
6415
|
+
const lines = [];
|
|
6416
|
+
let current = "";
|
|
6417
|
+
for (const word of words) {
|
|
6418
|
+
if (current && current.length + 1 + word.length > maxChars) {
|
|
6419
|
+
lines.push(current);
|
|
6420
|
+
current = word;
|
|
6421
|
+
} else {
|
|
6422
|
+
current = current ? current + " " + word : word;
|
|
6423
|
+
}
|
|
6424
|
+
}
|
|
6425
|
+
if (current) lines.push(current);
|
|
6426
|
+
return lines.join("\n");
|
|
6427
|
+
}
|
|
6428
|
+
function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, bg, titleConfig, chartWidth) {
|
|
6526
6429
|
const { xLabel, yLabel } = resolveAxisLabels(parsed);
|
|
6527
6430
|
const isHorizontal = parsed.orientation === "horizontal";
|
|
6528
6431
|
const labels = parsed.data.map((d) => d.label);
|
|
@@ -6537,7 +6440,11 @@ function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOp
|
|
|
6537
6440
|
}
|
|
6538
6441
|
};
|
|
6539
6442
|
});
|
|
6540
|
-
const
|
|
6443
|
+
const catLabels = isHorizontal ? labels.map((l) => wrapLabel(l, 12)) : labels;
|
|
6444
|
+
const maxVisibleLen = Math.max(
|
|
6445
|
+
...catLabels.map((l) => Math.max(...l.split("\n").map((seg) => seg.length)))
|
|
6446
|
+
);
|
|
6447
|
+
const hCatGap = isHorizontal && yLabel ? Math.max(40, maxVisibleLen * 8 + 16) : void 0;
|
|
6541
6448
|
const categoryAxis = makeGridAxis(
|
|
6542
6449
|
"category",
|
|
6543
6450
|
textColor,
|
|
@@ -6545,29 +6452,38 @@ function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOp
|
|
|
6545
6452
|
splitLineColor,
|
|
6546
6453
|
gridOpacity,
|
|
6547
6454
|
isHorizontal ? yLabel : xLabel,
|
|
6548
|
-
|
|
6455
|
+
catLabels,
|
|
6549
6456
|
hCatGap,
|
|
6550
6457
|
!isHorizontal ? chartWidth : void 0
|
|
6551
6458
|
);
|
|
6459
|
+
const hValueGap = isHorizontal && xLabel ? 40 : void 0;
|
|
6552
6460
|
const valueAxis = makeGridAxis(
|
|
6553
6461
|
"value",
|
|
6554
6462
|
textColor,
|
|
6555
6463
|
axisLineColor,
|
|
6556
6464
|
splitLineColor,
|
|
6557
6465
|
gridOpacity,
|
|
6558
|
-
isHorizontal ? xLabel : yLabel
|
|
6466
|
+
isHorizontal ? xLabel : yLabel,
|
|
6467
|
+
void 0,
|
|
6468
|
+
hValueGap
|
|
6559
6469
|
);
|
|
6560
6470
|
return {
|
|
6561
6471
|
...CHART_BASE,
|
|
6562
6472
|
title: titleConfig,
|
|
6563
|
-
grid: makeChartGrid({
|
|
6473
|
+
grid: makeChartGrid({
|
|
6474
|
+
xLabel,
|
|
6475
|
+
yLabel,
|
|
6476
|
+
hasTitle: !!parsed.title,
|
|
6477
|
+
isHorizontal
|
|
6478
|
+
}),
|
|
6564
6479
|
xAxis: isHorizontal ? valueAxis : categoryAxis,
|
|
6565
|
-
yAxis: isHorizontal ? categoryAxis : valueAxis,
|
|
6480
|
+
yAxis: isHorizontal ? { ...categoryAxis, inverse: true } : valueAxis,
|
|
6566
6481
|
series: [
|
|
6567
6482
|
{
|
|
6568
6483
|
type: "bar",
|
|
6569
6484
|
data,
|
|
6570
|
-
emphasis: EMPHASIS_SELF
|
|
6485
|
+
emphasis: EMPHASIS_SELF,
|
|
6486
|
+
blur: BLUR_DIM
|
|
6571
6487
|
}
|
|
6572
6488
|
]
|
|
6573
6489
|
};
|
|
@@ -6584,7 +6500,7 @@ function buildMarkArea(eras, labels, textColor, defaultColor) {
|
|
|
6584
6500
|
if (eras.length === 0) return void 0;
|
|
6585
6501
|
return {
|
|
6586
6502
|
silent: false,
|
|
6587
|
-
tooltip: { show:
|
|
6503
|
+
tooltip: { show: false },
|
|
6588
6504
|
data: eras.map((era) => {
|
|
6589
6505
|
const startIdx = labels.indexOf(era.start);
|
|
6590
6506
|
const endIdx = labels.indexOf(era.end);
|
|
@@ -6607,7 +6523,7 @@ function buildMarkArea(eras, labels, textColor, defaultColor) {
|
|
|
6607
6523
|
})
|
|
6608
6524
|
};
|
|
6609
6525
|
}
|
|
6610
|
-
function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig,
|
|
6526
|
+
function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig, chartWidth) {
|
|
6611
6527
|
const { xLabel, yLabel } = resolveAxisLabels(parsed);
|
|
6612
6528
|
const lineColor = parsed.color ?? parsed.seriesNameColors?.[0] ?? palette.primary;
|
|
6613
6529
|
const labels = parsed.data.map((d) => d.label);
|
|
@@ -6618,11 +6534,6 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
6618
6534
|
return {
|
|
6619
6535
|
...CHART_BASE,
|
|
6620
6536
|
title: titleConfig,
|
|
6621
|
-
tooltip: {
|
|
6622
|
-
trigger: "axis",
|
|
6623
|
-
...tooltipTheme,
|
|
6624
|
-
axisPointer: { type: "line" }
|
|
6625
|
-
},
|
|
6626
6537
|
grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
|
|
6627
6538
|
xAxis: makeGridAxis(
|
|
6628
6539
|
"category",
|
|
@@ -6653,12 +6564,13 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
6653
6564
|
lineStyle: { color: lineColor, width: 3 },
|
|
6654
6565
|
itemStyle: { color: lineColor },
|
|
6655
6566
|
emphasis: EMPHASIS_LINE,
|
|
6567
|
+
blur: BLUR_DIM,
|
|
6656
6568
|
...markArea && { markArea }
|
|
6657
6569
|
}
|
|
6658
6570
|
]
|
|
6659
6571
|
};
|
|
6660
6572
|
}
|
|
6661
|
-
function buildMultiLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig,
|
|
6573
|
+
function buildMultiLineOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, chartWidth) {
|
|
6662
6574
|
const { xLabel, yLabel } = resolveAxisLabels(parsed);
|
|
6663
6575
|
const seriesNames = parsed.seriesNames ?? [];
|
|
6664
6576
|
const labels = parsed.data.map((d) => d.label);
|
|
@@ -6679,17 +6591,13 @@ function buildMultiLineOption(parsed, palette, textColor, axisLineColor, splitLi
|
|
|
6679
6591
|
lineStyle: { color, width: 3 },
|
|
6680
6592
|
itemStyle: { color },
|
|
6681
6593
|
emphasis: EMPHASIS_LINE,
|
|
6594
|
+
blur: BLUR_DIM,
|
|
6682
6595
|
...idx === 0 && markArea && { markArea }
|
|
6683
6596
|
};
|
|
6684
6597
|
});
|
|
6685
6598
|
return {
|
|
6686
6599
|
...CHART_BASE,
|
|
6687
6600
|
title: titleConfig,
|
|
6688
|
-
tooltip: {
|
|
6689
|
-
trigger: "axis",
|
|
6690
|
-
...tooltipTheme,
|
|
6691
|
-
axisPointer: { type: "line" }
|
|
6692
|
-
},
|
|
6693
6601
|
legend: {
|
|
6694
6602
|
data: seriesNames,
|
|
6695
6603
|
bottom: 10,
|
|
@@ -6724,7 +6632,7 @@ function buildMultiLineOption(parsed, palette, textColor, axisLineColor, splitLi
|
|
|
6724
6632
|
series
|
|
6725
6633
|
};
|
|
6726
6634
|
}
|
|
6727
|
-
function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig,
|
|
6635
|
+
function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineColor, gridOpacity, titleConfig, chartWidth) {
|
|
6728
6636
|
const { xLabel, yLabel } = resolveAxisLabels(parsed);
|
|
6729
6637
|
const lineColor = parsed.color ?? parsed.seriesNameColors?.[0] ?? palette.primary;
|
|
6730
6638
|
const labels = parsed.data.map((d) => d.label);
|
|
@@ -6735,11 +6643,6 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
6735
6643
|
return {
|
|
6736
6644
|
...CHART_BASE,
|
|
6737
6645
|
title: titleConfig,
|
|
6738
|
-
tooltip: {
|
|
6739
|
-
trigger: "axis",
|
|
6740
|
-
...tooltipTheme,
|
|
6741
|
-
axisPointer: { type: "line" }
|
|
6742
|
-
},
|
|
6743
6646
|
grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
|
|
6744
6647
|
xAxis: makeGridAxis(
|
|
6745
6648
|
"category",
|
|
@@ -6771,6 +6674,7 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
|
|
|
6771
6674
|
itemStyle: { color: lineColor },
|
|
6772
6675
|
areaStyle: { opacity: 0.25 },
|
|
6773
6676
|
emphasis: EMPHASIS_LINE,
|
|
6677
|
+
blur: BLUR_DIM,
|
|
6774
6678
|
...markArea && { markArea }
|
|
6775
6679
|
}
|
|
6776
6680
|
]
|
|
@@ -6802,7 +6706,7 @@ function pieLabelLayout(parsed) {
|
|
|
6802
6706
|
if (maxLen > 18) return { outerRadius: 55, fontSize: 13 };
|
|
6803
6707
|
return { outerRadius: 70, fontSize: 14 };
|
|
6804
6708
|
}
|
|
6805
|
-
function buildPieOption(parsed, textColor, colors, bg, titleConfig,
|
|
6709
|
+
function buildPieOption(parsed, textColor, colors, bg, titleConfig, isDoughnut) {
|
|
6806
6710
|
const HIDE_AXES = { xAxis: { show: false }, yAxis: { show: false } };
|
|
6807
6711
|
const data = parsed.data.map((d, i) => {
|
|
6808
6712
|
const stroke2 = d.color ?? colors[i % colors.length];
|
|
@@ -6821,10 +6725,6 @@ function buildPieOption(parsed, textColor, colors, bg, titleConfig, tooltipTheme
|
|
|
6821
6725
|
...CHART_BASE,
|
|
6822
6726
|
...HIDE_AXES,
|
|
6823
6727
|
title: titleConfig,
|
|
6824
|
-
tooltip: {
|
|
6825
|
-
trigger: "item",
|
|
6826
|
-
...tooltipTheme
|
|
6827
|
-
},
|
|
6828
6728
|
series: [
|
|
6829
6729
|
{
|
|
6830
6730
|
type: "pie",
|
|
@@ -6838,12 +6738,13 @@ function buildPieOption(parsed, textColor, colors, bg, titleConfig, tooltipTheme
|
|
|
6838
6738
|
fontSize
|
|
6839
6739
|
},
|
|
6840
6740
|
labelLine: { show: true },
|
|
6841
|
-
emphasis: EMPHASIS_SELF
|
|
6741
|
+
emphasis: EMPHASIS_SELF,
|
|
6742
|
+
blur: BLUR_DIM
|
|
6842
6743
|
}
|
|
6843
6744
|
]
|
|
6844
6745
|
};
|
|
6845
6746
|
}
|
|
6846
|
-
function buildRadarOption(parsed, palette, isDark, textColor, gridOpacity, titleConfig
|
|
6747
|
+
function buildRadarOption(parsed, palette, isDark, textColor, gridOpacity, titleConfig) {
|
|
6847
6748
|
const bg = isDark ? palette.surface : palette.bg;
|
|
6848
6749
|
const radarColor = parsed.color ?? parsed.seriesNameColors?.[0] ?? palette.primary;
|
|
6849
6750
|
const values = parsed.data.map((d) => d.value);
|
|
@@ -6857,10 +6758,6 @@ function buildRadarOption(parsed, palette, isDark, textColor, gridOpacity, title
|
|
|
6857
6758
|
title: titleConfig,
|
|
6858
6759
|
xAxis: { show: false },
|
|
6859
6760
|
yAxis: { show: false },
|
|
6860
|
-
tooltip: {
|
|
6861
|
-
trigger: "item",
|
|
6862
|
-
...tooltipTheme
|
|
6863
|
-
},
|
|
6864
6761
|
radar: {
|
|
6865
6762
|
indicator,
|
|
6866
6763
|
axisName: {
|
|
@@ -6897,12 +6794,13 @@ function buildRadarOption(parsed, palette, isDark, textColor, gridOpacity, title
|
|
|
6897
6794
|
}
|
|
6898
6795
|
}
|
|
6899
6796
|
],
|
|
6900
|
-
emphasis: EMPHASIS_SELF
|
|
6797
|
+
emphasis: EMPHASIS_SELF,
|
|
6798
|
+
blur: BLUR_DIM
|
|
6901
6799
|
}
|
|
6902
6800
|
]
|
|
6903
6801
|
};
|
|
6904
6802
|
}
|
|
6905
|
-
function buildPolarAreaOption(parsed, textColor, colors, bg, titleConfig
|
|
6803
|
+
function buildPolarAreaOption(parsed, textColor, colors, bg, titleConfig) {
|
|
6906
6804
|
const data = parsed.data.map((d, i) => {
|
|
6907
6805
|
const stroke2 = d.color ?? colors[i % colors.length];
|
|
6908
6806
|
return {
|
|
@@ -6920,10 +6818,6 @@ function buildPolarAreaOption(parsed, textColor, colors, bg, titleConfig, toolti
|
|
|
6920
6818
|
title: titleConfig,
|
|
6921
6819
|
xAxis: { show: false },
|
|
6922
6820
|
yAxis: { show: false },
|
|
6923
|
-
tooltip: {
|
|
6924
|
-
trigger: "item",
|
|
6925
|
-
...tooltipTheme
|
|
6926
|
-
},
|
|
6927
6821
|
series: [
|
|
6928
6822
|
{
|
|
6929
6823
|
type: "pie",
|
|
@@ -6941,12 +6835,13 @@ function buildPolarAreaOption(parsed, textColor, colors, bg, titleConfig, toolti
|
|
|
6941
6835
|
fontSize: pieLabelLayout(parsed).fontSize
|
|
6942
6836
|
},
|
|
6943
6837
|
labelLine: { show: true },
|
|
6944
|
-
emphasis: EMPHASIS_SELF
|
|
6838
|
+
emphasis: EMPHASIS_SELF,
|
|
6839
|
+
blur: BLUR_DIM
|
|
6945
6840
|
}
|
|
6946
6841
|
]
|
|
6947
6842
|
};
|
|
6948
6843
|
}
|
|
6949
|
-
function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, bg, titleConfig,
|
|
6844
|
+
function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, bg, titleConfig, chartWidth) {
|
|
6950
6845
|
const { xLabel, yLabel } = resolveAxisLabels(parsed);
|
|
6951
6846
|
const isHorizontal = parsed.orientation === "horizontal";
|
|
6952
6847
|
const seriesNames = parsed.seriesNames ?? [];
|
|
@@ -6975,7 +6870,8 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
|
|
|
6975
6870
|
fontWeight: "bold",
|
|
6976
6871
|
fontFamily: FONT_FAMILY
|
|
6977
6872
|
},
|
|
6978
|
-
emphasis:
|
|
6873
|
+
emphasis: EMPHASIS_SERIES,
|
|
6874
|
+
blur: BLUR_DIM
|
|
6979
6875
|
};
|
|
6980
6876
|
});
|
|
6981
6877
|
const hCatGap = isHorizontal && yLabel ? Math.max(40, Math.max(...labels.map((l) => l.length)) * 8 + 16) : void 0;
|
|
@@ -7016,7 +6912,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
|
|
|
7016
6912
|
hasLegend: true
|
|
7017
6913
|
}),
|
|
7018
6914
|
xAxis: isHorizontal ? valueAxis : categoryAxis,
|
|
7019
|
-
yAxis: isHorizontal ? categoryAxis : valueAxis,
|
|
6915
|
+
yAxis: isHorizontal ? { ...categoryAxis, inverse: true } : valueAxis,
|
|
7020
6916
|
series
|
|
7021
6917
|
};
|
|
7022
6918
|
}
|
|
@@ -7100,7 +6996,7 @@ async function renderExtendedChartForExport(content, theme, palette, options) {
|
|
|
7100
6996
|
chart.dispose();
|
|
7101
6997
|
}
|
|
7102
6998
|
}
|
|
7103
|
-
var EMPHASIS_SELF, EMPHASIS_LINE, CHART_BASE, CHART_BORDER_WIDTH, VALID_EXTENDED_TYPES, KNOWN_EXTENDED_OPTIONS, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT, STANDARD_CHART_TYPES;
|
|
6999
|
+
var EMPHASIS_SELF, EMPHASIS_SERIES, BLUR_DIM, EMPHASIS_LINE, CHART_BASE, CHART_BORDER_WIDTH, VALID_EXTENDED_TYPES, KNOWN_EXTENDED_OPTIONS, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT, STANDARD_CHART_TYPES;
|
|
7104
7000
|
var init_echarts = __esm({
|
|
7105
7001
|
"src/echarts.ts"() {
|
|
7106
7002
|
"use strict";
|
|
@@ -7114,20 +7010,22 @@ var init_echarts = __esm({
|
|
|
7114
7010
|
init_colors();
|
|
7115
7011
|
init_parsing();
|
|
7116
7012
|
init_chart();
|
|
7117
|
-
EMPHASIS_SELF = {
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
}
|
|
7013
|
+
EMPHASIS_SELF = {
|
|
7014
|
+
focus: "self",
|
|
7015
|
+
blurScope: "global",
|
|
7016
|
+
itemStyle: { opacity: 1 }
|
|
7017
|
+
};
|
|
7018
|
+
EMPHASIS_SERIES = {
|
|
7019
|
+
focus: "series",
|
|
7020
|
+
blurScope: "global",
|
|
7021
|
+
itemStyle: { opacity: 1 }
|
|
7127
7022
|
};
|
|
7023
|
+
BLUR_DIM = { itemStyle: { opacity: 0.15 }, lineStyle: { opacity: 0.15 } };
|
|
7024
|
+
EMPHASIS_LINE = { ...EMPHASIS_SELF };
|
|
7128
7025
|
CHART_BASE = {
|
|
7129
7026
|
backgroundColor: "transparent",
|
|
7130
|
-
animation: false
|
|
7027
|
+
animation: false,
|
|
7028
|
+
tooltip: { show: false }
|
|
7131
7029
|
};
|
|
7132
7030
|
CHART_BORDER_WIDTH = 2;
|
|
7133
7031
|
VALID_EXTENDED_TYPES = /* @__PURE__ */ new Set([
|