@officedk/pptxdk 0.0.0-stage → 0.2.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.
Files changed (206) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build-zrZuX4fK.d.ts +3 -0
  3. package/dist/build.d.ts +35 -0
  4. package/dist/build.js +128 -0
  5. package/dist/capabilities/dist/all.js +34 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +84 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +32 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +142 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2403 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1119 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +192 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +592 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +60 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +168 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +119 -0
  38. package/dist/capabilities/dist/font/font-engine.js +834 -0
  39. package/dist/capabilities/dist/font/font-import.js +766 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +72 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +74 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +41 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +649 -0
  46. package/dist/capabilities/dist/group/group-xml.js +8 -0
  47. package/dist/capabilities/dist/group/group.js +260 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +164 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +244 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +984 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +147 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +552 -0
  57. package/dist/capabilities/dist/line/line-codegen.js +89 -0
  58. package/dist/capabilities/dist/line/line-declaration.js +72 -0
  59. package/dist/capabilities/dist/line/line-elements.js +12 -0
  60. package/dist/capabilities/dist/line/line-import.js +504 -0
  61. package/dist/capabilities/dist/line/line-xml.js +9 -0
  62. package/dist/capabilities/dist/line/line.js +331 -0
  63. package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
  64. package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
  65. package/dist/capabilities/dist/masters/masters.js +250 -0
  66. package/dist/capabilities/dist/motion/motion-api.js +757 -0
  67. package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
  68. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  69. package/dist/capabilities/dist/motion/motion-import.js +1568 -0
  70. package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
  71. package/dist/capabilities/dist/motion/motion-query.js +423 -0
  72. package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
  73. package/dist/capabilities/dist/motion/motion.js +1617 -0
  74. package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
  75. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  76. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  77. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  78. package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
  79. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  80. package/dist/capabilities/dist/notes/notes.js +194 -0
  81. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
  82. package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
  83. package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
  84. package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
  85. package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
  86. package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
  87. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  88. package/dist/capabilities/dist/shape/shape-import.js +628 -0
  89. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  90. package/dist/capabilities/dist/shape/shape.js +320 -0
  91. package/dist/capabilities/dist/shared/geometry.js +1681 -0
  92. package/dist/capabilities/dist/shared/identity.js +205 -0
  93. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  94. package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
  95. package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
  96. package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
  97. package/dist/capabilities/dist/shared/text-schemas.js +241 -0
  98. package/dist/capabilities/dist/shared/text-service.js +2252 -0
  99. package/dist/capabilities/dist/shared/visual.js +1197 -0
  100. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  101. package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
  102. package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
  103. package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
  104. package/dist/capabilities/dist/table/table-codegen.js +125 -0
  105. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  106. package/dist/capabilities/dist/table/table-elements.js +27 -0
  107. package/dist/capabilities/dist/table/table-import.js +606 -0
  108. package/dist/capabilities/dist/table/table-schemas.js +334 -0
  109. package/dist/capabilities/dist/table/table-xml.js +30 -0
  110. package/dist/capabilities/dist/table/table.js +739 -0
  111. package/dist/capabilities/dist/text/text-codegen.js +198 -0
  112. package/dist/capabilities/dist/text/text-declaration.js +27 -0
  113. package/dist/capabilities/dist/text/text-elements.js +54 -0
  114. package/dist/capabilities/dist/text/text-import.js +1224 -0
  115. package/dist/capabilities/dist/text/text-xml.js +9 -0
  116. package/dist/capabilities/dist/text/text.js +320 -0
  117. package/dist/capabilities/dist/transition/transition-api.js +136 -0
  118. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  119. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  120. package/dist/capabilities/dist/transition/transition.js +260 -0
  121. package/dist/capability-BbKW9w4O.d.ts +2131 -0
  122. package/dist/cli.js +20 -0
  123. package/dist/codegen/dist/assets.js +79 -0
  124. package/dist/codegen/dist/codegen.js +691 -0
  125. package/dist/codegen/dist/identifiers.js +203 -0
  126. package/dist/codegen/dist/index.js +3 -0
  127. package/dist/codegen/dist/printer.js +143 -0
  128. package/dist/codegen/dist/types.js +77 -0
  129. package/dist/core/dist/author-ids.js +51 -0
  130. package/dist/core/dist/author-schemas.js +330 -0
  131. package/dist/core/dist/block-flex-layout.js +801 -0
  132. package/dist/core/dist/build.js +4 -0
  133. package/dist/core/dist/capability.js +15 -0
  134. package/dist/core/dist/declaration.js +16 -0
  135. package/dist/core/dist/diagnostics.js +353 -0
  136. package/dist/core/dist/document-internals.js +26 -0
  137. package/dist/core/dist/document.js +417 -0
  138. package/dist/core/dist/font-seal.js +204 -0
  139. package/dist/core/dist/geometry-schemas.js +256 -0
  140. package/dist/core/dist/grid-layout.js +449 -0
  141. package/dist/core/dist/host.js +40 -0
  142. package/dist/core/dist/index.js +15 -0
  143. package/dist/core/dist/input-values.js +61 -0
  144. package/dist/core/dist/layout-protocol.js +61 -0
  145. package/dist/core/dist/layout-schemas.js +201 -0
  146. package/dist/core/dist/layout.js +340 -0
  147. package/dist/core/dist/masters.js +194 -0
  148. package/dist/core/dist/morph.js +30 -0
  149. package/dist/core/dist/placeholders.js +275 -0
  150. package/dist/core/dist/query.js +190 -0
  151. package/dist/core/dist/resolution.js +12 -0
  152. package/dist/core/dist/resolve.js +2246 -0
  153. package/dist/core/dist/stage-options.js +300 -0
  154. package/dist/core/dist/theme.js +1023 -0
  155. package/dist/core/dist/transform-geometry.js +72 -0
  156. package/dist/document-41spD7bq.d.ts +1350 -0
  157. package/dist/emit/dist/emit.js +957 -0
  158. package/dist/emit/dist/index.js +5 -0
  159. package/dist/emit/dist/ooxml.js +661 -0
  160. package/dist/emit/dist/shape-tree.js +12 -0
  161. package/dist/import/dist/alternate-content.js +54 -0
  162. package/dist/import/dist/diagnostics.js +157 -0
  163. package/dist/import/dist/fonts.js +309 -0
  164. package/dist/import/dist/import.js +513 -0
  165. package/dist/import/dist/index.js +16 -0
  166. package/dist/import/dist/masters.js +1293 -0
  167. package/dist/import/dist/mechanism.js +10 -0
  168. package/dist/import/dist/namespaces.js +61 -0
  169. package/dist/import/dist/notes-masters.js +300 -0
  170. package/dist/import/dist/opc.js +233 -0
  171. package/dist/import/dist/resources.js +166 -0
  172. package/dist/import/dist/sections.js +139 -0
  173. package/dist/import/dist/themes.js +777 -0
  174. package/dist/import/dist/visual.js +821 -0
  175. package/dist/import/dist/xml-fragments.js +277 -0
  176. package/dist/import/dist/xml-reader.js +267 -0
  177. package/dist/index-1ag7U9Jt.d.ts +63 -0
  178. package/dist/index-BEwhk7c8.d.ts +72 -0
  179. package/dist/index-cK2KtukZ.d.ts +161 -0
  180. package/dist/index-v77CTJev.d.ts +55 -0
  181. package/dist/index.d.ts +8 -0
  182. package/dist/index.js +82 -0
  183. package/dist/node.d.ts +53 -0
  184. package/dist/node.js +225 -0
  185. package/dist/pptxdk/src/cli-commands.js +907 -0
  186. package/dist/pptxdk/src/compose.js +53 -0
  187. package/dist/pptxdk/src/slide.js +9 -0
  188. package/dist/preview/dist/index.js +342 -0
  189. package/dist/preview/dist/options.js +40 -0
  190. package/dist/preview/dist/svg-guard.js +1089 -0
  191. package/dist/preview.d.ts +12 -0
  192. package/dist/preview.js +29 -0
  193. package/dist/react/dist/append.js +66 -0
  194. package/dist/react/dist/document-adapter.js +404 -0
  195. package/dist/react/dist/elements.js +82 -0
  196. package/dist/react/dist/from-vanilla.js +57 -0
  197. package/dist/react/dist/index.js +89 -0
  198. package/dist/react/dist/mount.js +34 -0
  199. package/dist/react/dist/reconciler.js +290 -0
  200. package/dist/react.d.ts +235 -0
  201. package/dist/react.js +31 -0
  202. package/dist/transition-6n8GZxSg.d.ts +9 -0
  203. package/dist/vanilla.d.ts +4 -0
  204. package/dist/vanilla.js +15 -0
  205. package/package.json +79 -3
  206. package/README.md +0 -3
