@officedk/pptxdk 0.2.0 → 0.2.1
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/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { measureParagraphMinContentWidth } from "../../shared/text-service.js";
|
|
2
|
+
import { chartDataLabelFieldOrder, mergeDataLabels } from "../chart-labels.js";
|
|
3
|
+
import { formatChartNumber } from "../chart-number-format.js";
|
|
4
|
+
import { resolveChartLineStroke, strokeAttrs } from "./style.js";
|
|
5
|
+
import { measureChartText, mergeChartTextStyle, reflowChartText, renderChartTextSvg, resolveChartFontSizePixels } from "./text-render.js";
|
|
6
|
+
// ../core/dist/capabilities/chart/preview/data-labels.js
|
|
7
|
+
const barLabelPositions = {
|
|
8
|
+
center: "center",
|
|
9
|
+
insideEnd: "insideEnd",
|
|
10
|
+
insideBase: "insideBase",
|
|
11
|
+
outsideEnd: "outsideEnd",
|
|
12
|
+
bestFit: "outsideEnd",
|
|
13
|
+
left: "outsideEnd",
|
|
14
|
+
right: "outsideEnd",
|
|
15
|
+
bottom: "outsideEnd",
|
|
16
|
+
top: "outsideEnd"
|
|
17
|
+
};
|
|
18
|
+
function barLabelBox(anchor, requestedPosition, textWidth, textHeight) {
|
|
19
|
+
const position = barLabelPositions[requestedPosition];
|
|
20
|
+
const pad = 3;
|
|
21
|
+
const labelH = Math.max(textHeight, 10);
|
|
22
|
+
if (!anchor.horizontal) {
|
|
23
|
+
const colW = Math.max(anchor.width, textWidth + 2);
|
|
24
|
+
const colX = anchor.x + (anchor.width - colW) / 2;
|
|
25
|
+
const endIsTop = anchor.valueEndSide === "top";
|
|
26
|
+
switch (position) {
|
|
27
|
+
case "center": return {
|
|
28
|
+
box: {
|
|
29
|
+
x: colX,
|
|
30
|
+
y: anchor.y,
|
|
31
|
+
width: colW,
|
|
32
|
+
height: Math.max(anchor.height, labelH)
|
|
33
|
+
},
|
|
34
|
+
align: "center",
|
|
35
|
+
verticalAlign: "middle"
|
|
36
|
+
};
|
|
37
|
+
case "insideEnd": return {
|
|
38
|
+
box: {
|
|
39
|
+
x: colX,
|
|
40
|
+
y: endIsTop ? anchor.y + pad : anchor.y + anchor.height - labelH - pad,
|
|
41
|
+
width: colW,
|
|
42
|
+
height: labelH
|
|
43
|
+
},
|
|
44
|
+
align: "center",
|
|
45
|
+
verticalAlign: endIsTop ? "top" : "bottom"
|
|
46
|
+
};
|
|
47
|
+
case "insideBase": return {
|
|
48
|
+
box: {
|
|
49
|
+
x: colX,
|
|
50
|
+
y: endIsTop ? anchor.y + anchor.height - labelH - pad : anchor.y + pad,
|
|
51
|
+
width: colW,
|
|
52
|
+
height: labelH
|
|
53
|
+
},
|
|
54
|
+
align: "center",
|
|
55
|
+
verticalAlign: endIsTop ? "bottom" : "top"
|
|
56
|
+
};
|
|
57
|
+
case "outsideEnd": return {
|
|
58
|
+
box: {
|
|
59
|
+
x: colX,
|
|
60
|
+
y: endIsTop ? anchor.y - labelH - pad : anchor.y + anchor.height + pad,
|
|
61
|
+
width: colW,
|
|
62
|
+
height: labelH
|
|
63
|
+
},
|
|
64
|
+
align: "center",
|
|
65
|
+
verticalAlign: endIsTop ? "bottom" : "top"
|
|
66
|
+
};
|
|
67
|
+
default: throw new Error(`Unsupported column label position: ${String(position)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const barW = Math.max(textWidth + 6, 12);
|
|
71
|
+
const barY = anchor.y + (anchor.height - labelH) / 2;
|
|
72
|
+
const endIsRight = anchor.valueEndSide === "right";
|
|
73
|
+
switch (position) {
|
|
74
|
+
case "center": return {
|
|
75
|
+
box: {
|
|
76
|
+
x: anchor.x,
|
|
77
|
+
y: barY,
|
|
78
|
+
width: Math.max(anchor.width, barW),
|
|
79
|
+
height: labelH
|
|
80
|
+
},
|
|
81
|
+
align: "center",
|
|
82
|
+
verticalAlign: "middle"
|
|
83
|
+
};
|
|
84
|
+
case "insideEnd": return {
|
|
85
|
+
box: {
|
|
86
|
+
x: endIsRight ? anchor.x + anchor.width - barW - pad : anchor.x + pad,
|
|
87
|
+
y: barY,
|
|
88
|
+
width: barW,
|
|
89
|
+
height: labelH
|
|
90
|
+
},
|
|
91
|
+
align: endIsRight ? "right" : "left",
|
|
92
|
+
verticalAlign: "middle"
|
|
93
|
+
};
|
|
94
|
+
case "insideBase": return {
|
|
95
|
+
box: {
|
|
96
|
+
x: endIsRight ? anchor.x + pad : anchor.x + anchor.width - barW - pad,
|
|
97
|
+
y: barY,
|
|
98
|
+
width: barW,
|
|
99
|
+
height: labelH
|
|
100
|
+
},
|
|
101
|
+
align: endIsRight ? "left" : "right",
|
|
102
|
+
verticalAlign: "middle"
|
|
103
|
+
};
|
|
104
|
+
case "outsideEnd": return {
|
|
105
|
+
box: {
|
|
106
|
+
x: endIsRight ? anchor.x + anchor.width + pad : anchor.x - barW - pad,
|
|
107
|
+
y: barY,
|
|
108
|
+
width: barW,
|
|
109
|
+
height: labelH
|
|
110
|
+
},
|
|
111
|
+
align: endIsRight ? "left" : "right",
|
|
112
|
+
verticalAlign: "middle"
|
|
113
|
+
};
|
|
114
|
+
default: throw new Error(`Unsupported bar label position: ${String(position)}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function pointLabelBox(anchor, position, textWidth, textHeight) {
|
|
118
|
+
const offset = (anchor.markerRadius ?? 1.5) + 4;
|
|
119
|
+
const w = Math.max(textWidth + 4, 12);
|
|
120
|
+
const h = Math.max(textHeight, 10);
|
|
121
|
+
switch (position) {
|
|
122
|
+
case "center": return {
|
|
123
|
+
box: {
|
|
124
|
+
x: anchor.x - w / 2,
|
|
125
|
+
y: anchor.y - h / 2,
|
|
126
|
+
width: w,
|
|
127
|
+
height: h
|
|
128
|
+
},
|
|
129
|
+
align: "center",
|
|
130
|
+
verticalAlign: "middle"
|
|
131
|
+
};
|
|
132
|
+
case "bottom": return {
|
|
133
|
+
box: {
|
|
134
|
+
x: anchor.x - w / 2,
|
|
135
|
+
y: anchor.y + offset,
|
|
136
|
+
width: w,
|
|
137
|
+
height: h
|
|
138
|
+
},
|
|
139
|
+
align: "center",
|
|
140
|
+
verticalAlign: "top"
|
|
141
|
+
};
|
|
142
|
+
case "left": return {
|
|
143
|
+
box: {
|
|
144
|
+
x: anchor.x - offset - w,
|
|
145
|
+
y: anchor.y - h / 2,
|
|
146
|
+
width: w,
|
|
147
|
+
height: h
|
|
148
|
+
},
|
|
149
|
+
align: "right",
|
|
150
|
+
verticalAlign: "middle"
|
|
151
|
+
};
|
|
152
|
+
case "right": return {
|
|
153
|
+
box: {
|
|
154
|
+
x: anchor.x + offset,
|
|
155
|
+
y: anchor.y - h / 2,
|
|
156
|
+
width: w,
|
|
157
|
+
height: h
|
|
158
|
+
},
|
|
159
|
+
align: "left",
|
|
160
|
+
verticalAlign: "middle"
|
|
161
|
+
};
|
|
162
|
+
case "insideEnd":
|
|
163
|
+
case "insideBase":
|
|
164
|
+
case "outsideEnd":
|
|
165
|
+
case "bestFit":
|
|
166
|
+
case "top": return {
|
|
167
|
+
box: {
|
|
168
|
+
x: anchor.x - w / 2,
|
|
169
|
+
y: anchor.y - offset - h,
|
|
170
|
+
width: w,
|
|
171
|
+
height: h
|
|
172
|
+
},
|
|
173
|
+
align: "center",
|
|
174
|
+
verticalAlign: "bottom"
|
|
175
|
+
};
|
|
176
|
+
default: throw new Error(`Unsupported point label position: ${String(position)}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function sliceLabelCenterRadius(anchor) {
|
|
180
|
+
return (anchor.innerR + anchor.outerR) * .56;
|
|
181
|
+
}
|
|
182
|
+
function sliceLabelWidthAtHeight(anchor, radius, height, verticalOffset) {
|
|
183
|
+
const cosMid = Math.cos(anchor.midAngleRad);
|
|
184
|
+
const sinMid = Math.sin(anchor.midAngleRad);
|
|
185
|
+
const centerX = radius * cosMid;
|
|
186
|
+
const centerY = radius * sinMid + verticalOffset;
|
|
187
|
+
const farY = Math.abs(centerY) + height / 2;
|
|
188
|
+
const squaredRoom = anchor.outerR ** 2 - farY ** 2;
|
|
189
|
+
if (squaredRoom <= 0) return 0;
|
|
190
|
+
let halfWidth = Math.sqrt(squaredRoom) - Math.abs(centerX);
|
|
191
|
+
if (anchor.spanDeg < 359.999) {
|
|
192
|
+
const halfSpan = Math.min(anchor.spanDeg, 180) * Math.PI / 360;
|
|
193
|
+
const sinHalf = Math.sin(halfSpan);
|
|
194
|
+
const cosHalf = Math.cos(halfSpan);
|
|
195
|
+
for (const side of [-1, 1]) {
|
|
196
|
+
const normalX = sinHalf * cosMid - side * cosHalf * sinMid;
|
|
197
|
+
const normalY = sinHalf * sinMid + side * cosHalf * cosMid;
|
|
198
|
+
const clearance = centerX * normalX + centerY * normalY - Math.abs(normalY) * height / 2;
|
|
199
|
+
if (clearance < 0) return 0;
|
|
200
|
+
if (Math.abs(normalX) > 1e-6) halfWidth = Math.min(halfWidth, clearance / Math.abs(normalX));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return Math.max(0, 2 * halfWidth);
|
|
204
|
+
}
|
|
205
|
+
function fitSliceLabel(anchor, natural, radius, fontSize, verticalOffset, minContentWidth) {
|
|
206
|
+
let measured = natural;
|
|
207
|
+
while (true) {
|
|
208
|
+
let top = verticalOffset - measured.height / 2;
|
|
209
|
+
let availableWidth = Number.POSITIVE_INFINITY;
|
|
210
|
+
let fits = true;
|
|
211
|
+
for (const paragraph of measured.layout.paragraphs) {
|
|
212
|
+
for (const line of paragraph.lines) {
|
|
213
|
+
const room = sliceLabelWidthAtHeight(anchor, radius, Math.min(fontSize, paragraph.lineHeight), top + paragraph.lineHeight / 2);
|
|
214
|
+
if (line.width > room + .01) fits = false;
|
|
215
|
+
availableWidth = Math.min(availableWidth, room);
|
|
216
|
+
top += paragraph.lineHeight;
|
|
217
|
+
}
|
|
218
|
+
top += paragraph.spacingAfter;
|
|
219
|
+
}
|
|
220
|
+
if (fits) return measured;
|
|
221
|
+
if (availableWidth + .01 < minContentWidth) return void 0;
|
|
222
|
+
const wrapped = reflowChartText(measured, availableWidth);
|
|
223
|
+
if (wrapped.height <= measured.height) return void 0;
|
|
224
|
+
measured = wrapped;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function sliceLabelBox(options) {
|
|
228
|
+
const { anchor, isDoughnut, requestedPosition, centerRadius, centerVerticalOffset, hasLeaderLines, textWidth, textHeight, leaderSpec, theme } = options;
|
|
229
|
+
const w = Math.max(textWidth + 4, 12);
|
|
230
|
+
const h = Math.max(textHeight, 10);
|
|
231
|
+
if (isDoughnut) {
|
|
232
|
+
const r = (anchor.innerR + anchor.outerR) / 2;
|
|
233
|
+
const lx = anchor.cx + r * Math.cos(anchor.midAngleRad);
|
|
234
|
+
const ly = anchor.cy + r * Math.sin(anchor.midAngleRad);
|
|
235
|
+
return {
|
|
236
|
+
placement: {
|
|
237
|
+
box: {
|
|
238
|
+
x: lx - w / 2,
|
|
239
|
+
y: ly - h / 2,
|
|
240
|
+
width: w,
|
|
241
|
+
height: h
|
|
242
|
+
},
|
|
243
|
+
align: "center",
|
|
244
|
+
verticalAlign: "middle"
|
|
245
|
+
},
|
|
246
|
+
leaderSvg: ""
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
switch (requestedPosition) {
|
|
250
|
+
case "center": {
|
|
251
|
+
const lx = anchor.cx + centerRadius * Math.cos(anchor.midAngleRad);
|
|
252
|
+
const ly = anchor.cy + centerRadius * Math.sin(anchor.midAngleRad) + centerVerticalOffset;
|
|
253
|
+
return {
|
|
254
|
+
placement: {
|
|
255
|
+
box: {
|
|
256
|
+
x: lx - w / 2,
|
|
257
|
+
y: ly - h / 2,
|
|
258
|
+
width: w,
|
|
259
|
+
height: h
|
|
260
|
+
},
|
|
261
|
+
align: "center",
|
|
262
|
+
verticalAlign: "middle"
|
|
263
|
+
},
|
|
264
|
+
leaderSvg: ""
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
case "insideEnd": {
|
|
268
|
+
const r = Math.max(anchor.innerR + 2, anchor.outerR - Math.max(10, (anchor.outerR - anchor.innerR) * .25));
|
|
269
|
+
const lx = anchor.cx + r * Math.cos(anchor.midAngleRad);
|
|
270
|
+
const ly = anchor.cy + r * Math.sin(anchor.midAngleRad);
|
|
271
|
+
return {
|
|
272
|
+
placement: {
|
|
273
|
+
box: {
|
|
274
|
+
x: lx - w / 2,
|
|
275
|
+
y: ly - h / 2,
|
|
276
|
+
width: w,
|
|
277
|
+
height: h
|
|
278
|
+
},
|
|
279
|
+
align: "center",
|
|
280
|
+
verticalAlign: "middle"
|
|
281
|
+
},
|
|
282
|
+
leaderSvg: ""
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
case "insideBase":
|
|
286
|
+
case "outsideEnd":
|
|
287
|
+
case "left":
|
|
288
|
+
case "right":
|
|
289
|
+
case "top":
|
|
290
|
+
case "bottom":
|
|
291
|
+
case "bestFit": break;
|
|
292
|
+
default: throw new Error(`Unsupported slice label position: ${String(requestedPosition)}`);
|
|
293
|
+
}
|
|
294
|
+
const cosM = Math.cos(anchor.midAngleRad);
|
|
295
|
+
const sinM = Math.sin(anchor.midAngleRad);
|
|
296
|
+
const ax = anchor.cx + anchor.outerR * cosM;
|
|
297
|
+
const ay = anchor.cy + anchor.outerR * sinM;
|
|
298
|
+
const elbowR = anchor.outerR + 10;
|
|
299
|
+
const ex = anchor.cx + elbowR * cosM;
|
|
300
|
+
const ey = anchor.cy + elbowR * sinM;
|
|
301
|
+
const isRight = cosM >= 0;
|
|
302
|
+
const armLen = 8;
|
|
303
|
+
const lx = isRight ? ex + armLen : ex - armLen;
|
|
304
|
+
const ly = ey;
|
|
305
|
+
let leaderSvg = "";
|
|
306
|
+
if (hasLeaderLines && leaderSpec !== void 0 && leaderSpec !== false) {
|
|
307
|
+
const leaderStroke = resolveChartLineStroke(leaderSpec, theme, {
|
|
308
|
+
color: "dk2",
|
|
309
|
+
width: 1
|
|
310
|
+
});
|
|
311
|
+
if (leaderStroke !== void 0) leaderSvg = `<polyline points="${ax},${ay} ${ex},${ey} ${lx},${ly}" fill="none" ${strokeAttrs(leaderStroke)}/>`;
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
placement: {
|
|
315
|
+
box: isRight ? {
|
|
316
|
+
x: lx + 2,
|
|
317
|
+
y: ly - h / 2,
|
|
318
|
+
width: w,
|
|
319
|
+
height: h
|
|
320
|
+
} : {
|
|
321
|
+
x: lx - 2 - w,
|
|
322
|
+
y: ly - h / 2,
|
|
323
|
+
width: w,
|
|
324
|
+
height: h
|
|
325
|
+
},
|
|
326
|
+
align: isRight ? "left" : "right",
|
|
327
|
+
verticalAlign: "middle"
|
|
328
|
+
},
|
|
329
|
+
leaderSvg,
|
|
330
|
+
outside: true
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function getDataLabelText(pointMerged, kind, anchor) {
|
|
334
|
+
if (pointMerged.text !== void 0) return pointMerged.text;
|
|
335
|
+
const fields = {
|
|
336
|
+
seriesName: anchor.seriesName,
|
|
337
|
+
category: kind === "scatter" ? void 0 : anchor.category,
|
|
338
|
+
xValue: kind === "scatter" && anchor.kind === "point" ? anchor.xValue : void 0,
|
|
339
|
+
value: anchor.value,
|
|
340
|
+
percent: anchor.percent
|
|
341
|
+
};
|
|
342
|
+
const labelSegments = chartDataLabelFieldOrder.flatMap((field) => {
|
|
343
|
+
const value = fields[field];
|
|
344
|
+
if (pointMerged[field] !== true || value === void 0) return [];
|
|
345
|
+
const code = pointMerged.numberFormat ?? (field === "percent" ? "0%" : void 0);
|
|
346
|
+
return [typeof value === "number" ? formatChartNumber(value, code) : value];
|
|
347
|
+
});
|
|
348
|
+
return labelSegments.length === 0 ? void 0 : labelSegments.join(pointMerged.separator ?? ", ");
|
|
349
|
+
}
|
|
350
|
+
function layoutSliceDataLabels(group, anchors, context) {
|
|
351
|
+
const { baseChartTextStyle, theme, slideNumber } = context;
|
|
352
|
+
const labels = [];
|
|
353
|
+
for (const anchor of anchors) {
|
|
354
|
+
const series = group.series[anchor.groupSeriesIndex];
|
|
355
|
+
const seriesMerged = mergeDataLabels(group.dataLabels, series.dataLabels);
|
|
356
|
+
const pointMerged = mergeDataLabels(seriesMerged, series.points?.[anchor.pointIndex]?.dataLabels);
|
|
357
|
+
if (pointMerged === void 0 || pointMerged === false) continue;
|
|
358
|
+
const text = getDataLabelText(pointMerged, group.kind, anchor);
|
|
359
|
+
if (text === void 0 || text.trim() === "") continue;
|
|
360
|
+
const style = mergeChartTextStyle(baseChartTextStyle, pointMerged.style);
|
|
361
|
+
const natural = measureChartText({
|
|
362
|
+
text,
|
|
363
|
+
style,
|
|
364
|
+
theme,
|
|
365
|
+
slideNumber,
|
|
366
|
+
labelPath: `Chart.groups[${anchor.groupIndex}].dataLabels`
|
|
367
|
+
});
|
|
368
|
+
const leaderSpec = seriesMerged !== void 0 && seriesMerged !== false ? seriesMerged.leaderLines : pointMerged.leaderLines;
|
|
369
|
+
const hasLeaderLines = leaderSpec !== void 0 && leaderSpec !== false;
|
|
370
|
+
const position = pointMerged.position ?? (hasLeaderLines ? "outsideEnd" : "bestFit");
|
|
371
|
+
const fontSize = resolveChartFontSizePixels(natural.resolvedStyle.fontSize);
|
|
372
|
+
const minimumHeight = fontSize * 1.15;
|
|
373
|
+
let measured = natural;
|
|
374
|
+
let centerRadius = sliceLabelCenterRadius(anchor);
|
|
375
|
+
let centerVerticalOffset = 0;
|
|
376
|
+
let resolvedPosition = position;
|
|
377
|
+
if (group.kind === "pie" && position === "bestFit") {
|
|
378
|
+
const minContentWidth = Math.max(0, ...natural.paragraphs.map(measureParagraphMinContentWidth));
|
|
379
|
+
const inwardOffset = -Math.sign(Math.sin(anchor.midAngleRad)) * fontSize / 3;
|
|
380
|
+
for (const [radius, offset] of [
|
|
381
|
+
[centerRadius, 0],
|
|
382
|
+
[anchor.outerR * .65, 0],
|
|
383
|
+
[anchor.outerR * .65, inwardOffset],
|
|
384
|
+
[anchor.outerR * .72, 0],
|
|
385
|
+
[anchor.outerR * .72, inwardOffset]
|
|
386
|
+
]) {
|
|
387
|
+
const fitted = fitSliceLabel(anchor, natural, radius, fontSize, offset, minContentWidth);
|
|
388
|
+
if (fitted === void 0) continue;
|
|
389
|
+
measured = fitted;
|
|
390
|
+
centerRadius = radius;
|
|
391
|
+
centerVerticalOffset = offset;
|
|
392
|
+
resolvedPosition = "center";
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const label = sliceLabelBox({
|
|
397
|
+
anchor,
|
|
398
|
+
isDoughnut: group.kind === "doughnut",
|
|
399
|
+
requestedPosition: resolvedPosition,
|
|
400
|
+
centerRadius,
|
|
401
|
+
centerVerticalOffset,
|
|
402
|
+
hasLeaderLines,
|
|
403
|
+
textWidth: measured.width,
|
|
404
|
+
textHeight: Math.max(measured.height, minimumHeight),
|
|
405
|
+
leaderSpec,
|
|
406
|
+
theme
|
|
407
|
+
});
|
|
408
|
+
labels.push({
|
|
409
|
+
text,
|
|
410
|
+
style,
|
|
411
|
+
measured,
|
|
412
|
+
groupIndex: anchor.groupIndex,
|
|
413
|
+
...label
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
return labels;
|
|
417
|
+
}
|
|
418
|
+
function renderDataLabelsSvg(options) {
|
|
419
|
+
const { parsed, anchors, sliceLabels, chartBox, baseChartTextStyle, theme, slideNumber, clipAllocator } = options;
|
|
420
|
+
const labels = [...sliceLabels];
|
|
421
|
+
for (const anchor of anchors) {
|
|
422
|
+
if (anchor.kind === "slice") continue;
|
|
423
|
+
const group = parsed.groups[anchor.groupIndex];
|
|
424
|
+
if (group === void 0) continue;
|
|
425
|
+
let series;
|
|
426
|
+
if (anchor.kind === "bar") {
|
|
427
|
+
if (group.kind !== "column" && group.kind !== "bar") continue;
|
|
428
|
+
series = group.series[anchor.groupSeriesIndex];
|
|
429
|
+
} else {
|
|
430
|
+
if (group.kind !== "line" && group.kind !== "area" && group.kind !== "scatter") continue;
|
|
431
|
+
series = group.series[anchor.groupSeriesIndex];
|
|
432
|
+
}
|
|
433
|
+
if (series === void 0) continue;
|
|
434
|
+
const seriesMerged = mergeDataLabels(group.dataLabels, series.dataLabels);
|
|
435
|
+
const pointMerged = mergeDataLabels(seriesMerged, series.points?.[anchor.pointIndex]?.dataLabels);
|
|
436
|
+
if (pointMerged === void 0 || pointMerged === false) continue;
|
|
437
|
+
const text = getDataLabelText(pointMerged, group.kind, anchor);
|
|
438
|
+
if (text === void 0) continue;
|
|
439
|
+
const style = mergeChartTextStyle(baseChartTextStyle, pointMerged.style);
|
|
440
|
+
const measured = measureChartText({
|
|
441
|
+
text,
|
|
442
|
+
style,
|
|
443
|
+
theme,
|
|
444
|
+
slideNumber,
|
|
445
|
+
labelPath: `Chart.groups[${anchor.groupIndex}].dataLabels`
|
|
446
|
+
});
|
|
447
|
+
const fontPx = resolveChartFontSizePixels(style?.fontSize);
|
|
448
|
+
const textH = Math.max(measured.height, fontPx * 1.15);
|
|
449
|
+
let placement;
|
|
450
|
+
if (anchor.kind === "bar") placement = barLabelBox(anchor, pointMerged.position ?? (group.kind === "column" || group.kind === "bar" ? group.stacking === "clustered" ? "outsideEnd" : "center" : "center"), measured.width, textH);
|
|
451
|
+
else placement = pointLabelBox(anchor, pointMerged.position ?? (group.kind === "scatter" ? "right" : group.kind === "area" ? "center" : "top"), measured.width, textH);
|
|
452
|
+
labels.push({
|
|
453
|
+
text,
|
|
454
|
+
style,
|
|
455
|
+
measured,
|
|
456
|
+
groupIndex: anchor.groupIndex,
|
|
457
|
+
placement
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return labels.map(({ text, style, measured, placement, groupIndex, leaderSvg = "" }) => leaderSvg + renderChartTextSvg({
|
|
461
|
+
text,
|
|
462
|
+
box: placement.box,
|
|
463
|
+
style,
|
|
464
|
+
measured,
|
|
465
|
+
theme,
|
|
466
|
+
slideNumber,
|
|
467
|
+
labelPath: `Chart.groups[${groupIndex}].dataLabels`,
|
|
468
|
+
align: placement.align,
|
|
469
|
+
verticalAlign: placement.verticalAlign,
|
|
470
|
+
clipBox: chartBox,
|
|
471
|
+
clipAllocator
|
|
472
|
+
})).join("");
|
|
473
|
+
}
|
|
474
|
+
export { layoutSliceDataLabels, renderDataLabelsSvg };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveChartLineStroke, strokeAttrs } from "./style.js";
|
|
2
|
-
// ../
|
|
2
|
+
// ../core/dist/capabilities/chart/preview/error-bars.js
|
|
3
3
|
/**
|
|
4
4
|
* Computes per-slot error bar bounds in data space for any of the 5 OOXML error bar types.
|
|
5
5
|
*/
|
|
@@ -56,6 +56,8 @@ function computeErrorBarBounds(bars, values, options) {
|
|
|
56
56
|
case "custom":
|
|
57
57
|
plusMag = bars.plus?.[i] !== null && bars.plus?.[i] !== void 0 ? bars.plus[i] : void 0;
|
|
58
58
|
minusMag = bars.minus?.[i] !== null && bars.minus?.[i] !== void 0 ? bars.minus[i] : void 0;
|
|
59
|
+
break;
|
|
60
|
+
default: throw new Error(`Unsupported chart error bar type: ${String(bars)}`);
|
|
59
61
|
}
|
|
60
62
|
const hasPlus = (include === "both" || include === "plus") && plusMag !== void 0 && Number.isFinite(plusMag);
|
|
61
63
|
const hasMinus = (include === "both" || include === "minus") && minusMag !== void 0 && Number.isFinite(minusMag);
|
|
@@ -2,19 +2,19 @@ import { parseTextContent } from "../../shared/text-service.js";
|
|
|
2
2
|
import { textOnlyChartStyle } from "../chart-model.js";
|
|
3
3
|
import { renderAxesSvg, renderGridlinesSvg } from "./axes-and-grid.js";
|
|
4
4
|
import { renderColumnOrBarGroup } from "./bar-column.js";
|
|
5
|
-
import { renderDataLabelsSvg } from "./data-labels.js";
|
|
5
|
+
import { layoutSliceDataLabels, renderDataLabelsSvg } from "./data-labels.js";
|
|
6
6
|
import { renderErrorBarsSvg } from "./error-bars.js";
|
|
7
7
|
import { computeChartLayout } from "./layout.js";
|
|
8
8
|
import { renderLegendSvg } from "./legend.js";
|
|
9
9
|
import { renderLineOrAreaGroup } from "./line-area.js";
|
|
10
|
-
import { renderPieOrDoughnutGroup } from "./pie-doughnut.js";
|
|
10
|
+
import { layoutPieOrDoughnutGroup, renderPieOrDoughnutGroup } from "./pie-doughnut.js";
|
|
11
11
|
import { buildAxisScales } from "./scales.js";
|
|
12
12
|
import { renderScatterGroup } from "./scatter.js";
|
|
13
13
|
import { resolveChartLineStroke, strokeAttrs } from "./style.js";
|
|
14
14
|
import { createChartClipAllocator, mergeChartTextStyle, renderChartTextSvg, resolveChartFontSizePixels } from "./text-render.js";
|
|
15
15
|
import { renderTrendlinesSvg } from "./trendlines.js";
|
|
16
16
|
import { assertNever } from "./types.js";
|
|
17
|
-
// ../
|
|
17
|
+
// ../core/dist/capabilities/chart/preview/index.js
|
|
18
18
|
/**
|
|
19
19
|
* Renders a static SVG preview for a resolved chart without mutating or leaking into native emit.
|
|
20
20
|
*/
|
|
@@ -47,6 +47,12 @@ function drawChartPreview(parsed, box, context) {
|
|
|
47
47
|
}));
|
|
48
48
|
const anchors = [];
|
|
49
49
|
const plotParts = [];
|
|
50
|
+
const sliceLabels = [];
|
|
51
|
+
const labelContext = {
|
|
52
|
+
baseChartTextStyle,
|
|
53
|
+
theme: context.theme,
|
|
54
|
+
slideNumber: context.slideNumber
|
|
55
|
+
};
|
|
50
56
|
for (let groupIndex = 0; groupIndex < parsed.groups.length; groupIndex += 1) {
|
|
51
57
|
const group = parsed.groups[groupIndex];
|
|
52
58
|
switch (group.kind) {
|
|
@@ -92,14 +98,26 @@ function drawChartPreview(parsed, box, context) {
|
|
|
92
98
|
}
|
|
93
99
|
case "pie":
|
|
94
100
|
case "doughnut": {
|
|
95
|
-
const
|
|
101
|
+
const plotOptions = {
|
|
96
102
|
group,
|
|
97
103
|
groupIndex,
|
|
98
|
-
plotRect: layout.plotRect
|
|
99
|
-
|
|
104
|
+
plotRect: layout.plotRect
|
|
105
|
+
};
|
|
106
|
+
let slices = layoutPieOrDoughnutGroup({
|
|
107
|
+
...plotOptions,
|
|
108
|
+
radiusScale: parsed.plotArea === void 0 ? .88 : 1
|
|
100
109
|
});
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
let labels = layoutSliceDataLabels(group, slices, labelContext);
|
|
111
|
+
if (parsed.plotArea === void 0 && labels.some((label) => label.outside)) {
|
|
112
|
+
slices = layoutPieOrDoughnutGroup({
|
|
113
|
+
...plotOptions,
|
|
114
|
+
radiusScale: .68
|
|
115
|
+
});
|
|
116
|
+
labels = layoutSliceDataLabels(group, slices, labelContext);
|
|
117
|
+
}
|
|
118
|
+
sliceLabels.push(...labels);
|
|
119
|
+
if (slices.length > 0) plotParts.push(renderPieOrDoughnutGroup(group, slices, context.theme));
|
|
120
|
+
anchors.push(...slices);
|
|
103
121
|
break;
|
|
104
122
|
}
|
|
105
123
|
default: assertNever(group);
|
|
@@ -155,6 +173,7 @@ function drawChartPreview(parsed, box, context) {
|
|
|
155
173
|
bodyParts.push(renderDataLabelsSvg({
|
|
156
174
|
parsed,
|
|
157
175
|
anchors,
|
|
176
|
+
sliceLabels,
|
|
158
177
|
chartBox: box,
|
|
159
178
|
baseChartTextStyle,
|
|
160
179
|
theme: context.theme,
|
|
@@ -182,7 +201,7 @@ function drawChartPreview(parsed, box, context) {
|
|
|
182
201
|
measured: layout.measuredLegend,
|
|
183
202
|
position: parsed.legend,
|
|
184
203
|
legendBox: layout.legendBox,
|
|
185
|
-
style: baseChartTextStyle,
|
|
204
|
+
style: mergeChartTextStyle(baseChartTextStyle, parsed.legendStyle),
|
|
186
205
|
theme: context.theme,
|
|
187
206
|
slideNumber: context.slideNumber,
|
|
188
207
|
clipAllocator
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mergeDataLabels } from "../chart-labels.js";
|
|
1
|
+
import { hasVisibleDataLabels, mergeDataLabels } from "../chart-labels.js";
|
|
2
|
+
import { formatChartNumber } from "../chart-number-format.js";
|
|
2
3
|
import { collectLegendEntries, measureLegend } from "./legend.js";
|
|
3
|
-
import { formatChartNumber } from "./number-format.js";
|
|
4
4
|
import { resolveAxisCrossingNormalized } from "./scales.js";
|
|
5
5
|
import { measureChartText, mergeChartTextStyle, resolveChartFontSizePixels } from "./text-render.js";
|
|
6
|
-
// ../
|
|
6
|
+
// ../core/dist/capabilities/chart/preview/layout.js
|
|
7
7
|
function titleTextOf(title) {
|
|
8
8
|
return typeof title === "string" ? { text: title } : title;
|
|
9
9
|
}
|
|
@@ -39,8 +39,7 @@ function hasOutsideEndBarLabels(parsed) {
|
|
|
39
39
|
if (val === null || val === void 0 || !Number.isFinite(val)) continue;
|
|
40
40
|
const ptOverride = series.points?.[i]?.dataLabels;
|
|
41
41
|
const eff = mergeDataLabels(serLabels, ptOverride);
|
|
42
|
-
if (
|
|
43
|
-
if (!eff.value && !eff.category && !eff.percent && !eff.seriesName) continue;
|
|
42
|
+
if (!hasVisibleDataLabels(group.kind, eff)) continue;
|
|
44
43
|
if ((eff.position ?? (group.stacking === "clustered" ? "outsideEnd" : "center")) !== "outsideEnd") continue;
|
|
45
44
|
if (group.kind === "column") {
|
|
46
45
|
if (val < 0) columnNeg = true;
|
|
@@ -71,8 +70,7 @@ function hasPointDataLabels(parsed) {
|
|
|
71
70
|
for (let i = 0; i < count; i += 1) {
|
|
72
71
|
const ptOverride = series.points?.[i]?.dataLabels;
|
|
73
72
|
const eff = mergeDataLabels(serLabels, ptOverride);
|
|
74
|
-
if (
|
|
75
|
-
if (!eff.value && !eff.category && !eff.percent && !eff.xValue && !eff.seriesName) continue;
|
|
73
|
+
if (!hasVisibleDataLabels(group.kind, eff)) continue;
|
|
76
74
|
const pos = eff.position ?? defaultPos;
|
|
77
75
|
if (pos === "top") top = true;
|
|
78
76
|
else if (pos === "bottom") bottom = true;
|
|
@@ -126,7 +124,7 @@ function computeChartLayout(options) {
|
|
|
126
124
|
position: parsed.legend,
|
|
127
125
|
maxWidth: Math.max(20, box.width - 16),
|
|
128
126
|
fontSizePx: baseFontSizePx,
|
|
129
|
-
style: baseChartTextStyle,
|
|
127
|
+
style: mergeChartTextStyle(baseChartTextStyle, parsed.legendStyle),
|
|
130
128
|
theme,
|
|
131
129
|
slideNumber
|
|
132
130
|
});
|
|
@@ -253,7 +251,7 @@ function computeChartLayout(options) {
|
|
|
253
251
|
position: pos,
|
|
254
252
|
maxWidth: avail.width,
|
|
255
253
|
fontSizePx: baseFontSizePx,
|
|
256
|
-
style: baseChartTextStyle,
|
|
254
|
+
style: mergeChartTextStyle(baseChartTextStyle, parsed.legendStyle),
|
|
257
255
|
theme,
|
|
258
256
|
slideNumber
|
|
259
257
|
});
|
|
@@ -2,7 +2,7 @@ import { renderMarkerSvg, resolveEffectiveMarker } from "./markers.js";
|
|
|
2
2
|
import { chartAccentSlot, resolveChartLineStroke, resolveSeriesColor } from "./style.js";
|
|
3
3
|
import { measureChartText, renderChartTextSvg } from "./text-render.js";
|
|
4
4
|
import { assertNever } from "./types.js";
|
|
5
|
-
// ../
|
|
5
|
+
// ../core/dist/capabilities/chart/preview/legend.js
|
|
6
6
|
function toLegendMarker(resolved) {
|
|
7
7
|
if (resolved === void 0) return void 0;
|
|
8
8
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderMarkerSvg, resolveEffectiveMarker } from "./markers.js";
|
|
2
2
|
import { chartAccentSlot, resolveChartLineStroke, resolveSeriesColor, strokeAttrs } from "./style.js";
|
|
3
|
-
// ../
|
|
3
|
+
// ../core/dist/capabilities/chart/preview/line-area.js
|
|
4
4
|
/**
|
|
5
5
|
* Computes Catmull-Rom cubic Bezier control points (tension = 1/6) for segment `pCurr -> pNext`.
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveChartLineStroke, resolveSeriesColor, strokeAttrs } from "./style.js";
|
|
2
2
|
import { assertNever } from "./types.js";
|
|
3
|
-
// ../
|
|
3
|
+
// ../core/dist/capabilities/chart/preview/markers.js
|
|
4
4
|
const DEFAULT_MARKER_SIZE_PT = 5;
|
|
5
5
|
const AUTO_MARKER_SYMBOLS = [
|
|
6
6
|
"diamond",
|