dsh-ppt 0.25.0 → 0.27.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 +22 -0
- package/README.en.md +14 -13
- package/README.md +14 -13
- package/docs/DATA.md +2 -2
- package/docs/REFERENCE.en.md +8 -8
- package/docs/REFERENCE.zh.md +8 -8
- package/docs/USAGE.en.md +12 -7
- package/docs/USAGE.md +12 -7
- package/docs/VALIDATION.md +8 -0
- package/docs/WORKBENCH.md +4 -4
- package/docs/assets/intro/workflow-en-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-light.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-light.svg +1 -1
- package/lib/client.js +312 -84
- package/lib/ecosystem.d.ts +73 -0
- package/lib/ecosystem.js +1352 -0
- package/lib/execution.d.ts +6 -1
- package/lib/execution.js +77 -4
- package/lib/tools.js +133 -1
- package/lib/types.d.ts +121 -1
- package/lib/workbench-language.js +4 -0
- package/lib/workbench.d.ts +2 -0
- package/lib/workbench.js +397 -10
- package/package.json +1 -1
- package/skills/dsh-ppt/SKILL.md +6 -6
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/advanced.md +10 -5
- package/skills/dsh-ppt/references/syntax.md +1 -0
- package/skills/dsh-ppt/scripts/build-deck.mjs +53 -10
- package/skills/dsh-ppt/scripts/deck-absorb.mjs +114 -1
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +153 -25
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +1814 -0
- package/skills/dsh-ppt/scripts/deck-core.mjs +122 -6
- package/skills/dsh-ppt/scripts/deck-covers.mjs +804 -0
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +636 -41
- package/skills/dsh-ppt/scripts/deck-diagrams.mjs +2842 -0
- package/skills/dsh-ppt/scripts/deck-director.mjs +167 -4
- package/skills/dsh-ppt/scripts/deck-icons.mjs +469 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +816 -5177
- package/skills/dsh-ppt/scripts/deck-media.mjs +159 -15
- package/skills/dsh-ppt/scripts/deck-mermaid.mjs +2737 -0
- package/skills/dsh-ppt/scripts/deck-office.mjs +1541 -0
- package/skills/dsh-ppt/scripts/deck-taste.mjs +347 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Shared geometry, media framing, and publication-grade chart compilers (SVG + OOXML + @office-kit/pptx).
|
|
2
2
|
import { resolveChromeStyle } from './deck-themes.mjs'
|
|
3
3
|
import { getChromeConfig, computeBadgePillWidth, roundRectAdj } from './deck-layouts.mjs'
|
|
4
|
+
import { resolveActiveTaste } from './deck-taste.mjs'
|
|
4
5
|
|
|
5
6
|
export const MEDIA_LAYOUTS = new Set(['image', 'image-left', 'image-right', 'chart', 'chart-split'])
|
|
6
7
|
export const CHART_KINDS = Object.freeze([
|
|
@@ -11,10 +12,25 @@ export const CANVAS = { w: 13.3333333333, h: 7.5 }
|
|
|
11
12
|
export const LOGO_BOX = { x: 11.55, y: 0.18, w: 0.95, h: 0.42 }
|
|
12
13
|
export const FOOTER_BOX = { x: 0.65, y: 6.98, w: 9.2, h: 0.28 }
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
function hasChartAnnotationStrip(slide, manifest = {}) {
|
|
16
|
+
if (!slide?.chart || slide.chart.kind === 'waterfall') return false
|
|
17
|
+
if (slide.layout !== 'chart' && slide.layout !== 'chart-split') return false
|
|
18
|
+
const c = slide.chart
|
|
19
|
+
if (c.referenceLine && Number.isFinite(c.referenceLine.value)) return true
|
|
20
|
+
if (c.callout?.label) return true
|
|
21
|
+
const taste = resolveActiveTaste(manifest, slide)
|
|
22
|
+
if ((c.showGrowthCallout || taste.chartGrowthCallout) && ['column', 'bar', 'line', 'area', 'combo'].includes(c.kind)) {
|
|
23
|
+
const vals = c.series?.[0]?.values || []
|
|
24
|
+
if (vals.length >= 2 && Math.abs(vals[0]) > 1e-9) return true
|
|
25
|
+
}
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function mediaBoxes(layout, variantInput, slide = {}, manifest = {}) {
|
|
15
30
|
const variant = String(variantInput ?? slide?.variant ?? '').trim().toLowerCase()
|
|
16
31
|
const hasTakeaway = Boolean(slide?.takeaway && String(slide.takeaway).trim())
|
|
17
32
|
const hasCaption = Boolean((slide?.image?.caption && String(slide.image.caption).trim()) || (slide?.chart?.caption && String(slide.chart.caption).trim()))
|
|
33
|
+
const annotReserve = hasChartAnnotationStrip(slide, manifest) ? 0.36 : 0
|
|
18
34
|
const bottomLimit = hasTakeaway ? (hasCaption ? 5.80 : 6.04) : 6.42
|
|
19
35
|
const bodyTop = 1.68
|
|
20
36
|
const bodyH = +(bottomLimit - bodyTop).toFixed(3)
|
|
@@ -52,8 +68,8 @@ export function mediaBoxes(layout, variantInput, slide = {}) {
|
|
|
52
68
|
if (layout === 'chart-split') {
|
|
53
69
|
const chartRight = variant === 'chart-right'
|
|
54
70
|
const chartBox = chartRight
|
|
55
|
-
? { x: 5.32, y: bodyTop, w: 7.36, h: bodyH }
|
|
56
|
-
: { x: 0.65, y: bodyTop, w: 7.36, h: bodyH }
|
|
71
|
+
? { x: 5.32, y: +(bodyTop + annotReserve).toFixed(3), w: 7.36, h: +(bodyH - annotReserve).toFixed(3) }
|
|
72
|
+
: { x: 0.65, y: +(bodyTop + annotReserve).toFixed(3), w: 7.36, h: +(bodyH - annotReserve).toFixed(3) }
|
|
57
73
|
const sideBox = chartRight
|
|
58
74
|
? { x: 0.65, y: bodyTop, w: 4.35, h: bodyH }
|
|
59
75
|
: { x: 8.33, y: bodyTop, w: 4.35, h: bodyH }
|
|
@@ -91,7 +107,7 @@ export function mediaBoxes(layout, variantInput, slide = {}) {
|
|
|
91
107
|
image: { ...imageTarget, h: +(bodyH - 0.14).toFixed(3) },
|
|
92
108
|
gallery,
|
|
93
109
|
body: layout === 'image-left' ? right : layout === 'image-right' ? left : null,
|
|
94
|
-
chart: { ...full, h: +(bodyH - 0.12).toFixed(3) },
|
|
110
|
+
chart: { ...full, y: +(full.y + annotReserve).toFixed(3), h: +(bodyH - 0.12 - annotReserve).toFixed(3) },
|
|
95
111
|
caption: captionBox,
|
|
96
112
|
takeaway,
|
|
97
113
|
}
|
|
@@ -201,12 +217,33 @@ export function normalizeChart(input, page = 1) {
|
|
|
201
217
|
const totalIndices = Array.isArray(input.totalIndices)
|
|
202
218
|
? input.totalIndices.filter(n => Number.isInteger(n) && n >= 0 && n < categories.length)
|
|
203
219
|
: undefined
|
|
220
|
+
const rawRef = input.referenceLine && typeof input.referenceLine === 'object' ? input.referenceLine : null
|
|
221
|
+
const refVal = rawRef ? Number(rawRef.value) : NaN
|
|
222
|
+
const referenceLine = Number.isFinite(refVal)
|
|
223
|
+
? {
|
|
224
|
+
value: refVal,
|
|
225
|
+
...(rawRef.label ? { label: String(rawRef.label).trim() } : {}),
|
|
226
|
+
...(rawRef.color ? { color: String(rawRef.color).trim() } : {}),
|
|
227
|
+
}
|
|
228
|
+
: undefined
|
|
229
|
+
const rawCallout = input.callout && typeof input.callout === 'object' ? input.callout : null
|
|
230
|
+
const callout = rawCallout && String(rawCallout.label ?? '').trim()
|
|
231
|
+
? {
|
|
232
|
+
label: String(rawCallout.label).trim(),
|
|
233
|
+
...(Number.isInteger(rawCallout.fromIndex) ? { fromIndex: rawCallout.fromIndex } : {}),
|
|
234
|
+
...(Number.isInteger(rawCallout.toIndex) ? { toIndex: rawCallout.toIndex } : {}),
|
|
235
|
+
}
|
|
236
|
+
: undefined
|
|
204
237
|
|
|
205
238
|
return {
|
|
206
239
|
kind,
|
|
207
240
|
categories: categories.map(c => String(c).trim()),
|
|
208
241
|
series: clean,
|
|
209
242
|
...(highlight !== undefined ? { highlight } : {}),
|
|
243
|
+
...(typeof input.spotlight === 'boolean' ? { spotlight: input.spotlight } : {}),
|
|
244
|
+
...(typeof input.showGrowthCallout === 'boolean' ? { showGrowthCallout: input.showGrowthCallout } : {}),
|
|
245
|
+
...(referenceLine ? { referenceLine } : {}),
|
|
246
|
+
...(callout ? { callout } : {}),
|
|
210
247
|
...(typeof input.showValues === 'boolean' ? { showValues: input.showValues } : {}),
|
|
211
248
|
...(typeof input.showLegend === 'boolean' ? { showLegend: input.showLegend } : {}),
|
|
212
249
|
...(totalIndices?.length ? { totalIndices } : {}),
|
|
@@ -589,8 +626,11 @@ export function renderChartSvg(chart, theme) {
|
|
|
589
626
|
else shapes += text(left + (i + 0.5) * (right - left) / n, bottom + 28, category, 'middle', fg, 15)
|
|
590
627
|
})
|
|
591
628
|
|
|
629
|
+
const effectiveHighlight = chart.highlight !== undefined
|
|
630
|
+
? chart.highlight
|
|
631
|
+
: (chart.spotlight === true ? 'max' : undefined)
|
|
592
632
|
const singleHighlights = chart.series.length === 1 && (kind === 'column' || kind === 'bar')
|
|
593
|
-
? resolveHighlights(chart.series[0].values,
|
|
633
|
+
? resolveHighlights(chart.series[0].values, effectiveHighlight)
|
|
594
634
|
: null
|
|
595
635
|
|
|
596
636
|
if (isStacked || isPercent) {
|
|
@@ -652,7 +692,10 @@ export function renderChartSvg(chart, theme) {
|
|
|
652
692
|
shapes += rect(bx, by, Math.max(3, w - 3), bh, color, 3)
|
|
653
693
|
if (showDirectValues && barSeries.length <= 2) {
|
|
654
694
|
if (kind === 'combo' && bh >= 24 && v >= 0) {
|
|
655
|
-
|
|
695
|
+
const secYAtI = lineSeries[0] ? (lineSeries[0].secondaryAxis ? ySec : y)(lineSeries[0].values[i]) : -999
|
|
696
|
+
const topLabelY = by + 18
|
|
697
|
+
const safeBarY = Math.abs(secYAtI - topLabelY) < 28 && bh >= 48 ? by + bh - 12 : topLabelY
|
|
698
|
+
shapes += text(bx + (w - 3) / 2, safeBarY, fmtNum(v), 'middle', tokens.inkOnAccent || '#FFFFFF', 13, 700)
|
|
656
699
|
} else {
|
|
657
700
|
shapes += text(bx + (w - 3) / 2, v >= 0 ? by - 8 : by + bh + 16, fmtNum(v), 'middle', isFocal ? fg : muted, 14, isFocal && singleHighlights ? 700 : 500)
|
|
658
701
|
}
|
|
@@ -681,6 +724,53 @@ export function renderChartSvg(chart, theme) {
|
|
|
681
724
|
})
|
|
682
725
|
}
|
|
683
726
|
|
|
727
|
+
// 基准参考虚线(Target / Average Benchmark Reference Line)
|
|
728
|
+
if (chart.referenceLine && Number.isFinite(chart.referenceLine.value)) {
|
|
729
|
+
const rv = chart.referenceLine.value
|
|
730
|
+
const rCol = chart.referenceLine.color || tokens.accentSecondary || focalColor
|
|
731
|
+
const rLbl = chart.referenceLine.label || `Target ${fmtNum(rv)}`
|
|
732
|
+
if (isHoriz && rv >= min && rv <= max) {
|
|
733
|
+
const rx = x(rv)
|
|
734
|
+
shapes += `<line x1="${rx.toFixed(1)}" y1="${top}" x2="${rx.toFixed(1)}" y2="${bottom}" stroke="${rCol}" stroke-width="1.8" stroke-dasharray="6 4"/>`
|
|
735
|
+
shapes += rect(Math.min(right - 130, rx + 6), top + 4, Math.max(84, rLbl.length * 10 + 18), 22, bg, 11)
|
|
736
|
+
shapes += text(Math.min(right - 122, rx + 14), top + 19, rLbl, 'start', rCol, 12, 700)
|
|
737
|
+
} else if (!isHoriz && rv >= min && rv <= max) {
|
|
738
|
+
const ry = y(rv)
|
|
739
|
+
const pw = Math.min(220, Math.max(82, rLbl.length * 11 + 22))
|
|
740
|
+
shapes += `<line x1="${left}" y1="${ry.toFixed(1)}" x2="${right}" y2="${ry.toFixed(1)}" stroke="${rCol}" stroke-width="1.8" stroke-dasharray="6 4"/>`
|
|
741
|
+
shapes += `<rect x="${(right - pw).toFixed(1)}" y="${(ry - 24).toFixed(1)}" width="${pw.toFixed(1)}" height="20" rx="10" fill="${bg}" stroke="${rCol}" stroke-width="1"/>`
|
|
742
|
+
shapes += text(right - pw / 2, ry - 10, rLbl, 'middle', rCol, 12, 700)
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// 麦肯锡增长飞线标注箭弧(CAGR / Growth Callout Arc)
|
|
747
|
+
if (!isHoriz && !isStacked && !isPercent && n >= 2 && (chart.callout?.label || chart.showGrowthCallout)) {
|
|
748
|
+
const vals = chart.series[0]?.values || []
|
|
749
|
+
const fromIdx = Number.isInteger(chart.callout?.fromIndex) ? Math.max(0, Math.min(n - 1, chart.callout.fromIndex)) : 0
|
|
750
|
+
const toIdx = Number.isInteger(chart.callout?.toIndex) ? Math.max(0, Math.min(n - 1, chart.callout.toIndex)) : n - 1
|
|
751
|
+
const v0 = vals[fromIdx]
|
|
752
|
+
const v1 = vals[toIdx]
|
|
753
|
+
let badgeLabel = chart.callout?.label || ''
|
|
754
|
+
if (!badgeLabel && Number.isFinite(v0) && Number.isFinite(v1) && Math.abs(v0) > 1e-9 && fromIdx !== toIdx) {
|
|
755
|
+
const pct = ((v1 - v0) / Math.abs(v0)) * 100
|
|
756
|
+
badgeLabel = (pct >= 0 ? '+' : '') + pct.toFixed(1) + '%'
|
|
757
|
+
}
|
|
758
|
+
if (badgeLabel && fromIdx !== toIdx) {
|
|
759
|
+
const x0 = left + (fromIdx + 0.5) * (right - left) / n
|
|
760
|
+
const x1 = left + (toIdx + 0.5) * (right - left) / n
|
|
761
|
+
const y0 = Math.max(top + 24, y(v0) - 24)
|
|
762
|
+
const y1 = Math.max(top + 24, y(v1) - 24)
|
|
763
|
+
const yArc = Math.max(top + 4, Math.min(y0, y1) - 22)
|
|
764
|
+
const midX = (x0 + x1) / 2
|
|
765
|
+
const cCol = v1 >= v0 ? posColor : negColor
|
|
766
|
+
const pw = Math.min(180, Math.max(76, badgeLabel.length * 10 + 24))
|
|
767
|
+
shapes += `<path d="M ${x0.toFixed(1)} ${y0.toFixed(1)} L ${x0.toFixed(1)} ${yArc.toFixed(1)} L ${x1.toFixed(1)} ${yArc.toFixed(1)} L ${x1.toFixed(1)} ${y1.toFixed(1)}" fill="none" stroke="${cCol}" stroke-width="1.8"/>`
|
|
768
|
+
shapes += `<polygon points="${(x1 - 5).toFixed(1)},${(y1 - 7).toFixed(1)} ${(x1 + 5).toFixed(1)},${(y1 - 7).toFixed(1)} ${x1.toFixed(1)},${(y1 + 1).toFixed(1)}" fill="${cCol}"/>`
|
|
769
|
+
shapes += `<rect x="${(midX - pw / 2).toFixed(1)}" y="${(yArc - 11).toFixed(1)}" width="${pw.toFixed(1)}" height="22" rx="11" fill="${bg}" stroke="${cCol}" stroke-width="1.2"/>`
|
|
770
|
+
shapes += text(midX, yArc + 4, badgeLabel, 'middle', cCol, 12.5, 700)
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
684
774
|
shapes += isHoriz ? line(x(0), top, x(0), bottom, axisColor, 1.5) : line(left, y(0), right, y(0), axisColor, 1.5)
|
|
685
775
|
}
|
|
686
776
|
|
|
@@ -737,7 +827,7 @@ function projectInsightCards(slide) {
|
|
|
737
827
|
}
|
|
738
828
|
|
|
739
829
|
export function renderMediaHtml(slide, manifest, theme) {
|
|
740
|
-
const boxes = mediaBoxes(slide.layout, slide.variant, slide)
|
|
830
|
+
const boxes = mediaBoxes(slide.layout, slide.variant, slide, manifest)
|
|
741
831
|
const variant = String(slide.variant ?? '').trim().toLowerCase()
|
|
742
832
|
const chromeStyle = resolveChromeStyle(theme, slide, manifest?.brand)
|
|
743
833
|
const slidesArr = Array.isArray(manifest?.slides) ? manifest.slides : []
|
|
@@ -783,7 +873,13 @@ export function renderMediaHtml(slide, manifest, theme) {
|
|
|
783
873
|
}
|
|
784
874
|
|
|
785
875
|
if (slide.layout === 'chart' || slide.layout === 'chart-split') {
|
|
786
|
-
|
|
876
|
+
const taste = resolveActiveTaste(manifest, slide)
|
|
877
|
+
const chartWithTaste = {
|
|
878
|
+
...slide.chart,
|
|
879
|
+
...(slide.chart?.highlight === undefined && slide.chart?.spotlight === undefined && taste.chartSpotlight ? { spotlight: true } : {}),
|
|
880
|
+
...(slide.chart?.showGrowthCallout === undefined && !slide.chart?.callout && taste.chartGrowthCallout ? { showGrowthCallout: true } : {}),
|
|
881
|
+
}
|
|
882
|
+
body += `<div class="media-chart" style="${position(boxes.chart)}">${renderChartSvg(chartWithTaste, theme)}</div>`
|
|
787
883
|
if (slide.layout === 'chart-split' && boxes.body) {
|
|
788
884
|
const cards = projectInsightCards(slide)
|
|
789
885
|
const cardsHtml = cards.map((card, idx) =>
|
|
@@ -955,16 +1051,17 @@ export function buildOfficeKitChartSpec(chart, theme, visual = {}, font = 'Micro
|
|
|
955
1051
|
: 'clustered'
|
|
956
1052
|
|
|
957
1053
|
let highlightSet = null
|
|
958
|
-
|
|
1054
|
+
const effHighlight = chart.highlight !== undefined ? chart.highlight : (chart.spotlight === true ? 'max' : undefined)
|
|
1055
|
+
if (chart.series.length === 1 && (kind === 'column' || kind === 'bar') && effHighlight !== undefined && effHighlight !== 'none') {
|
|
959
1056
|
const vals = chart.series[0].values
|
|
960
|
-
if (typeof
|
|
961
|
-
else if (Array.isArray(
|
|
962
|
-
else if (
|
|
963
|
-
else if (
|
|
1057
|
+
if (typeof effHighlight === 'number') highlightSet = new Set([effHighlight])
|
|
1058
|
+
else if (Array.isArray(effHighlight)) highlightSet = new Set(effHighlight)
|
|
1059
|
+
else if (effHighlight === 'last') highlightSet = new Set([vals.length - 1])
|
|
1060
|
+
else if (effHighlight === 'max') {
|
|
964
1061
|
let best = 0
|
|
965
1062
|
for (let i = 1; i < vals.length; i++) if (vals[i] > vals[best]) best = i
|
|
966
1063
|
highlightSet = new Set([best])
|
|
967
|
-
} else if (
|
|
1064
|
+
} else if (effHighlight === 'min') {
|
|
968
1065
|
let best = 0
|
|
969
1066
|
for (let i = 1; i < vals.length; i++) if (vals[i] < vals[best]) best = i
|
|
970
1067
|
highlightSet = new Set([best])
|
|
@@ -1124,7 +1221,7 @@ export function renderMediaPptxShapes(slide, index, theme, langId = 'zh-CN', fon
|
|
|
1124
1221
|
|
|
1125
1222
|
const toEmu = v => Math.round(v * 914400)
|
|
1126
1223
|
const boxEmu = b => ({ x: toEmu(b.x), y: toEmu(b.y), w: toEmu(b.w), h: toEmu(b.h) })
|
|
1127
|
-
const boxes = mediaBoxes(slide.layout, slide.variant, slide)
|
|
1224
|
+
const boxes = mediaBoxes(slide.layout, slide.variant, slide, manifest)
|
|
1128
1225
|
const variant = String(slide.variant ?? '').trim().toLowerCase()
|
|
1129
1226
|
const isBleed = variant === 'full-bleed' || variant === 'split-bleed'
|
|
1130
1227
|
let nextId = (index + 1) * 100 + 2
|
|
@@ -1351,6 +1448,53 @@ export function renderMediaPptxShapes(slide, index, theme, langId = 'zh-CN', fon
|
|
|
1351
1448
|
}
|
|
1352
1449
|
}
|
|
1353
1450
|
|
|
1451
|
+
// 原生图表顶部精修标注徽章(麦肯锡增长飞线结论 / 基准参考线提示,避免遮挡柱体,原生可编辑)
|
|
1452
|
+
if ((slide.layout === 'chart' || slide.layout === 'chart-split') && slide.chart && slide.chart.kind !== 'waterfall') {
|
|
1453
|
+
const taste = resolveActiveTaste(manifest, slide)
|
|
1454
|
+
const chartObj = slide.chart
|
|
1455
|
+
const badges = []
|
|
1456
|
+
if (chartObj.callout?.label || chartObj.showGrowthCallout || taste.chartGrowthCallout) {
|
|
1457
|
+
const vals = chartObj.series?.[0]?.values || []
|
|
1458
|
+
const fromIdx = Number.isInteger(chartObj.callout?.fromIndex) ? Math.max(0, Math.min(vals.length - 1, chartObj.callout.fromIndex)) : 0
|
|
1459
|
+
const toIdx = Number.isInteger(chartObj.callout?.toIndex) ? Math.max(0, Math.min(vals.length - 1, chartObj.callout.toIndex)) : vals.length - 1
|
|
1460
|
+
let gText = chartObj.callout?.label || ''
|
|
1461
|
+
let isPos = true
|
|
1462
|
+
if (vals.length >= 2 && fromIdx !== toIdx) {
|
|
1463
|
+
const v0 = vals[fromIdx]
|
|
1464
|
+
const v1 = vals[toIdx]
|
|
1465
|
+
isPos = v1 >= v0
|
|
1466
|
+
if (!gText && Math.abs(v0) > 1e-9 && ['column', 'bar', 'line', 'area', 'combo'].includes(chartObj.kind)) {
|
|
1467
|
+
const pct = ((v1 - v0) / Math.abs(v0)) * 100
|
|
1468
|
+
gText = `${chartObj.categories[fromIdx]}→${chartObj.categories[toIdx]} ${pct >= 0 ? '+' : ''}${pct.toFixed(1)}%`
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
if (gText) badges.push({ text: gText, color: isPos ? posColor : negColor })
|
|
1472
|
+
}
|
|
1473
|
+
if (chartObj.referenceLine && Number.isFinite(chartObj.referenceLine.value)) {
|
|
1474
|
+
const rLbl = chartObj.referenceLine.label || `${isEn ? 'Target' : '基准线'} ${chartObj.referenceLine.value}`
|
|
1475
|
+
badges.push({ text: '┄ ' + rLbl, color: chartObj.referenceLine.color || accent2 })
|
|
1476
|
+
}
|
|
1477
|
+
if (badges.length > 0 && boxes.chart) {
|
|
1478
|
+
let curRight = boxes.chart.x + boxes.chart.w
|
|
1479
|
+
const badgeY = Math.max(1.66, boxes.chart.y - 0.35)
|
|
1480
|
+
badges.forEach((b, bi) => {
|
|
1481
|
+
const bw = computeBadgePillWidth(b.text, 10.5, 3.6, 1.15)
|
|
1482
|
+
curRight -= bw
|
|
1483
|
+
if (curRight >= boxes.chart.x + 0.4) {
|
|
1484
|
+
shapes.push(spText('Chart Annotation ' + (bi + 1), { x: curRight, y: badgeY, w: bw, h: 0.28 }, [paraRich(b.text, { size: 1050, color: b.color, bold: true, align: 'ctr' })], {
|
|
1485
|
+
anchor: 'ctr',
|
|
1486
|
+
fill: t.canvas || p.bg || '#FFFFFF',
|
|
1487
|
+
stroke: b.color,
|
|
1488
|
+
strokeW: 9525,
|
|
1489
|
+
roundAdj: 50000,
|
|
1490
|
+
ins: [45720, 9144, 45720, 9144],
|
|
1491
|
+
}))
|
|
1492
|
+
curRight -= 0.12
|
|
1493
|
+
}
|
|
1494
|
+
})
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1354
1498
|
// Caption + Chrome-aware Takeaway coexistence
|
|
1355
1499
|
const caption = slide.chart?.caption || slide.image?.caption
|
|
1356
1500
|
if (caption) {
|