@tidaltolabs/markdown-echarts 0.4.0 → 0.4.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/README.md +30 -0
- package/dist/browser/freeze-png.d.ts +2 -23
- package/dist/browser/freeze-png.d.ts.map +1 -1
- package/dist/browser/freeze-png.js +1 -35
- package/dist/browser/freeze-png.js.map +1 -1
- package/dist/browser/freeze-svg.d.ts +1 -1
- package/dist/browser/layout.d.ts +1 -15
- package/dist/browser/layout.d.ts.map +1 -1
- package/dist/browser/layout.js +1 -146
- package/dist/browser/layout.js.map +1 -1
- package/dist/browser/render-options.d.ts +1 -1
- package/dist/browser/render-options.d.ts.map +1 -1
- package/dist/browser/render-options.js +4 -7
- package/dist/browser/render-options.js.map +1 -1
- package/dist/browser.d.ts +5 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +5 -0
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/layout/chart-layout.d.ts +19 -0
- package/dist/layout/chart-layout.d.ts.map +1 -0
- package/dist/layout/chart-layout.js +225 -0
- package/dist/layout/chart-layout.js.map +1 -0
- package/dist/layout/expanded-dimensions.d.ts +14 -0
- package/dist/layout/expanded-dimensions.d.ts.map +1 -0
- package/dist/layout/expanded-dimensions.js +29 -0
- package/dist/layout/expanded-dimensions.js.map +1 -0
- package/dist/layout/interactive-option.d.ts +15 -0
- package/dist/layout/interactive-option.d.ts.map +1 -0
- package/dist/layout/interactive-option.js +69 -0
- package/dist/layout/interactive-option.js.map +1 -0
- package/dist/theme/pipeline.d.ts.map +1 -1
- package/dist/theme/pipeline.js +22 -1
- package/dist/theme/pipeline.js.map +1 -1
- package/dist/theme/schema.d.ts +9 -0
- package/dist/theme/schema.d.ts.map +1 -1
- package/dist/theme/stages/axis-style.d.ts.map +1 -1
- package/dist/theme/stages/axis-style.js +14 -10
- package/dist/theme/stages/axis-style.js.map +1 -1
- package/dist/theme/stages/chrome-components.d.ts.map +1 -1
- package/dist/theme/stages/chrome-components.js +47 -40
- package/dist/theme/stages/chrome-components.js.map +1 -1
- package/dist/theme/stages/series-styler.d.ts.map +1 -1
- package/dist/theme/stages/series-styler.js +70 -6
- package/dist/theme/stages/series-styler.js.map +1 -1
- package/dist/theme/stats.d.ts +5 -1
- package/dist/theme/stats.d.ts.map +1 -1
- package/dist/theme/stats.js +20 -4
- package/dist/theme/stats.js.map +1 -1
- package/dist/theme/title-legend-layout.d.ts +12 -0
- package/dist/theme/title-legend-layout.d.ts.map +1 -0
- package/dist/theme/title-legend-layout.js +57 -0
- package/dist/theme/title-legend-layout.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -387,6 +387,36 @@ Chromium `page.pdf()`。
|
|
|
387
387
|
ECharts 围栏使用专用 `figure.md-echarts` DOM,不会套用普通代码围栏的
|
|
388
388
|
`pre.md-fences` 样式。
|
|
389
389
|
|
|
390
|
+
### 宿主自管图表实例
|
|
391
|
+
|
|
392
|
+
宿主自行创建或更新 ECharts 实例时,可以把已校验的 option 交给纯布局入口。
|
|
393
|
+
|
|
394
|
+
```ts
|
|
395
|
+
import {
|
|
396
|
+
computeExpandedChartDimensions,
|
|
397
|
+
deriveThemeStats,
|
|
398
|
+
planPngSampling,
|
|
399
|
+
prepareInteractiveChartOption
|
|
400
|
+
} from "@tidaltolabs/markdown-echarts";
|
|
401
|
+
|
|
402
|
+
const dimensions = computeExpandedChartDimensions(deriveThemeStats(validatedOption));
|
|
403
|
+
const sampling = planPngSampling(dimensions);
|
|
404
|
+
const option = prepareInteractiveChartOption(validatedOption, {
|
|
405
|
+
theme: "aurora-glass",
|
|
406
|
+
layout: { mode: "expanded", width: sampling.width, fontFamily: "PingFang SC, sans-serif" }
|
|
407
|
+
});
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
这些函数可以在 Node 中运行。配置包含库在布局阶段生成的类目折行函数,
|
|
411
|
+
可直接交给图表实例。宿主使用 native 或语义主题时,继续在 ECharts
|
|
412
|
+
初始化阶段传入相应的引擎主题。
|
|
413
|
+
|
|
414
|
+
展开态默认给低密纯柱图补数值标签,并关闭全局和系列动画。使用
|
|
415
|
+
`layout.autoBarLabels: false`、`layout.scaleExpandedChrome: false` 或
|
|
416
|
+
`disableAnimationOnExpanded: false` 可保留对应的原有行为。预设的
|
|
417
|
+
`autoBarLabels: "all-bars"` 可为柱折图补柱形标签,并复用预设的错层保护。
|
|
418
|
+
`applyChartLayout` 也可单独用于主题处理后的最终布局。
|
|
419
|
+
|
|
390
420
|
## 安全边界
|
|
391
421
|
|
|
392
422
|
默认策略会拒绝:
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PngSampling } from "../layout/expanded-dimensions.js";
|
|
2
2
|
import type { EChartsCanvasInstanceLike } from "./types.js";
|
|
3
|
-
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
}
|
|
7
|
-
export interface PngSampling extends ChartDimensions {
|
|
8
|
-
pixelRatio: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* 由图表统计与宿主的原始高度计算宽幅 PNG 的逻辑尺寸。
|
|
12
|
-
* @param stats 归一化图表的统计
|
|
13
|
-
* @param baseHeight 普通图表的逻辑高度
|
|
14
|
-
* @returns 经过宽幅尺寸范围约束的画布
|
|
15
|
-
*/
|
|
16
|
-
export declare function computeExpandedChartDimensions(stats: ThemeStats, baseHeight: number): ChartDimensions;
|
|
17
|
-
/**
|
|
18
|
-
* 在分配画布前选择满足像素预算的最高采样倍率。
|
|
19
|
-
* @param dimensions 宿主逻辑尺寸
|
|
20
|
-
* @returns 整数逻辑宽高以及 2× 到 4× 的采样倍率
|
|
21
|
-
* @throws Error 尺寸非法或最低倍率仍超过像素预算时抛出
|
|
22
|
-
*/
|
|
23
|
-
export declare function planPngSampling(dimensions: ChartDimensions): PngSampling;
|
|
3
|
+
export { computeExpandedChartDimensions, planPngSampling, type ChartDimensions, type PngSampling, type PngSamplingPlan } from "../layout/expanded-dimensions.js";
|
|
24
4
|
/**
|
|
25
5
|
* 从 Canvas 实例采样并交付静态图片。编码后的画布不再占用导出显存。
|
|
26
6
|
* @param host 静态图片所在的宿主容器
|
|
@@ -32,5 +12,4 @@ export declare function planPngSampling(dimensions: ChartDimensions): PngSamplin
|
|
|
32
12
|
* @returns 可替换图表容器内容的 PNG 图片
|
|
33
13
|
*/
|
|
34
14
|
export declare function freezeEChartsPng(host: HTMLElement, instance: EChartsCanvasInstanceLike, sampling: PngSampling, label: string, timeoutMs: number, signal?: AbortSignal): Promise<HTMLImageElement>;
|
|
35
|
-
export {};
|
|
36
15
|
//# sourceMappingURL=freeze-png.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freeze-png.d.ts","sourceRoot":"","sources":["../../src/browser/freeze-png.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"freeze-png.d.ts","sourceRoot":"","sources":["../../src/browser/freeze-png.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EACL,8BAA8B,EAC9B,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AA4D1C;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,yBAAyB,EACnC,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAqB3B"}
|
|
@@ -1,41 +1,7 @@
|
|
|
1
1
|
import { echartsDomContract } from "../dom-contract.js";
|
|
2
|
-
|
|
2
|
+
export { computeExpandedChartDimensions, planPngSampling } from "../layout/expanded-dimensions.js";
|
|
3
3
|
const maxPngBytes = 8 * 1024 * 1024;
|
|
4
4
|
const pngSignature = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
5
|
-
/**
|
|
6
|
-
* 由图表统计与宿主的原始高度计算宽幅 PNG 的逻辑尺寸。
|
|
7
|
-
* @param stats 归一化图表的统计
|
|
8
|
-
* @param baseHeight 普通图表的逻辑高度
|
|
9
|
-
* @returns 经过宽幅尺寸范围约束的画布
|
|
10
|
-
*/
|
|
11
|
-
export function computeExpandedChartDimensions(stats, baseHeight) {
|
|
12
|
-
const categoryWidth = Math.max(92, Math.round(Math.min(stats.maxCategoryUnits, 14) * 14 + 28));
|
|
13
|
-
const columnChart = stats.hasBarSeries && !stats.isHorizontalBar;
|
|
14
|
-
const width = columnChart
|
|
15
|
-
? Math.min(2200, Math.max(1360, stats.categoryCount * categoryWidth + 140))
|
|
16
|
-
: 1360;
|
|
17
|
-
const extraHeight = stats.hasTitle ? 40 : 0;
|
|
18
|
-
return { width, height: Math.min(980, Math.max(680, Math.round(baseHeight * 1.7 + extraHeight))) };
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 在分配画布前选择满足像素预算的最高采样倍率。
|
|
22
|
-
* @param dimensions 宿主逻辑尺寸
|
|
23
|
-
* @returns 整数逻辑宽高以及 2× 到 4× 的采样倍率
|
|
24
|
-
* @throws Error 尺寸非法或最低倍率仍超过像素预算时抛出
|
|
25
|
-
*/
|
|
26
|
-
export function planPngSampling(dimensions) {
|
|
27
|
-
const width = Math.round(dimensions.width);
|
|
28
|
-
const height = Math.round(dimensions.height);
|
|
29
|
-
if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1) {
|
|
30
|
-
throw new Error("PNG 导出需要有效的图表尺寸");
|
|
31
|
-
}
|
|
32
|
-
for (let pixelRatio = 4; pixelRatio >= 2; pixelRatio -= 0.5) {
|
|
33
|
-
if (Math.floor(width * pixelRatio) * Math.floor(height * pixelRatio) <= maxPngPixels) {
|
|
34
|
-
return { width, height, pixelRatio };
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
throw new Error("PNG 导出超过像素上限");
|
|
38
|
-
}
|
|
39
5
|
/**
|
|
40
6
|
* 等待浏览器编码 PNG,确保取消和超时时不会遗留监听。
|
|
41
7
|
* @param canvas 已绘制完成的画布
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freeze-png.js","sourceRoot":"","sources":["../../src/browser/freeze-png.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD,
|
|
1
|
+
{"version":3,"file":"freeze-png.js","sourceRoot":"","sources":["../../src/browser/freeze-png.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,EACL,8BAA8B,EAC9B,eAAe,EAIhB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACpC,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,MAAyB,EAAE,SAAiB,EAAE,MAAoB;IACnF,IAAI,KAAoC,CAAC;IACzC,IAAI,KAAiB,CAAC;IACtB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC;QACtE,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CA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,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACtD,KAAK,CAAC,SAAS,GAAG,GAAG,kBAAkB,CAAC,WAAW,YAAY,CAAC;QAChE,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC;QAClB,KAAK,CAAC,GAAG,GAAG,MAAM,cAAc,CAAC,MAAM,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5F,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;QAC3B,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACjB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;AACH,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function freezeEChartsSvg(host: HTMLElement, source: SVGSVGElement, outputMode: "inline-svg" | "svg-image", label: string):
|
|
1
|
+
export declare function freezeEChartsSvg(host: HTMLElement, source: SVGSVGElement, outputMode: "inline-svg" | "svg-image", label: string): HTMLImageElement | SVGSVGElement;
|
|
2
2
|
//# sourceMappingURL=freeze-svg.d.ts.map
|
package/dist/browser/layout.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ThemeStats } from "../theme/schema.js";
|
|
3
|
-
export interface PlotLayout {
|
|
4
|
-
mode: "card" | "expanded";
|
|
5
|
-
width: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* 根据宿主给出的宽度与档位处理笛卡尔坐标系的类目标签和网格。
|
|
9
|
-
* @param option 已应用主题和输出模式的配置
|
|
10
|
-
* @param rawOption 未变换的围栏配置,用于识别用户的显式值
|
|
11
|
-
* @param stats 从围栏数据派生的统计
|
|
12
|
-
* @param layout 宿主传入的显示尺寸与档位
|
|
13
|
-
* @returns 新的引擎配置
|
|
14
|
-
*/
|
|
15
|
-
export declare function applyChartLayout(option: JsonObject, rawOption: JsonObject, stats: ThemeStats, layout: PlotLayout): Record<string, unknown>;
|
|
1
|
+
export { applyChartLayout, type PlotLayout } from "../layout/chart-layout.js";
|
|
16
2
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/browser/layout.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/browser/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/browser/layout.js
CHANGED
|
@@ -1,147 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* 按字符宽单位折行,并对超出三行的文字给出省略提示。
|
|
4
|
-
* @param value 类目值
|
|
5
|
-
* @param limit 每行的宽单位
|
|
6
|
-
* @returns 最多三行的类目标签,原始类目数据不变
|
|
7
|
-
*/
|
|
8
|
-
function wrapCategory(value, limit) {
|
|
9
|
-
const lines = [];
|
|
10
|
-
let line = "";
|
|
11
|
-
let units = 0;
|
|
12
|
-
for (const char of value) {
|
|
13
|
-
const width = textWidthUnits(char);
|
|
14
|
-
if (char === "\n" || units + width > limit) {
|
|
15
|
-
if (lines.length === 2) {
|
|
16
|
-
return [...lines, line + "…"].join("\n");
|
|
17
|
-
}
|
|
18
|
-
lines.push(line);
|
|
19
|
-
line = "";
|
|
20
|
-
units = 0;
|
|
21
|
-
if (char === "\n")
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
line += char;
|
|
25
|
-
units += width;
|
|
26
|
-
}
|
|
27
|
-
return [...lines, line].join("\n");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 由类目统计、标题和图例的位置计算网格默认留白。
|
|
31
|
-
* @param option 已应用主题的配置
|
|
32
|
-
* @param stats 图表统计
|
|
33
|
-
* @param expanded 宿主是否要求宽幅布局
|
|
34
|
-
* @param fontSize 用于估算轴名称的字号
|
|
35
|
-
* @returns 四个方向的数字边距
|
|
36
|
-
*/
|
|
37
|
-
function gridMargins(option, stats, expanded, fontSize) {
|
|
38
|
-
const legends = toObjectList(option.legend).filter((legend) => legend.show !== false);
|
|
39
|
-
const hasTopLegend = legends.some(({ top }) => top !== undefined && top !== "auto");
|
|
40
|
-
const hasBottomLegend = legends.some(({ bottom }) => bottom !== undefined && bottom !== "auto");
|
|
41
|
-
const titleOrAxis = Number(stats.hasTitle) + Number(stats.hasYAxisName);
|
|
42
|
-
const topLevel = hasTopLegend ? 2 + titleOrAxis : titleOrAxis;
|
|
43
|
-
const top = (expanded ? [36, 56, 68, 80, 92] : [24, 44, 54, 66, 76])[topLevel];
|
|
44
|
-
const right = stats.maxXAxisNameUnits > 0
|
|
45
|
-
? Math.min(expanded ? 140 : 96, Math.max(expanded ? 40 : 24, Math.ceil(stats.maxXAxisNameUnits * fontSize + 34)))
|
|
46
|
-
: expanded ? 40 : 24;
|
|
47
|
-
return {
|
|
48
|
-
left: expanded ? 36 : 22,
|
|
49
|
-
right,
|
|
50
|
-
top,
|
|
51
|
-
bottom: hasBottomLegend ? (expanded ? 64 : 54) : (expanded ? 36 : 26)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* 应用默认最小边距,并保留用户选择的 ECharts 边界模式。
|
|
56
|
-
* @param grid 已应用主题的单个网格
|
|
57
|
-
* @param raw 原始网格,用于区分主题默认与显式配置
|
|
58
|
-
* @param margins 计算出的数字边距
|
|
59
|
-
* @returns 新的网格配置
|
|
60
|
-
*/
|
|
61
|
-
function applyGridMargins(grid, raw, margins) {
|
|
62
|
-
const result = { ...grid };
|
|
63
|
-
if (!Object.hasOwn(raw, "containLabel")) {
|
|
64
|
-
// 新布局采用 ECharts 6 外边界,旧预设默认值会使引擎进入兼容分支。
|
|
65
|
-
delete result.containLabel;
|
|
66
|
-
}
|
|
67
|
-
for (const side of ["left", "right", "top", "bottom"]) {
|
|
68
|
-
const current = result[side];
|
|
69
|
-
if (current === undefined || typeof current === "number") {
|
|
70
|
-
result[side] = Math.max(current ?? 0, margins[side]);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return withDefaults(result, { outerBoundsMode: "auto" });
|
|
74
|
-
}
|
|
75
|
-
/** 获取单轴标签的最长宽单位,支持 ECharts 的带样式类目项。 */
|
|
76
|
-
function axisMaxUnits(axis) {
|
|
77
|
-
if (!Array.isArray(axis.data))
|
|
78
|
-
return 0;
|
|
79
|
-
return axis.data.reduce((max, item) => {
|
|
80
|
-
const value = isJsonObject(item) ? item.value : item;
|
|
81
|
-
return typeof value === "string" || typeof value === "number"
|
|
82
|
-
? Math.max(max, textWidthUnits(String(value)))
|
|
83
|
-
: max;
|
|
84
|
-
}, 0);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 按槽宽倾斜横轴类目标签并追加库自己的折行函数。
|
|
88
|
-
* @param axis 单个轴配置
|
|
89
|
-
* @param context 包含槽宽所需的布局统计
|
|
90
|
-
* @param horizontalAxis 当前轴是否为 xAxis
|
|
91
|
-
* @returns 新的轴选项,保留显式格式化和对齐
|
|
92
|
-
*/
|
|
93
|
-
function styleCategoryAxis(axis, context, horizontalAxis) {
|
|
94
|
-
if (!isCategoryAxis(axis))
|
|
95
|
-
return axis;
|
|
96
|
-
const label = ensureObject(axis.axisLabel);
|
|
97
|
-
const fontSize = typeof label.fontSize === "number" ? label.fontSize : context.fontSize;
|
|
98
|
-
const width = Math.max(1, context.layout.width - context.margins.left - context.margins.right);
|
|
99
|
-
const count = Array.isArray(axis.data) ? axis.data.length : context.stats.categoryCount;
|
|
100
|
-
const slotPx = width / Math.max(1, count);
|
|
101
|
-
const longest = axisMaxUnits(axis) * fontSize;
|
|
102
|
-
const tilt = horizontalAxis && longest > slotPx * 0.94;
|
|
103
|
-
const defaults = tilt
|
|
104
|
-
? { rotate: longest > slotPx * 1.75 || count >= 14 ? 38 : 30, align: "right", verticalAlign: "top", margin: 10 }
|
|
105
|
-
: {};
|
|
106
|
-
const nextLabel = withDefaults(label, defaults);
|
|
107
|
-
if (!Object.hasOwn(label, "formatter") && !Object.hasOwn(label, "rich")) {
|
|
108
|
-
const limit = context.layout.mode === "expanded" ? 14 : 10;
|
|
109
|
-
// 只在运行期交给引擎,避免改写类目值或把函数放进围栏协议。
|
|
110
|
-
nextLabel.formatter = (value) => wrapCategory(String(value), limit);
|
|
111
|
-
}
|
|
112
|
-
return { ...axis, axisLabel: nextLabel };
|
|
113
|
-
}
|
|
114
|
-
/** 保持轴配置的对象或数组形态。 */
|
|
115
|
-
function styleAxes(value, context, horizontalAxis) {
|
|
116
|
-
if (Array.isArray(value)) {
|
|
117
|
-
return value.map((item) => isJsonObject(item) ? styleCategoryAxis(item, context, horizontalAxis) : item);
|
|
118
|
-
}
|
|
119
|
-
return styleCategoryAxis(ensureObject(value), context, horizontalAxis);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* 根据宿主给出的宽度与档位处理笛卡尔坐标系的类目标签和网格。
|
|
123
|
-
* @param option 已应用主题和输出模式的配置
|
|
124
|
-
* @param rawOption 未变换的围栏配置,用于识别用户的显式值
|
|
125
|
-
* @param stats 从围栏数据派生的统计
|
|
126
|
-
* @param layout 宿主传入的显示尺寸与档位
|
|
127
|
-
* @returns 新的引擎配置
|
|
128
|
-
*/
|
|
129
|
-
export function applyChartLayout(option, rawOption, stats, layout) {
|
|
130
|
-
if (toObjectList(option.xAxis).length === 0 || toObjectList(option.yAxis).length === 0)
|
|
131
|
-
return option;
|
|
132
|
-
const textStyle = ensureObject(option.textStyle);
|
|
133
|
-
const fontSize = typeof textStyle.fontSize === "number" ? textStyle.fontSize : 12;
|
|
134
|
-
const margins = gridMargins(option, stats, layout.mode === "expanded", fontSize);
|
|
135
|
-
const rawGrids = Array.isArray(rawOption.grid) ? rawOption.grid : [];
|
|
136
|
-
const context = { layout, stats, fontSize, margins };
|
|
137
|
-
const grid = Array.isArray(option.grid)
|
|
138
|
-
? option.grid.map((item, index) => applyGridMargins(ensureObject(item), ensureObject(rawGrids[index]), margins))
|
|
139
|
-
: applyGridMargins(ensureObject(option.grid), ensureObject(rawOption.grid), margins);
|
|
140
|
-
return {
|
|
141
|
-
...option,
|
|
142
|
-
grid,
|
|
143
|
-
xAxis: styleAxes(option.xAxis, context, true),
|
|
144
|
-
yAxis: styleAxes(option.yAxis, context, false)
|
|
145
|
-
};
|
|
146
|
-
}
|
|
1
|
+
export { applyChartLayout } from "../layout/chart-layout.js";
|
|
147
2
|
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/browser/layout.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/browser/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JsonObject } from "../theme/json.js";
|
|
2
2
|
import type { ThemeDefinition, ThemeStats } from "../theme/schema.js";
|
|
3
|
-
import { type PlotLayout } from "
|
|
3
|
+
import { type PlotLayout } from "../layout/chart-layout.js";
|
|
4
4
|
import type { EChartsOutputMode } from "./types.js";
|
|
5
5
|
/**
|
|
6
6
|
* 将主题注册表的解析结果与宿主选定的输出模式合成引擎选项。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-options.d.ts","sourceRoot":"","sources":["../../src/browser/render-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"render-options.d.ts","sourceRoot":"","sources":["../../src/browser/render-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAoCpD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,UAAU,EAAE,iBAAiB,EAC7B,KAAK,EAAE,UAAU,EACjB,MAAM,CAAC,EAAE,UAAU,GAClB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAezB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { applyChartLayout } from "../layout/chart-layout.js";
|
|
2
|
+
import { styleChartOption } from "../layout/interactive-option.js";
|
|
3
3
|
const maxMotionTimeMs = 5_000;
|
|
4
4
|
const timingKeys = [
|
|
5
5
|
"animationDelay",
|
|
@@ -42,10 +42,7 @@ function boundMotionTiming(option) {
|
|
|
42
42
|
* @throws EChartsFenceError 预设的管线输出不通过安全校验时抛出
|
|
43
43
|
*/
|
|
44
44
|
export function prepareChartRenderOptions(rawOption, theme, outputMode, stats, layout) {
|
|
45
|
-
const
|
|
46
|
-
const themedOption = preset
|
|
47
|
-
? applyThemePreset(rawOption, preset, stats)
|
|
48
|
-
: rawOption;
|
|
45
|
+
const themedOption = styleChartOption(rawOption, theme, stats, layout);
|
|
49
46
|
const exportBg = theme?.tokens.colors?.exportBg;
|
|
50
47
|
const option = outputMode !== "interactive" &&
|
|
51
48
|
exportBg !== undefined &&
|
|
@@ -54,7 +51,7 @@ export function prepareChartRenderOptions(rawOption, theme, outputMode, stats, l
|
|
|
54
51
|
: themedOption;
|
|
55
52
|
// 关闭动效时同样覆写系列,防止系列显式开关让静态输出停在中间帧。
|
|
56
53
|
const series = option.series;
|
|
57
|
-
const adjusted = outputMode === "interactive" && preset && option.animation === true
|
|
54
|
+
const adjusted = outputMode === "interactive" && theme?.kind === "preset" && option.animation === true
|
|
58
55
|
? { ...boundMotionTiming(option), series: series.map(boundMotionTiming) }
|
|
59
56
|
: { ...option, ...disabledMotion, series: series.map((item) => ({ ...item, ...disabledMotion })) };
|
|
60
57
|
return layout ? applyChartLayout(adjusted, rawOption, stats, layout) : adjusted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../src/browser/render-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../src/browser/render-options.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,UAAU,GAAG;IACjB,gBAAgB;IAChB,sBAAsB;IACtB,mBAAmB;IACnB,yBAAyB;CACjB,CAAC;AAEX,MAAM,cAAc,GAAG;IACrB,SAAS,EAAE,KAAK;IAChB,cAAc,EAAE,CAAC;IACjB,oBAAoB,EAAE,CAAC;IACvB,iBAAiB,EAAE,CAAC;IACpB,uBAAuB,EAAE,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,MAAkB;IAC3C,MAAM,OAAO,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB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c,EAAE,CAAC,CAAC,EAAE,CAAC;IACrG,OAAO,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClF,CAAC"}
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export * from "./browser/engine.js";
|
|
2
|
+
export * from "./browser/freeze-png.js";
|
|
2
3
|
export * from "./browser/freeze-svg.js";
|
|
3
4
|
export * from "./browser/render-blocks.js";
|
|
4
5
|
export * from "./browser/render-chart.js";
|
|
6
|
+
export { prepareChartRenderOptions } from "./browser/render-options.js";
|
|
5
7
|
export * from "./browser/resource-policy.js";
|
|
6
8
|
export * from "./browser/types.js";
|
|
9
|
+
export { applyChartLayout, type PlotLayout } from "./layout/chart-layout.js";
|
|
10
|
+
export { prepareInteractiveChartOption, type PrepareInteractiveChartOptions } from "./layout/interactive-option.js";
|
|
11
|
+
export { applyThemePreset } from "./theme/preset.js";
|
|
7
12
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,KAAK,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AACpH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/browser.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export * from "./browser/engine.js";
|
|
2
|
+
export * from "./browser/freeze-png.js";
|
|
2
3
|
export * from "./browser/freeze-svg.js";
|
|
3
4
|
export * from "./browser/render-blocks.js";
|
|
4
5
|
export * from "./browser/render-chart.js";
|
|
6
|
+
export { prepareChartRenderOptions } from "./browser/render-options.js";
|
|
5
7
|
export * from "./browser/resource-policy.js";
|
|
6
8
|
export * from "./browser/types.js";
|
|
9
|
+
export { applyChartLayout } from "./layout/chart-layout.js";
|
|
10
|
+
export { prepareInteractiveChartOption } from "./layout/interactive-option.js";
|
|
11
|
+
export { applyThemePreset } from "./theme/preset.js";
|
|
7
12
|
//# sourceMappingURL=browser.js.map
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAuC,MAAM,gCAAgC,CAAC;AACpH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from "./dom-contract.js";
|
|
2
|
+
export { applyChartLayout, type PlotLayout } from "./layout/chart-layout.js";
|
|
3
|
+
export * from "./layout/expanded-dimensions.js";
|
|
4
|
+
export { prepareInteractiveChartOption, type PrepareInteractiveChartOptions } from "./layout/interactive-option.js";
|
|
2
5
|
export * from "./markdown-it-plugin.js";
|
|
3
6
|
export * from "./normalize-spec.js";
|
|
4
7
|
export * from "./parse-yaml.js";
|
|
@@ -13,4 +16,5 @@ export * from "./theme/registry.js";
|
|
|
13
16
|
export { assertSafeNativeTheme, assertSafeExtraCssText } from "./theme/sanitize.js";
|
|
14
17
|
export * from "./theme/schema.js";
|
|
15
18
|
export * from "./theme/stats.js";
|
|
19
|
+
export { defaultTitleTop, pixelPosition, legendPlacement, safeLegendTop, keepLegendBelowTitle } from "./theme/title-legend-layout.js";
|
|
16
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACpF,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7E,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,KAAK,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AACpH,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACpF,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from "./dom-contract.js";
|
|
2
|
+
export { applyChartLayout } from "./layout/chart-layout.js";
|
|
3
|
+
export * from "./layout/expanded-dimensions.js";
|
|
4
|
+
export { prepareInteractiveChartOption } from "./layout/interactive-option.js";
|
|
2
5
|
export * from "./markdown-it-plugin.js";
|
|
3
6
|
export * from "./normalize-spec.js";
|
|
4
7
|
export * from "./parse-yaml.js";
|
|
@@ -12,4 +15,5 @@ export * from "./theme/registry.js";
|
|
|
12
15
|
export { assertSafeNativeTheme, assertSafeExtraCssText } from "./theme/sanitize.js";
|
|
13
16
|
export * from "./theme/schema.js";
|
|
14
17
|
export * from "./theme/stats.js";
|
|
18
|
+
export { defaultTitleTop, pixelPosition, legendPlacement, safeLegendTop, keepLegendBelowTitle } from "./theme/title-legend-layout.js";
|
|
15
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AAExC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACpF,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAC7E,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAuC,MAAM,gCAAgC,CAAC;AACpH,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AAExC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACpF,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type JsonObject } from "../theme/json.js";
|
|
2
|
+
import type { ThemeStats } from "../theme/schema.js";
|
|
3
|
+
export interface PlotLayout {
|
|
4
|
+
mode: "card" | "expanded";
|
|
5
|
+
width: number;
|
|
6
|
+
fontFamily?: string;
|
|
7
|
+
autoBarLabels?: boolean | "pure-bar" | "all-bars";
|
|
8
|
+
scaleExpandedChrome?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 根据宿主给出的宽度与档位处理笛卡尔坐标系的类目标签和网格。
|
|
12
|
+
* @param option 已应用主题和输出模式的配置
|
|
13
|
+
* @param rawOption 未变换的围栏配置,用于识别用户的显式值
|
|
14
|
+
* @param stats 从围栏数据派生的统计
|
|
15
|
+
* @param layout 宿主传入的显示尺寸与档位
|
|
16
|
+
* @returns 新的引擎配置
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyChartLayout(option: JsonObject, rawOption: JsonObject, stats: ThemeStats, layout: PlotLayout): Record<string, unknown>;
|
|
19
|
+
//# sourceMappingURL=chart-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-layout.d.ts","sourceRoot":"","sources":["../../src/layout/chart-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMrD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;IAClD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAkOD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,UAAU,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkBzB"}
|