@officedk/pptxdk 0.0.0-stage → 0.1.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 (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -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 +2272 -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 +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -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 +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -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 +48 -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 +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
@@ -0,0 +1,298 @@
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 { 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, theme, slideNumber, clipAllocator } = options;
91
+ const { plotRect } = layout;
92
+ const parts = [];
93
+ for (const axis of parsed.axes) {
94
+ if (axis.spec.visible === false) continue;
95
+ const scale = scales.get(axis.name);
96
+ if (scale === void 0) continue;
97
+ const crossAxis = parsed.axes.find((a) => a.id === axis.crossAxisId);
98
+ const crossScale = crossAxis ? scales.get(crossAxis.name) : void 0;
99
+ 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;
100
+ const lineStroke = resolveChartLineStroke(axis.spec.line, theme, {
101
+ color: "dk1",
102
+ width: 1
103
+ });
104
+ const tickStroke = lineStroke ?? resolveChartLineStroke(true, theme, {
105
+ color: "dk1",
106
+ width: 1
107
+ });
108
+ if (lineStroke !== void 0) {
109
+ const path = axis.direction === "horizontal" ? `M${plotRect.x} ${crossCoord}H${plotRect.x + plotRect.width}` : `M${crossCoord} ${plotRect.y}V${plotRect.y + plotRect.height}`;
110
+ parts.push(`<path d="${path}" ${strokeAttrs(lineStroke)} fill="none"/>`);
111
+ }
112
+ 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;
113
+ const majorTickCoords = scale.kind === "value" ? scale.majorTicks.map((v) => scale.valueToScreen(v, plotRect)) : categoryGridCoordinates(scale, plotRect, false);
114
+ const minorTickCoords = scale.kind === "value" ? scale.minorTicks.map((v) => scale.valueToScreen(v, plotRect)) : categoryGridCoordinates(scale, plotRect, true);
115
+ parts.push(renderTickMarks({
116
+ coords: majorTickCoords,
117
+ direction: axis.direction,
118
+ crossCoord,
119
+ mark: axis.spec.majorTickMark,
120
+ length: 4,
121
+ outDir,
122
+ stroke: tickStroke
123
+ }));
124
+ parts.push(renderTickMarks({
125
+ coords: minorTickCoords,
126
+ direction: axis.direction,
127
+ crossCoord,
128
+ mark: axis.spec.minorTickMark,
129
+ length: 2.5,
130
+ outDir,
131
+ stroke: tickStroke
132
+ }));
133
+ const axisTextStyle = mergeChartTextStyle(baseChartTextStyle, axis.spec.style);
134
+ const axisFontPx = resolveChartFontSizePixels(axisTextStyle?.fontSize);
135
+ const labelSide = resolveAxisLabelSide(axis, crossScale);
136
+ const tickProtrusion = axis.spec.majorTickMark === "out" || axis.spec.majorTickMark === "cross" ? 4 : 0;
137
+ const labelGap = 4;
138
+ if (labelSide !== "none") {
139
+ if (axis.direction === "horizontal") {
140
+ const zone = layout.labelZones.get(axis.name);
141
+ const zoneOffset = zone?.offset ?? 0;
142
+ const zoneH = Math.max(axisFontPx * 1.3, (zone?.depth ?? axisFontPx * 1.4) - labelGap - tickProtrusion);
143
+ const labelY = labelSide === "top" ? plotRect.y - labelGap - tickProtrusion - zoneOffset - zoneH : labelSide === "bottom" ? plotRect.y + plotRect.height + labelGap + tickProtrusion + zoneOffset : crossCoord + 4;
144
+ if (scale.kind === "category") {
145
+ const slotW = scale.slotSpan(plotRect);
146
+ for (let i = 0; i < scale.categories.length; i += 1) {
147
+ const labelBox = {
148
+ x: scale.indexToScreen(i, plotRect) - slotW / 2,
149
+ y: labelY,
150
+ width: Math.max(4, slotW),
151
+ height: zoneH
152
+ };
153
+ parts.push(renderChartTextSvg({
154
+ text: scale.categories[i],
155
+ box: labelBox,
156
+ style: axisTextStyle,
157
+ theme,
158
+ slideNumber,
159
+ labelPath: `Chart.axes.${axis.name}.style`,
160
+ align: "center",
161
+ verticalAlign: labelSide === "top" ? "bottom" : "top",
162
+ wrap: true,
163
+ clipBox: labelBox,
164
+ clipAllocator
165
+ }));
166
+ }
167
+ } else {
168
+ const tickSpacing = Math.max(24, plotRect.width / Math.max(1, scale.majorTicks.length - 1));
169
+ for (const val of scale.majorTicks) {
170
+ const cx = scale.valueToScreen(val, plotRect);
171
+ const text = formatChartNumber(val, scale.numberFormat);
172
+ const labelBox = {
173
+ x: cx - tickSpacing / 2,
174
+ y: labelY,
175
+ width: tickSpacing,
176
+ height: zoneH
177
+ };
178
+ parts.push(renderChartTextSvg({
179
+ text,
180
+ box: labelBox,
181
+ style: axisTextStyle,
182
+ theme,
183
+ slideNumber,
184
+ labelPath: `Chart.axes.${axis.name}.style`,
185
+ align: "center",
186
+ verticalAlign: labelSide === "top" ? "bottom" : "top",
187
+ wrap: false,
188
+ clipBox: chartBox,
189
+ clipAllocator
190
+ }));
191
+ }
192
+ }
193
+ } else {
194
+ const titleBox = layout.axisTitleBoxes.get(axis.name);
195
+ const leftBound = titleBox !== void 0 && titleBox.x < plotRect.x ? titleBox.x + titleBox.width + 2 : chartBox.x + 2;
196
+ const rightBound = titleBox !== void 0 && titleBox.x >= plotRect.x + plotRect.width ? titleBox.x - 2 : chartBox.x + chartBox.width - 2;
197
+ const zoneOffset = layout.labelZones.get(axis.name)?.offset ?? 0;
198
+ let boxX;
199
+ let boxW;
200
+ let align;
201
+ if (labelSide === "right") {
202
+ boxX = plotRect.x + plotRect.width + labelGap + tickProtrusion + zoneOffset;
203
+ boxW = Math.max(6, rightBound - boxX);
204
+ align = "left";
205
+ } else if (labelSide === "left") {
206
+ const rightEdge = plotRect.x - labelGap - tickProtrusion - zoneOffset;
207
+ boxX = leftBound;
208
+ boxW = Math.max(6, rightEdge - leftBound);
209
+ align = "right";
210
+ } else {
211
+ const leftRoom = crossCoord - plotRect.x - 4;
212
+ if (leftRoom >= 16) {
213
+ boxW = Math.min(56, leftRoom);
214
+ boxX = crossCoord - 4 - boxW;
215
+ align = "right";
216
+ } else {
217
+ boxX = crossCoord + 4;
218
+ boxW = Math.max(6, Math.min(56, plotRect.x + plotRect.width - boxX));
219
+ align = "left";
220
+ }
221
+ }
222
+ if (scale.kind === "value") {
223
+ const labelH = Math.max(axisFontPx * 1.4, 12);
224
+ for (const val of scale.majorTicks) {
225
+ const cy = scale.valueToScreen(val, plotRect);
226
+ const text = formatChartNumber(val, scale.numberFormat);
227
+ const labelBox = {
228
+ x: boxX,
229
+ y: cy - labelH / 2,
230
+ width: boxW,
231
+ height: labelH
232
+ };
233
+ parts.push(renderChartTextSvg({
234
+ text,
235
+ box: labelBox,
236
+ style: axisTextStyle,
237
+ theme,
238
+ slideNumber,
239
+ labelPath: `Chart.axes.${axis.name}.style`,
240
+ align,
241
+ verticalAlign: "middle",
242
+ wrap: false,
243
+ clipBox: labelBox,
244
+ clipAllocator
245
+ }));
246
+ }
247
+ } else {
248
+ const slotH = scale.slotSpan(plotRect);
249
+ const labelH = Math.max(slotH, axisFontPx * 1.2);
250
+ for (let i = 0; i < scale.categories.length; i += 1) {
251
+ const cy = scale.indexToScreen(i, plotRect);
252
+ const labelBox = {
253
+ x: boxX,
254
+ y: cy - labelH / 2,
255
+ width: boxW,
256
+ height: labelH
257
+ };
258
+ parts.push(renderChartTextSvg({
259
+ text: scale.categories[i],
260
+ box: labelBox,
261
+ style: axisTextStyle,
262
+ theme,
263
+ slideNumber,
264
+ labelPath: `Chart.axes.${axis.name}.style`,
265
+ align,
266
+ verticalAlign: "middle",
267
+ wrap: slotH >= axisFontPx * 2.2,
268
+ clipBox: labelBox,
269
+ clipAllocator
270
+ }));
271
+ }
272
+ }
273
+ }
274
+ }
275
+ const title = axisTitleParts(axis);
276
+ const titleBox = layout.axisTitleBoxes.get(axis.name);
277
+ if (title !== void 0 && titleBox !== void 0) {
278
+ const titleStyle = mergeChartTextStyle(axisTextStyle, title.style);
279
+ const rotationDegrees = axis.direction === "vertical" ? titleBox.x < plotRect.x ? -90 : 90 : void 0;
280
+ parts.push(renderChartTextSvg({
281
+ text: title.text,
282
+ box: titleBox,
283
+ style: titleStyle,
284
+ theme,
285
+ slideNumber,
286
+ labelPath: `Chart.axes.${axis.name}.title`,
287
+ align: "center",
288
+ verticalAlign: "middle",
289
+ wrap: true,
290
+ clipBox: titleBox,
291
+ clipAllocator,
292
+ ...rotationDegrees === void 0 ? {} : { rotationDegrees }
293
+ }));
294
+ }
295
+ }
296
+ return parts.join("");
297
+ }
298
+ 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 };