@@ -0,0 +1,311 @@
1
+ import { resolveAxisLabelSide } from "./layout.js";
2
+ import { formatChartNumber } from "./number-format.js";
3
+ import { resolveAxisCrossingScreen } from "./scales.js";
4
+ import { resolveChartLineStroke, strokeAttrs } from "./style.js";
5
+ import { measureChartText, mergeChartTextStyle, renderChartTextSvg, resolveChartFontSizePixels } from "./text-render.js";
6
+ import { assertNever } from "./types.js";
7
+ // ../capabilities/dist/chart/preview/axes-and-grid.js
8
+ function categoryGridCoordinates(scale, plot, minor) {
9
+ const coords = [];
10
+ if (minor) {
11
+ if (scale.crossBetween === "midCat" && scale.count > 1) for (let i = 0; i < scale.count - 1; i += 1) {
12
+ const rawT = (i + .5) / (scale.count - 1);
13
+ coords.push(scale.mapScreen(scale.reversed ? 1 - rawT : rawT, plot));
14
+ }
15
+ else for (let i = 0; i < scale.count; i += 1) coords.push(scale.indexToScreen(i, plot));
16
+ return coords;
17
+ }
18
+ if (scale.crossBetween === "midCat") for (let i = 0; i < scale.count; i += 1) coords.push(scale.indexToScreen(i, plot));
19
+ else for (let b = 0; b <= scale.count; b += 1) coords.push(scale.mapScreen(scale.mapBoundary(b), plot));
20
+ return coords;
21
+ }
22
+ function drawGridlineSet(coords, direction, plot, stroke) {
23
+ if (coords.length === 0) return "";
24
+ const segs = [];
25
+ for (const coord of coords) if (direction === "vertical") segs.push(`M${plot.x} ${coord}H${plot.x + plot.width}`);
26
+ else segs.push(`M${coord} ${plot.y}V${plot.y + plot.height}`);
27
+ return `<path d="${segs.join("")}" ${strokeAttrs(stroke)} fill="none"/>`;
28
+ }
29
+ function renderGridlinesSvg(options) {
30
+ const { parsed, scales, plotRect, theme } = options;
31
+ const parts = [];
32
+ for (const axis of parsed.axes) {
33
+ if (axis.spec.visible === false) continue;
34
+ const scale = scales.get(axis.name);
35
+ if (scale === void 0) continue;
36
+ const emitFor = (setting, minor) => {
37
+ if (setting === void 0 || setting === false) return;
38
+ const stroke = resolveChartLineStroke(setting, theme, {
39
+ color: "dk1",
40
+ width: minor ? .75 : 1,
41
+ alpha: minor ? .1 : .2
42
+ });
43
+ if (stroke === void 0) return;
44
+ const svg = drawGridlineSet(scale.kind === "value" ? (minor ? scale.minorTicks : scale.majorTicks).map((v) => scale.valueToScreen(v, plotRect)) : categoryGridCoordinates(scale, plotRect, minor), axis.direction, plotRect, stroke);
45
+ if (svg !== "") parts.push(svg);
46
+ };
47
+ emitFor(axis.spec.minorGridlines, true);
48
+ emitFor(axis.spec.gridlines, false);
49
+ }
50
+ return parts.join("");
51
+ }
52
+ function tickMarkRange(mark, length, outDir) {
53
+ const effective = mark ?? "none";
54
+ switch (effective) {
55
+ case "none": return;
56
+ case "out": return outDir > 0 ? {
57
+ startOffset: 0,
58
+ endOffset: length
59
+ } : {
60
+ startOffset: -length,
61
+ endOffset: 0
62
+ };
63
+ case "in": return outDir > 0 ? {
64
+ startOffset: -length,
65
+ endOffset: 0
66
+ } : {
67
+ startOffset: 0,
68
+ endOffset: length
69
+ };
70
+ case "cross": return {
71
+ startOffset: -length,
72
+ endOffset: length
73
+ };
74
+ default: return assertNever(effective);
75
+ }
76
+ }
77
+ function renderTickMarks(options) {
78
+ const range = tickMarkRange(options.mark, options.length, options.outDir);
79
+ if (range === void 0 || options.coords.length === 0) return "";
80
+ const segs = [];
81
+ for (const coord of options.coords) if (options.direction === "horizontal") segs.push(`M${coord} ${options.crossCoord + range.startOffset}V${options.crossCoord + range.endOffset}`);
82
+ else segs.push(`M${options.crossCoord + range.startOffset} ${coord}H${options.crossCoord + range.endOffset}`);
83
+ return `<path d="${segs.join("")}" ${strokeAttrs(options.stroke)} fill="none"/>`;
84
+ }
85
+ function axisTitleParts(axis) {
86
+ if (axis.spec.title === void 0) return void 0;
87
+ return typeof axis.spec.title === "string" ? { text: axis.spec.title } : axis.spec.title;
88
+ }
89
+ function renderAxesSvg(options) {
90
+ const { parsed, chartBox, layout, scales, baseChartTextStyle, baseFontSizePx, theme, slideNumber, clipAllocator } = options;
91
+ const { plotRect } = layout;
92
+ const parts = [];
93
+ let leftTitleRightEdge;
94
+ let rightTitleLeftEdge;
95
+ for (const tb of layout.axisTitleBoxes.values()) if (tb.x < plotRect.x) {
96
+ const right = tb.x + tb.width;
97
+ leftTitleRightEdge = leftTitleRightEdge === void 0 ? right : Math.max(leftTitleRightEdge, right);
98
+ } else if (tb.x >= plotRect.x + plotRect.width) rightTitleLeftEdge = rightTitleLeftEdge === void 0 ? tb.x : Math.min(rightTitleLeftEdge, tb.x);
99
+ for (const axis of parsed.axes) {
100
+ if (axis.spec.visible === false) continue;
101
+ const scale = scales.get(axis.name);
102
+ if (scale === void 0) continue;
103
+ const crossAxis = parsed.axes.find((a) => a.id === axis.crossAxisId);
104
+ const crossScale = crossAxis ? scales.get(crossAxis.name) : void 0;
105
+ const crossCoord = crossScale !== void 0 ? resolveAxisCrossingScreen(axis, crossScale, plotRect) : axis.position === "top" ? plotRect.y : axis.position === "bottom" ? plotRect.y + plotRect.height : axis.position === "right" ? plotRect.x + plotRect.width : plotRect.x;
106
+ const lineStroke = resolveChartLineStroke(axis.spec.line, theme, {
107
+ color: "dk1",
108
+ width: 1
109
+ });
110
+ const tickStroke = lineStroke ?? resolveChartLineStroke(true, theme, {
111
+ color: "dk1",
112
+ width: 1
113
+ });
114
+ if (lineStroke !== void 0) {
115
+ const path = axis.direction === "horizontal" ? `M${plotRect.x} ${crossCoord}H${plotRect.x + plotRect.width}` : `M${crossCoord} ${plotRect.y}V${plotRect.y + plotRect.height}`;
116
+ parts.push(`<path d="${path}" ${strokeAttrs(lineStroke)} fill="none"/>`);
117
+ }
118
+ const outDir = axis.direction === "horizontal" ? axis.position === "top" || crossCoord <= plotRect.y + 1 ? -1 : 1 : axis.position === "right" || crossCoord >= plotRect.x + plotRect.width - 1 ? 1 : -1;
119
+ const majorTickCoords = scale.kind === "value" ? scale.majorTicks.map((v) => scale.valueToScreen(v, plotRect)) : categoryGridCoordinates(scale, plotRect, false);
120
+ const minorTickCoords = scale.kind === "value" ? scale.minorTicks.map((v) => scale.valueToScreen(v, plotRect)) : categoryGridCoordinates(scale, plotRect, true);
121
+ parts.push(renderTickMarks({
122
+ coords: majorTickCoords,
123
+ direction: axis.direction,
124
+ crossCoord,
125
+ mark: axis.spec.majorTickMark,
126
+ length: 4,
127
+ outDir,
128
+ stroke: tickStroke
129
+ }));
130
+ parts.push(renderTickMarks({
131
+ coords: minorTickCoords,
132
+ direction: axis.direction,
133
+ crossCoord,
134
+ mark: axis.spec.minorTickMark,
135
+ length: 2.5,
136
+ outDir,
137
+ stroke: tickStroke
138
+ }));
139
+ const axisTextStyle = mergeChartTextStyle(baseChartTextStyle, axis.spec.style);
140
+ const axisFontPx = axisTextStyle?.fontSize !== void 0 ? resolveChartFontSizePixels(axisTextStyle.fontSize) : baseFontSizePx;
141
+ const labelSide = resolveAxisLabelSide(axis, crossScale);
142
+ const tickProtrusion = axis.spec.majorTickMark === "out" || axis.spec.majorTickMark === "cross" ? 4 : 0;
143
+ const labelGap = 4;
144
+ if (labelSide !== "none") {
145
+ if (axis.direction === "horizontal") {
146
+ const zone = layout.labelZones.get(axis.name);
147
+ const zoneOffset = zone?.offset ?? 0;
148
+ const zoneH = Math.max(axisFontPx * 1.3, (zone?.depth ?? axisFontPx * 1.4) - labelGap - tickProtrusion);
149
+ const labelY = labelSide === "top" ? plotRect.y - labelGap - tickProtrusion - zoneOffset - zoneH : labelSide === "bottom" ? plotRect.y + plotRect.height + labelGap + tickProtrusion + zoneOffset : crossCoord + 4;
150
+ if (scale.kind === "category") {
151
+ const slotW = scale.slotSpan(plotRect);
152
+ for (let i = 0; i < scale.categories.length; i += 1) {
153
+ const labelBox = {
154
+ x: scale.indexToScreen(i, plotRect) - slotW / 2,
155
+ y: labelY,
156
+ width: Math.max(4, slotW),
157
+ height: zoneH
158
+ };
159
+ parts.push(renderChartTextSvg({
160
+ text: scale.categories[i],
161
+ box: labelBox,
162
+ style: axisTextStyle,
163
+ theme,
164
+ slideNumber,
165
+ labelPath: `Chart.axes.${axis.name}.style`,
166
+ align: "center",
167
+ verticalAlign: labelSide === "top" ? "bottom" : "top",
168
+ wrap: true,
169
+ clipBox: labelBox,
170
+ clipAllocator
171
+ }));
172
+ }
173
+ } else {
174
+ const tickSpacing = Math.max(24, plotRect.width / Math.max(1, scale.majorTicks.length - 1));
175
+ for (const val of scale.majorTicks) {
176
+ const cx = scale.valueToScreen(val, plotRect);
177
+ const text = formatChartNumber(val, scale.numberFormat);
178
+ const labelBox = {
179
+ x: cx - tickSpacing / 2,
180
+ y: labelY,
181
+ width: tickSpacing,
182
+ height: zoneH
183
+ };
184
+ parts.push(renderChartTextSvg({
185
+ text,
186
+ box: labelBox,
187
+ style: axisTextStyle,
188
+ theme,
189
+ slideNumber,
190
+ labelPath: `Chart.axes.${axis.name}.style`,
191
+ align: "center",
192
+ verticalAlign: labelSide === "top" ? "bottom" : "top",
193
+ wrap: false,
194
+ clipBox: chartBox,
195
+ clipAllocator
196
+ }));
197
+ }
198
+ }
199
+ } else {
200
+ const titleInnerGap = 4;
201
+ const leftBound = leftTitleRightEdge !== void 0 ? leftTitleRightEdge + titleInnerGap : chartBox.x + 2;
202
+ const rightBound = rightTitleLeftEdge !== void 0 ? rightTitleLeftEdge - titleInnerGap : chartBox.x + chartBox.width - 2;
203
+ const zoneOffset = layout.labelZones.get(axis.name)?.offset ?? 0;
204
+ let boxX;
205
+ let boxW;
206
+ let align;
207
+ if (labelSide === "right") {
208
+ boxX = plotRect.x + plotRect.width + labelGap + tickProtrusion + zoneOffset;
209
+ boxW = Math.max(6, rightBound - boxX);
210
+ align = "left";
211
+ } else if (labelSide === "left") {
212
+ const rightEdge = plotRect.x - labelGap - tickProtrusion - zoneOffset;
213
+ boxX = leftBound;
214
+ boxW = Math.max(6, rightEdge - leftBound);
215
+ align = "right";
216
+ } else {
217
+ const leftRoom = crossCoord - plotRect.x - 4;
218
+ if (leftRoom >= 16) {
219
+ boxW = Math.min(56, leftRoom);
220
+ boxX = crossCoord - 4 - boxW;
221
+ align = "right";
222
+ } else {
223
+ boxX = crossCoord + 4;
224
+ boxW = Math.max(6, Math.min(56, plotRect.x + plotRect.width - boxX));
225
+ align = "left";
226
+ }
227
+ }
228
+ if (scale.kind === "value") {
229
+ const measuredLineH = measureChartText({
230
+ text: "",
231
+ style: axisTextStyle,
232
+ theme,
233
+ slideNumber,
234
+ labelPath: `Chart.axes.${axis.name}.style`
235
+ }).height;
236
+ const labelH = Math.max(Math.ceil(measuredLineH) + 2, 12);
237
+ for (const val of scale.majorTicks) {
238
+ const cy = scale.valueToScreen(val, plotRect);
239
+ const text = formatChartNumber(val, scale.numberFormat);
240
+ const labelBox = {
241
+ x: boxX,
242
+ y: cy - labelH / 2,
243
+ width: boxW,
244
+ height: labelH
245
+ };
246
+ parts.push(renderChartTextSvg({
247
+ text,
248
+ box: labelBox,
249
+ style: axisTextStyle,
250
+ theme,
251
+ slideNumber,
252
+ labelPath: `Chart.axes.${axis.name}.style`,
253
+ align,
254
+ verticalAlign: "middle",
255
+ wrap: false,
256
+ clipBox: labelBox,
257
+ clipAllocator
258
+ }));
259
+ }
260
+ } else {
261
+ const slotH = scale.slotSpan(plotRect);
262
+ const labelH = Math.max(slotH, axisFontPx * 1.2);
263
+ for (let i = 0; i < scale.categories.length; i += 1) {
264
+ const cy = scale.indexToScreen(i, plotRect);
265
+ const labelBox = {
266
+ x: boxX,
267
+ y: cy - labelH / 2,
268
+ width: boxW,
269
+ height: labelH
270
+ };
271
+ parts.push(renderChartTextSvg({
272
+ text: scale.categories[i],
273
+ box: labelBox,
274
+ style: axisTextStyle,
275
+ theme,
276
+ slideNumber,
277
+ labelPath: `Chart.axes.${axis.name}.style`,
278
+ align,
279
+ verticalAlign: "middle",
280
+ wrap: slotH >= axisFontPx * 2.2,
281
+ clipBox: labelBox,
282
+ clipAllocator
283
+ }));
284
+ }
285
+ }
286
+ }
287
+ }
288
+ const title = axisTitleParts(axis);
289
+ const titleBox = layout.axisTitleBoxes.get(axis.name);
290
+ if (title !== void 0 && titleBox !== void 0) {
291
+ const titleStyle = mergeChartTextStyle(axisTextStyle, title.style);
292
+ const rotationDegrees = axis.titleRotationDegrees;
293
+ parts.push(renderChartTextSvg({
294
+ text: title.text,
295
+ box: titleBox,
296
+ style: titleStyle,
297
+ theme,
298
+ slideNumber,
299
+ labelPath: `Chart.axes.${axis.name}.title`,
300
+ align: "center",
301
+ verticalAlign: "middle",
302
+ wrap: true,
303
+ clipBox: titleBox,
304
+ clipAllocator,
305
+ ...rotationDegrees === void 0 ? {} : { rotationDegrees }
306
+ }));
307
+ }
308
+ }
309
+ return parts.join("");
310
+ }
311
+ export { renderAxesSvg, renderGridlinesSvg };
@@ -0,0 +1,143 @@
1
+ import { resolveChartLineStroke, resolveSeriesColor, strokeAttrs } from "./style.js";
2
+ // ../capabilities/dist/chart/preview/bar-column.js
3
+ function renderColumnOrBarGroup(options) {
4
+ const { group, groupIndex, scales, plotRect, theme } = options;
5
+ const catScale = scales.get(group.axes.category.name);
6
+ const valScale = scales.get(group.axes.value.name);
7
+ if (catScale?.kind !== "category" || valScale?.kind !== "value") return {
8
+ svg: "",
9
+ anchors: []
10
+ };
11
+ const isHorizontal = group.kind === "bar";
12
+ const categories = group.data.categories;
13
+ const seriesCount = group.series.length;
14
+ if (categories.length === 0 || seriesCount === 0) return {
15
+ svg: "",
16
+ anchors: []
17
+ };
18
+ const slotSpan = catScale.slotSpan(plotRect);
19
+ const g = group.gapWidth / 100;
20
+ const parts = [];
21
+ const anchors = [];
22
+ const emitBar = (params) => {
23
+ const series = group.series[params.groupSeriesIndex];
24
+ const point = series.points?.[params.pointIndex];
25
+ const fill = resolveSeriesColor(point?.color ?? series.color, series.seriesIndex, theme);
26
+ const lineSpec = point?.line ?? series.line;
27
+ const stroke = lineSpec === void 0 ? void 0 : resolveChartLineStroke(lineSpec, theme, {
28
+ color: "dk1",
29
+ width: 1
30
+ });
31
+ const x = isHorizontal ? Math.min(params.startCoord, params.endCoord) : params.bandStart;
32
+ const y = isHorizontal ? params.bandStart : Math.min(params.startCoord, params.endCoord);
33
+ const width = isHorizontal ? Math.abs(params.endCoord - params.startCoord) : params.bandThickness;
34
+ const height = isHorizontal ? params.bandThickness : Math.abs(params.endCoord - params.startCoord);
35
+ const valueEndSide = isHorizontal ? params.endCoord >= params.startCoord ? "right" : "left" : params.endCoord <= params.startCoord ? "top" : "bottom";
36
+ if (width > 0 && height > 0) {
37
+ const strokeAttr = stroke === void 0 ? "" : ` ${strokeAttrs(stroke)}`;
38
+ parts.push(`<rect x="${x}" y="${y}" width="${width}" height="${height}" fill="#${fill.hex}" fill-opacity="${fill.alpha ?? 1}"${strokeAttr}/>`);
39
+ } else if (stroke !== void 0) parts.push(`<rect x="${x}" y="${y}" width="${width}" height="${height}" fill="none" ${strokeAttrs(stroke)}/>`);
40
+ anchors.push({
41
+ kind: "bar",
42
+ groupIndex,
43
+ seriesIndex: params.seriesIndex,
44
+ groupSeriesIndex: params.groupSeriesIndex,
45
+ pointIndex: params.pointIndex,
46
+ value: params.rawValue,
47
+ ...params.plottedValue === void 0 ? {} : { plottedValue: params.plottedValue },
48
+ category: categories[params.pointIndex] ?? "",
49
+ seriesName: params.seriesName,
50
+ x,
51
+ y,
52
+ width,
53
+ height,
54
+ isNegative: params.rawValue < 0,
55
+ horizontal: isHorizontal,
56
+ valueEndSide,
57
+ ...params.percent === void 0 ? {} : { percent: params.percent }
58
+ });
59
+ };
60
+ if (group.stacking === "clustered") {
61
+ const o = (group.overlap ?? 0) / 100;
62
+ const denom = Math.max(.1, g + 1 + Math.max(0, seriesCount - 1) * (1 - o));
63
+ const barThickness = Math.max(.5, slotSpan / denom);
64
+ const clusterSpan = barThickness * (1 + Math.max(0, seriesCount - 1) * (1 - o));
65
+ const zeroCoord = valScale.zeroScreen(plotRect);
66
+ for (let catIdx = 0; catIdx < categories.length; catIdx += 1) {
67
+ const catCenter = catScale.indexToScreen(catIdx, plotRect);
68
+ for (let s = 0; s < seriesCount; s += 1) {
69
+ const series = group.series[s];
70
+ const value = series.values[catIdx];
71
+ if (value === null || value === void 0 || !Number.isFinite(value)) continue;
72
+ if (valScale.logBase !== void 0 && value <= 0) continue;
73
+ const bandStart = catCenter - clusterSpan / 2 + s * barThickness * (1 - o);
74
+ const endCoord = valScale.valueToScreen(value, plotRect);
75
+ emitBar({
76
+ seriesIndex: series.seriesIndex,
77
+ groupSeriesIndex: s,
78
+ seriesName: series.name,
79
+ pointIndex: catIdx,
80
+ rawValue: value,
81
+ bandStart,
82
+ bandThickness: barThickness,
83
+ startCoord: zeroCoord,
84
+ endCoord
85
+ });
86
+ }
87
+ }
88
+ } else {
89
+ const barThickness = Math.max(.5, slotSpan / Math.max(.1, g + 1));
90
+ const isPercent = group.stacking === "percent";
91
+ for (let catIdx = 0; catIdx < categories.length; catIdx += 1) {
92
+ const bandStart = catScale.indexToScreen(catIdx, plotRect) - barThickness / 2;
93
+ let totalAbs = 0;
94
+ if (isPercent) {
95
+ for (const series of group.series) {
96
+ const v = series.values[catIdx];
97
+ if (v !== null && v !== void 0 && Number.isFinite(v)) totalAbs += Math.abs(v);
98
+ }
99
+ if (totalAbs === 0) continue;
100
+ }
101
+ let posAcc = 0;
102
+ let negAcc = 0;
103
+ for (let s = 0; s < seriesCount; s += 1) {
104
+ const series = group.series[s];
105
+ const raw = series.values[catIdx];
106
+ if (raw === null || raw === void 0 || !Number.isFinite(raw)) continue;
107
+ const plotted = isPercent ? raw / totalAbs : raw;
108
+ if (valScale.logBase !== void 0 && plotted <= 0) continue;
109
+ let startVal;
110
+ let endVal;
111
+ if (plotted >= 0) {
112
+ startVal = posAcc;
113
+ endVal = posAcc + plotted;
114
+ posAcc = endVal;
115
+ } else {
116
+ startVal = negAcc;
117
+ endVal = negAcc + plotted;
118
+ negAcc = endVal;
119
+ }
120
+ const startCoord = valScale.valueToScreen(valScale.logBase !== void 0 ? Math.max(valScale.min, startVal) : startVal, plotRect);
121
+ const endCoord = valScale.valueToScreen(endVal, plotRect);
122
+ emitBar({
123
+ seriesIndex: series.seriesIndex,
124
+ groupSeriesIndex: s,
125
+ seriesName: series.name,
126
+ pointIndex: catIdx,
127
+ rawValue: raw,
128
+ plottedValue: endVal,
129
+ ...isPercent ? { percent: Math.abs(raw) / totalAbs } : {},
130
+ bandStart,
131
+ bandThickness: barThickness,
132
+ startCoord,
133
+ endCoord
134
+ });
135
+ }
136
+ }
137
+ }
138
+ return {
139
+ svg: parts.join(""),
140
+ anchors
141
+ };
142
+ }
143
+ export { renderColumnOrBarGroup };