feat: 扩展 ECharts 第二阶段图表支持

新增 tree、treemap、sunburst、graph、sankey、chord、funnel、gauge 和 pictorialBar 系列,并注册对应的 ECharts 按需模块。

完善层级与关系数据校验、节点和边数量限制、默认布局及错误占位规则,同时补充默认 Markdown 与 README 示例。

静态渲染全局关闭 ECharts 动画,修复 Treemap 标签冻结在透明动画帧的问题,并完成快速预览、精确 PDF、容器镜像和 147 项全项目测试验证。
This commit is contained in:
SkyJourney
2026-07-27 17:47:28 +08:00
parent f5a46f79f1
commit 92a5bfd016
13 changed files with 1162 additions and 21 deletions
@@ -182,4 +182,184 @@ describe("ECharts 系列语义验证", () => {
})
).toThrow(/option\.polar/u);
});
it("支持树图并校验递归 children 结构", () => {
expect(
validate({
series: [
{
type: "tree",
data: [
{
name: "根节点",
children: [{ name: "子节点" }]
}
]
}
]
})
).toMatchObject({
series: [{ type: "tree" }]
});
expect(() =>
validate({
series: [
{
type: "tree",
data: [{ name: "根节点", children: "错误" }]
}
]
})
).toThrow(/data\.0\.children /u);
});
it("矩形树图和旭日图要求叶节点数值", () => {
for (const type of ["treemap", "sunburst"]) {
expect(
validate({
series: [
{
type,
data: [
{
name: "分类",
children: [{ name: "项目", value: 12 }]
}
]
}
]
})
).toMatchObject({ series: [{ type }] });
expect(() =>
validate({
series: [
{
type,
data: [{ name: "无数值叶节点" }]
}
]
})
).toThrow(/data\.0\.value /u);
}
});
it("关系图默认选择可渲染布局并校验边引用", () => {
expect(
validate({
series: [
{
type: "graph",
data: [{ name: "A" }, { name: "B" }],
links: [{ source: "A", target: "B" }]
}
]
})
).toMatchObject({
series: [{ type: "graph", layout: "force" }]
});
expect(
validate({
series: [
{
type: "graph",
data: [
{ name: "A", x: 10, y: 20 },
{ name: "B", x: 30, y: 40 }
]
}
]
})
).toMatchObject({
series: [{ type: "graph", layout: "none" }]
});
expect(() =>
validate({
series: [
{
type: "graph",
nodes: [{ name: "A" }],
edges: [{ source: "A", target: "B" }]
}
]
})
).toThrow(/edges\.0\.target /u);
});
it("桑基图和和弦图要求有效节点、关系边和权重", () => {
for (const type of ["sankey", "chord"]) {
expect(
validate({
series: [
{
type,
data: [{ name: "A" }, { name: "B" }],
links: [
{ source: "A", target: "B", value: 12 }
]
}
]
})
).toMatchObject({ series: [{ type }] });
expect(() =>
validate({
series: [
{
type,
data: [{ name: "A" }, { name: "B" }],
links: [{ source: "A", target: "B" }]
}
]
})
).toThrow(/links\.0\.value /u);
}
});
it("漏斗图和仪表盘要求有限数值", () => {
for (const type of ["funnel", "gauge"]) {
expect(
validate({
series: [
{
type,
data: [{ name: "完成率", value: 72 }]
}
]
})
).toMatchObject({ series: [{ type }] });
expect(() =>
validate({
series: [
{
type,
data: [{ name: "完成率", value: "72" }]
}
]
})
).toThrow(/data\.0\.value /u);
}
});
it("象形柱图复用柱图数据和坐标轴默认值", () => {
expect(
validate({
series: [
{
type: "pictorialBar",
symbol: "path://M0,0 L10,0 L10,10 Z",
data: [12, 18]
}
]
})
).toMatchObject({
xAxis: {},
yAxis: {},
series: [{ type: "pictorialBar" }]
});
});
});