dsh-ppt 0.33.0 → 0.35.0
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/CHANGELOG.md +42 -0
- package/README.en.md +8 -10
- package/README.md +8 -10
- package/docs/USAGE.en.md +44 -35
- package/docs/USAGE.md +45 -36
- package/docs/VALIDATION.md +8 -0
- package/lib/client.js +116 -17
- package/lib/ecosystem.js +10 -0
- package/lib/execution.js +36 -5
- package/lib/tools.js +74 -4
- package/lib/types.d.ts +79 -1
- package/lib/workbench.js +255 -14
- package/package.json +2 -2
- package/skills/dsh-ppt/SKILL.md +34 -31
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/office-pack.md +124 -0
- package/skills/dsh-ppt/references/research-plan.md +93 -62
- package/skills/dsh-ppt/scripts/build-deck.mjs +109 -3
- package/skills/dsh-ppt/scripts/deck-absorb.mjs +21 -0
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +330 -37
- package/skills/dsh-ppt/scripts/deck-brand-kit.mjs +257 -0
- package/skills/dsh-ppt/scripts/deck-charts-exec.mjs +805 -0
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +47 -1
- package/skills/dsh-ppt/scripts/deck-compose.mjs +386 -0
- package/skills/dsh-ppt/scripts/deck-core.mjs +136 -16
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +750 -17
- package/skills/dsh-ppt/scripts/deck-evidence.mjs +811 -118
- package/skills/dsh-ppt/scripts/deck-export.mjs +652 -0
- package/skills/dsh-ppt/scripts/deck-i18n.mjs +170 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +72 -8
- package/skills/dsh-ppt/scripts/deck-media.mjs +22 -0
- package/skills/dsh-ppt/scripts/deck-office.mjs +1455 -14
- package/skills/dsh-ppt/scripts/deck-remix.mjs +471 -0
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deck-charts-exec.mjs —— 4 套高管咨询级原生矢量图谱渲染器(零新增依赖):
|
|
3
|
+
* 1. `issue-tree`(别名 `mece` / `logic-tree`):麦肯锡 MECE 逻辑议题树(左核心议题 → 中一级分支 → 右二级假设/行动叶节点 + 原生正交连接线)
|
|
4
|
+
* 2. `treemap`(别名 `rect-map` / `budget-map`):Squarified Treemap 比例矩形树图(预算/营收/成本占比面积精确切分 + WCAG 自动反白文字)
|
|
5
|
+
* 3. `gauge`(别名 `bullet-chart` / `okr-gauge`):Stephen Few 高管水平子弹图 / OKR 达标仪(三段定性区间底带 + 实绩柱 + 目标阈值垂线 + 右侧达标徽章)
|
|
6
|
+
* 4. `pricing`(别名 `tiers` / `packages`):Good / Better / Best 三档商业报价与方案选型矩阵(主推档顶条高亮 + 价格锚点 + 权益清单)
|
|
7
|
+
*
|
|
8
|
+
* 100% HTML/SVG 与 PPTX 原生可编辑 OOXML 双端同构渲染。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { relativeLuminance, mixHex } from './deck-themes.mjs'
|
|
12
|
+
import {
|
|
13
|
+
escapeHtml,
|
|
14
|
+
stripInlineMarkdown,
|
|
15
|
+
renderInlineHtml,
|
|
16
|
+
computeTextFit,
|
|
17
|
+
resolveEffectiveItems,
|
|
18
|
+
ooxmlShape,
|
|
19
|
+
ooxmlRichParagraph,
|
|
20
|
+
ooxmlLine,
|
|
21
|
+
renderSurfaceCardPptx,
|
|
22
|
+
} from './deck-chrome.mjs'
|
|
23
|
+
|
|
24
|
+
export const EXEC_CHART_LAYOUTS = new Set(['issue-tree', 'treemap', 'gauge', 'pricing'])
|
|
25
|
+
|
|
26
|
+
function parseNumericVal(raw, fallback = 0) {
|
|
27
|
+
if (typeof raw === 'number' && Number.isFinite(raw)) return raw
|
|
28
|
+
const s = String(raw ?? '').replace(/,/g, '')
|
|
29
|
+
const m = /[+-]?(?:\d+\.?\d*|\.\d+)/.exec(s)
|
|
30
|
+
if (!m) return fallback
|
|
31
|
+
const n = Number(m[0])
|
|
32
|
+
return Number.isFinite(n) ? n : fallback
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function extractUnit(raw) {
|
|
36
|
+
const s = String(raw ?? '').trim()
|
|
37
|
+
if (!s) return ''
|
|
38
|
+
const cur = /^[¥$€£]/.exec(s)?.[0] || ''
|
|
39
|
+
const suf = /(%|%|亿元|亿美元|万元|美元|元|万|亿|k|K|M|B|GWh|GW|ms|s|家|人|天|小时|\/月|\/年|\/mo|\/yr)$/.exec(s)?.[1] || ''
|
|
40
|
+
return suf || cur
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function fmtCompact(num, unit = '') {
|
|
44
|
+
if (!Number.isFinite(num)) return '0'
|
|
45
|
+
const abs = Math.abs(num)
|
|
46
|
+
const str = abs >= 1000 ? Math.round(num).toLocaleString('en-US') : (Number.isInteger(num) ? String(num) : Number(num.toFixed(1)).toString())
|
|
47
|
+
if (['¥', '$', '€', '£'].includes(unit)) return unit + str
|
|
48
|
+
if (unit === '%' || unit === '%') return str + '%'
|
|
49
|
+
return unit ? `${str}${unit}` : str
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function contrastInkOn(bgHex) {
|
|
53
|
+
return relativeLuminance(bgHex) > 0.36 ? '#0F172A' : '#FFFFFF'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// 1. issue-tree (MECE Logic Tree)
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
export function computeIssueTreeModel(slide) {
|
|
61
|
+
const items = resolveEffectiveItems(slide).slice(0, 4)
|
|
62
|
+
const rootLabel = stripInlineMarkdown(slide.text || slide.subtitle || slide.title || 'Core Strategic Question').slice(0, 56)
|
|
63
|
+
const rootTag = stripInlineMarkdown(slide.kicker || 'ROOT ISSUE').slice(0, 22)
|
|
64
|
+
|
|
65
|
+
const branches = (items.length > 0 ? items : [
|
|
66
|
+
{ tag: '01', title: '增长引擎', bullets: ['拓展高价值行业客户', '提升现有客户净留存 NRR'] },
|
|
67
|
+
{ tag: '02', title: '成本优化', bullets: ['推理算力单元成本压缩 40%', '自动化交付缩短实施周期'] },
|
|
68
|
+
{ tag: '03', title: '组织保障', bullets: ['建立标杆案例复用机制', '季度 OKR 与激励强绑定'] },
|
|
69
|
+
]).map((it, idx) => {
|
|
70
|
+
let leaves = []
|
|
71
|
+
if (Array.isArray(it.bullets) && it.bullets.length > 0) {
|
|
72
|
+
leaves = it.bullets.slice(0, 3).map((b) => stripInlineMarkdown(b).trim()).filter(Boolean)
|
|
73
|
+
} else if (typeof it.text === 'string' && it.text.trim()) {
|
|
74
|
+
leaves = it.text
|
|
75
|
+
.split(/[;;|\n]/)
|
|
76
|
+
.map((s) => stripInlineMarkdown(s).trim())
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.slice(0, 3)
|
|
79
|
+
}
|
|
80
|
+
if (leaves.length === 0) {
|
|
81
|
+
leaves = [stripInlineMarkdown(it.delta || it.value || it.title || `Sub-driver ${idx + 1}`)]
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
tag: stripInlineMarkdown(it.tag || String(idx + 1).padStart(2, '0')).slice(0, 12),
|
|
85
|
+
title: stripInlineMarkdown(it.title || `Branch ${idx + 1}`).slice(0, 36),
|
|
86
|
+
metric: stripInlineMarkdown([it.value, it.unit, it.delta].filter(Boolean).join(' ')).slice(0, 20),
|
|
87
|
+
status: it.status || (idx === 0 ? 'accent' : ''),
|
|
88
|
+
leaves,
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
return { rootTag, rootLabel, branches }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function renderIssueTreePptx(slide, ctx) {
|
|
96
|
+
const { theme, langAttr, chromeCfg, nextId, bodyTopY, bodyH, cardMaterial = 'solid' } = ctx
|
|
97
|
+
const tk = theme.tokens
|
|
98
|
+
const model = computeIssueTreeModel(slide)
|
|
99
|
+
const branches = model.branches
|
|
100
|
+
const totalLeaves = branches.reduce((s, b) => s + Math.max(1, b.leaves.length), 0)
|
|
101
|
+
|
|
102
|
+
const rootX = 0.62, rootW = 2.48, rootH = Math.min(2.1, Math.max(1.35, bodyH * 0.36))
|
|
103
|
+
const rootY = bodyTopY + (bodyH - rootH) / 2
|
|
104
|
+
const branchX = 3.66, branchW = 2.98
|
|
105
|
+
const leafX = 7.20, leafW = 5.51
|
|
106
|
+
|
|
107
|
+
const gutter1Mid = (rootX + rootW + branchX) / 2
|
|
108
|
+
const gutter2Mid = (branchX + branchW + leafX) / 2
|
|
109
|
+
const lineColor = mixHex(tk.accentText || theme.palette.accent, tk.hairline || '#CBD5E1', 0.45)
|
|
110
|
+
|
|
111
|
+
let xml = ''
|
|
112
|
+
|
|
113
|
+
// Root Node (accent filled)
|
|
114
|
+
const rootFill = theme.palette.accent
|
|
115
|
+
const rootInk = contrastInkOn(rootFill)
|
|
116
|
+
const rootFit = computeTextFit(model.rootLabel, { w: rootW - 0.24, h: rootH - 0.56 }, 'cardTitle', { maxPt: 17, minPt: 13.5 })
|
|
117
|
+
xml += ooxmlShape(nextId(), 'IssueTree Root', { x: rootX, y: rootY, w: rootW, h: rootH }, {
|
|
118
|
+
preset: 'roundRect',
|
|
119
|
+
adj: 8000,
|
|
120
|
+
fill: rootFill,
|
|
121
|
+
stroke: rootFill,
|
|
122
|
+
strokePt: 1,
|
|
123
|
+
anchor: 'ctr',
|
|
124
|
+
marginsIn: { l: 0.16, r: 0.16, t: 0.14, b: 0.14 },
|
|
125
|
+
paragraphs: [
|
|
126
|
+
ooxmlRichParagraph(model.rootTag, { sizePt: 10, bold: true, color: mixHex(rootInk, rootFill, 0.22), lang: langAttr, font: theme.fonts.body, spaceAfterPt: 4 }),
|
|
127
|
+
ooxmlRichParagraph(model.rootLabel, { sizePt: rootFit.fontPt, bold: true, color: rootInk, lang: langAttr, font: theme.fonts.heading, lineHeight: 1.24 }),
|
|
128
|
+
],
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const branchGap = 0.18
|
|
132
|
+
const usableH = bodyH - branchGap * Math.max(0, branches.length - 1)
|
|
133
|
+
let curY = bodyTopY
|
|
134
|
+
const branchCentersY = []
|
|
135
|
+
|
|
136
|
+
branches.forEach((br, bIdx) => {
|
|
137
|
+
const share = Math.max(1, br.leaves.length) / Math.max(1, totalLeaves)
|
|
138
|
+
const bandH = usableH * share
|
|
139
|
+
const brH = Math.min(bandH - 0.04, Math.max(0.88, bandH * 0.72))
|
|
140
|
+
const brY = curY + (bandH - brH) / 2
|
|
141
|
+
const brMidY = brY + brH / 2
|
|
142
|
+
branchCentersY.push(brMidY)
|
|
143
|
+
|
|
144
|
+
const isAccent = bIdx === 0 || br.status === 'accent'
|
|
145
|
+
const brFit = computeTextFit(br.title, { w: branchW - 0.28, h: brH - 0.36 }, 'cardTitle', { maxPt: 15, minPt: 12.5 })
|
|
146
|
+
xml += renderSurfaceCardPptx(`IssueTree Branch ${bIdx + 1}`, { x: branchX, y: brY, w: branchW, h: brH }, {
|
|
147
|
+
focal: isAccent,
|
|
148
|
+
cardMaterial,
|
|
149
|
+
anchor: 'ctr',
|
|
150
|
+
marginsIn: { l: 0.18, r: 0.14, t: 0.08, b: 0.08 },
|
|
151
|
+
paragraphs: [
|
|
152
|
+
ooxmlRichParagraph(br.metric ? `${br.tag} · ${br.metric}` : br.tag, { sizePt: 9.5, bold: true, color: tk.accentText, lang: langAttr, font: theme.fonts.body, spaceAfterPt: 2 }),
|
|
153
|
+
ooxmlRichParagraph(br.title, { sizePt: brFit.fontPt, bold: true, color: tk.inkPrimary, lang: langAttr, font: theme.fonts.heading, lineHeight: 1.2 }),
|
|
154
|
+
],
|
|
155
|
+
}, nextId, chromeCfg, theme)
|
|
156
|
+
|
|
157
|
+
const leafGap = 0.09
|
|
158
|
+
const leafCount = br.leaves.length
|
|
159
|
+
const leafH = Math.max(0.42, (bandH - leafGap * Math.max(0, leafCount - 1)) / Math.max(1, leafCount))
|
|
160
|
+
const leafCentersY = []
|
|
161
|
+
|
|
162
|
+
br.leaves.forEach((leafText, lIdx) => {
|
|
163
|
+
const ly = curY + lIdx * (leafH + leafGap)
|
|
164
|
+
const lMidY = ly + leafH / 2
|
|
165
|
+
leafCentersY.push(lMidY)
|
|
166
|
+
const leafFit = computeTextFit(leafText, { w: leafW - 0.3, h: leafH - 0.08 }, 'cardBody', { maxPt: 13.5, minPt: 11.5 })
|
|
167
|
+
xml += ooxmlShape(nextId(), `IssueTree Leaf ${bIdx + 1}-${lIdx + 1}`, { x: leafX, y: ly, w: leafW, h: leafH }, {
|
|
168
|
+
preset: 'roundRect',
|
|
169
|
+
adj: 11000,
|
|
170
|
+
fill: tk.surface1,
|
|
171
|
+
stroke: tk.hairline,
|
|
172
|
+
strokePt: 0.85,
|
|
173
|
+
anchor: 'ctr',
|
|
174
|
+
marginsIn: { l: 0.16, r: 0.14, t: 0.05, b: 0.05 },
|
|
175
|
+
paragraphs: [
|
|
176
|
+
ooxmlRichParagraph(leafText, { sizePt: leafFit.fontPt, color: tk.inkPrimary, secondaryColor: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.18, autoLeadBold: true }),
|
|
177
|
+
],
|
|
178
|
+
})
|
|
179
|
+
xml += ooxmlLine(nextId(), `IssueTree LConn ${bIdx + 1}-${lIdx + 1}`, { x: gutter2Mid, y: lMidY }, { x: leafX, y: lMidY }, { color: lineColor, widthPt: 1.25 })
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
xml += ooxmlLine(nextId(), `IssueTree BOut ${bIdx + 1}`, { x: branchX + branchW, y: brMidY }, { x: gutter2Mid, y: brMidY }, { color: lineColor, widthPt: 1.25 })
|
|
183
|
+
if (leafCentersY.length >= 2) {
|
|
184
|
+
xml += ooxmlLine(nextId(), `IssueTree BSpine ${bIdx + 1}`, { x: gutter2Mid, y: leafCentersY[0] }, { x: gutter2Mid, y: leafCentersY[leafCentersY.length - 1] }, { color: lineColor, widthPt: 1.25 })
|
|
185
|
+
}
|
|
186
|
+
xml += ooxmlLine(nextId(), `IssueTree RBranch ${bIdx + 1}`, { x: gutter1Mid, y: brMidY }, { x: branchX, y: brMidY }, { color: lineColor, widthPt: 1.5 })
|
|
187
|
+
|
|
188
|
+
curY += bandH + branchGap
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
const rootMidY = rootY + rootH / 2
|
|
192
|
+
xml += ooxmlLine(nextId(), 'IssueTree ROut', { x: rootX + rootW, y: rootMidY }, { x: gutter1Mid, y: rootMidY }, { color: lineColor, widthPt: 1.5 })
|
|
193
|
+
if (branchCentersY.length >= 2) {
|
|
194
|
+
xml += ooxmlLine(nextId(), 'IssueTree RSpine', { x: gutter1Mid, y: branchCentersY[0] }, { x: gutter1Mid, y: branchCentersY[branchCentersY.length - 1] }, { color: lineColor, widthPt: 1.5 })
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return xml
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function renderIssueTreeHtml(slide) {
|
|
201
|
+
const model = computeIssueTreeModel(slide)
|
|
202
|
+
return (
|
|
203
|
+
'<div class="itree-board">' +
|
|
204
|
+
'<div class="itree-root">' +
|
|
205
|
+
'<span class="itree-root-tag">' + escapeHtml(model.rootTag) + '</span>' +
|
|
206
|
+
'<div class="itree-root-title">' + renderInlineHtml(model.rootLabel) + '</div>' +
|
|
207
|
+
'</div>' +
|
|
208
|
+
'<div class="itree-branches">' +
|
|
209
|
+
model.branches.map((br, idx) =>
|
|
210
|
+
'<div class="itree-row" data-item-index="' + idx + '">' +
|
|
211
|
+
'<div class="surface-card itree-branch' + (idx === 0 || br.status === 'accent' ? ' is-focal' : '') + '">' +
|
|
212
|
+
'<span class="itree-tag">' + escapeHtml(br.metric ? `${br.tag} · ${br.metric}` : br.tag) + '</span>' +
|
|
213
|
+
'<div class="itree-branch-title">' + renderInlineHtml(br.title) + '</div>' +
|
|
214
|
+
'</div>' +
|
|
215
|
+
'<div class="itree-leaves">' +
|
|
216
|
+
br.leaves.map((lf) => '<div class="itree-leaf">' + renderInlineHtml(lf, { autoLeadBold: true }) + '</div>').join('') +
|
|
217
|
+
'</div></div>',
|
|
218
|
+
).join('') +
|
|
219
|
+
'</div></div>'
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
// 2. treemap (Squarified Proportional Area Treemap)
|
|
225
|
+
// ---------------------------------------------------------------------------
|
|
226
|
+
|
|
227
|
+
function squarifyLayout(entries, rect) {
|
|
228
|
+
const results = []
|
|
229
|
+
let rem = [...entries]
|
|
230
|
+
let x = rect.x, y = rect.y, w = rect.w, h = rect.h
|
|
231
|
+
|
|
232
|
+
const worstRatio = (row, sideLen) => {
|
|
233
|
+
if (row.length === 0 || sideLen <= 0) return Infinity
|
|
234
|
+
const s = row.reduce((acc, r) => acc + r.area, 0)
|
|
235
|
+
if (s <= 0) return Infinity
|
|
236
|
+
const maxA = Math.max(...row.map((r) => r.area))
|
|
237
|
+
const minA = Math.min(...row.map((r) => r.area))
|
|
238
|
+
const s2 = s * s
|
|
239
|
+
const w2 = sideLen * sideLen
|
|
240
|
+
return Math.max((w2 * maxA) / s2, s2 / (w2 * Math.max(1e-9, minA)))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
while (rem.length > 0 && w > 0.01 && h > 0.01) {
|
|
244
|
+
const shortSide = Math.min(w, h)
|
|
245
|
+
const row = [rem[0]]
|
|
246
|
+
let idx = 1
|
|
247
|
+
while (idx < rem.length) {
|
|
248
|
+
const candidate = [...row, rem[idx]]
|
|
249
|
+
if (worstRatio(candidate, shortSide) <= worstRatio(row, shortSide)) {
|
|
250
|
+
row.push(rem[idx])
|
|
251
|
+
idx += 1
|
|
252
|
+
} else {
|
|
253
|
+
break
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
rem = rem.slice(row.length)
|
|
257
|
+
const rowArea = row.reduce((acc, r) => acc + r.area, 0)
|
|
258
|
+
if (w >= h) {
|
|
259
|
+
const colW = h > 0 ? rowArea / h : w
|
|
260
|
+
let cy = y
|
|
261
|
+
for (const item of row) {
|
|
262
|
+
const ih = colW > 0 ? item.area / colW : h / row.length
|
|
263
|
+
results.push({ ...item, x, y: cy, w: colW, h: ih })
|
|
264
|
+
cy += ih
|
|
265
|
+
}
|
|
266
|
+
x += colW
|
|
267
|
+
w = Math.max(0, w - colW)
|
|
268
|
+
} else {
|
|
269
|
+
const rowH = w > 0 ? rowArea / w : h
|
|
270
|
+
let cx = x
|
|
271
|
+
for (const item of row) {
|
|
272
|
+
const iw = rowH > 0 ? item.area / rowH : w / row.length
|
|
273
|
+
results.push({ ...item, x: cx, y, w: iw, h: rowH })
|
|
274
|
+
cx += iw
|
|
275
|
+
}
|
|
276
|
+
y += rowH
|
|
277
|
+
h = Math.max(0, h - rowH)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return results
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function computeTreemapModel(slide, box = { x: 0.62, y: 1.78, w: 12.09, h: 4.35 }) {
|
|
284
|
+
let rawEntries = []
|
|
285
|
+
if (Array.isArray(slide.items) && slide.items.length > 0) {
|
|
286
|
+
rawEntries = slide.items.map((it, idx) => {
|
|
287
|
+
const num = Math.max(0.01, parseNumericVal(it.value ?? it.size ?? it.weight ?? it.text, 10))
|
|
288
|
+
const unit = it.unit || extractUnit(it.value)
|
|
289
|
+
return {
|
|
290
|
+
label: stripInlineMarkdown(it.title || it.tag || `Item ${idx + 1}`).slice(0, 32),
|
|
291
|
+
tag: stripInlineMarkdown(it.tag || '').slice(0, 18),
|
|
292
|
+
value: num,
|
|
293
|
+
unit,
|
|
294
|
+
displayValue: it.value !== undefined && it.value !== '' ? `${stripInlineMarkdown(String(it.value))}${it.unit && !String(it.value).includes(it.unit) ? it.unit : ''}` : fmtCompact(num, unit),
|
|
295
|
+
delta: stripInlineMarkdown(it.delta || ''),
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
} else if (Array.isArray(slide.rows) && slide.rows.length >= 2) {
|
|
299
|
+
rawEntries = slide.rows.slice(1).map((r, idx) => {
|
|
300
|
+
const num = Math.max(0.01, parseNumericVal(r[1], 10))
|
|
301
|
+
const unit = extractUnit(r[1])
|
|
302
|
+
return {
|
|
303
|
+
label: stripInlineMarkdown(r[0] || `Segment ${idx + 1}`).slice(0, 32),
|
|
304
|
+
tag: stripInlineMarkdown(r[2] || '').slice(0, 18),
|
|
305
|
+
value: num,
|
|
306
|
+
unit,
|
|
307
|
+
displayValue: stripInlineMarkdown(r[1] || fmtCompact(num, unit)),
|
|
308
|
+
delta: '',
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
} else {
|
|
312
|
+
rawEntries = resolveEffectiveItems(slide).map((it, idx) => {
|
|
313
|
+
const num = Math.max(1, parseNumericVal(it.value || it.text || it.title, 25 - idx * 4))
|
|
314
|
+
return {
|
|
315
|
+
label: stripInlineMarkdown(it.title || `Segment ${idx + 1}`).slice(0, 32),
|
|
316
|
+
tag: stripInlineMarkdown(it.tag || '').slice(0, 18),
|
|
317
|
+
value: num,
|
|
318
|
+
unit: '',
|
|
319
|
+
displayValue: fmtCompact(num),
|
|
320
|
+
delta: '',
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
rawEntries = rawEntries.filter((e) => e.value > 0).sort((a, b) => b.value - a.value).slice(0, 12)
|
|
326
|
+
if (rawEntries.length === 0) {
|
|
327
|
+
rawEntries = [
|
|
328
|
+
{ label: 'Core Platform', tag: 'CORE', value: 45, unit: '%', displayValue: '45%', delta: '' },
|
|
329
|
+
{ label: 'Cloud AI', tag: 'GROWTH', value: 30, unit: '%', displayValue: '30%', delta: '' },
|
|
330
|
+
{ label: 'Services', tag: 'OPS', value: 25, unit: '%', displayValue: '25%', delta: '' },
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const total = rawEntries.reduce((s, e) => s + e.value, 0)
|
|
335
|
+
const totalArea = box.w * box.h
|
|
336
|
+
const scaled = rawEntries.map((e, idx) => ({
|
|
337
|
+
...e,
|
|
338
|
+
rank: idx,
|
|
339
|
+
sharePct: Math.round((e.value / Math.max(1e-9, total)) * 1000) / 10,
|
|
340
|
+
area: (e.value / Math.max(1e-9, total)) * totalArea,
|
|
341
|
+
}))
|
|
342
|
+
const rects = squarifyLayout(scaled, box)
|
|
343
|
+
return { total, rects, box }
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function treemapPalette(theme) {
|
|
347
|
+
const p = theme.palette
|
|
348
|
+
const tk = theme.tokens
|
|
349
|
+
const base = Array.isArray(tk.chartSeries) && tk.chartSeries.length >= 4
|
|
350
|
+
? tk.chartSeries
|
|
351
|
+
: [p.accent, p.accent2, mixHex(p.accent, p.fg, 0.3), mixHex(p.accent2, p.fg, 0.25), tk.positive || '#0D7A4E', tk.warning || '#B45309']
|
|
352
|
+
return [
|
|
353
|
+
base[0] || p.accent,
|
|
354
|
+
base[1] || p.accent2,
|
|
355
|
+
mixHex(base[0] || p.accent, p.bg, 0.22),
|
|
356
|
+
mixHex(base[1] || p.accent2, p.bg, 0.22),
|
|
357
|
+
base[2] || mixHex(p.accent, p.fg, 0.35),
|
|
358
|
+
base[3] || mixHex(p.accent2, p.fg, 0.35),
|
|
359
|
+
mixHex(p.accent, p.panel, 0.38),
|
|
360
|
+
mixHex(p.accent2, p.panel, 0.38),
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function renderTreemapPptx(slide, ctx) {
|
|
365
|
+
const { theme, langAttr, nextId, bodyTopY, bodyH } = ctx
|
|
366
|
+
const box = { x: 0.62, y: bodyTopY, w: 12.09, h: bodyH }
|
|
367
|
+
const model = computeTreemapModel(slide, box)
|
|
368
|
+
const fills = treemapPalette(theme)
|
|
369
|
+
const gap = 0.045
|
|
370
|
+
let xml = ''
|
|
371
|
+
|
|
372
|
+
model.rects.forEach((tile, idx) => {
|
|
373
|
+
const fill = fills[idx % fills.length]
|
|
374
|
+
const ink = contrastInkOn(fill)
|
|
375
|
+
const subInk = mixHex(ink, fill, 0.18)
|
|
376
|
+
const tx = tile.x + gap / 2
|
|
377
|
+
const ty = tile.y + gap / 2
|
|
378
|
+
const tw = Math.max(0.35, tile.w - gap)
|
|
379
|
+
const th = Math.max(0.35, tile.h - gap)
|
|
380
|
+
|
|
381
|
+
const isLarge = tw >= 2.2 && th >= 1.3
|
|
382
|
+
const isMed = tw >= 1.4 && th >= 0.85
|
|
383
|
+
const paragraphs = []
|
|
384
|
+
if (isLarge) {
|
|
385
|
+
if (tile.tag && tile.tag !== tile.label) {
|
|
386
|
+
paragraphs.push(ooxmlRichParagraph(tile.tag, { sizePt: 9.5, bold: true, color: subInk, lang: langAttr, font: theme.fonts.body, spaceAfterPt: 3 }))
|
|
387
|
+
}
|
|
388
|
+
paragraphs.push(ooxmlRichParagraph(tile.label, { sizePt: 15, bold: true, color: ink, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 4 }))
|
|
389
|
+
paragraphs.push(ooxmlRichParagraph(`${tile.displayValue} (${tile.sharePct}%)`, { sizePt: 18, bold: true, color: ink, lang: langAttr, font: theme.fonts.heading }))
|
|
390
|
+
} else if (isMed) {
|
|
391
|
+
paragraphs.push(ooxmlRichParagraph(tile.label, { sizePt: 12.5, bold: true, color: ink, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 2 }))
|
|
392
|
+
paragraphs.push(ooxmlRichParagraph(`${tile.displayValue} · ${tile.sharePct}%`, { sizePt: 12, bold: true, color: subInk, lang: langAttr, font: theme.fonts.body }))
|
|
393
|
+
} else {
|
|
394
|
+
paragraphs.push(ooxmlRichParagraph(`${tile.label} ${tile.sharePct}%`, { sizePt: 10, bold: true, color: ink, lang: langAttr, font: theme.fonts.body }))
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
xml += ooxmlShape(nextId(), `Treemap Tile ${idx + 1}`, { x: tx, y: ty, w: tw, h: th }, {
|
|
398
|
+
preset: 'roundRect',
|
|
399
|
+
adj: 4500,
|
|
400
|
+
fill,
|
|
401
|
+
stroke: theme.palette.bg,
|
|
402
|
+
strokePt: 1.5,
|
|
403
|
+
anchor: isLarge ? 't' : 'ctr',
|
|
404
|
+
marginsIn: { l: 0.14, r: 0.12, t: 0.12, b: 0.1 },
|
|
405
|
+
paragraphs,
|
|
406
|
+
})
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
return xml
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function renderTreemapHtml(slide, theme) {
|
|
413
|
+
const vw = 1000, vh = 400
|
|
414
|
+
const model = computeTreemapModel(slide, { x: 0, y: 0, w: vw, h: vh })
|
|
415
|
+
const fills = treemapPalette(theme)
|
|
416
|
+
const pad = 4
|
|
417
|
+
const rectsSvg = model.rects.map((t, idx) => {
|
|
418
|
+
const fill = fills[idx % fills.length]
|
|
419
|
+
const ink = contrastInkOn(fill)
|
|
420
|
+
const x = t.x + pad / 2, y = t.y + pad / 2
|
|
421
|
+
const w = Math.max(8, t.w - pad), h = Math.max(8, t.h - pad)
|
|
422
|
+
const isLarge = w >= 190 && h >= 105
|
|
423
|
+
const isMed = w >= 115 && h >= 64
|
|
424
|
+
let labels = ''
|
|
425
|
+
if (isLarge) {
|
|
426
|
+
labels =
|
|
427
|
+
`<text x="${(x + 14).toFixed(1)}" y="${(y + 28).toFixed(1)}" fill="${ink}" font-size="16" font-weight="700">${escapeHtml(t.label)}</text>` +
|
|
428
|
+
`<text x="${(x + 14).toFixed(1)}" y="${(y + 58).toFixed(1)}" fill="${ink}" font-size="22" font-weight="800">${escapeHtml(t.displayValue)} (${t.sharePct}%)</text>`
|
|
429
|
+
} else if (isMed) {
|
|
430
|
+
labels =
|
|
431
|
+
`<text x="${(x + 10).toFixed(1)}" y="${(y + 24).toFixed(1)}" fill="${ink}" font-size="13.5" font-weight="700">${escapeHtml(t.label)}</text>` +
|
|
432
|
+
`<text x="${(x + 10).toFixed(1)}" y="${(y + 46).toFixed(1)}" fill="${ink}" opacity="0.9" font-size="13" font-weight="600">${escapeHtml(t.displayValue)} · ${t.sharePct}%</text>`
|
|
433
|
+
} else {
|
|
434
|
+
labels = `<text x="${(x + 8).toFixed(1)}" y="${(y + h / 2 + 4).toFixed(1)}" fill="${ink}" font-size="11" font-weight="700">${escapeHtml(t.label)} ${t.sharePct}%</text>`
|
|
435
|
+
}
|
|
436
|
+
return `<g data-item-index="${idx}"><rect x="${x.toFixed(1)}" y="${y.toFixed(1)}" width="${w.toFixed(1)}" height="${h.toFixed(1)}" rx="8" fill="${fill}"/>${labels}</g>`
|
|
437
|
+
}).join('')
|
|
438
|
+
return `<div class="treemap-wrap"><svg class="treemap-svg" viewBox="0 0 ${vw} ${vh}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${escapeHtml(stripInlineMarkdown(slide.title || 'Treemap'))}">${rectsSvg}</svg></div>`
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// ---------------------------------------------------------------------------
|
|
442
|
+
// 3. gauge (Stephen Few Horizontal Bullet / OKR Attainment Dashboard)
|
|
443
|
+
// ---------------------------------------------------------------------------
|
|
444
|
+
|
|
445
|
+
export function computeGaugeModel(slide) {
|
|
446
|
+
const items = resolveEffectiveItems(slide).slice(0, 5)
|
|
447
|
+
const list = items.length > 0 ? items : [
|
|
448
|
+
{ title: '年度 ARR 营收达成', value: 86, target: 80, max: 100, unit: '%', text: '大客户续约超预期' },
|
|
449
|
+
{ title: '毛利率水平', value: 74, target: 75, max: 100, unit: '%', text: '算力优化持续推进' },
|
|
450
|
+
{ title: '交付周期达标率', value: 92, target: 90, max: 100, unit: '%', text: '全自动化部署落地' },
|
|
451
|
+
]
|
|
452
|
+
return list.map((it, idx) => {
|
|
453
|
+
const actual = Math.max(0, parseNumericVal(it.actual ?? it.value ?? it.after, 75))
|
|
454
|
+
const rawTarget = it.target ?? it.before
|
|
455
|
+
const target = rawTarget !== undefined && rawTarget !== '' ? Math.max(0.01, parseNumericVal(rawTarget, actual)) : Math.max(actual, 100)
|
|
456
|
+
const rawMax = it.max
|
|
457
|
+
const max = rawMax !== undefined && rawMax !== '' ? Math.max(actual, target, parseNumericVal(rawMax, 100)) : Math.max(100, Math.ceil(Math.max(actual, target) * 1.15))
|
|
458
|
+
const unit = it.unit || extractUnit(it.value ?? it.actual) || (max === 100 ? '%' : '')
|
|
459
|
+
const attainmentPct = Math.round((actual / Math.max(1e-9, target)) * 100)
|
|
460
|
+
const status = it.status || (attainmentPct >= 100 ? 'positive' : attainmentPct >= 85 ? 'accent' : attainmentPct >= 70 ? 'warning' : 'negative')
|
|
461
|
+
return {
|
|
462
|
+
index: idx,
|
|
463
|
+
tag: stripInlineMarkdown(it.tag || `KR${idx + 1}`).slice(0, 14),
|
|
464
|
+
title: stripInlineMarkdown(it.title || `Metric ${idx + 1}`).slice(0, 34),
|
|
465
|
+
subtitle: stripInlineMarkdown(it.text || '').slice(0, 46),
|
|
466
|
+
actual,
|
|
467
|
+
target,
|
|
468
|
+
max,
|
|
469
|
+
unit,
|
|
470
|
+
actualRatio: Math.min(1, actual / Math.max(1e-9, max)),
|
|
471
|
+
targetRatio: Math.min(1, target / Math.max(1e-9, max)),
|
|
472
|
+
attainmentPct,
|
|
473
|
+
displayActual: fmtCompact(actual, unit),
|
|
474
|
+
displayTarget: fmtCompact(target, unit),
|
|
475
|
+
delta: stripInlineMarkdown(it.delta || `${attainmentPct}% 达标`),
|
|
476
|
+
status,
|
|
477
|
+
}
|
|
478
|
+
})
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function gaugeStatusColor(status, theme) {
|
|
482
|
+
const tk = theme.tokens
|
|
483
|
+
if (status === 'positive') return tk.positive || '#0D7A4E'
|
|
484
|
+
if (status === 'warning') return tk.warning || '#B45309'
|
|
485
|
+
if (status === 'negative') return tk.negative || '#C81E1E'
|
|
486
|
+
return theme.palette.accent
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function renderGaugePptx(slide, ctx) {
|
|
490
|
+
const { theme, langAttr, chromeCfg, nextId, bodyTopY, bodyH, cardMaterial = 'solid' } = ctx
|
|
491
|
+
const tk = theme.tokens
|
|
492
|
+
const rows = computeGaugeModel(slide)
|
|
493
|
+
const count = rows.length
|
|
494
|
+
const gap = 0.16
|
|
495
|
+
const rowH = Math.min(1.04, (bodyH - gap * Math.max(0, count - 1)) / Math.max(1, count))
|
|
496
|
+
const totalH = rowH * count + gap * Math.max(0, count - 1)
|
|
497
|
+
const startY = bodyTopY + Math.max(0, (bodyH - totalH) / 2)
|
|
498
|
+
|
|
499
|
+
const leftX = 0.62, leftW = 3.22
|
|
500
|
+
const trackX = 4.04, trackW = 6.68
|
|
501
|
+
const rightX = 10.90, rightW = 1.81
|
|
502
|
+
|
|
503
|
+
const band1 = mixHex(tk.inkMuted || '#64748B', theme.palette.bg, 0.58)
|
|
504
|
+
const band2 = mixHex(tk.inkMuted || '#64748B', theme.palette.bg, 0.74)
|
|
505
|
+
const band3 = mixHex(tk.inkMuted || '#64748B', theme.palette.bg, 0.87)
|
|
506
|
+
let xml = ''
|
|
507
|
+
|
|
508
|
+
rows.forEach((r, idx) => {
|
|
509
|
+
const ry = startY + idx * (rowH + gap)
|
|
510
|
+
const barColor = gaugeStatusColor(r.status, theme)
|
|
511
|
+
|
|
512
|
+
xml += renderSurfaceCardPptx(`Gauge Row ${idx + 1}`, { x: leftX, y: ry, w: 12.09, h: rowH }, {
|
|
513
|
+
focal: false,
|
|
514
|
+
cardMaterial,
|
|
515
|
+
paragraphs: [],
|
|
516
|
+
}, nextId, chromeCfg, theme)
|
|
517
|
+
|
|
518
|
+
xml += ooxmlShape(nextId(), `Gauge Label ${idx + 1}`, { x: leftX + 0.16, y: ry + 0.06, w: leftW - 0.18, h: rowH - 0.12 }, {
|
|
519
|
+
txBox: true,
|
|
520
|
+
anchor: 'ctr',
|
|
521
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
522
|
+
paragraphs: [
|
|
523
|
+
ooxmlRichParagraph(r.title, { sizePt: 13.5, bold: true, color: tk.inkPrimary, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 2 }),
|
|
524
|
+
...(r.subtitle ? [ooxmlRichParagraph(r.subtitle, { sizePt: 10.5, color: tk.inkMuted, lang: langAttr, font: theme.fonts.body })] : []),
|
|
525
|
+
],
|
|
526
|
+
})
|
|
527
|
+
|
|
528
|
+
const trH = Math.min(0.40, rowH * 0.42)
|
|
529
|
+
const trY = ry + (rowH - trH) / 2 - 0.04
|
|
530
|
+
xml += ooxmlShape(nextId(), `Gauge Band3 ${idx + 1}`, { x: trackX, y: trY, w: trackW, h: trH }, { preset: 'rect', fill: band3 })
|
|
531
|
+
xml += ooxmlShape(nextId(), `Gauge Band2 ${idx + 1}`, { x: trackX, y: trY, w: trackW * 0.85, h: trH }, { preset: 'rect', fill: band2 })
|
|
532
|
+
xml += ooxmlShape(nextId(), `Gauge Band1 ${idx + 1}`, { x: trackX, y: trY, w: trackW * 0.6, h: trH }, { preset: 'rect', fill: band1 })
|
|
533
|
+
xml += ooxmlShape(nextId(), `Gauge Track Frame ${idx + 1}`, { x: trackX, y: trY, w: trackW, h: trH }, { preset: 'rect', fill: '', stroke: tk.hairline, strokePt: 0.6 })
|
|
534
|
+
|
|
535
|
+
const actH = trH * 0.48
|
|
536
|
+
const actY = trY + (trH - actH) / 2
|
|
537
|
+
const actW = Math.max(0.12, trackW * r.actualRatio)
|
|
538
|
+
xml += ooxmlShape(nextId(), `Gauge Actual ${idx + 1}`, { x: trackX, y: actY, w: actW, h: actH }, { preset: 'roundRect', adj: 22000, fill: barColor })
|
|
539
|
+
|
|
540
|
+
const tgtX = trackX + trackW * r.targetRatio - 0.025
|
|
541
|
+
xml += ooxmlShape(nextId(), `Gauge Target ${idx + 1}`, { x: tgtX, y: trY - 0.06, w: 0.05, h: trH + 0.12 }, { preset: 'rect', fill: tk.inkPrimary })
|
|
542
|
+
|
|
543
|
+
xml += ooxmlShape(nextId(), `Gauge TgtLabel ${idx + 1}`, { x: Math.max(trackX, Math.min(trackX + trackW - 1.25, tgtX - 0.55)), y: trY + trH + 0.03, w: 1.25, h: 0.2 }, {
|
|
544
|
+
txBox: true,
|
|
545
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
546
|
+
paragraphs: [ooxmlRichParagraph(`目标 ${r.displayTarget}`, { sizePt: 8.5, color: tk.inkMuted, align: 'ctr', lang: langAttr, font: theme.fonts.body })],
|
|
547
|
+
})
|
|
548
|
+
|
|
549
|
+
xml += ooxmlShape(nextId(), `Gauge Value ${idx + 1}`, { x: rightX, y: ry + 0.06, w: rightW - 0.14, h: rowH - 0.12 }, {
|
|
550
|
+
txBox: true,
|
|
551
|
+
anchor: 'ctr',
|
|
552
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
553
|
+
paragraphs: [
|
|
554
|
+
ooxmlRichParagraph(r.displayActual, { sizePt: 18, bold: true, color: barColor, align: 'r', lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 2 }),
|
|
555
|
+
ooxmlRichParagraph(r.delta, { sizePt: 10, bold: true, color: tk.inkSecondary, align: 'r', lang: langAttr, font: theme.fonts.body }),
|
|
556
|
+
],
|
|
557
|
+
})
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
return xml
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function renderGaugeHtml(slide) {
|
|
564
|
+
const rows = computeGaugeModel(slide)
|
|
565
|
+
return (
|
|
566
|
+
'<div class="gauge-board">' +
|
|
567
|
+
rows.map((r) =>
|
|
568
|
+
'<div class="surface-card gauge-row" data-item-index="' + r.index + '">' +
|
|
569
|
+
'<div class="gauge-label"><div class="card-title">' + renderInlineHtml(r.title) + '</div>' +
|
|
570
|
+
(r.subtitle ? '<div class="gauge-sub">' + renderInlineHtml(r.subtitle) + '</div>' : '') +
|
|
571
|
+
'</div>' +
|
|
572
|
+
'<div class="gauge-track-wrap">' +
|
|
573
|
+
'<div class="gauge-track">' +
|
|
574
|
+
'<div class="gauge-band b1" style="width:60%"></div>' +
|
|
575
|
+
'<div class="gauge-band b2" style="width:85%"></div>' +
|
|
576
|
+
'<div class="gauge-actual tone-' + escapeHtml(r.status) + '" style="width:' + (r.actualRatio * 100).toFixed(1) + '%"></div>' +
|
|
577
|
+
'<div class="gauge-target" style="left:' + (r.targetRatio * 100).toFixed(1) + '%" title="Target ' + escapeHtml(r.displayTarget) + '"></div>' +
|
|
578
|
+
'</div>' +
|
|
579
|
+
'<span class="gauge-tgt-lbl" style="left:' + (r.targetRatio * 100).toFixed(1) + '%">目标 ' + escapeHtml(r.displayTarget) + '</span>' +
|
|
580
|
+
'</div>' +
|
|
581
|
+
'<div class="gauge-readout"><strong class="tone-' + escapeHtml(r.status) + '">' + escapeHtml(r.displayActual) + '</strong><span>' + escapeHtml(r.delta) + '</span></div>' +
|
|
582
|
+
'</div>',
|
|
583
|
+
).join('') +
|
|
584
|
+
'</div>'
|
|
585
|
+
)
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// ---------------------------------------------------------------------------
|
|
589
|
+
// 4. pricing (Good / Better / Best Executive Pricing & Package Matrix)
|
|
590
|
+
// ---------------------------------------------------------------------------
|
|
591
|
+
|
|
592
|
+
export function computePricingModel(slide) {
|
|
593
|
+
const items = resolveEffectiveItems(slide).slice(0, 4)
|
|
594
|
+
const list = items.length >= 2 ? items : [
|
|
595
|
+
{ tag: '标准版', title: 'Standard', value: '¥9,800', unit: '/年', text: '适合单团队快速启动', bullets: ['✓ 10 席位协作', '✓ 标准模板库', '✗ 私有化部署'] },
|
|
596
|
+
{ tag: '推荐主推', title: 'Enterprise Pro', value: '¥29,800', unit: '/年', status: 'accent', text: '适合中大型企业规模化赋能', bullets: ['✓ 无限席位与品牌宪章锁', '✓ Office 双向引擎 + 权威溯源', '✓ 专属客户成功顾问'] },
|
|
597
|
+
{ tag: '旗舰定制', title: 'Private Cloud', value: '定制报价', unit: '', text: '金融政企专享隔离部署', bullets: ['✓ 全链路本地化/内网运行', '✓ SSO 单点登录与审计日志', '✓ 7×24 SLA 响应'] },
|
|
598
|
+
]
|
|
599
|
+
const hasExplicitRec = list.some((it) => it.status === 'accent' || /推荐|主推|首选|recommend|popular|best/i.test(String(it.tag || '')))
|
|
600
|
+
return list.map((it, idx) => {
|
|
601
|
+
const recommended = hasExplicitRec
|
|
602
|
+
? (it.status === 'accent' || /推荐|主推|首选|recommend|popular|best/i.test(String(it.tag || '')))
|
|
603
|
+
: (list.length === 3 && idx === 1)
|
|
604
|
+
const rawBullets = Array.isArray(it.bullets) && it.bullets.length > 0
|
|
605
|
+
? it.bullets
|
|
606
|
+
: (typeof it.text === 'string' && it.text.includes(';') ? it.text.split(/[;;]/) : [])
|
|
607
|
+
const features = rawBullets.slice(0, 5).map((b) => {
|
|
608
|
+
const clean = stripInlineMarkdown(b).trim()
|
|
609
|
+
const excluded = /^[✗✘×\-]\s*/.test(clean)
|
|
610
|
+
const label = clean.replace(/^[✓✔✗✘ו\-]\s*/, '')
|
|
611
|
+
return { label, included: !excluded }
|
|
612
|
+
})
|
|
613
|
+
return {
|
|
614
|
+
index: idx,
|
|
615
|
+
tag: stripInlineMarkdown(it.tag || (recommended ? 'RECOMMENDED' : `TIER 0${idx + 1}`)).slice(0, 22),
|
|
616
|
+
title: stripInlineMarkdown(it.title || `Plan ${idx + 1}`).slice(0, 28),
|
|
617
|
+
price: stripInlineMarkdown(it.value !== undefined && it.value !== '' ? String(it.value) : '—').slice(0, 20),
|
|
618
|
+
unit: stripInlineMarkdown(it.unit || '').slice(0, 14),
|
|
619
|
+
subtitle: stripInlineMarkdown(it.text && !it.text.includes(';') ? it.text : '').slice(0, 56),
|
|
620
|
+
features,
|
|
621
|
+
recommended,
|
|
622
|
+
}
|
|
623
|
+
})
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function renderPricingPptx(slide, ctx) {
|
|
627
|
+
const { theme, langAttr, chromeCfg, nextId, bodyTopY, bodyH, cardMaterial = 'solid' } = ctx
|
|
628
|
+
const tk = theme.tokens
|
|
629
|
+
const tiers = computePricingModel(slide)
|
|
630
|
+
const cols = tiers.length
|
|
631
|
+
const gap = 0.24
|
|
632
|
+
const totalW = 12.09
|
|
633
|
+
const cardW = (totalW - gap * Math.max(0, cols - 1)) / Math.max(1, cols)
|
|
634
|
+
let xml = ''
|
|
635
|
+
|
|
636
|
+
tiers.forEach((tier, idx) => {
|
|
637
|
+
const cx = 0.62 + idx * (cardW + gap)
|
|
638
|
+
const cy = bodyTopY + (tier.recommended ? 0 : 0.12)
|
|
639
|
+
const ch = bodyH - (tier.recommended ? 0 : 0.12)
|
|
640
|
+
|
|
641
|
+
xml += renderSurfaceCardPptx(`Pricing Card ${idx + 1}`, { x: cx, y: cy, w: cardW, h: ch }, {
|
|
642
|
+
focal: tier.recommended,
|
|
643
|
+
cardMaterial,
|
|
644
|
+
paragraphs: [],
|
|
645
|
+
}, nextId, chromeCfg, theme)
|
|
646
|
+
|
|
647
|
+
if (tier.recommended) {
|
|
648
|
+
xml += ooxmlShape(nextId(), `Pricing Accent Top ${idx + 1}`, { x: cx, y: cy, w: cardW, h: 0.08 }, { preset: 'rect', fill: theme.palette.accent })
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
const badgeFill = tier.recommended ? theme.palette.accent : tk.surface2
|
|
652
|
+
const badgeInk = tier.recommended ? contrastInkOn(badgeFill) : tk.accentText
|
|
653
|
+
xml += ooxmlShape(nextId(), `Pricing Tag ${idx + 1}`, { x: cx + 0.22, y: cy + 0.24, w: Math.min(cardW - 0.44, 1.85), h: 0.3 }, {
|
|
654
|
+
preset: 'roundRect',
|
|
655
|
+
adj: 40000,
|
|
656
|
+
fill: badgeFill,
|
|
657
|
+
anchor: 'ctr',
|
|
658
|
+
marginsIn: { l: 0.08, r: 0.08, t: 0.02, b: 0.02 },
|
|
659
|
+
paragraphs: [ooxmlRichParagraph(tier.tag, { sizePt: 9.5, bold: true, color: badgeInk, align: 'ctr', lang: langAttr, font: theme.fonts.body })],
|
|
660
|
+
})
|
|
661
|
+
|
|
662
|
+
const priceRuns = [{ text: tier.price, bold: true }]
|
|
663
|
+
if (tier.unit) {
|
|
664
|
+
const unitPrefix = tier.unit.startsWith('/') ? '' : ' '
|
|
665
|
+
priceRuns.push({ text: unitPrefix + tier.unit, bold: false, sizePt: 13.5, secondary: true })
|
|
666
|
+
}
|
|
667
|
+
const headParas = [
|
|
668
|
+
ooxmlRichParagraph(tier.title, { sizePt: 17, bold: true, color: tk.inkPrimary, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 4 }),
|
|
669
|
+
ooxmlRichParagraph(priceRuns, {
|
|
670
|
+
sizePt: 25,
|
|
671
|
+
bold: false,
|
|
672
|
+
color: tier.recommended ? theme.palette.accent : tk.inkPrimary,
|
|
673
|
+
secondaryColor: tk.inkMuted,
|
|
674
|
+
lang: langAttr,
|
|
675
|
+
font: theme.fonts.heading,
|
|
676
|
+
spaceAfterPt: 4,
|
|
677
|
+
}),
|
|
678
|
+
...(tier.subtitle ? [ooxmlRichParagraph(tier.subtitle, { sizePt: 11, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body })] : []),
|
|
679
|
+
]
|
|
680
|
+
xml += ooxmlShape(nextId(), `Pricing Head ${idx + 1}`, { x: cx + 0.22, y: cy + 0.64, w: cardW - 0.44, h: 1.44 }, {
|
|
681
|
+
txBox: true,
|
|
682
|
+
anchor: 't',
|
|
683
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
684
|
+
paragraphs: headParas,
|
|
685
|
+
})
|
|
686
|
+
|
|
687
|
+
const divY = cy + 2.16
|
|
688
|
+
xml += ooxmlLine(nextId(), `Pricing Rule ${idx + 1}`, { x: cx + 0.22, y: divY }, { x: cx + cardW - 0.22, y: divY }, { color: tk.hairline, widthPt: 1 })
|
|
689
|
+
|
|
690
|
+
if (tier.features.length > 0) {
|
|
691
|
+
const featParas = tier.features.map((f) =>
|
|
692
|
+
ooxmlRichParagraph(f.label, {
|
|
693
|
+
sizePt: 12,
|
|
694
|
+
color: f.included ? tk.inkPrimary : tk.inkMuted,
|
|
695
|
+
bullet: true,
|
|
696
|
+
bulletChar: f.included ? '✓' : '×',
|
|
697
|
+
bulletColor: f.included ? (tk.positive || '#0D7A4E') : tk.inkMuted,
|
|
698
|
+
lang: langAttr,
|
|
699
|
+
font: theme.fonts.body,
|
|
700
|
+
spaceAfterPt: 6,
|
|
701
|
+
lineHeight: 1.25,
|
|
702
|
+
})
|
|
703
|
+
)
|
|
704
|
+
xml += ooxmlShape(nextId(), `Pricing Features ${idx + 1}`, { x: cx + 0.22, y: divY + 0.16, w: cardW - 0.44, h: Math.max(0.8, cy + ch - divY - 0.28) }, {
|
|
705
|
+
txBox: true,
|
|
706
|
+
anchor: 't',
|
|
707
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
708
|
+
paragraphs: featParas,
|
|
709
|
+
})
|
|
710
|
+
}
|
|
711
|
+
})
|
|
712
|
+
|
|
713
|
+
return xml
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function renderPricingHtml(slide) {
|
|
717
|
+
const tiers = computePricingModel(slide)
|
|
718
|
+
return (
|
|
719
|
+
'<div class="layout-grid pricing-grid cols-' + tiers.length + '">' +
|
|
720
|
+
tiers.map((t) =>
|
|
721
|
+
'<article class="surface-card pricing-card' + (t.recommended ? ' is-recommended is-focal' : '') + '" data-item-index="' + t.index + '">' +
|
|
722
|
+
'<span class="pricing-badge">' + escapeHtml(t.tag) + '</span>' +
|
|
723
|
+
'<h3 class="card-title">' + renderInlineHtml(t.title) + '</h3>' +
|
|
724
|
+
'<div class="pricing-anchor"><span class="pricing-val">' + escapeHtml(t.price) + '</span>' +
|
|
725
|
+
(t.unit ? '<small class="pricing-unit">' + escapeHtml(t.unit) + '</small>' : '') +
|
|
726
|
+
'</div>' +
|
|
727
|
+
(t.subtitle ? '<div class="card-body">' + renderInlineHtml(t.subtitle) + '</div>' : '') +
|
|
728
|
+
'<div class="pricing-rule"></div>' +
|
|
729
|
+
'<ul class="pricing-features">' +
|
|
730
|
+
t.features.map((f) => '<li class="' + (f.included ? 'is-inc' : 'is-exc') + '"><span>' + (f.included ? '✓' : '✗') + '</span>' + renderInlineHtml(f.label) + '</li>').join('') +
|
|
731
|
+
'</ul></article>',
|
|
732
|
+
).join('') +
|
|
733
|
+
'</div>'
|
|
734
|
+
)
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// ---------------------------------------------------------------------------
|
|
738
|
+
// Dispatch Entrypoints & CSS
|
|
739
|
+
// ---------------------------------------------------------------------------
|
|
740
|
+
|
|
741
|
+
export function renderExecChartSlideBodyPptx(slide, ctx) {
|
|
742
|
+
const layout = slide.layout
|
|
743
|
+
if (layout === 'issue-tree') return renderIssueTreePptx(slide, ctx)
|
|
744
|
+
if (layout === 'treemap') return renderTreemapPptx(slide, ctx)
|
|
745
|
+
if (layout === 'gauge') return renderGaugePptx(slide, ctx)
|
|
746
|
+
if (layout === 'pricing') return renderPricingPptx(slide, ctx)
|
|
747
|
+
return null
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
export function renderExecChartSlideBodyHtml(slide, ctx) {
|
|
751
|
+
const layout = slide.layout
|
|
752
|
+
if (layout === 'issue-tree') return renderIssueTreeHtml(slide)
|
|
753
|
+
if (layout === 'treemap') return renderTreemapHtml(slide, ctx?.theme)
|
|
754
|
+
if (layout === 'gauge') return renderGaugeHtml(slide)
|
|
755
|
+
if (layout === 'pricing') return renderPricingHtml(slide)
|
|
756
|
+
return null
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
export const EXEC_CHARTS_CSS = `
|
|
760
|
+
.itree-board{display:grid;grid-template-columns:22% 1fr;gap:clamp(18px,2.2vw,30px);align-items:center;width:100%}
|
|
761
|
+
.itree-root{background:var(--accent);color:var(--ink-on-accent);border-radius:var(--radius);padding:clamp(18px,2.2vw,28px);display:flex;flex-direction:column;gap:8px;box-shadow:0 10px 26px rgba(0,0,0,.14)}
|
|
762
|
+
.itree-root-tag{font-size:11px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;opacity:.85}
|
|
763
|
+
.itree-root-title{font-family:var(--font-heading);font-size:clamp(17px,1.7vw,24px);font-weight:800;line-height:1.25}
|
|
764
|
+
.itree-branches{display:flex;flex-direction:column;gap:clamp(10px,1.3vw,16px)}
|
|
765
|
+
.itree-row{display:grid;grid-template-columns:34% 1fr;gap:clamp(14px,1.8vw,24px);align-items:center}
|
|
766
|
+
.itree-branch{padding:clamp(12px,1.4vw,18px);border-left:4px solid var(--accent);position:relative}
|
|
767
|
+
.itree-tag{font-size:11px;font-weight:700;color:var(--accent-text);letter-spacing:.08em}
|
|
768
|
+
.itree-branch-title{font-family:var(--font-heading);font-size:clamp(15px,1.45vw,20px);font-weight:700;color:var(--fg)}
|
|
769
|
+
.itree-leaves{display:flex;flex-direction:column;gap:8px}
|
|
770
|
+
.itree-leaf{background:var(--surface1);border:1px solid var(--hairline);border-radius:calc(var(--radius) * .8);padding:9px 14px;font-size:clamp(13px,1.2vw,17px);line-height:1.35;color:var(--fg)}
|
|
771
|
+
.treemap-wrap{width:100%;display:flex;align-items:center;justify-content:center}
|
|
772
|
+
.treemap-svg{width:100%;max-height:58vh;display:block}
|
|
773
|
+
.gauge-board{display:flex;flex-direction:column;gap:clamp(10px,1.3vw,16px);width:100%}
|
|
774
|
+
.gauge-row{display:grid;grid-template-columns:27% 1fr 16%;gap:clamp(12px,1.6vw,22px);align-items:center;padding:clamp(12px,1.5vw,20px)}
|
|
775
|
+
.gauge-sub{font-size:clamp(12px,1.05vw,14px);color:var(--muted);margin-top:2px}
|
|
776
|
+
.gauge-track-wrap{position:relative;padding:8px 0 18px}
|
|
777
|
+
.gauge-track{position:relative;height:26px;border-radius:6px;background:color-mix(in srgb,var(--hairline) 32%,var(--bg));overflow:hidden;border:1px solid var(--hairline)}
|
|
778
|
+
.gauge-band{position:absolute;top:0;bottom:0;left:0}
|
|
779
|
+
.gauge-band.b1{background:color-mix(in srgb,var(--hairline) 75%,var(--bg))}
|
|
780
|
+
.gauge-band.b2{background:color-mix(in srgb,var(--hairline) 48%,var(--bg))}
|
|
781
|
+
.gauge-actual{position:absolute;top:6px;bottom:6px;left:0;border-radius:3px;background:var(--accent);z-index:2}
|
|
782
|
+
.gauge-actual.tone-positive{background:var(--positive)}.gauge-actual.tone-warning{background:var(--warning)}.gauge-actual.tone-negative{background:var(--negative)}
|
|
783
|
+
.gauge-target{position:absolute;top:-3px;bottom:-3px;width:3.5px;background:var(--fg);transform:translateX(-50%);z-index:3;border-radius:2px}
|
|
784
|
+
.gauge-tgt-lbl{position:absolute;bottom:0;transform:translateX(-50%);font-size:11px;color:var(--muted);white-space:nowrap}
|
|
785
|
+
.gauge-readout{text-align:right;display:flex;flex-direction:column;gap:2px}
|
|
786
|
+
.gauge-readout strong{font-family:var(--font-heading);font-size:clamp(20px,2vw,28px);font-weight:800;font-variant-numeric:tabular-nums}
|
|
787
|
+
.gauge-readout strong.tone-positive{color:var(--positive)}.gauge-readout strong.tone-warning{color:var(--warning)}.gauge-readout strong.tone-negative{color:var(--negative)}.gauge-readout strong.tone-accent{color:var(--accent-text)}
|
|
788
|
+
.gauge-readout span{font-size:12px;font-weight:600;color:var(--muted)}
|
|
789
|
+
.pricing-grid{align-items:stretch}
|
|
790
|
+
.pricing-card{padding:clamp(18px,2.1vw,28px);gap:10px;position:relative}
|
|
791
|
+
.pricing-card.is-recommended{border:2px solid var(--accent);box-shadow:0 14px 32px rgba(0,0,0,.1);transform:translateY(-4px)}
|
|
792
|
+
.pricing-badge{display:inline-flex;align-self:flex-start;padding:3px 11px;border-radius:99px;font-size:11px;font-weight:700;background:var(--surface2);color:var(--accent-text);letter-spacing:.06em}
|
|
793
|
+
.pricing-card.is-recommended .pricing-badge{background:var(--accent);color:var(--ink-on-accent)}
|
|
794
|
+
.pricing-anchor{display:flex;align-items:baseline;gap:6px;margin:4px 0}
|
|
795
|
+
.pricing-val{font-family:var(--font-heading);font-size:clamp(26px,3vw,42px);font-weight:800;color:var(--fg);font-variant-numeric:tabular-nums}
|
|
796
|
+
.pricing-card.is-recommended .pricing-val{color:var(--accent-text)}
|
|
797
|
+
.pricing-unit{font-size:14px;color:var(--muted);font-weight:600}
|
|
798
|
+
.pricing-rule{height:1px;background:var(--hairline);margin:4px 0}
|
|
799
|
+
.pricing-features{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px;font-size:clamp(13px,1.25vw,17px);line-height:1.4}
|
|
800
|
+
.pricing-features li{display:flex;gap:8px;align-items:flex-start}
|
|
801
|
+
.pricing-features li.is-inc span{color:var(--positive);font-weight:800}
|
|
802
|
+
.pricing-features li.is-exc{color:var(--muted);text-decoration:line-through;opacity:.72}
|
|
803
|
+
.pricing-features li.is-exc span{color:var(--muted);font-weight:700}
|
|
804
|
+
@media (max-width:900px){.itree-board,.itree-row,.gauge-row{grid-template-columns:1fr}}
|
|
805
|
+
`
|