PPTX
SmartArt
创建预定义的 SmartArt 图示,用于流程、层级结构等
使用 SmartArtFrame 添加 SmartArt 图形 — 预定义的图示布局,用于可视化流程、层级结构、关系等。
基本 SmartArt
import { Slide, SmartArtFrame } from "@office-open/pptx";
new Slide({
children: [
new SmartArtFrame({
x: 1,
y: 1,
width: 8,
height: 4,
layout: "process",
data: [
{ text: "Step 1", bullets: ["Detail A"] },
{ text: "Step 2", bullets: ["Detail B"] },
{ text: "Step 3", bullets: ["Detail C"] },
],
}),
],
});
可用布局
常用的 SmartArt 布局包括:
| 布局 | 说明 |
|---|---|
process | 顺序流程步骤 |
cycle | 循环/重复流程 |
hierarchy | 组织层级结构 |
relationship | 径向/关系图 |
matrix | 矩阵布局 |
pyramid | 金字塔/比例关系 |
list | 垂直列表 |
chevron | 箭头流程 |
层级结构示例
new SmartArtFrame({
x: 0.5,
y: 0.5,
width: 9,
height: 5,
layout: "hierarchy",
data: [
{ text: "CEO" },
{
text: "CTO",
bullets: ["Engineering", "Product"],
},
{
text: "CFO",
bullets: ["Finance", "Accounting"],
},
],
});
循环示例
new SmartArtFrame({
x: 1,
y: 1,
width: 7,
height: 4,
layout: "cycle",
data: [
{ text: "Plan" },
{ text: "Design" },
{ text: "Develop" },
{ text: "Test" },
{ text: "Deploy" },
],
});
SmartArt 样式
控制配色方案和快速样式:
new SmartArtFrame({
x: 1,
y: 1,
width: 8,
height: 4,
layout: "process",
data: [{ text: "Phase 1" }, { text: "Phase 2" }, { text: "Phase 3" }],
colorStyle: "accent2_1", // 配色方案
quickStyle: "simple", // 视觉样式
});
带项目符号的嵌套数据
new SmartArtFrame({
x: 1,
y: 1,
width: 8,
height: 5,
layout: "list",
data: [
{
text: "Strategy",
bullets: ["Market Analysis", "Competitive Review", "Growth Planning"],
},
{
text: "Execution",
bullets: ["Product Development", "Sales & Marketing"],
},
],
});
配色方案
可用的配色方案选项:
| 值 | 说明 |
|---|---|
"accent1_1" — "accent6_1" | 强调色,变体 1 |
"accent1_2" — "accent6_2" | 强调色,变体 2 |
"accent1_3" — "accent6_3" | 强调色,变体 3 |
"colorful" | 多色 |
"primary" | 主主题色 |
快速样式
| 值 | 说明 |
|---|---|
"simple" | 简洁外观 |
"whiteOutline" | 白色轮廓样式 |
"intense" | 醒目高对比 |
"gradient" | 渐变填充 |
"flat" | 扁平,无 3D 效果 |
SmartArtFrame 选项
| 选项 | 类型 | 说明 |
|---|---|---|
x | number | 水平位置(英寸) |
y | number | 垂直位置(英寸) |
width | number | 宽度(英寸) |
height | number | 高度(英寸) |
layout | string | SmartArt 布局名称 |
data | array | { text, bullets? } 对象数组 |
colorStyle | string | 配色方案标识符 |
quickStyle | string | 视觉样式标识符 |