feat: 扩展 ECharts 第二阶段图表支持
新增 tree、treemap、sunburst、graph、sankey、chord、funnel、gauge 和 pictorialBar 系列,并注册对应的 ECharts 按需模块。 完善层级与关系数据校验、节点和边数量限制、默认布局及错误占位规则,同时补充默认 Markdown 与 README 示例。 静态渲染全局关闭 ECharts 动画,修复 Treemap 标签冻结在透明动画帧的问题,并完成快速预览、精确 PDF、容器镜像和 147 项全项目测试验证。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
defaultEChartsSecurityLimits,
|
||||
normalizeAndValidateEChartsOption
|
||||
} from "../src/index.js";
|
||||
|
||||
@@ -47,6 +48,73 @@ describe("normalizeAndValidateEChartsOption", () => {
|
||||
).toThrow(/暂不支持 custom/u);
|
||||
});
|
||||
|
||||
it("接受第二阶段系列和安全的内嵌矢量路径", () => {
|
||||
const types = [
|
||||
"tree",
|
||||
"treemap",
|
||||
"sunburst",
|
||||
"graph",
|
||||
"sankey",
|
||||
"chord",
|
||||
"funnel",
|
||||
"gauge",
|
||||
"pictorialBar"
|
||||
];
|
||||
expect(
|
||||
normalizeAndValidateEChartsOption({
|
||||
series: types.map((type) => ({
|
||||
type,
|
||||
...(type === "pictorialBar"
|
||||
? { symbol: "path://M0,0 L10,0 L10,10 Z" }
|
||||
: {})
|
||||
}))
|
||||
}).series
|
||||
).toHaveLength(types.length);
|
||||
});
|
||||
|
||||
it("限制层级节点和关系边数量", () => {
|
||||
const limits = {
|
||||
...defaultEChartsSecurityLimits,
|
||||
maxHierarchyNodes: 2,
|
||||
maxGraphEdges: 1
|
||||
};
|
||||
expect(() =>
|
||||
normalizeAndValidateEChartsOption(
|
||||
{
|
||||
series: [
|
||||
{
|
||||
type: "tree",
|
||||
data: [
|
||||
{
|
||||
children: [{ value: 1 }, { value: 2 }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
limits
|
||||
)
|
||||
).toThrow(/层级节点数量不能超过 2/u);
|
||||
|
||||
expect(() =>
|
||||
normalizeAndValidateEChartsOption(
|
||||
{
|
||||
series: [
|
||||
{
|
||||
type: "graph",
|
||||
data: [{ name: "A" }, { name: "B" }],
|
||||
links: [
|
||||
{ source: "A", target: "B" },
|
||||
{ source: "B", target: "A" }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
limits
|
||||
)
|
||||
).toThrow(/边数量不能超过 1/u);
|
||||
});
|
||||
|
||||
it("拒绝外部资源和危险链接", () => {
|
||||
expect(() =>
|
||||
normalizeAndValidateEChartsOption({
|
||||
|
||||
Reference in New Issue
Block a user