ooxml-core 1.29.0 → 1.30.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/{PptxHandler-CZG6ISCZ.cjs → PptxHandler-DHQPVTUI.cjs} +3 -3
- package/dist/PptxHandler-E4DDV3FQ.mjs +4 -0
- package/dist/{PptxHandler-QIHYALOV.mjs → PptxHandler-KKLAYUGQ.mjs} +2 -2
- package/dist/{PresentationBuilder-66EU3N3O.cjs → PresentationBuilder-JORMF5CP.cjs} +5 -5
- package/dist/{PresentationBuilder-5YM2L7DA.mjs → PresentationBuilder-Q2Z33LLM.mjs} +2 -2
- package/dist/{PresentationBuilder-UAINQZA2.mjs → PresentationBuilder-YYZYCKTZ.mjs} +2 -2
- package/dist/automation/index.cjs +4250 -3145
- package/dist/automation/index.mjs +4250 -3145
- package/dist/chart/box-distribution.d.ts +10 -0
- package/dist/chart/box-distribution.d.ts.map +1 -0
- package/dist/chart/data-table-layout.d.ts +8 -0
- package/dist/chart/data-table-layout.d.ts.map +1 -0
- package/dist/chart/date-axis.d.ts +3 -0
- package/dist/chart/date-axis.d.ts.map +1 -0
- package/dist/chart/date-format.d.ts +39 -0
- package/dist/chart/date-format.d.ts.map +1 -0
- package/dist/chart/edit/chartex-action.d.ts.map +1 -1
- package/dist/chart/edit/chartex-axis.d.ts.map +1 -1
- package/dist/chart/edit/chartex-structure.d.ts.map +1 -1
- package/dist/chart/edit/chartex.d.ts +3 -1
- package/dist/chart/edit/chartex.d.ts.map +1 -1
- package/dist/chart/edit/draft.d.ts.map +1 -1
- package/dist/chart/funnel-geometry.d.ts +15 -0
- package/dist/chart/funnel-geometry.d.ts.map +1 -0
- package/dist/chart/index.cjs +1392 -404
- package/dist/chart/index.d.ts +6 -0
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.mjs +1379 -405
- package/dist/chart/line-path.d.ts +30 -0
- package/dist/chart/line-path.d.ts.map +1 -0
- package/dist/chart/manual-layout.d.ts +15 -0
- package/dist/chart/manual-layout.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-analysis.d.ts +2 -0
- package/dist/chart/render/chart-svg-analysis.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-bars.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-box.d.ts +5 -0
- package/dist/chart/render/chart-svg-box.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-cartesian.d.ts +3 -1
- package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-data-table.d.ts +11 -0
- package/dist/chart/render/chart-svg-data-table.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-date-axis.d.ts +9 -0
- package/dist/chart/render/chart-svg-date-axis.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-funnel.d.ts +4 -0
- package/dist/chart/render/chart-svg-funnel.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-labels.d.ts +16 -16
- package/dist/chart/render/chart-svg-labels.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-line.d.ts +5 -0
- package/dist/chart/render/chart-svg-line.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-plot-layout.d.ts +6 -0
- package/dist/chart/render/chart-svg-plot-layout.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-plots.d.ts +2 -1
- package/dist/chart/render/chart-svg-plots.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-radial.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-slice-labels.d.ts +18 -0
- package/dist/chart/render/chart-svg-slice-labels.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-xy.d.ts +2 -1
- package/dist/chart/render/chart-svg-xy.d.ts.map +1 -1
- package/dist/chart/render/chart-svg.d.ts.map +1 -1
- package/dist/chart/render/chart-title-text.d.ts +3 -1
- package/dist/chart/render/chart-title-text.d.ts.map +1 -1
- package/dist/chart/render/chart-view-analysis.d.ts +2 -1
- package/dist/chart/render/chart-view-analysis.d.ts.map +1 -1
- package/dist/chart/render/chart-view-data-table.d.ts +13 -0
- package/dist/chart/render/chart-view-data-table.d.ts.map +1 -0
- package/dist/chart/render/chart-view-labels.d.ts +6 -1
- package/dist/chart/render/chart-view-labels.d.ts.map +1 -1
- package/dist/chart/render/chart-view-series.d.ts.map +1 -1
- package/dist/chart/render/chart-view.d.ts +13 -0
- package/dist/chart/render/chart-view.d.ts.map +1 -1
- package/dist/chart/render/render-space.d.ts.map +1 -1
- package/dist/chart/render/summary-ex-series.d.ts +5 -0
- package/dist/chart/render/summary-ex-series.d.ts.map +1 -0
- package/dist/chart/render/summary-from-chartex.d.ts.map +1 -1
- package/dist/chart/render/summary-from-space.d.ts +1 -1
- package/dist/chart/render/summary-from-space.d.ts.map +1 -1
- package/dist/chart/render/summary-labels.d.ts.map +1 -1
- package/dist/chart/render/summary.d.ts +14 -1
- package/dist/chart/render/summary.d.ts.map +1 -1
- package/dist/{chunk-6C4NLBLB.mjs → chunk-6FXOAMNL.mjs} +1 -1
- package/dist/{chunk-T7HBA3CW.cjs → chunk-7T3SJQA6.cjs} +11 -9
- package/dist/{chunk-XROY25LN.cjs → chunk-7XYVFUB3.cjs} +4 -0
- package/dist/{chunk-I2CGNAP2.cjs → chunk-B4LXDHBX.cjs} +1409 -1389
- package/dist/{chunk-GUNTIFGT.cjs → chunk-CZXM4ZJH.cjs} +158 -26
- package/dist/{chunk-RYOJHYA3.mjs → chunk-DJ3CDTMX.mjs} +157 -27
- package/dist/{chunk-BBK3UB7M.mjs → chunk-FFJBOR2Y.mjs} +4 -4
- package/dist/{chunk-DWEQWFQU.mjs → chunk-GJDFCP2T.mjs} +248 -228
- package/dist/{chunk-KBER3RAP.mjs → chunk-KWJYMAEF.mjs} +248 -228
- package/dist/{chunk-XCRDAVFN.mjs → chunk-MKDONWNO.mjs} +237 -95
- package/dist/{chunk-3UMDVJRN.mjs → chunk-NBMXEVHL.mjs} +4 -1
- package/dist/{chunk-TVJL7QIG.cjs → chunk-OGEL4Z4S.cjs} +8 -1
- package/dist/{chunk-HRU3KOE5.mjs → chunk-OORQCSVA.mjs} +5 -3
- package/dist/{chunk-7RJYOVQU.mjs → chunk-R7NS42KQ.mjs} +5 -2
- package/dist/{chunk-DXOBT2JE.mjs → chunk-UZWV2HAJ.mjs} +8 -2
- package/dist/{chunk-PDZ4GQLI.mjs → chunk-WZJ25K7P.mjs} +1 -1
- package/dist/{chunk-IETFPVLN.cjs → chunk-XTUX5RMG.cjs} +15 -12
- package/dist/diagram/drawing.d.ts.map +1 -1
- package/dist/diagram/index.cjs +1218 -592
- package/dist/diagram/index.mjs +1218 -592
- package/dist/diagram/load.d.ts.map +1 -1
- package/dist/diagram/relationships.d.ts +1 -0
- package/dist/diagram/relationships.d.ts.map +1 -1
- package/dist/diagram/types.d.ts +2 -0
- package/dist/diagram/types.d.ts.map +1 -1
- package/dist/docx/diagram.d.ts.map +1 -1
- package/dist/docx/drawing.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +1850 -1138
- package/dist/docx/embedded.mjs +1850 -1138
- package/dist/docx/index.cjs +3312 -1713
- package/dist/docx/index.mjs +3312 -1713
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/fonts.d.ts +1 -1
- package/dist/docx/layout/fonts.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +1933 -518
- package/dist/docx/layout/index.mjs +1933 -518
- package/dist/docx/layout/script-fonts.d.ts +6 -0
- package/dist/docx/layout/script-fonts.d.ts.map +1 -0
- package/dist/docx/load/index.cjs +1853 -1141
- package/dist/docx/load/index.mjs +1853 -1141
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/shape-model.d.ts +2 -0
- package/dist/docx/shape-model.d.ts.map +1 -1
- package/dist/docx/shape-parse.d.ts.map +1 -1
- package/dist/docx/shape-svg.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +1763 -593
- package/dist/docx/ui/index.mjs +1763 -593
- package/dist/docx/write-shape.d.ts.map +1 -1
- package/dist/drawingml/custom-geometry.d.ts +5 -0
- package/dist/drawingml/custom-geometry.d.ts.map +1 -0
- package/dist/drawingml/drawing-fill.d.ts.map +1 -1
- package/dist/drawingml/drawing-geometry.d.ts.map +1 -1
- package/dist/drawingml/image-content-type.d.ts +2 -0
- package/dist/drawingml/image-content-type.d.ts.map +1 -0
- package/dist/drawingml/index.cjs +1128 -179
- package/dist/drawingml/index.d.ts +9 -0
- package/dist/drawingml/index.d.ts.map +1 -1
- package/dist/drawingml/index.mjs +1110 -180
- package/dist/drawingml/path-data.d.ts +4 -0
- package/dist/drawingml/path-data.d.ts.map +1 -0
- package/dist/drawingml/picture-crop.d.ts +8 -0
- package/dist/drawingml/picture-crop.d.ts.map +1 -0
- package/dist/drawingml/picture-effects.d.ts +37 -0
- package/dist/drawingml/picture-effects.d.ts.map +1 -0
- package/dist/drawingml/picture-fill.d.ts +7 -0
- package/dist/drawingml/picture-fill.d.ts.map +1 -0
- package/dist/drawingml/read-3d-values.d.ts +8 -0
- package/dist/drawingml/read-3d-values.d.ts.map +1 -0
- package/dist/drawingml/read-text-3d.d.ts +8 -0
- package/dist/drawingml/read-text-3d.d.ts.map +1 -0
- package/dist/drawingml/read-text-body.d.ts.map +1 -1
- package/dist/drawingml/scene3d-coordinate.d.ts +45 -0
- package/dist/drawingml/scene3d-coordinate.d.ts.map +1 -0
- package/dist/drawingml/scene3d-presets.d.ts +12 -0
- package/dist/drawingml/scene3d-presets.d.ts.map +1 -0
- package/dist/drawingml/text-3d-model.d.ts +71 -0
- package/dist/drawingml/text-3d-model.d.ts.map +1 -0
- package/dist/drawingml/text-model.d.ts +3 -0
- package/dist/drawingml/text-model.d.ts.map +1 -1
- package/dist/drawingml/types.d.ts +3 -0
- package/dist/drawingml/types.d.ts.map +1 -1
- package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
- package/dist/drawingml/write-text-3d.d.ts +6 -0
- package/dist/drawingml/write-text-3d.d.ts.map +1 -0
- package/dist/drawingml/write-text-body.d.ts.map +1 -1
- package/dist/geometry/element-transform.d.ts +3 -0
- package/dist/geometry/element-transform.d.ts.map +1 -1
- package/dist/geometry/index.cjs +69 -4
- package/dist/geometry/index.d.ts +2 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +66 -5
- package/dist/geometry/picture-crop.d.ts +21 -0
- package/dist/geometry/picture-crop.d.ts.map +1 -0
- package/dist/geometry/resize-aspect.d.ts +12 -0
- package/dist/geometry/resize-aspect.d.ts.map +1 -0
- package/dist/index.cjs +4201 -2058
- package/dist/index.mjs +4201 -2058
- package/dist/opc/index.cjs +9 -6
- package/dist/opc/index.mjs +9 -6
- package/dist/opc/safe-href.d.ts +10 -3
- package/dist/opc/safe-href.d.ts.map +1 -1
- package/dist/pptx/automation/index.cjs +634 -361
- package/dist/pptx/automation/index.d.ts +6 -6
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{elements-CCEghtE_.d.ts → elements-mSCZ84Tc.d.ts} +4 -4
- package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-D90lhgiE.d.ts → index-BQDcu_0a.d.ts} +19 -111
- package/dist/pptx/chunks/index-BQDcu_0a.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-CmnbpSCL.d.ts → index-CBV1oHN7.d.ts} +5 -5
- package/dist/pptx/chunks/{index-CmnbpSCL.d.ts.map → index-CBV1oHN7.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-DJIPX0Ge.d.ts → index-PdM5zpmu.d.ts} +5 -5
- package/dist/pptx/chunks/{index-DJIPX0Ge.d.ts.map → index-PdM5zpmu.d.ts.map} +1 -1
- package/dist/pptx/chunks/{smart-art-BLBSej3J.d.ts → smart-art-DLumQo90.d.ts} +135 -103
- package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-D49FKllA.d.ts → text-P9xVnXXf.d.ts} +49 -60
- package/dist/pptx/chunks/text-P9xVnXXf.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-DZ1IgDJN.d.ts → text-operations-hyPODwIQ.d.ts} +4 -4
- package/dist/pptx/chunks/{text-operations-DZ1IgDJN.d.ts.map → text-operations-hyPODwIQ.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +630 -357
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +102 -67
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-assets.cjs +15 -11
- package/dist/pptx/editor/render/collaboration-assets.d.ts +2 -2
- package/dist/pptx/editor/render/collaboration-assets.mjs +1 -1
- package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +5 -5
- package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +3 -3
- package/dist/pptx/editor/render/collaboration-reconcile.cjs +9 -9
- package/dist/pptx/editor/render/collaboration-reconcile.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-reconcile.mjs +3 -3
- package/dist/pptx/editor/render/collaboration-sync.cjs +29 -25
- package/dist/pptx/editor/render/collaboration-sync.d.ts +7 -0
- package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-sync.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/font-family-update.d.ts +1 -1
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/editor/render/table-cell-edit.cjs +8 -4
- package/dist/pptx/editor/render/table-cell-edit.d.ts +5 -0
- package/dist/pptx/editor/render/table-cell-edit.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-cell-edit.mjs +1 -1
- package/dist/pptx/editor/render/table-cell-merge.cjs +3 -3
- package/dist/pptx/editor/render/table-cell-merge.mjs +1 -1
- package/dist/pptx/editor/render/table-data-grid-ops.cjs +2 -2
- package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
- package/dist/pptx/editor/render/table-merge.cjs +5 -5
- package/dist/pptx/editor/render/table-merge.mjs +1 -1
- package/dist/pptx/editor/render/text-content-style.d.ts +1 -1
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +2 -2
- package/dist/pptx/editor/render/text-style-scope.d.ts +2 -2
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +1 -1
- package/dist/pptx/index.cjs +696 -419
- package/dist/pptx/index.d.ts +8 -8
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/teams/index.cjs +1816 -1049
- package/dist/teams/index.mjs +1816 -1049
- package/dist/text/font-style-name.d.ts +11 -0
- package/dist/text/font-style-name.d.ts.map +1 -0
- package/dist/text/font-substitution-map.d.ts +3 -0
- package/dist/text/font-substitution-map.d.ts.map +1 -0
- package/dist/text/font-substitution.d.ts +34 -0
- package/dist/text/font-substitution.d.ts.map +1 -0
- package/dist/text/index.cjs +460 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.mjs +443 -1
- package/dist/text/metric-font-family.d.ts +7 -0
- package/dist/text/metric-font-family.d.ts.map +1 -0
- package/dist/text/panose.d.ts +55 -0
- package/dist/text/panose.d.ts.map +1 -0
- package/dist/text/script-fonts.d.ts +26 -0
- package/dist/text/script-fonts.d.ts.map +1 -0
- package/dist/visio/edit-geometry-admission.d.ts +1 -1
- package/dist/visio/edit-geometry-admission.d.ts.map +1 -1
- package/dist/visio/edit-group-resize.d.ts +26 -0
- package/dist/visio/edit-group-resize.d.ts.map +1 -0
- package/dist/visio/edit-recalculate-index.d.ts +2 -0
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
- package/dist/visio/edit-resize-plan.d.ts +14 -0
- package/dist/visio/edit-resize-plan.d.ts.map +1 -0
- package/dist/visio/edit-scope.d.ts.map +1 -1
- package/dist/visio/index.cjs +1326 -389
- package/dist/visio/index.mjs +1326 -389
- package/dist/visio/ui/geometry-expectation.d.ts +17 -0
- package/dist/visio/ui/geometry-expectation.d.ts.map +1 -0
- package/dist/visio/ui/guides.d.ts +2 -0
- package/dist/visio/ui/guides.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +1582 -411
- package/dist/visio/ui/index.d.ts +2 -0
- package/dist/visio/ui/index.d.ts.map +1 -1
- package/dist/visio/ui/index.mjs +1579 -412
- package/dist/visio/ui/selection-resize.d.ts +19 -0
- package/dist/visio/ui/selection-resize.d.ts.map +1 -0
- package/dist/visio/ui/shape-move.d.ts +1 -1
- package/dist/visio/ui/shape-move.d.ts.map +1 -1
- package/dist/visio/ui/shape-resize.d.ts.map +1 -1
- package/dist/xlsx/edit/drawings.d.ts +5 -0
- package/dist/xlsx/edit/drawings.d.ts.map +1 -1
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/types.d.ts +4 -0
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +3908 -2256
- package/dist/xlsx/index.mjs +3908 -2256
- package/dist/xlsx/layout/chart-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +2003 -1239
- package/dist/xlsx/load/index.mjs +2003 -1239
- package/dist/xlsx/model.d.ts +4 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/chart.d.ts.map +1 -1
- package/dist/xlsx/read/drawing.d.ts.map +1 -1
- package/dist/xlsx/read/smart-art.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +3880 -2228
- package/dist/xlsx/ui/index.mjs +3880 -2228
- package/dist/xlsx/write/drawing.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/PptxHandler-DSXSXMEG.mjs +0 -4
- package/dist/pptx/chunks/elements-CCEghtE_.d.ts.map +0 -1
- package/dist/pptx/chunks/index-D90lhgiE.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-BLBSej3J.d.ts.map +0 -1
- package/dist/pptx/chunks/text-D49FKllA.d.ts.map +0 -1
|
@@ -1419,6 +1419,89 @@ function resolveDrawingColor(color, theme, options2) {
|
|
|
1419
1419
|
};
|
|
1420
1420
|
}
|
|
1421
1421
|
|
|
1422
|
+
// drawingml/picture-crop.ts
|
|
1423
|
+
var SIDES = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
|
|
1424
|
+
function parsePictureCrop(blipFill) {
|
|
1425
|
+
const rect3 = first(blipFill, "srcRect", NS.a);
|
|
1426
|
+
if (!rect3) return void 0;
|
|
1427
|
+
const result = {};
|
|
1428
|
+
for (const [attr3, key] of Object.entries(SIDES)) {
|
|
1429
|
+
const raw = rect3.getAttribute(attr3);
|
|
1430
|
+
if (raw === null || !raw.trim()) continue;
|
|
1431
|
+
const percent = raw.endsWith("%");
|
|
1432
|
+
const value = Number(percent ? raw.slice(0, -1) : raw) / (percent ? 100 : 1e5);
|
|
1433
|
+
if (Number.isFinite(value)) result[key] = value;
|
|
1434
|
+
}
|
|
1435
|
+
return result;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// drawingml/picture-effects.ts
|
|
1439
|
+
function picturePercentage(value) {
|
|
1440
|
+
const text2 = String(value ?? "").trim();
|
|
1441
|
+
if (!text2) return void 0;
|
|
1442
|
+
const percent = text2.endsWith("%");
|
|
1443
|
+
const n2 = Number(percent ? text2.slice(0, -1) : text2) / (percent ? 100 : 1e5);
|
|
1444
|
+
return Number.isFinite(n2) ? n2 : void 0;
|
|
1445
|
+
}
|
|
1446
|
+
function readPictureEffect(name, attribute) {
|
|
1447
|
+
if (name === "grayscl") return { kind: "grayscale" };
|
|
1448
|
+
if (name === "lum") {
|
|
1449
|
+
const brightness = picturePercentage(attribute("bright"));
|
|
1450
|
+
const contrast = picturePercentage(attribute("contrast"));
|
|
1451
|
+
for (const [name2, value] of [
|
|
1452
|
+
["bright", brightness],
|
|
1453
|
+
["contrast", contrast]
|
|
1454
|
+
]) {
|
|
1455
|
+
const raw = attribute(name2);
|
|
1456
|
+
if (raw !== void 0 && raw !== null && (value === void 0 || Math.abs(value) > 1))
|
|
1457
|
+
return void 0;
|
|
1458
|
+
}
|
|
1459
|
+
return {
|
|
1460
|
+
kind: "luminance",
|
|
1461
|
+
...brightness !== void 0 ? { brightness } : {},
|
|
1462
|
+
...contrast !== void 0 ? { contrast } : {}
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
if (name === "alphaModFix") {
|
|
1466
|
+
const raw = attribute("amt");
|
|
1467
|
+
const amount = raw === void 0 || raw === null ? 1 : picturePercentage(raw);
|
|
1468
|
+
if (amount !== void 0 && amount >= 0) return { kind: "alphaModFix", amount };
|
|
1469
|
+
}
|
|
1470
|
+
return void 0;
|
|
1471
|
+
}
|
|
1472
|
+
function parsePictureEffects(blip) {
|
|
1473
|
+
if (!blip) return [];
|
|
1474
|
+
return elements(blip).map((node) => ({
|
|
1475
|
+
...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
|
|
1476
|
+
sourceXml: buildXml(node)
|
|
1477
|
+
}));
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
// drawingml/picture-fill.ts
|
|
1481
|
+
function parseDrawingPictureFill(fill) {
|
|
1482
|
+
const blip = first(fill, "blip", NS.a);
|
|
1483
|
+
const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
|
|
1484
|
+
const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
|
|
1485
|
+
const crop = parsePictureCrop(fill);
|
|
1486
|
+
const effects = parsePictureEffects(blip);
|
|
1487
|
+
const tile = first(fill, "tile", NS.a);
|
|
1488
|
+
const rect3 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
|
|
1489
|
+
const unsupported = [
|
|
1490
|
+
...tile ? ["tile"] : [],
|
|
1491
|
+
...rect3 && ["l", "t", "r", "b"].some((key) => Number(rect3.getAttribute(key) ?? 0) !== 0) ? ["fillRect"] : [],
|
|
1492
|
+
...fill.getAttribute("rotWithShape") === "0" || fill.getAttribute("rotWithShape") === "false" ? ["rotWithShape"] : []
|
|
1493
|
+
];
|
|
1494
|
+
return {
|
|
1495
|
+
kind: "picture",
|
|
1496
|
+
sourceXml: buildXml(fill),
|
|
1497
|
+
...relId ? { relId } : {},
|
|
1498
|
+
...linkRelId ? { linkRelId } : {},
|
|
1499
|
+
...crop ? { crop } : {},
|
|
1500
|
+
...effects.length ? { effects } : {},
|
|
1501
|
+
...unsupported.length ? { unsupportedPicture: unsupported } : {}
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1422
1505
|
// drawingml/drawing-fill.ts
|
|
1423
1506
|
var FILL_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1424
1507
|
"noFill",
|
|
@@ -1428,13 +1511,13 @@ var FILL_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
1428
1511
|
"blipFill",
|
|
1429
1512
|
"grpFill"
|
|
1430
1513
|
]);
|
|
1431
|
-
function fillElementOf(
|
|
1432
|
-
return
|
|
1514
|
+
function fillElementOf(properties) {
|
|
1515
|
+
return properties ? elements(properties).find(
|
|
1433
1516
|
(element) => FILL_ELEMENTS.has(element.localName) && (!element.namespaceURI || element.namespaceURI === NS.a)
|
|
1434
1517
|
) : void 0;
|
|
1435
1518
|
}
|
|
1436
|
-
function parseDrawingFill(
|
|
1437
|
-
const fill = fillElementOf(
|
|
1519
|
+
function parseDrawingFill(properties) {
|
|
1520
|
+
const fill = fillElementOf(properties);
|
|
1438
1521
|
if (!fill) return void 0;
|
|
1439
1522
|
switch (fill.localName) {
|
|
1440
1523
|
case "noFill":
|
|
@@ -1489,17 +1572,8 @@ function parseDrawingFill(properties2) {
|
|
|
1489
1572
|
...background ? { background } : {}
|
|
1490
1573
|
};
|
|
1491
1574
|
}
|
|
1492
|
-
case "blipFill":
|
|
1493
|
-
|
|
1494
|
-
const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
|
|
1495
|
-
const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
|
|
1496
|
-
return {
|
|
1497
|
-
kind: "picture",
|
|
1498
|
-
sourceXml: buildXml(fill),
|
|
1499
|
-
...relId ? { relId } : {},
|
|
1500
|
-
...linkRelId ? { linkRelId } : {}
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1575
|
+
case "blipFill":
|
|
1576
|
+
return parseDrawingPictureFill(fill);
|
|
1503
1577
|
default:
|
|
1504
1578
|
return { kind: "unsupported", element: fill.localName };
|
|
1505
1579
|
}
|
|
@@ -1823,143 +1897,6 @@ function drawingColorCss(value) {
|
|
|
1823
1897
|
return `rgba(${channels.join(",")},${value.alpha})`;
|
|
1824
1898
|
}
|
|
1825
1899
|
|
|
1826
|
-
// drawingml/drawing-shadow.ts
|
|
1827
|
-
function resolveDrawingShadow(effects, theme) {
|
|
1828
|
-
const effect = parseDrawingEffects(effects)?.effects.find(
|
|
1829
|
-
(entry) => entry.kind === "outerShadow"
|
|
1830
|
-
);
|
|
1831
|
-
return effect?.kind === "outerShadow" ? resolveDrawingOuterShadow(effect, theme) : void 0;
|
|
1832
|
-
}
|
|
1833
|
-
function resolveDrawingOuterShadow(effect, theme) {
|
|
1834
|
-
if (effect.sourceXml) {
|
|
1835
|
-
const source = parseXml(effect.sourceXml).documentElement;
|
|
1836
|
-
for (const attribute of ["blurRad", "dist", "dir", "sx", "sy", "kx", "ky"]) {
|
|
1837
|
-
const value = source.getAttribute(attribute);
|
|
1838
|
-
if (value !== null && !Number.isFinite(Number(value))) return void 0;
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
if ((effect.scaleX ?? 1e5) !== 1e5 || (effect.scaleY ?? 1e5) !== 1e5 || (effect.skewXAngle ?? 0) !== 0 || (effect.skewYAngle ?? 0) !== 0)
|
|
1842
|
-
return void 0;
|
|
1843
|
-
const color = effect.color;
|
|
1844
|
-
const resolved = color && resolveDrawingColor(color, theme, { transformOrder: "document" });
|
|
1845
|
-
const blur = (effect.blurRadiusEmu ?? 0) / EMU_PER_PIXEL;
|
|
1846
|
-
const distance = (effect.distanceEmu ?? 0) / EMU_PER_PIXEL;
|
|
1847
|
-
const angle = (effect.directionAngle ?? 0) / 6e4 * Math.PI / 180;
|
|
1848
|
-
if (!resolved || ![blur, distance, angle].every(Number.isFinite) || blur < 0 || distance < 0)
|
|
1849
|
-
return void 0;
|
|
1850
|
-
return {
|
|
1851
|
-
color: resolved.hex,
|
|
1852
|
-
opacity: resolved.alpha,
|
|
1853
|
-
blur,
|
|
1854
|
-
dx: Math.cos(angle) * distance,
|
|
1855
|
-
dy: Math.sin(angle) * distance
|
|
1856
|
-
};
|
|
1857
|
-
}
|
|
1858
|
-
function resolveDrawingShadowXml(xml, theme) {
|
|
1859
|
-
return xml ? resolveDrawingShadow(parseXml(xml).documentElement, theme) : void 0;
|
|
1860
|
-
}
|
|
1861
|
-
function svgDropShadowElement(s, format) {
|
|
1862
|
-
const num = format.number;
|
|
1863
|
-
return `<feDropShadow dx="${num(s.dx)}" dy="${num(s.dy)}" stdDeviation="${num(s.blur / 2)}" flood-color="${format.color(s.color, "#000000")}" flood-opacity="${num(s.opacity)}" result="shadow"/>`;
|
|
1864
|
-
}
|
|
1865
|
-
function hexToRgb2(color) {
|
|
1866
|
-
const parsed = hexToRgbChannels(color);
|
|
1867
|
-
if (parsed) return parsed;
|
|
1868
|
-
const hex = color.replace("#", "");
|
|
1869
|
-
return {
|
|
1870
|
-
r: Number.parseInt(hex.slice(0, 2), 16) || 0,
|
|
1871
|
-
g: Number.parseInt(hex.slice(2, 4), 16) || 0,
|
|
1872
|
-
b: Number.parseInt(hex.slice(4, 6), 16) || 0
|
|
1873
|
-
};
|
|
1874
|
-
}
|
|
1875
|
-
function toHexChannel(value) {
|
|
1876
|
-
return toHex(value).toLowerCase();
|
|
1877
|
-
}
|
|
1878
|
-
function lerpStops(a, b, t) {
|
|
1879
|
-
const ca = hexToRgb2(a.color);
|
|
1880
|
-
const cb = hexToRgb2(b.color);
|
|
1881
|
-
const oa = a.opacity ?? 1;
|
|
1882
|
-
const ob = b.opacity ?? 1;
|
|
1883
|
-
return {
|
|
1884
|
-
color: `#${toHexChannel(ca.r + (cb.r - ca.r) * t)}${toHexChannel(ca.g + (cb.g - ca.g) * t)}${toHexChannel(ca.b + (cb.b - ca.b) * t)}`,
|
|
1885
|
-
opacity: oa + (ob - oa) * t
|
|
1886
|
-
};
|
|
1887
|
-
}
|
|
1888
|
-
function colorAt(stops, position) {
|
|
1889
|
-
const first3 = stops[0];
|
|
1890
|
-
const last = stops[stops.length - 1];
|
|
1891
|
-
if (position <= first3.position) {
|
|
1892
|
-
return { color: first3.color, opacity: first3.opacity ?? 1 };
|
|
1893
|
-
}
|
|
1894
|
-
if (position >= last.position) {
|
|
1895
|
-
return { color: last.color, opacity: last.opacity ?? 1 };
|
|
1896
|
-
}
|
|
1897
|
-
for (let i = 0; i < stops.length - 1; i += 1) {
|
|
1898
|
-
const from = stops[i];
|
|
1899
|
-
const to = stops[i + 1];
|
|
1900
|
-
if (position >= from.position && position <= to.position) {
|
|
1901
|
-
const span = to.position - from.position;
|
|
1902
|
-
const t = span > 0 ? (position - from.position) / span : 0;
|
|
1903
|
-
return lerpStops(from, to, t);
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
return { color: last.color, opacity: last.opacity ?? 1 };
|
|
1907
|
-
}
|
|
1908
|
-
function resolveInnerRect(fillToRect, focalPoint) {
|
|
1909
|
-
let centerX = 50;
|
|
1910
|
-
let centerY = 50;
|
|
1911
|
-
let width = 0;
|
|
1912
|
-
let height = 0;
|
|
1913
|
-
if (fillToRect) {
|
|
1914
|
-
const { l, t, r, b } = fillToRect;
|
|
1915
|
-
centerX = (l + (1 - r)) / 2 * 100;
|
|
1916
|
-
centerY = (t + (1 - b)) / 2 * 100;
|
|
1917
|
-
width = Math.max(0, Math.min(1, 1 - l - r)) * 100;
|
|
1918
|
-
height = Math.max(0, Math.min(1, 1 - t - b)) * 100;
|
|
1919
|
-
}
|
|
1920
|
-
return {
|
|
1921
|
-
left: centerX - width / 2,
|
|
1922
|
-
top: centerY - height / 2,
|
|
1923
|
-
right: centerX + width / 2,
|
|
1924
|
-
bottom: centerY + height / 2
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
function lerpEdge(inner, outer, t) {
|
|
1928
|
-
return inner + (outer - inner) * t;
|
|
1929
|
-
}
|
|
1930
|
-
function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options2) {
|
|
1931
|
-
if (stops.length === 0) {
|
|
1932
|
-
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"/>';
|
|
1933
|
-
}
|
|
1934
|
-
const sorted = [...stops].sort((a, b) => a.position - b.position);
|
|
1935
|
-
const inner = resolveInnerRect(fillToRect);
|
|
1936
|
-
const rects = [];
|
|
1937
|
-
const alphaRects = [];
|
|
1938
|
-
const masked = sorted.some((stop) => (stop.opacity ?? 1) < 1);
|
|
1939
|
-
const bands = options2?.bands;
|
|
1940
|
-
if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
|
|
1941
|
-
for (let i = bands; i >= 0; i -= 1) {
|
|
1942
|
-
const t = i / bands;
|
|
1943
|
-
const { color, opacity } = colorAt(sorted, t * 100);
|
|
1944
|
-
const left = lerpEdge(inner.left, 0, t);
|
|
1945
|
-
const top = lerpEdge(inner.top, 0, t);
|
|
1946
|
-
const right = lerpEdge(inner.right, 100, t);
|
|
1947
|
-
const bottom = lerpEdge(inner.bottom, 100, t);
|
|
1948
|
-
const opacityAttr = !masked && opacity < 1 ? ` fill-opacity="${Math.max(0, opacity).toFixed(3)}"` : "";
|
|
1949
|
-
rects.push(
|
|
1950
|
-
`<rect x="${left.toFixed(2)}" y="${top.toFixed(2)}" width="${(right - left).toFixed(2)}" height="${(bottom - top).toFixed(2)}" fill="${color}"${opacityAttr}/>`
|
|
1951
|
-
);
|
|
1952
|
-
if (masked) {
|
|
1953
|
-
const channel = toHexChannel(opacity * 255);
|
|
1954
|
-
alphaRects.push(
|
|
1955
|
-
`<rect x="${left.toFixed(2)}" y="${top.toFixed(2)}" width="${(right - left).toFixed(2)}" height="${(bottom - top).toFixed(2)}" fill="#${channel}${channel}${channel}"/>`
|
|
1956
|
-
);
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
const paint2 = masked ? `<defs><mask id="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="100" mask-type="luminance" color-interpolation="sRGB">${alphaRects.join("")}</mask></defs><g mask="url(#alpha)">${rects.join("")}</g>` : rects.join("");
|
|
1960
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">${paint2}</svg>`;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
1900
|
// geometry/guide-formula-eval.ts
|
|
1964
1901
|
var ANGLE_SCALE = 6e4;
|
|
1965
1902
|
function angleToRadians(ooxmlAngle) {
|
|
@@ -2148,67 +2085,353 @@ function evaluateGuides(guides, ctx, adjustments) {
|
|
|
2148
2085
|
return vars;
|
|
2149
2086
|
}
|
|
2150
2087
|
|
|
2151
|
-
//
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2088
|
+
// drawingml/custom-geometry.ts
|
|
2089
|
+
var ARITY = {
|
|
2090
|
+
val: 1,
|
|
2091
|
+
abs: 1,
|
|
2092
|
+
sqrt: 1,
|
|
2093
|
+
"+-": 3,
|
|
2094
|
+
"*/": 3,
|
|
2095
|
+
"+/": 3,
|
|
2096
|
+
"?:": 3,
|
|
2097
|
+
at2: 2,
|
|
2098
|
+
cat2: 3,
|
|
2099
|
+
cos: 2,
|
|
2100
|
+
max: 2,
|
|
2101
|
+
min: 2,
|
|
2102
|
+
mod: 3,
|
|
2103
|
+
pin: 3,
|
|
2104
|
+
sat2: 3,
|
|
2105
|
+
sin: 2,
|
|
2106
|
+
tan: 2
|
|
2107
|
+
};
|
|
2108
|
+
function operand(value, vars) {
|
|
2109
|
+
if (value === null || !value.trim()) return NaN;
|
|
2110
|
+
const literal = Number(value);
|
|
2111
|
+
return Number.isFinite(literal) ? literal : vars.get(value) ?? NaN;
|
|
2112
|
+
}
|
|
2113
|
+
function parseCustomGeometry(custom, width, height) {
|
|
2114
|
+
const pathList = first(custom, "pathLst", NS.a);
|
|
2115
|
+
if (!pathList) return void 0;
|
|
2116
|
+
const pathNodes = children(pathList, "path", NS.a);
|
|
2117
|
+
const contextWidth = width;
|
|
2118
|
+
const contextHeight = height;
|
|
2119
|
+
const vars = createBuiltinVariables({ w: contextWidth, h: contextHeight });
|
|
2120
|
+
for (const list of ["avLst", "gdLst"]) {
|
|
2121
|
+
const parent = first(custom, list, NS.a);
|
|
2122
|
+
if (!parent) continue;
|
|
2123
|
+
for (const guide of children(parent, "gd", NS.a)) {
|
|
2124
|
+
const name = guide.getAttribute("name");
|
|
2125
|
+
const formula = parseFormula(guide.getAttribute("fmla") ?? "");
|
|
2126
|
+
if (!name || ARITY[formula.op] !== formula.args.length || formula.args.some((arg2) => !Number.isFinite(operand(arg2, vars))))
|
|
2127
|
+
return void 0;
|
|
2128
|
+
const result = evaluateFormula(formula, vars);
|
|
2129
|
+
if (!Number.isFinite(result)) return void 0;
|
|
2130
|
+
vars.set(name, result);
|
|
2131
|
+
}
|
|
2155
2132
|
}
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
const pieces = Math.ceil(Math.abs(sweep2) / 108e5);
|
|
2159
|
-
let x = penX;
|
|
2160
|
-
let y = penY;
|
|
2161
|
-
let angle = stAng;
|
|
2133
|
+
const paths = [];
|
|
2134
|
+
for (const path of pathNodes) {
|
|
2162
2135
|
const commands = [];
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2136
|
+
const value = (node, name) => operand(node.getAttribute(name), vars);
|
|
2137
|
+
for (const node of elements(path)) {
|
|
2138
|
+
if (node.namespaceURI !== NS.a) return void 0;
|
|
2139
|
+
const points = children(node, "pt", NS.a).map((point) => ({
|
|
2140
|
+
x: value(point, "x"),
|
|
2141
|
+
y: value(point, "y")
|
|
2142
|
+
}));
|
|
2143
|
+
if (points.some((point) => !Number.isFinite(point.x) || !Number.isFinite(point.y)))
|
|
2144
|
+
return void 0;
|
|
2145
|
+
const [p0, p1, p2] = points;
|
|
2146
|
+
switch (node.localName) {
|
|
2147
|
+
case "moveTo":
|
|
2148
|
+
case "lnTo":
|
|
2149
|
+
if (points.length !== 1 || !p0) return void 0;
|
|
2150
|
+
commands.push({ op: node.localName === "moveTo" ? "M" : "L", ...p0 });
|
|
2151
|
+
break;
|
|
2152
|
+
case "quadBezTo":
|
|
2153
|
+
if (points.length !== 2 || !p0 || !p1) return void 0;
|
|
2154
|
+
commands.push({ op: "Q", x1: p0.x, y1: p0.y, ...p1 });
|
|
2155
|
+
break;
|
|
2156
|
+
case "cubicBezTo":
|
|
2157
|
+
if (points.length !== 3 || !p0 || !p1 || !p2) return void 0;
|
|
2158
|
+
commands.push({ op: "C", x1: p0.x, y1: p0.y, x2: p1.x, y2: p1.y, ...p2 });
|
|
2159
|
+
break;
|
|
2160
|
+
case "arcTo": {
|
|
2161
|
+
const wR = value(node, "wR");
|
|
2162
|
+
const hR = value(node, "hR");
|
|
2163
|
+
const start = value(node, "stAng");
|
|
2164
|
+
const swing = value(node, "swAng");
|
|
2165
|
+
if (![wR, hR, start, swing].every(Number.isFinite)) return void 0;
|
|
2166
|
+
commands.push({ op: "A", wR, hR, startAngle: start / 6e4, swingAngle: swing / 6e4 });
|
|
2167
|
+
break;
|
|
2168
|
+
}
|
|
2169
|
+
case "close":
|
|
2170
|
+
commands.push({ op: "Z" });
|
|
2171
|
+
break;
|
|
2172
|
+
default:
|
|
2173
|
+
return void 0;
|
|
2174
|
+
}
|
|
2169
2175
|
}
|
|
2170
|
-
|
|
2176
|
+
const pathWidth = path.hasAttribute("w") ? Number(path.getAttribute("w")) : contextWidth;
|
|
2177
|
+
const pathHeight = path.hasAttribute("h") ? Number(path.getAttribute("h")) : contextHeight;
|
|
2178
|
+
if (![pathWidth, pathHeight].every((n2) => Number.isFinite(n2) && n2 > 0)) return void 0;
|
|
2179
|
+
paths.push({
|
|
2180
|
+
commands,
|
|
2181
|
+
width: pathWidth,
|
|
2182
|
+
height: pathHeight,
|
|
2183
|
+
...path.getAttribute("fill") ? { fill: path.getAttribute("fill") } : {},
|
|
2184
|
+
...["0", "false"].includes(path.getAttribute("stroke") ?? "") ? { stroke: false } : {}
|
|
2185
|
+
});
|
|
2171
2186
|
}
|
|
2172
|
-
|
|
2173
|
-
const sweepRad = angleToRadians(swAng);
|
|
2174
|
-
const endRad = startRad + sweepRad;
|
|
2175
|
-
const cx = penX - wR * Math.cos(startRad);
|
|
2176
|
-
const cy = penY - hR * Math.sin(startRad);
|
|
2177
|
-
const endX = cx + wR * Math.cos(endRad);
|
|
2178
|
-
const endY = cy + hR * Math.sin(endRad);
|
|
2179
|
-
const largeArc = Math.abs(sweepRad) > Math.PI ? 1 : 0;
|
|
2180
|
-
const sweep = sweepRad > 0 ? 1 : 0;
|
|
2181
|
-
const rx = Math.round(wR * 1e3) / 1e3;
|
|
2182
|
-
const ry = Math.round(hR * 1e3) / 1e3;
|
|
2183
|
-
const ex = Math.round(endX * 1e3) / 1e3;
|
|
2184
|
-
const ey = Math.round(endY * 1e3) / 1e3;
|
|
2185
|
-
return {
|
|
2186
|
-
svg: `A ${rx} ${ry} 0 ${largeArc} ${sweep} ${ex} ${ey}`,
|
|
2187
|
-
endX,
|
|
2188
|
-
endY
|
|
2189
|
-
};
|
|
2187
|
+
return paths.length ? paths : void 0;
|
|
2190
2188
|
}
|
|
2191
2189
|
|
|
2192
|
-
//
|
|
2193
|
-
function
|
|
2194
|
-
const
|
|
2195
|
-
|
|
2190
|
+
// drawingml/drawing-shadow.ts
|
|
2191
|
+
function resolveDrawingShadow(effects, theme) {
|
|
2192
|
+
const effect = parseDrawingEffects(effects)?.effects.find(
|
|
2193
|
+
(entry) => entry.kind === "outerShadow"
|
|
2194
|
+
);
|
|
2195
|
+
return effect?.kind === "outerShadow" ? resolveDrawingOuterShadow(effect, theme) : void 0;
|
|
2196
2196
|
}
|
|
2197
|
-
function
|
|
2197
|
+
function resolveDrawingOuterShadow(effect, theme) {
|
|
2198
|
+
if (effect.sourceXml) {
|
|
2199
|
+
const source = parseXml(effect.sourceXml).documentElement;
|
|
2200
|
+
for (const attribute of ["blurRad", "dist", "dir", "sx", "sy", "kx", "ky"]) {
|
|
2201
|
+
const value = source.getAttribute(attribute);
|
|
2202
|
+
if (value !== null && !Number.isFinite(Number(value))) return void 0;
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
if ((effect.scaleX ?? 1e5) !== 1e5 || (effect.scaleY ?? 1e5) !== 1e5 || (effect.skewXAngle ?? 0) !== 0 || (effect.skewYAngle ?? 0) !== 0)
|
|
2206
|
+
return void 0;
|
|
2207
|
+
const color = effect.color;
|
|
2208
|
+
const resolved = color && resolveDrawingColor(color, theme, { transformOrder: "document" });
|
|
2209
|
+
const blur = (effect.blurRadiusEmu ?? 0) / EMU_PER_PIXEL;
|
|
2210
|
+
const distance = (effect.distanceEmu ?? 0) / EMU_PER_PIXEL;
|
|
2211
|
+
const angle = (effect.directionAngle ?? 0) / 6e4 * Math.PI / 180;
|
|
2212
|
+
if (!resolved || ![blur, distance, angle].every(Number.isFinite) || blur < 0 || distance < 0)
|
|
2213
|
+
return void 0;
|
|
2198
2214
|
return {
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2215
|
+
color: resolved.hex,
|
|
2216
|
+
opacity: resolved.alpha,
|
|
2217
|
+
blur,
|
|
2218
|
+
dx: Math.cos(angle) * distance,
|
|
2219
|
+
dy: Math.sin(angle) * distance
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
function resolveDrawingShadowXml(xml, theme) {
|
|
2223
|
+
return xml ? resolveDrawingShadow(parseXml(xml).documentElement, theme) : void 0;
|
|
2224
|
+
}
|
|
2225
|
+
function svgDropShadowElement(s, format) {
|
|
2226
|
+
const num = format.number;
|
|
2227
|
+
return `<feDropShadow dx="${num(s.dx)}" dy="${num(s.dy)}" stdDeviation="${num(s.blur / 2)}" flood-color="${format.color(s.color, "#000000")}" flood-opacity="${num(s.opacity)}" result="shadow"/>`;
|
|
2228
|
+
}
|
|
2229
|
+
function hexToRgb2(color) {
|
|
2230
|
+
const parsed = hexToRgbChannels(color);
|
|
2231
|
+
if (parsed) return parsed;
|
|
2232
|
+
const hex = color.replace("#", "");
|
|
2233
|
+
return {
|
|
2234
|
+
r: Number.parseInt(hex.slice(0, 2), 16) || 0,
|
|
2235
|
+
g: Number.parseInt(hex.slice(2, 4), 16) || 0,
|
|
2236
|
+
b: Number.parseInt(hex.slice(4, 6), 16) || 0
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2239
|
+
function toHexChannel(value) {
|
|
2240
|
+
return toHex(value).toLowerCase();
|
|
2241
|
+
}
|
|
2242
|
+
function lerpStops(a, b, t) {
|
|
2243
|
+
const ca = hexToRgb2(a.color);
|
|
2244
|
+
const cb = hexToRgb2(b.color);
|
|
2245
|
+
const oa = a.opacity ?? 1;
|
|
2246
|
+
const ob = b.opacity ?? 1;
|
|
2247
|
+
return {
|
|
2248
|
+
color: `#${toHexChannel(ca.r + (cb.r - ca.r) * t)}${toHexChannel(ca.g + (cb.g - ca.g) * t)}${toHexChannel(ca.b + (cb.b - ca.b) * t)}`,
|
|
2249
|
+
opacity: oa + (ob - oa) * t
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
function colorAt(stops, position) {
|
|
2253
|
+
const first3 = stops[0];
|
|
2254
|
+
const last = stops[stops.length - 1];
|
|
2255
|
+
if (position <= first3.position) {
|
|
2256
|
+
return { color: first3.color, opacity: first3.opacity ?? 1 };
|
|
2257
|
+
}
|
|
2258
|
+
if (position >= last.position) {
|
|
2259
|
+
return { color: last.color, opacity: last.opacity ?? 1 };
|
|
2260
|
+
}
|
|
2261
|
+
for (let i = 0; i < stops.length - 1; i += 1) {
|
|
2262
|
+
const from = stops[i];
|
|
2263
|
+
const to = stops[i + 1];
|
|
2264
|
+
if (position >= from.position && position <= to.position) {
|
|
2265
|
+
const span = to.position - from.position;
|
|
2266
|
+
const t = span > 0 ? (position - from.position) / span : 0;
|
|
2267
|
+
return lerpStops(from, to, t);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
return { color: last.color, opacity: last.opacity ?? 1 };
|
|
2271
|
+
}
|
|
2272
|
+
function resolveInnerRect(fillToRect, focalPoint) {
|
|
2273
|
+
let centerX = 50;
|
|
2274
|
+
let centerY = 50;
|
|
2275
|
+
let width = 0;
|
|
2276
|
+
let height = 0;
|
|
2277
|
+
if (fillToRect) {
|
|
2278
|
+
const { l, t, r, b } = fillToRect;
|
|
2279
|
+
centerX = (l + (1 - r)) / 2 * 100;
|
|
2280
|
+
centerY = (t + (1 - b)) / 2 * 100;
|
|
2281
|
+
width = Math.max(0, Math.min(1, 1 - l - r)) * 100;
|
|
2282
|
+
height = Math.max(0, Math.min(1, 1 - t - b)) * 100;
|
|
2283
|
+
}
|
|
2284
|
+
return {
|
|
2285
|
+
left: centerX - width / 2,
|
|
2286
|
+
top: centerY - height / 2,
|
|
2287
|
+
right: centerX + width / 2,
|
|
2288
|
+
bottom: centerY + height / 2
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
function lerpEdge(inner, outer, t) {
|
|
2292
|
+
return inner + (outer - inner) * t;
|
|
2293
|
+
}
|
|
2294
|
+
function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options2) {
|
|
2295
|
+
if (stops.length === 0) {
|
|
2296
|
+
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"/>';
|
|
2297
|
+
}
|
|
2298
|
+
const sorted = [...stops].sort((a, b) => a.position - b.position);
|
|
2299
|
+
const inner = resolveInnerRect(fillToRect);
|
|
2300
|
+
const rects = [];
|
|
2301
|
+
const alphaRects = [];
|
|
2302
|
+
const masked = sorted.some((stop) => (stop.opacity ?? 1) < 1);
|
|
2303
|
+
const bands = options2?.bands;
|
|
2304
|
+
if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
|
|
2305
|
+
for (let i = bands; i >= 0; i -= 1) {
|
|
2306
|
+
const t = i / bands;
|
|
2307
|
+
const { color, opacity } = colorAt(sorted, t * 100);
|
|
2308
|
+
const left = lerpEdge(inner.left, 0, t);
|
|
2309
|
+
const top = lerpEdge(inner.top, 0, t);
|
|
2310
|
+
const right = lerpEdge(inner.right, 100, t);
|
|
2311
|
+
const bottom = lerpEdge(inner.bottom, 100, t);
|
|
2312
|
+
const opacityAttr = !masked && opacity < 1 ? ` fill-opacity="${Math.max(0, opacity).toFixed(3)}"` : "";
|
|
2313
|
+
rects.push(
|
|
2314
|
+
`<rect x="${left.toFixed(2)}" y="${top.toFixed(2)}" width="${(right - left).toFixed(2)}" height="${(bottom - top).toFixed(2)}" fill="${color}"${opacityAttr}/>`
|
|
2315
|
+
);
|
|
2316
|
+
if (masked) {
|
|
2317
|
+
const channel = toHexChannel(opacity * 255);
|
|
2318
|
+
alphaRects.push(
|
|
2319
|
+
`<rect x="${left.toFixed(2)}" y="${top.toFixed(2)}" width="${(right - left).toFixed(2)}" height="${(bottom - top).toFixed(2)}" fill="#${channel}${channel}${channel}"/>`
|
|
2320
|
+
);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
const paint2 = masked ? `<defs><mask id="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="100" mask-type="luminance" color-interpolation="sRGB">${alphaRects.join("")}</mask></defs><g mask="url(#alpha)">${rects.join("")}</g>` : rects.join("");
|
|
2324
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">${paint2}</svg>`;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
// geometry/ooxml-arc.ts
|
|
2328
|
+
function ooxmlArcToSvg(wR, hR, stAng, swAng, penX, penY) {
|
|
2329
|
+
if (![wR, hR, stAng, swAng, penX, penY].every(Number.isFinite) || wR <= 0 || hR <= 0 || swAng === 0) {
|
|
2330
|
+
return null;
|
|
2331
|
+
}
|
|
2332
|
+
if (Math.abs(swAng) >= 216e5) {
|
|
2333
|
+
const sweep2 = Math.sign(swAng) * (216e5 + Math.abs(swAng) % 216e5);
|
|
2334
|
+
const pieces = Math.ceil(Math.abs(sweep2) / 108e5);
|
|
2335
|
+
let x = penX;
|
|
2336
|
+
let y = penY;
|
|
2337
|
+
let angle = stAng;
|
|
2338
|
+
const commands = [];
|
|
2339
|
+
for (let index = 0; index < pieces; index++) {
|
|
2340
|
+
const part = ooxmlArcToSvg(wR, hR, angle, sweep2 / pieces, x, y);
|
|
2341
|
+
commands.push(part.svg);
|
|
2342
|
+
x = part.endX;
|
|
2343
|
+
y = part.endY;
|
|
2344
|
+
angle += sweep2 / pieces;
|
|
2345
|
+
}
|
|
2346
|
+
return { svg: commands.join(" "), endX: x, endY: y };
|
|
2347
|
+
}
|
|
2348
|
+
const startRad = angleToRadians(stAng);
|
|
2349
|
+
const sweepRad = angleToRadians(swAng);
|
|
2350
|
+
const endRad = startRad + sweepRad;
|
|
2351
|
+
const cx = penX - wR * Math.cos(startRad);
|
|
2352
|
+
const cy = penY - hR * Math.sin(startRad);
|
|
2353
|
+
const endX = cx + wR * Math.cos(endRad);
|
|
2354
|
+
const endY = cy + hR * Math.sin(endRad);
|
|
2355
|
+
const largeArc = Math.abs(sweepRad) > Math.PI ? 1 : 0;
|
|
2356
|
+
const sweep = sweepRad > 0 ? 1 : 0;
|
|
2357
|
+
const rx = Math.round(wR * 1e3) / 1e3;
|
|
2358
|
+
const ry = Math.round(hR * 1e3) / 1e3;
|
|
2359
|
+
const ex = Math.round(endX * 1e3) / 1e3;
|
|
2360
|
+
const ey = Math.round(endY * 1e3) / 1e3;
|
|
2361
|
+
return {
|
|
2362
|
+
svg: `A ${rx} ${ry} 0 ${largeArc} ${sweep} ${ex} ${ey}`,
|
|
2363
|
+
endX,
|
|
2364
|
+
endY
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
// drawingml/path-data.ts
|
|
2369
|
+
function drawingPathData(path, width, height) {
|
|
2370
|
+
const sx = path.width ? width / path.width : 1;
|
|
2371
|
+
const sy = path.height ? height / path.height : 1;
|
|
2372
|
+
const out = [];
|
|
2373
|
+
let px = 0;
|
|
2374
|
+
let py = 0;
|
|
2375
|
+
let startX = 0;
|
|
2376
|
+
let startY = 0;
|
|
2377
|
+
for (const command of path.commands) {
|
|
2378
|
+
if (command.op === "A") {
|
|
2379
|
+
const arc2 = ooxmlArcToSvg(
|
|
2380
|
+
command.wR * sx,
|
|
2381
|
+
command.hR * sy,
|
|
2382
|
+
command.startAngle * 6e4,
|
|
2383
|
+
command.swingAngle * 6e4,
|
|
2384
|
+
px,
|
|
2385
|
+
py
|
|
2386
|
+
);
|
|
2387
|
+
if (arc2) {
|
|
2388
|
+
out.push(arc2.svg);
|
|
2389
|
+
px = arc2.endX;
|
|
2390
|
+
py = arc2.endY;
|
|
2391
|
+
}
|
|
2392
|
+
} else if (command.op === "Z") {
|
|
2393
|
+
out.push("Z");
|
|
2394
|
+
px = startX;
|
|
2395
|
+
py = startY;
|
|
2396
|
+
} else {
|
|
2397
|
+
px = command.x * sx;
|
|
2398
|
+
py = command.y * sy;
|
|
2399
|
+
if (command.op === "M" || command.op === "L") {
|
|
2400
|
+
out.push(`${command.op}${px} ${py}`);
|
|
2401
|
+
if (command.op === "M") {
|
|
2402
|
+
startX = px;
|
|
2403
|
+
startY = py;
|
|
2404
|
+
}
|
|
2405
|
+
} else if (command.op === "C")
|
|
2406
|
+
out.push(
|
|
2407
|
+
`C${command.x1 * sx} ${command.y1 * sy} ${command.x2 * sx} ${command.y2 * sy} ${px} ${py}`
|
|
2408
|
+
);
|
|
2409
|
+
else if (command.op === "Q") out.push(`Q${command.x1 * sx} ${command.y1 * sy} ${px} ${py}`);
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
return out.join(" ");
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
// geometry/preset-shape-definitions-action-buttons.ts
|
|
2416
|
+
function gd(name, formula) {
|
|
2417
|
+
const parts = formula.trim().split(/\s+/);
|
|
2418
|
+
return { name, formula, args: parts.slice(1) };
|
|
2419
|
+
}
|
|
2420
|
+
function buildActionButton(name) {
|
|
2421
|
+
return {
|
|
2422
|
+
name,
|
|
2423
|
+
gdLst: [gd("x1", "*/ ss 6250 100000"), gd("x2", "+- r 0 x1"), gd("y2", "+- b 0 x1")],
|
|
2424
|
+
rect: { l: "x1", t: "x1", r: "x2", b: "y2" },
|
|
2425
|
+
pathLst: [
|
|
2426
|
+
// Outer rectangle (the button face).
|
|
2427
|
+
{
|
|
2428
|
+
fill: "norm",
|
|
2429
|
+
extrusionOk: false,
|
|
2430
|
+
commands: [
|
|
2431
|
+
{ kind: "moveTo", x: "l", y: "t" },
|
|
2432
|
+
{ kind: "lnTo", x: "r", y: "t" },
|
|
2433
|
+
{ kind: "lnTo", x: "r", y: "b" },
|
|
2434
|
+
{ kind: "lnTo", x: "l", y: "b" },
|
|
2212
2435
|
{ kind: "close" }
|
|
2213
2436
|
]
|
|
2214
2437
|
},
|
|
@@ -11465,16 +11688,46 @@ function groupRowsByCategory(rawCategories) {
|
|
|
11465
11688
|
const rowIndexesByCategory = /* @__PURE__ */ new Map();
|
|
11466
11689
|
rawCategories.forEach((rawLabel, rowIndex) => {
|
|
11467
11690
|
const label = rawLabel ?? "";
|
|
11468
|
-
let
|
|
11469
|
-
if (!
|
|
11470
|
-
|
|
11471
|
-
rowIndexesByCategory.set(label,
|
|
11691
|
+
let rows2 = rowIndexesByCategory.get(label);
|
|
11692
|
+
if (!rows2) {
|
|
11693
|
+
rows2 = [];
|
|
11694
|
+
rowIndexesByCategory.set(label, rows2);
|
|
11472
11695
|
uniqueCategories.push(label);
|
|
11473
11696
|
}
|
|
11474
|
-
|
|
11697
|
+
rows2.push(rowIndex);
|
|
11475
11698
|
});
|
|
11476
11699
|
return { uniqueCategories, rowIndexesByCategory };
|
|
11477
11700
|
}
|
|
11701
|
+
function percentile(sorted, p, method) {
|
|
11702
|
+
const rank = method === "inclusive" ? (sorted.length - 1) * p : (sorted.length + 1) * p - 1;
|
|
11703
|
+
const clamped = Math.max(0, Math.min(rank, sorted.length - 1));
|
|
11704
|
+
const lower = Math.floor(clamped);
|
|
11705
|
+
const upper = Math.ceil(clamped);
|
|
11706
|
+
const fraction2 = clamped - lower;
|
|
11707
|
+
return sorted[lower] + (sorted[upper] - sorted[lower]) * fraction2;
|
|
11708
|
+
}
|
|
11709
|
+
function computeBoxStats(values, method) {
|
|
11710
|
+
if (values.length < 2) {
|
|
11711
|
+
return void 0;
|
|
11712
|
+
}
|
|
11713
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
11714
|
+
if (!method) {
|
|
11715
|
+
return {
|
|
11716
|
+
min: sorted[0],
|
|
11717
|
+
q1: sorted[Math.floor(sorted.length * 0.25)],
|
|
11718
|
+
median: sorted[Math.floor(sorted.length * 0.5)],
|
|
11719
|
+
q3: sorted[Math.floor(sorted.length * 0.75)],
|
|
11720
|
+
max: sorted[sorted.length - 1]
|
|
11721
|
+
};
|
|
11722
|
+
}
|
|
11723
|
+
return {
|
|
11724
|
+
min: sorted[0],
|
|
11725
|
+
q1: percentile(sorted, 0.25, method),
|
|
11726
|
+
median: percentile(sorted, 0.5, method),
|
|
11727
|
+
q3: percentile(sorted, 0.75, method),
|
|
11728
|
+
max: sorted[sorted.length - 1]
|
|
11729
|
+
};
|
|
11730
|
+
}
|
|
11478
11731
|
|
|
11479
11732
|
// chart/number-format-pattern.ts
|
|
11480
11733
|
var NAMED_FORMAT_COLORS = {
|
|
@@ -12170,11 +12423,11 @@ function computeHistogramBins(values, options2, format = String) {
|
|
|
12170
12423
|
function aggregateByCategory(values, rawCategories) {
|
|
12171
12424
|
const { uniqueCategories, rowIndexesByCategory } = groupRowsByCategory(rawCategories);
|
|
12172
12425
|
return uniqueCategories.map((label) => {
|
|
12173
|
-
const
|
|
12426
|
+
const rows2 = rowIndexesByCategory.get(label) ?? [];
|
|
12174
12427
|
return {
|
|
12175
|
-
value:
|
|
12428
|
+
value: rows2.reduce((sum, row2) => sum + (values[row2] ?? 0), 0),
|
|
12176
12429
|
label,
|
|
12177
|
-
sourceIndices:
|
|
12430
|
+
sourceIndices: rows2
|
|
12178
12431
|
};
|
|
12179
12432
|
});
|
|
12180
12433
|
}
|
|
@@ -12426,6 +12679,62 @@ function placeBestFitLabel(slice, w, h) {
|
|
|
12426
12679
|
return { x: slice.cx + outside * ux, y: slice.cy + outside * uy, inside: false };
|
|
12427
12680
|
}
|
|
12428
12681
|
|
|
12682
|
+
// chart/pie-label-collision.ts
|
|
12683
|
+
var LABEL_COLLISION_GAP = 2;
|
|
12684
|
+
function boxDistanceToCentre(box, y, disc) {
|
|
12685
|
+
const nearestX = Math.max(box.x - box.w / 2, Math.min(disc.cx, box.x + box.w / 2));
|
|
12686
|
+
const nearestY = Math.max(y - box.h / 2, Math.min(disc.cy, y + box.h / 2));
|
|
12687
|
+
return Math.hypot(nearestX - disc.cx, nearestY - disc.cy);
|
|
12688
|
+
}
|
|
12689
|
+
function clearOfDisc(box, y, disc) {
|
|
12690
|
+
if (boxDistanceToCentre(box, y, disc) >= disc.r) {
|
|
12691
|
+
return 0;
|
|
12692
|
+
}
|
|
12693
|
+
const sign = box.x >= disc.cx ? 1 : -1;
|
|
12694
|
+
let dx = 0;
|
|
12695
|
+
while (dx < disc.r * 2 && boxDistanceToCentre({ ...box, x: box.x + sign * dx }, y, disc) < disc.r) {
|
|
12696
|
+
dx += 1;
|
|
12697
|
+
}
|
|
12698
|
+
return sign * dx;
|
|
12699
|
+
}
|
|
12700
|
+
function overlapsX(a, b) {
|
|
12701
|
+
return Math.abs(a.x - b.x) < (a.w + b.w) / 2;
|
|
12702
|
+
}
|
|
12703
|
+
function sweepSide(boxes, minY, maxY) {
|
|
12704
|
+
const sorted = [...boxes].sort((a, b) => a.y - b.y || a.id - b.id);
|
|
12705
|
+
const ys = sorted.map((box) => box.y);
|
|
12706
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
12707
|
+
const prev = sorted[i - 1];
|
|
12708
|
+
const box = sorted[i];
|
|
12709
|
+
if (overlapsX(prev, box)) {
|
|
12710
|
+
ys[i] = Math.max(ys[i], ys[i - 1] + (prev.h + box.h) / 2 + LABEL_COLLISION_GAP);
|
|
12711
|
+
}
|
|
12712
|
+
}
|
|
12713
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
12714
|
+
const box = sorted[i];
|
|
12715
|
+
const limit = i === sorted.length - 1 ? maxY - box.h / 2 : ys[i + 1] - (box.h + sorted[i + 1].h) / 2 - LABEL_COLLISION_GAP;
|
|
12716
|
+
if (ys[i] > limit) {
|
|
12717
|
+
ys[i] = Math.max(limit, minY + box.h / 2);
|
|
12718
|
+
}
|
|
12719
|
+
}
|
|
12720
|
+
return new Map(sorted.map((box, i) => [box.id, ys[i]]));
|
|
12721
|
+
}
|
|
12722
|
+
function nudgeOutsideLabels(boxes, disc, minY, maxY) {
|
|
12723
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
12724
|
+
for (const side of [
|
|
12725
|
+
boxes.filter((box) => box.x >= disc.cx),
|
|
12726
|
+
boxes.filter((box) => box.x < disc.cx)
|
|
12727
|
+
]) {
|
|
12728
|
+
for (const [id, y] of sweepSide(side, minY, maxY)) {
|
|
12729
|
+
resolved.set(id, y);
|
|
12730
|
+
}
|
|
12731
|
+
}
|
|
12732
|
+
return boxes.map((box) => {
|
|
12733
|
+
const y = resolved.get(box.id) ?? box.y;
|
|
12734
|
+
return { id: box.id, dx: y === box.y ? 0 : clearOfDisc(box, y, disc), dy: y - box.y };
|
|
12735
|
+
});
|
|
12736
|
+
}
|
|
12737
|
+
|
|
12429
12738
|
// chart/color-palettes.ts
|
|
12430
12739
|
var COLORFUL_VARIATIONS = [
|
|
12431
12740
|
{},
|
|
@@ -12587,6 +12896,20 @@ function resolveManualLayoutRect(layout, frame2, auto) {
|
|
|
12587
12896
|
const height = layout.height === void 0 ? auto.height : layout.heightMode === "edge" ? layout.height * frame2.height - y : layout.height * frame2.height;
|
|
12588
12897
|
return { x, y, width: Math.max(width, 1), height: Math.max(height, 1) };
|
|
12589
12898
|
}
|
|
12899
|
+
function resolveManualPlotRect(layout, frame2, auto, bands) {
|
|
12900
|
+
const rect3 = resolveManualLayoutRect(layout, frame2, auto);
|
|
12901
|
+
if (!rect3 || layout?.layoutTarget === "inner") return rect3;
|
|
12902
|
+
return {
|
|
12903
|
+
x: rect3.x + bands.left,
|
|
12904
|
+
y: rect3.y + bands.top,
|
|
12905
|
+
width: Math.max(1, rect3.width - bands.left - bands.right),
|
|
12906
|
+
height: Math.max(1, rect3.height - bands.top - bands.bottom)
|
|
12907
|
+
};
|
|
12908
|
+
}
|
|
12909
|
+
function applyLabelManualLayout(layout, frame2, point) {
|
|
12910
|
+
const rect3 = resolveManualLayoutRect(layout, frame2, { ...point, width: 1, height: 1 });
|
|
12911
|
+
return rect3 ? { x: rect3.x, y: rect3.y } : point;
|
|
12912
|
+
}
|
|
12590
12913
|
|
|
12591
12914
|
// chart/gradient-stop-edit.ts
|
|
12592
12915
|
function sortGradientStops(stops) {
|
|
@@ -12967,6 +13290,9 @@ function summaryAnalysis(series) {
|
|
|
12967
13290
|
// chart/render/summary-labels.ts
|
|
12968
13291
|
function level(options2, custom) {
|
|
12969
13292
|
const out = {};
|
|
13293
|
+
if (options2.layout) out.layout = options2.layout;
|
|
13294
|
+
if (options2.showLeaderLines !== void 0) out.showLeaderLines = options2.showLeaderLines;
|
|
13295
|
+
if (options2.leaderLines?.spPr?.line) out.leaderLine = options2.leaderLines.spPr.line;
|
|
12970
13296
|
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
12971
13297
|
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
12972
13298
|
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
@@ -13016,7 +13342,7 @@ var GROUP_TYPES = {
|
|
|
13016
13342
|
surface: "surface"
|
|
13017
13343
|
};
|
|
13018
13344
|
var GROUPINGS = /* @__PURE__ */ new Set(["clustered", "stacked", "percentStacked", "standard"]);
|
|
13019
|
-
function chartSummarySeries(source, chartType, groupLabels) {
|
|
13345
|
+
function chartSummarySeries(source, chartType, groupLabels, groupSmooth) {
|
|
13020
13346
|
const categories = source.categories ?? source.xValues;
|
|
13021
13347
|
const values = source.values ?? source.yValues;
|
|
13022
13348
|
const numeric = (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null;
|
|
@@ -13024,6 +13350,9 @@ function chartSummarySeries(source, chartType, groupLabels) {
|
|
|
13024
13350
|
categories: chartSourceValues(categories),
|
|
13025
13351
|
values: chartSourceValues(values).map(numeric)
|
|
13026
13352
|
};
|
|
13353
|
+
const smooth = source.smooth ?? groupSmooth;
|
|
13354
|
+
if (smooth !== void 0) out.smooth = smooth;
|
|
13355
|
+
if (source.spPr?.line) out.line = source.spPr.line;
|
|
13027
13356
|
if (values?.cache?.formatCode !== void 0) out.numberFormat = values.cache.formatCode;
|
|
13028
13357
|
if (source.bubbleSizes) {
|
|
13029
13358
|
out.bubbleSizes = chartSourceValues(source.bubbleSizes).map(numeric);
|
|
@@ -13044,12 +13373,12 @@ function chartSummarySeries(source, chartType, groupLabels) {
|
|
|
13044
13373
|
const points = {};
|
|
13045
13374
|
const pointFills = {};
|
|
13046
13375
|
for (const point of source.dataPoints) {
|
|
13047
|
-
const
|
|
13376
|
+
const properties = point.spPr ?? point.marker?.spPr;
|
|
13048
13377
|
if (point.index === void 0) continue;
|
|
13049
|
-
const pointColor = solidColor(
|
|
13378
|
+
const pointColor = solidColor(properties?.fill);
|
|
13050
13379
|
if (pointColor) points[point.index] = pointColor;
|
|
13051
|
-
if (
|
|
13052
|
-
pointFills[point.index] =
|
|
13380
|
+
if (properties?.fill && properties.fill.kind !== "solid")
|
|
13381
|
+
pointFills[point.index] = properties.fill;
|
|
13053
13382
|
}
|
|
13054
13383
|
if (Object.keys(points).length) out.pointColors = points;
|
|
13055
13384
|
if (Object.keys(pointFills).length) out.pointFills = pointFills;
|
|
@@ -13083,7 +13412,12 @@ function extraGroups(chartSpace, firstType) {
|
|
|
13083
13412
|
const entry = {
|
|
13084
13413
|
chartType: type,
|
|
13085
13414
|
series: group2.series.map((source, index) => ({
|
|
13086
|
-
...chartSummarySeries(
|
|
13415
|
+
...chartSummarySeries(
|
|
13416
|
+
source,
|
|
13417
|
+
type,
|
|
13418
|
+
group2.dataLabels,
|
|
13419
|
+
group2.smooth ?? (group2.scatterStyle ? ["smooth", "smoothMarker"].includes(group2.scatterStyle) : void 0)
|
|
13420
|
+
),
|
|
13087
13421
|
...summaryMarkers(source, group2, index)
|
|
13088
13422
|
})),
|
|
13089
13423
|
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
@@ -13104,8 +13438,14 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
13104
13438
|
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
13105
13439
|
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
13106
13440
|
const series = (group2?.series ?? []).map((source, index) => ({
|
|
13107
|
-
...chartSummarySeries(
|
|
13108
|
-
|
|
13441
|
+
...chartSummarySeries(
|
|
13442
|
+
source,
|
|
13443
|
+
chartType,
|
|
13444
|
+
group2?.dataLabels,
|
|
13445
|
+
group2?.smooth ?? (group2?.scatterStyle ? ["smooth", "smoothMarker"].includes(group2.scatterStyle) : void 0)
|
|
13446
|
+
),
|
|
13447
|
+
...group2 ? summaryMarkers(source, group2, index) : {},
|
|
13448
|
+
...group2?.kind === "scatter" ? { showLine: !["marker", "none"].includes(group2.scatterStyle ?? "marker") } : {}
|
|
13109
13449
|
}));
|
|
13110
13450
|
const summary = {
|
|
13111
13451
|
chartType,
|
|
@@ -13114,6 +13454,9 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
13114
13454
|
axes: chartSpace.plotArea.axes,
|
|
13115
13455
|
axisIds: group2?.axisIds ?? []
|
|
13116
13456
|
};
|
|
13457
|
+
if (chartSpace.plotArea.dataTable) summary.dataTable = chartSpace.plotArea.dataTable;
|
|
13458
|
+
if (chartSpace.date1904 !== void 0) summary.date1904 = chartSpace.date1904;
|
|
13459
|
+
if (chartSpace.plotArea.layout) summary.plotLayout = chartSpace.plotArea.layout;
|
|
13117
13460
|
const combined = extraGroups(chartSpace, chartType);
|
|
13118
13461
|
if (combined.length) summary.extraGroups = combined;
|
|
13119
13462
|
if (chartType === "stock" && group2) summary.stock = stockStyle(group2);
|
|
@@ -13152,45 +13495,15 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
13152
13495
|
return summary;
|
|
13153
13496
|
}
|
|
13154
13497
|
|
|
13155
|
-
// chart/
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
}
|
|
13163
|
-
|
|
13164
|
-
var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
|
|
13165
|
-
function text(x, y, content, attrs = {}) {
|
|
13166
|
-
const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
|
|
13167
|
-
parts.push(`font-size="${attrs.size ?? FONT_SIZE}"`);
|
|
13168
|
-
parts.push(`fill="${esc(attrs.fill ?? TEXT_COLOR)}"`);
|
|
13169
|
-
if (attrs.anchor && attrs.anchor !== "start") parts.push(`text-anchor="${attrs.anchor}"`);
|
|
13170
|
-
if (attrs.weight) parts.push(`font-weight="${attrs.weight}"`);
|
|
13171
|
-
if (attrs.baseline) parts.push(`dominant-baseline="${attrs.baseline}"`);
|
|
13172
|
-
if (attrs.family) parts.push(`font-family="${esc(attrs.family)}"`);
|
|
13173
|
-
if (attrs.filter) parts.push(`filter="${esc(attrs.filter)}"`);
|
|
13174
|
-
if (attrs.italic !== void 0) parts.push(`font-style="${attrs.italic ? "italic" : "normal"}"`);
|
|
13175
|
-
if (attrs.underline !== void 0)
|
|
13176
|
-
parts.push(`text-decoration="${attrs.underline ? "underline" : "none"}"`);
|
|
13177
|
-
return `<text ${parts.join(" ")}>${esc(content)}</text>`;
|
|
13178
|
-
}
|
|
13179
|
-
var line2 = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
|
|
13180
|
-
var rect2 = (x, y, w, h, fill, filter) => `<rect x="${n(x)}" y="${n(y)}" width="${n(Math.max(0, w))}" height="${n(Math.max(0, h))}" fill="${fill}"${filter ? ` filter="${esc(filter)}"` : ""}/>`;
|
|
13181
|
-
function fit(content, maxWidth, size = FONT_SIZE) {
|
|
13182
|
-
if (textWidth(content, size) <= maxWidth) return content;
|
|
13183
|
-
const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
|
|
13184
|
-
return `${content.slice(0, chars)}\u2026`;
|
|
13185
|
-
}
|
|
13186
|
-
|
|
13187
|
-
// chart/render/chart-spacing.ts
|
|
13188
|
-
function chartBarSpacing(chart) {
|
|
13189
|
-
const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
|
|
13190
|
-
return {
|
|
13191
|
-
barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
|
|
13192
|
-
barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
|
|
13193
|
-
};
|
|
13498
|
+
// chart/funnel-geometry.ts
|
|
13499
|
+
function computeFunnelGeometry(values, plot) {
|
|
13500
|
+
const max = Math.max(...values.map((v) => Math.abs(v)), 1);
|
|
13501
|
+
const height = plot.height / Math.max(1, values.length);
|
|
13502
|
+
const center = plot.x + plot.width / 2;
|
|
13503
|
+
return values.map((value, index) => {
|
|
13504
|
+
const width = Math.abs(value) / max * plot.width;
|
|
13505
|
+
return { index, x: center - width / 2, y: plot.y + index * height, width, height, center };
|
|
13506
|
+
});
|
|
13194
13507
|
}
|
|
13195
13508
|
|
|
13196
13509
|
// chart/render/theme-palette.ts
|
|
@@ -13333,6 +13646,38 @@ function chartAppearance(chart, theme) {
|
|
|
13333
13646
|
return out;
|
|
13334
13647
|
}
|
|
13335
13648
|
|
|
13649
|
+
// chart/render/chart-svg-util.ts
|
|
13650
|
+
var TEXT_COLOR = "#595959";
|
|
13651
|
+
var GRID_COLOR = "#D9D9D9";
|
|
13652
|
+
var AXIS_COLOR = "#BFBFBF";
|
|
13653
|
+
var FONT_SIZE = 10;
|
|
13654
|
+
function esc(text2) {
|
|
13655
|
+
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
13656
|
+
}
|
|
13657
|
+
var n = (value) => String(Math.round(value * 100) / 100);
|
|
13658
|
+
var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
|
|
13659
|
+
function text(x, y, content, attrs = {}) {
|
|
13660
|
+
const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
|
|
13661
|
+
parts.push(`font-size="${attrs.size ?? FONT_SIZE}"`);
|
|
13662
|
+
parts.push(`fill="${esc(attrs.fill ?? TEXT_COLOR)}"`);
|
|
13663
|
+
if (attrs.anchor && attrs.anchor !== "start") parts.push(`text-anchor="${attrs.anchor}"`);
|
|
13664
|
+
if (attrs.weight) parts.push(`font-weight="${attrs.weight}"`);
|
|
13665
|
+
if (attrs.baseline) parts.push(`dominant-baseline="${attrs.baseline}"`);
|
|
13666
|
+
if (attrs.family) parts.push(`font-family="${esc(attrs.family)}"`);
|
|
13667
|
+
if (attrs.filter) parts.push(`filter="${esc(attrs.filter)}"`);
|
|
13668
|
+
if (attrs.italic !== void 0) parts.push(`font-style="${attrs.italic ? "italic" : "normal"}"`);
|
|
13669
|
+
if (attrs.underline !== void 0)
|
|
13670
|
+
parts.push(`text-decoration="${attrs.underline ? "underline" : "none"}"`);
|
|
13671
|
+
return `<text ${parts.join(" ")}>${esc(content)}</text>`;
|
|
13672
|
+
}
|
|
13673
|
+
var line2 = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
|
|
13674
|
+
var rect2 = (x, y, w, h, fill, filter) => `<rect x="${n(x)}" y="${n(y)}" width="${n(Math.max(0, w))}" height="${n(Math.max(0, h))}" fill="${fill}"${filter ? ` filter="${esc(filter)}"` : ""}/>`;
|
|
13675
|
+
function fit(content, maxWidth, size = FONT_SIZE) {
|
|
13676
|
+
if (textWidth(content, size) <= maxWidth) return content;
|
|
13677
|
+
const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
|
|
13678
|
+
return `${content.slice(0, chars)}\u2026`;
|
|
13679
|
+
}
|
|
13680
|
+
|
|
13336
13681
|
// text/css-font-family.ts
|
|
13337
13682
|
var FALLBACKS = {
|
|
13338
13683
|
calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
@@ -13358,9 +13703,9 @@ function chartGradientPaint(model, width = 1024, height = 768) {
|
|
|
13358
13703
|
const defs = [];
|
|
13359
13704
|
const shadowPaint = (shadow, suffix) => {
|
|
13360
13705
|
const id = `${prefix2}-${suffix}`;
|
|
13361
|
-
const
|
|
13706
|
+
const pad2 = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
|
|
13362
13707
|
defs.push(
|
|
13363
|
-
`<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-
|
|
13708
|
+
`<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad2)}" y="${n(-pad2)}" width="${n(width + pad2 * 2)}" height="${n(height + pad2 * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
|
|
13364
13709
|
);
|
|
13365
13710
|
return `url(#${id})`;
|
|
13366
13711
|
};
|
|
@@ -13438,6 +13783,155 @@ function chartAreaRect(model, part, area) {
|
|
|
13438
13783
|
return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
|
|
13439
13784
|
}
|
|
13440
13785
|
|
|
13786
|
+
// chart/render/chart-svg-funnel.ts
|
|
13787
|
+
function funnelSvg(model, area) {
|
|
13788
|
+
const series = model.series[0];
|
|
13789
|
+
if (!series || series.hidden) return "";
|
|
13790
|
+
const attrs = chartTextAttributes(model, "categoryAxis", 10);
|
|
13791
|
+
const width = Math.min(
|
|
13792
|
+
area.w * 0.3,
|
|
13793
|
+
Math.max(32, ...model.categories.map((s) => s.length * (attrs.size ?? 10) * 0.55 + 8))
|
|
13794
|
+
);
|
|
13795
|
+
const plot = { x: area.x + width, y: area.y, width: Math.max(1, area.w - width), height: area.h };
|
|
13796
|
+
const out = [
|
|
13797
|
+
chartAreaRect(model, "plotArea", { x: plot.x, y: plot.y, w: plot.width, h: plot.height })
|
|
13798
|
+
];
|
|
13799
|
+
for (const bar of computeFunnelGeometry(
|
|
13800
|
+
series.values.map((v) => v ?? 0),
|
|
13801
|
+
plot
|
|
13802
|
+
)) {
|
|
13803
|
+
const value = series.values[bar.index];
|
|
13804
|
+
if (value === null || value === void 0) continue;
|
|
13805
|
+
out.push(`<g data-chart-series="${series.sourceIndex ?? 0}" data-chart-point="${bar.index}">`);
|
|
13806
|
+
out.push(
|
|
13807
|
+
rect2(bar.x, bar.y, bar.width, bar.height, series.pointColors?.[bar.index] ?? series.color)
|
|
13808
|
+
);
|
|
13809
|
+
const size = Math.min(10, bar.height * 0.4);
|
|
13810
|
+
const label = series.labels?.[bar.index];
|
|
13811
|
+
if (label)
|
|
13812
|
+
out.push(
|
|
13813
|
+
text(bar.center, bar.y + bar.height / 2 + size * 0.35, label.text, {
|
|
13814
|
+
...chartTextAttributes(model, "dataLabel", size),
|
|
13815
|
+
size,
|
|
13816
|
+
anchor: "middle"
|
|
13817
|
+
})
|
|
13818
|
+
);
|
|
13819
|
+
out.push(
|
|
13820
|
+
text(
|
|
13821
|
+
plot.x - 8,
|
|
13822
|
+
bar.y + bar.height / 2 + (attrs.size ?? 10) * 0.35,
|
|
13823
|
+
fit(model.categories[bar.index] ?? "", width - 8, attrs.size ?? 10),
|
|
13824
|
+
{ ...attrs, anchor: "end" }
|
|
13825
|
+
)
|
|
13826
|
+
);
|
|
13827
|
+
out.push("</g>");
|
|
13828
|
+
}
|
|
13829
|
+
return out.join("");
|
|
13830
|
+
}
|
|
13831
|
+
|
|
13832
|
+
// chart/box-distribution.ts
|
|
13833
|
+
function boxWhiskerDistribution(values, method = "exclusive", trimOutliers = false) {
|
|
13834
|
+
const stats = computeBoxStats(values, method);
|
|
13835
|
+
if (!stats) return void 0;
|
|
13836
|
+
const iqr = stats.q3 - stats.q1;
|
|
13837
|
+
const lowerFence = stats.q1 - 1.5 * iqr;
|
|
13838
|
+
const upperFence = stats.q3 + 1.5 * iqr;
|
|
13839
|
+
const inliers = values.filter((v) => !trimOutliers || v >= lowerFence && v <= upperFence);
|
|
13840
|
+
return {
|
|
13841
|
+
stats,
|
|
13842
|
+
whiskerMin: inliers.length ? Math.min(...inliers) : stats.min,
|
|
13843
|
+
whiskerMax: inliers.length ? Math.max(...inliers) : stats.max,
|
|
13844
|
+
mean: values.reduce((a, b) => a + b, 0) / values.length
|
|
13845
|
+
};
|
|
13846
|
+
}
|
|
13847
|
+
function boxMeanMarkerPath(x, y, radius = 3) {
|
|
13848
|
+
return `M${x - radius},${y - radius} L${x + radius},${y + radius} M${x - radius},${y + radius} L${x + radius},${y - radius}`;
|
|
13849
|
+
}
|
|
13850
|
+
|
|
13851
|
+
// chart/render/chart-svg-box.ts
|
|
13852
|
+
function boxWhiskerSvg(model, frame2, out) {
|
|
13853
|
+
const visible = model.series.filter((s) => !s.hidden);
|
|
13854
|
+
const slot = frame2.bandSize / Math.max(1, visible.length);
|
|
13855
|
+
const width = slot * 0.7;
|
|
13856
|
+
visible.forEach((series, si) => {
|
|
13857
|
+
if (series.hidden) return;
|
|
13858
|
+
const groups = groupRowsByCategory(series.boxCategories ?? []);
|
|
13859
|
+
model.categories.forEach((category, ci) => {
|
|
13860
|
+
const observations = (groups.rowIndexesByCategory.get(category) ?? []).flatMap((row2) => {
|
|
13861
|
+
const value = series.values[row2];
|
|
13862
|
+
return value === null || value === void 0 ? [] : [{ row: row2, value }];
|
|
13863
|
+
});
|
|
13864
|
+
const options2 = series.boxWhisker;
|
|
13865
|
+
const rawMethod = options2?.statistics?.quartileMethod;
|
|
13866
|
+
const method = rawMethod === "inclusive" ? "inclusive" : "exclusive";
|
|
13867
|
+
const visibility = options2?.visibility;
|
|
13868
|
+
const trim = rawMethod === "inclusive" || rawMethod === "exclusive" || !!visibility && Object.values(visibility).some((v) => v !== void 0);
|
|
13869
|
+
const distribution = boxWhiskerDistribution(
|
|
13870
|
+
observations.map((p) => p.value),
|
|
13871
|
+
method,
|
|
13872
|
+
trim
|
|
13873
|
+
);
|
|
13874
|
+
if (!distribution) return;
|
|
13875
|
+
const { stats, whiskerMin, whiskerMax, mean } = distribution;
|
|
13876
|
+
const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot + (slot - width) / 2;
|
|
13877
|
+
const mid = x + width / 2;
|
|
13878
|
+
const y = frame2.value;
|
|
13879
|
+
out.push(
|
|
13880
|
+
`<g data-chart-part="box" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${ci}">`
|
|
13881
|
+
);
|
|
13882
|
+
out.push(line2(mid, y(whiskerMax), mid, y(stats.q3), "#64748b", 1));
|
|
13883
|
+
out.push(line2(mid, y(stats.q1), mid, y(whiskerMin), "#64748b", 1));
|
|
13884
|
+
out.push(
|
|
13885
|
+
line2(x + width * 0.25, y(whiskerMin), x + width * 0.75, y(whiskerMin), "#64748b", 1)
|
|
13886
|
+
);
|
|
13887
|
+
out.push(
|
|
13888
|
+
line2(x + width * 0.25, y(whiskerMax), x + width * 0.75, y(whiskerMax), "#64748b", 1)
|
|
13889
|
+
);
|
|
13890
|
+
out.push(
|
|
13891
|
+
rect2(
|
|
13892
|
+
x,
|
|
13893
|
+
Math.min(y(stats.q1), y(stats.q3)),
|
|
13894
|
+
width,
|
|
13895
|
+
Math.abs(y(stats.q1) - y(stats.q3)),
|
|
13896
|
+
series.pointColors?.[ci] ?? series.color
|
|
13897
|
+
)
|
|
13898
|
+
);
|
|
13899
|
+
out.push(line2(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
|
|
13900
|
+
if (visibility?.meanLine) out.push(line2(x, y(mean), x + width, y(mean), "#0f766e", 1.5));
|
|
13901
|
+
if (visibility?.meanMarker !== false)
|
|
13902
|
+
out.push(
|
|
13903
|
+
`<path d="${boxMeanMarkerPath(mid, y(mean))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
|
|
13904
|
+
);
|
|
13905
|
+
observations.forEach((point, index) => {
|
|
13906
|
+
const outlier = point.value < whiskerMin || point.value > whiskerMax;
|
|
13907
|
+
if (outlier ? !visibility?.outliers : !visibility?.nonoutliers) return;
|
|
13908
|
+
const px = x + width * (0.2 + 0.6 * (index + 1) / (observations.length + 1));
|
|
13909
|
+
out.push(
|
|
13910
|
+
`<circle cx="${n(px)}" cy="${n(y(point.value))}" r="2.25" fill="${outlier ? "#dc2626" : "#1e293b"}" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${point.row}" data-chart-part="${outlier ? "outlier" : "observation"}"/>`
|
|
13911
|
+
);
|
|
13912
|
+
});
|
|
13913
|
+
out.push("</g>");
|
|
13914
|
+
});
|
|
13915
|
+
});
|
|
13916
|
+
}
|
|
13917
|
+
|
|
13918
|
+
// chart/data-table-layout.ts
|
|
13919
|
+
function chartDataTableMetrics(fontSize, names, showKeys = true) {
|
|
13920
|
+
const rowH = Math.max(14, Math.round(fontSize * 1.45));
|
|
13921
|
+
const longestName = names.reduce((m, name) => Math.max(m, name.length), 0);
|
|
13922
|
+
const keyW = Math.min(160, Math.max(40, longestName * fontSize * 0.55 + (showKeys ? 24 : 8)));
|
|
13923
|
+
return { fontSize, rowH, keyW, height: rowH * (1 + names.length) };
|
|
13924
|
+
}
|
|
13925
|
+
|
|
13926
|
+
// chart/render/chart-spacing.ts
|
|
13927
|
+
function chartBarSpacing(chart) {
|
|
13928
|
+
const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
|
|
13929
|
+
return {
|
|
13930
|
+
barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
|
|
13931
|
+
barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
|
|
13932
|
+
};
|
|
13933
|
+
}
|
|
13934
|
+
|
|
13441
13935
|
// chart/render/chart-svg-labels.ts
|
|
13442
13936
|
var GAP = 3;
|
|
13443
13937
|
var LINE = 1.2;
|
|
@@ -13447,6 +13941,7 @@ function measure(model, label) {
|
|
|
13447
13941
|
const size = attrs.size ?? 10;
|
|
13448
13942
|
const lines = label.text.split("\n");
|
|
13449
13943
|
return {
|
|
13944
|
+
...model.frameSize ? { frame: model.frameSize } : {},
|
|
13450
13945
|
lines,
|
|
13451
13946
|
size,
|
|
13452
13947
|
w: Math.max(...lines.map((l) => textWidth(l, size))),
|
|
@@ -13455,6 +13950,7 @@ function measure(model, label) {
|
|
|
13455
13950
|
};
|
|
13456
13951
|
}
|
|
13457
13952
|
function draw(m, label, x, y, anchor, out) {
|
|
13953
|
+
if (m.frame) ({ x, y } = applyLabelManualLayout(label.layout, m.frame, { x, y }));
|
|
13458
13954
|
const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
|
|
13459
13955
|
m.lines.forEach((line3, k) => {
|
|
13460
13956
|
const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
|
|
@@ -13514,46 +14010,6 @@ function pointLabels(model, marks, out) {
|
|
|
13514
14010
|
}
|
|
13515
14011
|
}
|
|
13516
14012
|
}
|
|
13517
|
-
function sliceLabels(model, marks, out) {
|
|
13518
|
-
for (const mark of marks) {
|
|
13519
|
-
const label = mark.series.labels?.[mark.index];
|
|
13520
|
-
if (!label) continue;
|
|
13521
|
-
const m = measure(model, label);
|
|
13522
|
-
const mid = (mark.start + mark.end) / 2;
|
|
13523
|
-
const ux = Math.sin(mid);
|
|
13524
|
-
const uy = -Math.cos(mid);
|
|
13525
|
-
const place2 = (radius) => [
|
|
13526
|
-
mark.cx + radius * ux,
|
|
13527
|
-
mark.cy + radius * uy
|
|
13528
|
-
];
|
|
13529
|
-
const position = model.type === "doughnut" ? "ctr" : label.position ?? "bestFit";
|
|
13530
|
-
let x;
|
|
13531
|
-
let y;
|
|
13532
|
-
if (position === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
|
|
13533
|
-
else if (position === "inEnd") {
|
|
13534
|
-
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
13535
|
-
[x, y] = place2(Math.max(0, mark.outer - GAP - extent));
|
|
13536
|
-
} else if (position === "outEnd") {
|
|
13537
|
-
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
13538
|
-
[x, y] = place2(mark.outer + GAP + extent);
|
|
13539
|
-
} else {
|
|
13540
|
-
const placed2 = placeBestFitLabel(
|
|
13541
|
-
{
|
|
13542
|
-
cx: mark.cx,
|
|
13543
|
-
cy: mark.cy,
|
|
13544
|
-
outerR: mark.outer,
|
|
13545
|
-
startAngle: mark.start - Math.PI / 2,
|
|
13546
|
-
endAngle: mark.end - Math.PI / 2
|
|
13547
|
-
},
|
|
13548
|
-
m.w,
|
|
13549
|
-
m.h
|
|
13550
|
-
);
|
|
13551
|
-
x = placed2.x;
|
|
13552
|
-
y = placed2.y;
|
|
13553
|
-
}
|
|
13554
|
-
draw(m, label, x, y, "middle", out);
|
|
13555
|
-
}
|
|
13556
|
-
}
|
|
13557
14013
|
function hasOutsideLabels(model) {
|
|
13558
14014
|
return model.series.some(
|
|
13559
14015
|
(s) => s.labels?.some(
|
|
@@ -13579,7 +14035,8 @@ function bars(model, frame2, out, values) {
|
|
|
13579
14035
|
const marks = [];
|
|
13580
14036
|
model.series.forEach((s, si) => {
|
|
13581
14037
|
values[si]?.forEach((v, i) => {
|
|
13582
|
-
if (v === null || i >= model.categories.length)
|
|
14038
|
+
if (v === null || i >= model.categories.length || frame2.order && !frame2.order.includes(i))
|
|
14039
|
+
return;
|
|
13583
14040
|
let from = 0;
|
|
13584
14041
|
let to = v;
|
|
13585
14042
|
if (stacked) {
|
|
@@ -13705,6 +14162,476 @@ function scatterAnalysis(model, px, py, out) {
|
|
|
13705
14162
|
});
|
|
13706
14163
|
}
|
|
13707
14164
|
|
|
14165
|
+
// chart/render/chart-scale.ts
|
|
14166
|
+
var clean = (n2) => Number(n2.toPrecision(12));
|
|
14167
|
+
function* units(raw) {
|
|
14168
|
+
let exp = Math.floor(Math.log10(raw)) - 1;
|
|
14169
|
+
for (; ; ) {
|
|
14170
|
+
const base = 10 ** exp;
|
|
14171
|
+
for (const m of [1, 2, 5]) yield clean(m * base);
|
|
14172
|
+
exp++;
|
|
14173
|
+
}
|
|
14174
|
+
}
|
|
14175
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
14176
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
14177
|
+
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
14178
|
+
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
14179
|
+
if (lo > hi) [lo, hi] = [hi, lo];
|
|
14180
|
+
if (lo === hi) {
|
|
14181
|
+
if (lo === 0) hi = 1;
|
|
14182
|
+
else if (options2.noZero) {
|
|
14183
|
+
const pad2 = Math.abs(lo) * 0.1 || 1;
|
|
14184
|
+
lo -= pad2;
|
|
14185
|
+
hi += pad2;
|
|
14186
|
+
} else if (lo > 0) lo = 0;
|
|
14187
|
+
else hi = 0;
|
|
14188
|
+
}
|
|
14189
|
+
let fixedLo = false;
|
|
14190
|
+
let fixedHi = false;
|
|
14191
|
+
if (!options2.noZero) {
|
|
14192
|
+
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
14193
|
+
lo = 0;
|
|
14194
|
+
fixedLo = true;
|
|
14195
|
+
} else if (hi <= 0 && hi - lo >= -lo / 6) {
|
|
14196
|
+
hi = 0;
|
|
14197
|
+
fixedHi = true;
|
|
14198
|
+
}
|
|
14199
|
+
}
|
|
14200
|
+
const range = hi - lo;
|
|
14201
|
+
const top = fixedHi ? hi : hi + range * 0.05;
|
|
14202
|
+
const bottom = fixedLo ? lo : lo - range * 0.05;
|
|
14203
|
+
for (const unit of units(range / maxIntervals)) {
|
|
14204
|
+
const min = fixedLo ? lo : Math.floor(clean(bottom / unit)) * unit;
|
|
14205
|
+
const max = fixedHi ? hi : Math.ceil(clean(top / unit)) * unit;
|
|
14206
|
+
const intervals = Math.round((max - min) / unit);
|
|
14207
|
+
if (intervals <= maxIntervals && intervals > 0) {
|
|
14208
|
+
const ticks = [];
|
|
14209
|
+
for (let i = 0; i <= intervals; i++) ticks.push(clean(min + i * unit));
|
|
14210
|
+
return { min: clean(min), max: clean(max), majorUnit: unit, ticks };
|
|
14211
|
+
}
|
|
14212
|
+
}
|
|
14213
|
+
return { min: lo, max: hi, majorUnit: range, ticks: [lo, hi] };
|
|
14214
|
+
}
|
|
14215
|
+
var PERCENT_SCALE = {
|
|
14216
|
+
min: 0,
|
|
14217
|
+
max: 1,
|
|
14218
|
+
majorUnit: 0.1,
|
|
14219
|
+
ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
|
14220
|
+
};
|
|
14221
|
+
function formatAxisValue(value, percent = false) {
|
|
14222
|
+
if (percent) return `${clean(value * 100)}%`;
|
|
14223
|
+
const v = clean(value);
|
|
14224
|
+
if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
|
|
14225
|
+
return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
|
|
14226
|
+
const [int = "0", frac] = String(Math.abs(v)).split(".");
|
|
14227
|
+
const grouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
14228
|
+
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
14229
|
+
}
|
|
14230
|
+
|
|
14231
|
+
// chart/render/chart-svg-data-table.ts
|
|
14232
|
+
var rows = (model) => [
|
|
14233
|
+
...model.series,
|
|
14234
|
+
...(model.extraGroups ?? []).flatMap((g) => g.series)
|
|
14235
|
+
];
|
|
14236
|
+
function chartTableMetrics(model) {
|
|
14237
|
+
if (!model.dataTable) return void 0;
|
|
14238
|
+
const size = model.dataTable.text?.fontSize;
|
|
14239
|
+
return chartDataTableMetrics(
|
|
14240
|
+
size === void 0 ? 13.333333333333334 : chartPointsToPixels(size),
|
|
14241
|
+
rows(model).map((s) => s.name),
|
|
14242
|
+
model.dataTable.source.showKeys !== false
|
|
14243
|
+
);
|
|
14244
|
+
}
|
|
14245
|
+
function chartDataTableSvg(model, plot) {
|
|
14246
|
+
const table = model.dataTable;
|
|
14247
|
+
const metrics = chartTableMetrics(model);
|
|
14248
|
+
if (!table || !metrics) return "";
|
|
14249
|
+
const { source } = table;
|
|
14250
|
+
const { rowH, keyW, height, fontSize } = metrics;
|
|
14251
|
+
const series = rows(model);
|
|
14252
|
+
const top = plot.y + plot.h;
|
|
14253
|
+
const left = plot.x - keyW;
|
|
14254
|
+
const right = plot.x + plot.w;
|
|
14255
|
+
const bottom = top + height;
|
|
14256
|
+
const cellW = plot.w / Math.max(1, model.categories.length);
|
|
14257
|
+
const styled = { ...model, appearance: { ...model.appearance, dataLabel: table.text ?? {} } };
|
|
14258
|
+
const attrs = chartTextAttributes(styled, "dataLabel", fontSize);
|
|
14259
|
+
const out = ['<g data-chart-part="dataTable">'];
|
|
14260
|
+
const border2 = (x1, y1, x2, y2) => out.push(
|
|
14261
|
+
`<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" ${strokeAttributes(table.stroke)}/>`
|
|
14262
|
+
);
|
|
14263
|
+
const label = (x, y, value, width, anchor = "middle") => out.push(
|
|
14264
|
+
text(x, y + fontSize * 0.35, fit(value, Math.max(1, width), fontSize), { ...attrs, anchor })
|
|
14265
|
+
);
|
|
14266
|
+
if (table.fill) out.push(rect2(left, top, right - left, height, table.fill));
|
|
14267
|
+
if (source.showOutline !== false) {
|
|
14268
|
+
border2(plot.x, top, right, top);
|
|
14269
|
+
border2(right, top, right, bottom);
|
|
14270
|
+
border2(right, bottom, left, bottom);
|
|
14271
|
+
border2(left, bottom, left, top + rowH);
|
|
14272
|
+
border2(left, top + rowH, plot.x, top + rowH);
|
|
14273
|
+
border2(plot.x, top, plot.x, top + rowH);
|
|
14274
|
+
}
|
|
14275
|
+
model.categories.forEach((category, i) => {
|
|
14276
|
+
label(plot.x + (i + 0.5) * cellW, top + rowH / 2, category, cellW - 4);
|
|
14277
|
+
if (source.showVerticalBorder !== false && i > 0)
|
|
14278
|
+
border2(plot.x + i * cellW, top, plot.x + i * cellW, bottom);
|
|
14279
|
+
});
|
|
14280
|
+
if (source.showVerticalBorder !== false) border2(plot.x, top, plot.x, bottom);
|
|
14281
|
+
series.forEach((s, i) => {
|
|
14282
|
+
const rowTop = top + rowH * (i + 1);
|
|
14283
|
+
const cy = rowTop + rowH / 2;
|
|
14284
|
+
if (source.showHorizontalBorder !== false) border2(left, rowTop, right, rowTop);
|
|
14285
|
+
if (source.showKeys !== false) {
|
|
14286
|
+
const swatch = Math.max(6, Math.round(fontSize * 0.55));
|
|
14287
|
+
out.push(rect2(left + 4, cy - swatch / 2, swatch, swatch, s.color));
|
|
14288
|
+
}
|
|
14289
|
+
const keyInset = source.showKeys !== false ? Math.max(6, Math.round(fontSize * 0.55)) + 7 : 4;
|
|
14290
|
+
label(left + keyInset, cy, s.name, keyW - keyInset - 4, "start");
|
|
14291
|
+
model.categories.forEach((_, j) => {
|
|
14292
|
+
const value = s.values[j];
|
|
14293
|
+
const formatted = value === null || value === void 0 ? "" : formatChartNumber(value, s.numberFormat) ?? formatAxisValue(value);
|
|
14294
|
+
label(plot.x + (j + 0.5) * cellW, cy, formatted, cellW - 4);
|
|
14295
|
+
});
|
|
14296
|
+
});
|
|
14297
|
+
return out.join("") + "</g>";
|
|
14298
|
+
}
|
|
14299
|
+
|
|
14300
|
+
// chart/date-axis.ts
|
|
14301
|
+
var DAY_MS = 864e5;
|
|
14302
|
+
function excelSerialToDate(serial, date1904 = false) {
|
|
14303
|
+
const epoch = date1904 ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, serial < 60 ? 31 : 30);
|
|
14304
|
+
return new Date(epoch + serial * DAY_MS);
|
|
14305
|
+
}
|
|
14306
|
+
function addUnit(date, amount, unit) {
|
|
14307
|
+
const next = new Date(date);
|
|
14308
|
+
if (unit === "days") {
|
|
14309
|
+
next.setUTCDate(next.getUTCDate() + amount);
|
|
14310
|
+
} else if (unit === "months") {
|
|
14311
|
+
next.setUTCMonth(next.getUTCMonth() + amount);
|
|
14312
|
+
} else {
|
|
14313
|
+
next.setUTCFullYear(next.getUTCFullYear() + amount);
|
|
14314
|
+
}
|
|
14315
|
+
return next;
|
|
14316
|
+
}
|
|
14317
|
+
function calendarTicks(min, max, date1904, unit, step) {
|
|
14318
|
+
const result = [];
|
|
14319
|
+
let date = excelSerialToDate(min, date1904);
|
|
14320
|
+
for (let guard = 0; guard < 1e3 && date.getTime() <= excelSerialToDate(max, date1904).getTime(); guard++) {
|
|
14321
|
+
result.push(min + (date.getTime() - excelSerialToDate(min, date1904).getTime()) / DAY_MS);
|
|
14322
|
+
date = addUnit(date, step, unit);
|
|
14323
|
+
}
|
|
14324
|
+
return result;
|
|
14325
|
+
}
|
|
14326
|
+
|
|
14327
|
+
// chart/date-format.ts
|
|
14328
|
+
var MONTH_ABBR = [
|
|
14329
|
+
"Jan",
|
|
14330
|
+
"Feb",
|
|
14331
|
+
"Mar",
|
|
14332
|
+
"Apr",
|
|
14333
|
+
"May",
|
|
14334
|
+
"Jun",
|
|
14335
|
+
"Jul",
|
|
14336
|
+
"Aug",
|
|
14337
|
+
"Sep",
|
|
14338
|
+
"Oct",
|
|
14339
|
+
"Nov",
|
|
14340
|
+
"Dec"
|
|
14341
|
+
];
|
|
14342
|
+
var MONTH_FULL = [
|
|
14343
|
+
"January",
|
|
14344
|
+
"February",
|
|
14345
|
+
"March",
|
|
14346
|
+
"April",
|
|
14347
|
+
"May",
|
|
14348
|
+
"June",
|
|
14349
|
+
"July",
|
|
14350
|
+
"August",
|
|
14351
|
+
"September",
|
|
14352
|
+
"October",
|
|
14353
|
+
"November",
|
|
14354
|
+
"December"
|
|
14355
|
+
];
|
|
14356
|
+
var WEEKDAY_ABBR = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
14357
|
+
var WEEKDAY_FULL = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
14358
|
+
function scanDateFormatTokens(code) {
|
|
14359
|
+
const tokens = [];
|
|
14360
|
+
let i = 0;
|
|
14361
|
+
while (i < code.length) {
|
|
14362
|
+
const ch = code[i];
|
|
14363
|
+
if (ch === '"') {
|
|
14364
|
+
const close = code.indexOf('"', i + 1);
|
|
14365
|
+
tokens.push({
|
|
14366
|
+
kind: "literal",
|
|
14367
|
+
text: close === -1 ? code.slice(i + 1) : code.slice(i + 1, close)
|
|
14368
|
+
});
|
|
14369
|
+
i = close === -1 ? code.length : close + 1;
|
|
14370
|
+
continue;
|
|
14371
|
+
}
|
|
14372
|
+
if (ch === "\\") {
|
|
14373
|
+
tokens.push({ kind: "literal", text: code[i + 1] ?? "" });
|
|
14374
|
+
i += 2;
|
|
14375
|
+
continue;
|
|
14376
|
+
}
|
|
14377
|
+
const rest = code.slice(i);
|
|
14378
|
+
if (/^am\/pm/iu.test(rest)) {
|
|
14379
|
+
tokens.push({ kind: "ampm", upper: ch === ch.toUpperCase(), short: false });
|
|
14380
|
+
i += 5;
|
|
14381
|
+
continue;
|
|
14382
|
+
}
|
|
14383
|
+
if (/^a\/p/iu.test(rest)) {
|
|
14384
|
+
tokens.push({ kind: "ampm", upper: ch === ch.toUpperCase(), short: true });
|
|
14385
|
+
i += 3;
|
|
14386
|
+
continue;
|
|
14387
|
+
}
|
|
14388
|
+
if (/[ymdhs]/iu.test(ch)) {
|
|
14389
|
+
let j = i + 1;
|
|
14390
|
+
while (j < code.length && code[j].toLowerCase() === ch.toLowerCase()) {
|
|
14391
|
+
j += 1;
|
|
14392
|
+
}
|
|
14393
|
+
tokens.push({
|
|
14394
|
+
kind: "letters",
|
|
14395
|
+
letter: ch.toLowerCase(),
|
|
14396
|
+
count: j - i
|
|
14397
|
+
});
|
|
14398
|
+
i = j;
|
|
14399
|
+
continue;
|
|
14400
|
+
}
|
|
14401
|
+
tokens.push({ kind: "literal", text: ch });
|
|
14402
|
+
i += 1;
|
|
14403
|
+
}
|
|
14404
|
+
return tokens;
|
|
14405
|
+
}
|
|
14406
|
+
function findNonLiteral(tokens, index, step) {
|
|
14407
|
+
for (let i = index + step; i >= 0 && i < tokens.length; i += step) {
|
|
14408
|
+
if (tokens[i].kind !== "literal") {
|
|
14409
|
+
return tokens[i];
|
|
14410
|
+
}
|
|
14411
|
+
}
|
|
14412
|
+
return void 0;
|
|
14413
|
+
}
|
|
14414
|
+
function pad(n2, width) {
|
|
14415
|
+
return String(n2).padStart(width, "0");
|
|
14416
|
+
}
|
|
14417
|
+
function renderDatePart(part, count, date, twelveHour) {
|
|
14418
|
+
switch (part) {
|
|
14419
|
+
case "year":
|
|
14420
|
+
return count >= 4 ? pad(date.getUTCFullYear(), 4) : pad(date.getUTCFullYear() % 100, 2);
|
|
14421
|
+
case "month":
|
|
14422
|
+
if (count >= 4) {
|
|
14423
|
+
return MONTH_FULL[date.getUTCMonth()] ?? "";
|
|
14424
|
+
}
|
|
14425
|
+
if (count === 3) {
|
|
14426
|
+
return MONTH_ABBR[date.getUTCMonth()] ?? "";
|
|
14427
|
+
}
|
|
14428
|
+
return count >= 2 ? pad(date.getUTCMonth() + 1, 2) : String(date.getUTCMonth() + 1);
|
|
14429
|
+
case "day":
|
|
14430
|
+
if (count >= 4) {
|
|
14431
|
+
return WEEKDAY_FULL[date.getUTCDay()] ?? "";
|
|
14432
|
+
}
|
|
14433
|
+
if (count === 3) {
|
|
14434
|
+
return WEEKDAY_ABBR[date.getUTCDay()] ?? "";
|
|
14435
|
+
}
|
|
14436
|
+
return count >= 2 ? pad(date.getUTCDate(), 2) : String(date.getUTCDate());
|
|
14437
|
+
case "hour": {
|
|
14438
|
+
const h24 = date.getUTCHours();
|
|
14439
|
+
const h = twelveHour ? h24 % 12 === 0 ? 12 : h24 % 12 : h24;
|
|
14440
|
+
return count >= 2 ? pad(h, 2) : String(h);
|
|
14441
|
+
}
|
|
14442
|
+
case "minute":
|
|
14443
|
+
return count >= 2 ? pad(date.getUTCMinutes(), 2) : String(date.getUTCMinutes());
|
|
14444
|
+
case "second":
|
|
14445
|
+
return count >= 2 ? pad(date.getUTCSeconds(), 2) : String(date.getUTCSeconds());
|
|
14446
|
+
}
|
|
14447
|
+
}
|
|
14448
|
+
function renderExcelDateFormat(date, code) {
|
|
14449
|
+
const tokens = scanDateFormatTokens(code);
|
|
14450
|
+
const hasAmPm = tokens.some((t) => t.kind === "ampm");
|
|
14451
|
+
let out = "";
|
|
14452
|
+
for (const [index, token] of tokens.entries()) {
|
|
14453
|
+
if (token.kind === "literal") {
|
|
14454
|
+
out += token.text;
|
|
14455
|
+
continue;
|
|
14456
|
+
}
|
|
14457
|
+
if (token.kind === "ampm") {
|
|
14458
|
+
const hour = date.getUTCHours(), text2 = token.short ? hour < 12 ? "A" : "P" : hour < 12 ? "AM" : "PM";
|
|
14459
|
+
out += token.upper ? text2 : text2.toLowerCase();
|
|
14460
|
+
continue;
|
|
14461
|
+
}
|
|
14462
|
+
if (token.letter === "m") {
|
|
14463
|
+
const prev = findNonLiteral(tokens, index, -1), next = findNonLiteral(tokens, index, 1), isMinute = prev?.kind === "letters" && prev.letter === "h" || next?.kind === "letters" && next.letter === "s";
|
|
14464
|
+
out += renderDatePart(isMinute ? "minute" : "month", token.count, date, hasAmPm);
|
|
14465
|
+
continue;
|
|
14466
|
+
}
|
|
14467
|
+
const part = { y: "year", d: "day", h: "hour", s: "second" };
|
|
14468
|
+
out += renderDatePart(part[token.letter], token.count, date, hasAmPm);
|
|
14469
|
+
}
|
|
14470
|
+
return out;
|
|
14471
|
+
}
|
|
14472
|
+
function formatDate(date, unit, format) {
|
|
14473
|
+
if (format && /[ymdhs]/iu.test(format)) {
|
|
14474
|
+
const rendered = renderExcelDateFormat(date, format);
|
|
14475
|
+
if (rendered.length > 0) {
|
|
14476
|
+
return rendered;
|
|
14477
|
+
}
|
|
14478
|
+
}
|
|
14479
|
+
const month = date.toLocaleString("en-US", { month: "short", timeZone: "UTC" }), year = String(date.getUTCFullYear()), day = String(date.getUTCDate());
|
|
14480
|
+
if (unit === "years") {
|
|
14481
|
+
return year;
|
|
14482
|
+
}
|
|
14483
|
+
if (unit === "months") {
|
|
14484
|
+
return `${month} ${year}`;
|
|
14485
|
+
}
|
|
14486
|
+
return `${day} ${month}`;
|
|
14487
|
+
}
|
|
14488
|
+
|
|
14489
|
+
// chart/render/chart-svg-date-axis.ts
|
|
14490
|
+
function chartDateAxis(model, plot, out) {
|
|
14491
|
+
const axis = model.axes?.category?.source;
|
|
14492
|
+
const values = model.dateCategories;
|
|
14493
|
+
if (axis?.kind !== "date" || !values?.length) return void 0;
|
|
14494
|
+
const points = values.flatMap(
|
|
14495
|
+
(value, index) => value === null || !Number.isFinite(value) ? [] : [{ value, index }]
|
|
14496
|
+
).sort((a, b) => a.value - b.value);
|
|
14497
|
+
if (!points.length) return void 0;
|
|
14498
|
+
const min = axis.scaling.min ?? points[0].value;
|
|
14499
|
+
const max = axis.scaling.max ?? points.at(-1).value;
|
|
14500
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || max < min) return void 0;
|
|
14501
|
+
const position = (value) => {
|
|
14502
|
+
const ratio = max === min ? 0.5 : (value - min) / (max - min);
|
|
14503
|
+
const t = axis.scaling.orientation === "maxMin" ? 1 - ratio : ratio;
|
|
14504
|
+
return model.horizontal ? plot.y + plot.h * (1 - t) : plot.x + plot.w * t;
|
|
14505
|
+
};
|
|
14506
|
+
const visible = points.filter((p) => p.value >= min && p.value <= max);
|
|
14507
|
+
const unitOf = (unit2) => unit2 === "months" || unit2 === "years" ? unit2 : "days";
|
|
14508
|
+
const unit = unitOf(axis.majorTimeUnit ?? axis.baseTimeUnit);
|
|
14509
|
+
const ticks = calendarTicks(
|
|
14510
|
+
min,
|
|
14511
|
+
max,
|
|
14512
|
+
model.date1904 ?? false,
|
|
14513
|
+
unit,
|
|
14514
|
+
Math.max(1, axis.majorUnit ?? 1)
|
|
14515
|
+
);
|
|
14516
|
+
const attrs = chartTextAttributes(model, "categoryAxis");
|
|
14517
|
+
const size = attrs.size ?? 10;
|
|
14518
|
+
const y = axis.position === "t" ? plot.y : plot.y + plot.h;
|
|
14519
|
+
const paint2 = model.axes?.category?.line;
|
|
14520
|
+
const stroke = { color: paint2?.color ?? "#BFBFBF", width: paint2?.width ?? 1 };
|
|
14521
|
+
const mark = (serial, placement, length) => {
|
|
14522
|
+
if (!placement || placement === "none" || axis.deleted) return;
|
|
14523
|
+
const inward = axis.position === "t" ? length : -length;
|
|
14524
|
+
const start = placement === "cross" ? -length : 0;
|
|
14525
|
+
const end = placement === "cross" ? length : placement === "in" ? inward : -inward;
|
|
14526
|
+
if (model.horizontal) {
|
|
14527
|
+
const x = axis.position === "r" ? plot.x + plot.w : plot.x;
|
|
14528
|
+
const direction = axis.position === "r" ? -1 : 1;
|
|
14529
|
+
const a = placement === "cross" ? -length : 0;
|
|
14530
|
+
const b = placement === "cross" ? length : placement === "in" ? direction * length : -direction * length;
|
|
14531
|
+
out.push(
|
|
14532
|
+
`<line x1="${x + a}" y1="${position(serial)}" x2="${x + b}" y2="${position(serial)}" ${strokeAttributes(stroke)} data-chart-part="dateTick"/>`
|
|
14533
|
+
);
|
|
14534
|
+
} else
|
|
14535
|
+
out.push(
|
|
14536
|
+
`<line x1="${position(serial)}" y1="${y + start}" x2="${position(serial)}" y2="${y + end}" ${strokeAttributes(stroke)} data-chart-part="dateTick"/>`
|
|
14537
|
+
);
|
|
14538
|
+
};
|
|
14539
|
+
ticks.forEach((serial, index) => {
|
|
14540
|
+
if (index % Math.max(1, axis.tickMarkSkip ?? 1) === 0) mark(serial, axis.majorTickMark, 4);
|
|
14541
|
+
if (axis.deleted || model.dataTable || axis.tickLabelPosition === "none" || index % Math.max(1, axis.tickLabelSkip ?? 1))
|
|
14542
|
+
return;
|
|
14543
|
+
const label = formatDate(
|
|
14544
|
+
excelSerialToDate(serial, model.date1904),
|
|
14545
|
+
unit,
|
|
14546
|
+
axis.numberFormat?.formatCode
|
|
14547
|
+
);
|
|
14548
|
+
if (model.horizontal)
|
|
14549
|
+
out.push(text(plot.x - 4, position(serial) + size * 0.3, label, { ...attrs, anchor: "end" }));
|
|
14550
|
+
else {
|
|
14551
|
+
const above2 = axis.tickLabelPosition === "high" || axis.tickLabelPosition !== "low" && axis.position === "t";
|
|
14552
|
+
const baseline = axis.tickLabelPosition === "high" ? plot.y : axis.tickLabelPosition === "low" ? plot.y + plot.h : y;
|
|
14553
|
+
out.push(
|
|
14554
|
+
text(position(serial), baseline + (above2 ? -4 : size + 3), label, {
|
|
14555
|
+
...attrs,
|
|
14556
|
+
anchor: "middle"
|
|
14557
|
+
})
|
|
14558
|
+
);
|
|
14559
|
+
}
|
|
14560
|
+
});
|
|
14561
|
+
if (axis.minorTickMark && axis.minorTickMark !== "none")
|
|
14562
|
+
for (const serial of calendarTicks(
|
|
14563
|
+
min,
|
|
14564
|
+
max,
|
|
14565
|
+
model.date1904 ?? false,
|
|
14566
|
+
unitOf(axis.minorTimeUnit ?? axis.baseTimeUnit ?? unit),
|
|
14567
|
+
Math.max(1, axis.minorUnit ?? 1)
|
|
14568
|
+
))
|
|
14569
|
+
mark(serial, axis.minorTickMark, 2.5);
|
|
14570
|
+
return {
|
|
14571
|
+
order: visible.map((p) => p.index),
|
|
14572
|
+
band: (index) => position(values[index] ?? min),
|
|
14573
|
+
bandSize: (model.horizontal ? plot.h : plot.w) / Math.max(1, max - min + 1)
|
|
14574
|
+
};
|
|
14575
|
+
}
|
|
14576
|
+
|
|
14577
|
+
// chart/line-path.ts
|
|
14578
|
+
function smoothLinePath(points) {
|
|
14579
|
+
if (points.length === 0) {
|
|
14580
|
+
return "";
|
|
14581
|
+
}
|
|
14582
|
+
if (points.length === 1) {
|
|
14583
|
+
return `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)}`;
|
|
14584
|
+
}
|
|
14585
|
+
if (points.length === 2) {
|
|
14586
|
+
return `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)} L${points[1].x.toFixed(2)},${points[1].y.toFixed(2)}`;
|
|
14587
|
+
}
|
|
14588
|
+
let d = `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)}`;
|
|
14589
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
14590
|
+
const [cp1, cp2, end] = smoothSegment(points, i);
|
|
14591
|
+
d += ` C${cp1.x.toFixed(2)},${cp1.y.toFixed(2)} ${cp2.x.toFixed(2)},${cp2.y.toFixed(2)} ${end.x.toFixed(2)},${end.y.toFixed(2)}`;
|
|
14592
|
+
}
|
|
14593
|
+
return d;
|
|
14594
|
+
}
|
|
14595
|
+
function smoothSegment(points, i) {
|
|
14596
|
+
const p0 = points[i - 1] ?? points[i];
|
|
14597
|
+
const p1 = points[i];
|
|
14598
|
+
const p2 = points[i + 1];
|
|
14599
|
+
const p3 = points[i + 2] ?? p2;
|
|
14600
|
+
return [
|
|
14601
|
+
{ x: p1.x + (p2.x - p0.x) / 6, y: p1.y + (p2.y - p0.y) / 6 },
|
|
14602
|
+
{ x: p2.x - (p3.x - p1.x) / 6, y: p2.y - (p3.y - p1.y) / 6 },
|
|
14603
|
+
p2
|
|
14604
|
+
];
|
|
14605
|
+
}
|
|
14606
|
+
|
|
14607
|
+
// chart/render/chart-svg-line.ts
|
|
14608
|
+
function chartLineSvg(points, series) {
|
|
14609
|
+
if (points.length < 2) return "";
|
|
14610
|
+
const stroke = series.stroke;
|
|
14611
|
+
const attrs = strokeAttributes(
|
|
14612
|
+
stroke ? { ...stroke, color: stroke.color === "none" ? "none" : series.color } : { color: series.color, width: 2.25 }
|
|
14613
|
+
);
|
|
14614
|
+
const filter = series.shadowFilter ? ` filter="${series.shadowFilter}"` : "";
|
|
14615
|
+
return series.smooth ? `<path d="${smoothLinePath(points)}" fill="none" ${attrs} stroke-linejoin="round"${filter}/>` : `<polyline points="${points.map((p) => `${n(p.x)},${n(p.y)}`).join(" ")}" fill="none" ${attrs} stroke-linejoin="round"${filter}/>`;
|
|
14616
|
+
}
|
|
14617
|
+
|
|
14618
|
+
// chart/render/chart-svg-plot-layout.ts
|
|
14619
|
+
function chartPlotRect(model, auto, outer, frame2) {
|
|
14620
|
+
if (!frame2) return auto;
|
|
14621
|
+
const rect3 = resolveManualPlotRect(
|
|
14622
|
+
model.plotLayout,
|
|
14623
|
+
frame2,
|
|
14624
|
+
{ x: auto.x, y: auto.y, width: auto.w, height: auto.h },
|
|
14625
|
+
{
|
|
14626
|
+
left: auto.x - outer.x,
|
|
14627
|
+
top: auto.y - outer.y,
|
|
14628
|
+
right: Math.max(0, outer.x + outer.w - auto.x - auto.w),
|
|
14629
|
+
bottom: Math.max(0, outer.y + outer.h - auto.y - auto.h)
|
|
14630
|
+
}
|
|
14631
|
+
);
|
|
14632
|
+
return rect3 ? { x: rect3.x, y: rect3.y, w: rect3.width, h: rect3.height } : auto;
|
|
14633
|
+
}
|
|
14634
|
+
|
|
13708
14635
|
// chart/render/chart-svg-markers.ts
|
|
13709
14636
|
function chartMarkerRadius(series, index, defaultRadius = 3) {
|
|
13710
14637
|
const marker = { ...series.marker, ...series.pointMarkers?.[index] };
|
|
@@ -13744,85 +14671,19 @@ function chartSeriesMarkerSvg(series, index, cx, cy, defaultRadius = 3) {
|
|
|
13744
14671
|
return `<${primitive.kind} ${geometry} fill="${esc(primitive.fill)}"${outline}${filter}/>`;
|
|
13745
14672
|
}
|
|
13746
14673
|
|
|
13747
|
-
// chart/line-dash.ts
|
|
13748
|
-
function chartLineDashArray(style, width) {
|
|
13749
|
-
if (!style || style === "solid") {
|
|
13750
|
-
return void 0;
|
|
13751
|
-
}
|
|
13752
|
-
const unit = Math.max(width, 1);
|
|
13753
|
-
if (style === "dot" || style === "sysDot") {
|
|
13754
|
-
return `${unit} ${unit * 2}`;
|
|
13755
|
-
}
|
|
13756
|
-
if (style === "lgDash") {
|
|
13757
|
-
return `${unit * 6} ${unit * 3}`;
|
|
13758
|
-
}
|
|
13759
|
-
return `${unit * 3} ${unit * 2}`;
|
|
13760
|
-
}
|
|
13761
|
-
|
|
13762
|
-
// chart/render/chart-scale.ts
|
|
13763
|
-
var clean = (n2) => Number(n2.toPrecision(12));
|
|
13764
|
-
function* units(raw) {
|
|
13765
|
-
let exp = Math.floor(Math.log10(raw)) - 1;
|
|
13766
|
-
for (; ; ) {
|
|
13767
|
-
const base = 10 ** exp;
|
|
13768
|
-
for (const m of [1, 2, 5]) yield clean(m * base);
|
|
13769
|
-
exp++;
|
|
13770
|
-
}
|
|
13771
|
-
}
|
|
13772
|
-
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
13773
|
-
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
13774
|
-
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
13775
|
-
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
13776
|
-
if (lo > hi) [lo, hi] = [hi, lo];
|
|
13777
|
-
if (lo === hi) {
|
|
13778
|
-
if (lo === 0) hi = 1;
|
|
13779
|
-
else if (options2.noZero) {
|
|
13780
|
-
const pad = Math.abs(lo) * 0.1 || 1;
|
|
13781
|
-
lo -= pad;
|
|
13782
|
-
hi += pad;
|
|
13783
|
-
} else if (lo > 0) lo = 0;
|
|
13784
|
-
else hi = 0;
|
|
14674
|
+
// chart/line-dash.ts
|
|
14675
|
+
function chartLineDashArray(style, width) {
|
|
14676
|
+
if (!style || style === "solid") {
|
|
14677
|
+
return void 0;
|
|
13785
14678
|
}
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
13790
|
-
lo = 0;
|
|
13791
|
-
fixedLo = true;
|
|
13792
|
-
} else if (hi <= 0 && hi - lo >= -lo / 6) {
|
|
13793
|
-
hi = 0;
|
|
13794
|
-
fixedHi = true;
|
|
13795
|
-
}
|
|
14679
|
+
const unit = Math.max(width, 1);
|
|
14680
|
+
if (style === "dot" || style === "sysDot") {
|
|
14681
|
+
return `${unit} ${unit * 2}`;
|
|
13796
14682
|
}
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
const bottom = fixedLo ? lo : lo - range * 0.05;
|
|
13800
|
-
for (const unit of units(range / maxIntervals)) {
|
|
13801
|
-
const min = fixedLo ? lo : Math.floor(clean(bottom / unit)) * unit;
|
|
13802
|
-
const max = fixedHi ? hi : Math.ceil(clean(top / unit)) * unit;
|
|
13803
|
-
const intervals = Math.round((max - min) / unit);
|
|
13804
|
-
if (intervals <= maxIntervals && intervals > 0) {
|
|
13805
|
-
const ticks = [];
|
|
13806
|
-
for (let i = 0; i <= intervals; i++) ticks.push(clean(min + i * unit));
|
|
13807
|
-
return { min: clean(min), max: clean(max), majorUnit: unit, ticks };
|
|
13808
|
-
}
|
|
14683
|
+
if (style === "lgDash") {
|
|
14684
|
+
return `${unit * 6} ${unit * 3}`;
|
|
13809
14685
|
}
|
|
13810
|
-
return {
|
|
13811
|
-
}
|
|
13812
|
-
var PERCENT_SCALE = {
|
|
13813
|
-
min: 0,
|
|
13814
|
-
max: 1,
|
|
13815
|
-
majorUnit: 0.1,
|
|
13816
|
-
ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
|
13817
|
-
};
|
|
13818
|
-
function formatAxisValue(value, percent = false) {
|
|
13819
|
-
if (percent) return `${clean(value * 100)}%`;
|
|
13820
|
-
const v = clean(value);
|
|
13821
|
-
if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
|
|
13822
|
-
return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
|
|
13823
|
-
const [int = "0", frac] = String(Math.abs(v)).split(".");
|
|
13824
|
-
const grouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
13825
|
-
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
14686
|
+
return `${unit * 3} ${unit * 2}`;
|
|
13826
14687
|
}
|
|
13827
14688
|
|
|
13828
14689
|
// chart/render/chart-svg-axes.ts
|
|
@@ -14051,6 +14912,50 @@ function applyChartAxes(model, chart, color) {
|
|
|
14051
14912
|
model.axes = out;
|
|
14052
14913
|
}
|
|
14053
14914
|
|
|
14915
|
+
// chart/render/chart-title-text.ts
|
|
14916
|
+
function chartRunStyle(run) {
|
|
14917
|
+
return {
|
|
14918
|
+
...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
|
|
14919
|
+
...run.bold === void 0 ? {} : { bold: run.bold },
|
|
14920
|
+
...run.italic === void 0 ? {} : { italic: run.italic },
|
|
14921
|
+
...run.underline === void 0 ? {} : { underline: run.underline },
|
|
14922
|
+
...run.typeface === void 0 ? {} : { typeface: run.typeface },
|
|
14923
|
+
...run.color === void 0 ? {} : { textColor: run.color }
|
|
14924
|
+
};
|
|
14925
|
+
}
|
|
14926
|
+
function chartTitleText(chart, theme) {
|
|
14927
|
+
const formatting = chart.formatting;
|
|
14928
|
+
const entry = formatting?.entries.title;
|
|
14929
|
+
const body = entry?.textBody;
|
|
14930
|
+
if (!formatting || !body || body.text !== chart.title) return void 0;
|
|
14931
|
+
if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
|
|
14932
|
+
return void 0;
|
|
14933
|
+
return {
|
|
14934
|
+
paragraphs: body.paragraphs.map((paragraph) => ({
|
|
14935
|
+
...paragraph.align ? { align: paragraph.align } : {},
|
|
14936
|
+
...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
|
|
14937
|
+
...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
|
|
14938
|
+
...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
|
|
14939
|
+
runs: paragraph.runs.map((run) => {
|
|
14940
|
+
const direct = {
|
|
14941
|
+
sourceXml: "",
|
|
14942
|
+
...entry.textBodyStyle,
|
|
14943
|
+
...chartRunStyle(paragraph.defaultProperties ?? {}),
|
|
14944
|
+
...chartRunStyle(run)
|
|
14945
|
+
};
|
|
14946
|
+
const appearance = chartAppearance(
|
|
14947
|
+
{
|
|
14948
|
+
...chart,
|
|
14949
|
+
formatting: { ...formatting, entries: { ...formatting.entries, title: direct } }
|
|
14950
|
+
},
|
|
14951
|
+
theme
|
|
14952
|
+
)?.title ?? {};
|
|
14953
|
+
return { text: run.text, appearance };
|
|
14954
|
+
})
|
|
14955
|
+
}))
|
|
14956
|
+
};
|
|
14957
|
+
}
|
|
14958
|
+
|
|
14054
14959
|
// chart/render/chart-view-analysis.ts
|
|
14055
14960
|
function strokeOf(line3, fallback, resolve) {
|
|
14056
14961
|
if (line3?.fill?.kind === "none") return void 0;
|
|
@@ -14078,6 +14983,40 @@ function analysisView(source, seriesColor, resolve) {
|
|
|
14078
14983
|
};
|
|
14079
14984
|
}
|
|
14080
14985
|
|
|
14986
|
+
// chart/render/chart-view-data-table.ts
|
|
14987
|
+
function chartDataTableView(chart, theme, color) {
|
|
14988
|
+
const source = chart.dataTable;
|
|
14989
|
+
if (!source) return void 0;
|
|
14990
|
+
const props = source.txPr?.paragraphs[0];
|
|
14991
|
+
const direct = {
|
|
14992
|
+
sourceXml: "",
|
|
14993
|
+
...chartRunStyle(props?.defaultProperties ?? {}),
|
|
14994
|
+
...chartRunStyle(props?.runs[0] ?? {})
|
|
14995
|
+
};
|
|
14996
|
+
const formatting = chart.formatting;
|
|
14997
|
+
const appearance = chartAppearance(
|
|
14998
|
+
{
|
|
14999
|
+
...chart,
|
|
15000
|
+
formatting: {
|
|
15001
|
+
...formatting,
|
|
15002
|
+
sourceXml: formatting?.sourceXml ?? "",
|
|
15003
|
+
entries: { ...formatting?.entries, categoryAxis: direct }
|
|
15004
|
+
}
|
|
15005
|
+
},
|
|
15006
|
+
theme
|
|
15007
|
+
);
|
|
15008
|
+
const fill = source.spPr?.fill;
|
|
15009
|
+
return {
|
|
15010
|
+
source,
|
|
15011
|
+
stroke: strokeOf(source.spPr?.line, { color: "#D9D9D9", width: 1 }, color) ?? {
|
|
15012
|
+
color: "none",
|
|
15013
|
+
width: 0
|
|
15014
|
+
},
|
|
15015
|
+
...fill?.kind === "solid" && color(fill.color) ? { fill: color(fill.color) } : {},
|
|
15016
|
+
...appearance?.categoryAxis ? { text: appearance.categoryAxis } : {}
|
|
15017
|
+
};
|
|
15018
|
+
}
|
|
15019
|
+
|
|
14081
15020
|
// chart/render/chart-view-series.ts
|
|
14082
15021
|
var isRefError = (value) => typeof value === "object" && value !== null && "error" in value;
|
|
14083
15022
|
function toText(value) {
|
|
@@ -14119,7 +15058,8 @@ function seriesContext(chart, theme, options2) {
|
|
|
14119
15058
|
function seriesView(ctx, s, index, total, categoriesOf) {
|
|
14120
15059
|
const { theme, scheme, palette, evaluateRef } = ctx;
|
|
14121
15060
|
const values = resolveRef(s.valuesRef, evaluateRef)?.map(toNumber) ?? s.values.map(toNumber);
|
|
14122
|
-
|
|
15061
|
+
const categoryValues = resolveRef(s.categoriesRef, evaluateRef) ?? s.categories;
|
|
15062
|
+
categoriesOf(categoryValues);
|
|
14123
15063
|
const paletteColor = palette && chartPaletteSeriesColor(palette, index, total, scheme);
|
|
14124
15064
|
const color = s.fill?.kind === "none" ? "none" : ctx.drawingColor(s.fill?.kind === "solid" ? s.fill.color : s.drawingColor) ?? ctx.seriesColor?.(s, index) ?? paletteColor ?? autoSeriesColor(theme, index);
|
|
14125
15065
|
const view = {
|
|
@@ -14128,6 +15068,19 @@ function seriesView(ctx, s, index, total, categoriesOf) {
|
|
|
14128
15068
|
color,
|
|
14129
15069
|
sourceIndex: index
|
|
14130
15070
|
};
|
|
15071
|
+
if (s.hidden !== void 0) view.hidden = s.hidden;
|
|
15072
|
+
if (s.boxWhisker) {
|
|
15073
|
+
view.boxWhisker = s.boxWhisker;
|
|
15074
|
+
view.boxCategories = categoryValues.map(toText);
|
|
15075
|
+
}
|
|
15076
|
+
if (s.numberFormat !== void 0) view.numberFormat = s.numberFormat;
|
|
15077
|
+
if (s.showLine !== void 0) view.showLine = s.showLine;
|
|
15078
|
+
if (s.smooth !== void 0) view.smooth = s.smooth;
|
|
15079
|
+
if (s.line)
|
|
15080
|
+
view.stroke = strokeOf(s.line, { color, width: 2.25 }, ctx.drawingColor) ?? {
|
|
15081
|
+
color: "none",
|
|
15082
|
+
width: 0
|
|
15083
|
+
};
|
|
14131
15084
|
const shadow = resolveDrawingShadowXml(s.effectsXml, { scheme: (name) => scheme[name] });
|
|
14132
15085
|
if (shadow) view.shadow = shadow;
|
|
14133
15086
|
const resolvedGradient = ctx.gradient(s.fill);
|
|
@@ -14272,52 +15225,8 @@ function categoryTotals(model) {
|
|
|
14272
15225
|
);
|
|
14273
15226
|
}
|
|
14274
15227
|
|
|
14275
|
-
// chart/render/chart-title-text.ts
|
|
14276
|
-
function properties(run) {
|
|
14277
|
-
return {
|
|
14278
|
-
...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
|
|
14279
|
-
...run.bold === void 0 ? {} : { bold: run.bold },
|
|
14280
|
-
...run.italic === void 0 ? {} : { italic: run.italic },
|
|
14281
|
-
...run.underline === void 0 ? {} : { underline: run.underline },
|
|
14282
|
-
...run.typeface === void 0 ? {} : { typeface: run.typeface },
|
|
14283
|
-
...run.color === void 0 ? {} : { textColor: run.color }
|
|
14284
|
-
};
|
|
14285
|
-
}
|
|
14286
|
-
function chartTitleText(chart, theme) {
|
|
14287
|
-
const formatting = chart.formatting;
|
|
14288
|
-
const entry = formatting?.entries.title;
|
|
14289
|
-
const body = entry?.textBody;
|
|
14290
|
-
if (!formatting || !body || body.text !== chart.title) return void 0;
|
|
14291
|
-
if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
|
|
14292
|
-
return void 0;
|
|
14293
|
-
return {
|
|
14294
|
-
paragraphs: body.paragraphs.map((paragraph) => ({
|
|
14295
|
-
...paragraph.align ? { align: paragraph.align } : {},
|
|
14296
|
-
...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
|
|
14297
|
-
...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
|
|
14298
|
-
...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
|
|
14299
|
-
runs: paragraph.runs.map((run) => {
|
|
14300
|
-
const direct = {
|
|
14301
|
-
sourceXml: "",
|
|
14302
|
-
...entry.textBodyStyle,
|
|
14303
|
-
...properties(paragraph.defaultProperties ?? {}),
|
|
14304
|
-
...properties(run)
|
|
14305
|
-
};
|
|
14306
|
-
const appearance = chartAppearance(
|
|
14307
|
-
{
|
|
14308
|
-
...chart,
|
|
14309
|
-
formatting: { ...formatting, entries: { ...formatting.entries, title: direct } }
|
|
14310
|
-
},
|
|
14311
|
-
theme
|
|
14312
|
-
)?.title ?? {};
|
|
14313
|
-
return { text: run.text, appearance };
|
|
14314
|
-
})
|
|
14315
|
-
}))
|
|
14316
|
-
};
|
|
14317
|
-
}
|
|
14318
|
-
|
|
14319
15228
|
// chart/render/chart-view-labels.ts
|
|
14320
|
-
function labelsOf(source, view, categories, numberFormat) {
|
|
15229
|
+
function labelsOf(source, view, categories, numberFormat, resolveColor) {
|
|
14321
15230
|
const { chart, series, points } = source;
|
|
14322
15231
|
if ((series?.deleted ?? chart?.deleted) === true) return void 0;
|
|
14323
15232
|
const percentBase = view.values.reduce(
|
|
@@ -14353,19 +15262,35 @@ function labelsOf(source, view, categories, numberFormat) {
|
|
|
14353
15262
|
});
|
|
14354
15263
|
}
|
|
14355
15264
|
if (!built) return;
|
|
15265
|
+
const layout = point?.layout;
|
|
15266
|
+
const showLeaderLines = series?.showLeaderLines ?? chart?.showLeaderLines;
|
|
15267
|
+
const leaderLine = strokeOf(
|
|
15268
|
+
series?.leaderLine ?? chart?.leaderLine,
|
|
15269
|
+
{ color: "#94a3b8", width: 0.75 },
|
|
15270
|
+
resolveColor
|
|
15271
|
+
) ?? { color: "none", width: 0 };
|
|
14356
15272
|
any = true;
|
|
14357
15273
|
out[i] = {
|
|
14358
15274
|
text: built.text,
|
|
15275
|
+
...layout ? { layout } : {},
|
|
15276
|
+
...showLeaderLines !== void 0 ? { showLeaderLines } : {},
|
|
15277
|
+
...leaderLine ? { leaderLine } : {},
|
|
14359
15278
|
...position ? { position } : {},
|
|
14360
15279
|
...built.color ? { color: built.color } : {}
|
|
14361
15280
|
};
|
|
14362
15281
|
});
|
|
14363
15282
|
return any ? out : void 0;
|
|
14364
15283
|
}
|
|
14365
|
-
function applyDataLabels(model, sources, extra) {
|
|
15284
|
+
function applyDataLabels(model, sources, extra, resolveColor) {
|
|
14366
15285
|
const apply = (source, view) => {
|
|
14367
15286
|
if (!source?.dataLabels) return;
|
|
14368
|
-
const labels = labelsOf(
|
|
15287
|
+
const labels = labelsOf(
|
|
15288
|
+
source.dataLabels,
|
|
15289
|
+
view,
|
|
15290
|
+
model.categories,
|
|
15291
|
+
source.numberFormat,
|
|
15292
|
+
resolveColor
|
|
15293
|
+
);
|
|
14369
15294
|
if (labels) view.labels = labels;
|
|
14370
15295
|
};
|
|
14371
15296
|
model.series.forEach((view, i) => apply(sources[i], view));
|
|
@@ -14470,7 +15395,9 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
14470
15395
|
"bubble",
|
|
14471
15396
|
"stock",
|
|
14472
15397
|
"treemap",
|
|
14473
|
-
"sunburst"
|
|
15398
|
+
"sunburst",
|
|
15399
|
+
"funnel",
|
|
15400
|
+
"boxWhisker"
|
|
14474
15401
|
]);
|
|
14475
15402
|
function chartSummaryView(chart, theme, options2 = {}) {
|
|
14476
15403
|
const type = chart.chartType;
|
|
@@ -14528,10 +15455,17 @@ function chartSummaryView(chart, theme, options2 = {}) {
|
|
|
14528
15455
|
showLegend: chart.showLegend,
|
|
14529
15456
|
legendPosition: chart.legendPosition ?? "r",
|
|
14530
15457
|
categories,
|
|
14531
|
-
series,
|
|
15458
|
+
series: type === "boxWhisker" ? series.filter((s) => !s.hidden) : series,
|
|
14532
15459
|
horizontal: type === "bar",
|
|
14533
15460
|
supported: SUPPORTED.has(type)
|
|
14534
15461
|
};
|
|
15462
|
+
const table = chartDataTableView(chart, theme, ctx.drawingColor);
|
|
15463
|
+
if (table) model.dataTable = table;
|
|
15464
|
+
if (chart.date1904 !== void 0) model.date1904 = chart.date1904;
|
|
15465
|
+
if (chart.axes?.some((a) => a.kind === "date")) model.dateCategories = firstCats.map(toNumber);
|
|
15466
|
+
if (chart.plotLayout) model.plotLayout = chart.plotLayout;
|
|
15467
|
+
if (type === "boxWhisker")
|
|
15468
|
+
model.categories = [...new Set(model.series.flatMap((s) => s.boxCategories ?? []))];
|
|
14535
15469
|
if (chart.title) model.title = chart.title;
|
|
14536
15470
|
const titleFormatting = chart.formatting?.entries.title;
|
|
14537
15471
|
if (titleFormatting?.layout) model.titleLayout = titleFormatting.layout;
|
|
@@ -14553,6 +15487,11 @@ function chartSummaryView(chart, theme, options2 = {}) {
|
|
|
14553
15487
|
const range = extentOf(xs);
|
|
14554
15488
|
model.xAxis = xs.length ? niceScale(range.min, range.max) : niceScale(0, 1);
|
|
14555
15489
|
}
|
|
15490
|
+
if (type === "funnel" || type === "boxWhisker")
|
|
15491
|
+
series.forEach((s, i) => {
|
|
15492
|
+
const points = chart.series[i]?.pointColors;
|
|
15493
|
+
if (points) s.pointColors = s.values.map((_, j) => drawingColor(points[j]) ?? s.color);
|
|
15494
|
+
});
|
|
14556
15495
|
if (type === "stock") model.stock = stockView(chart.stock, ctx);
|
|
14557
15496
|
if (type === "bubble") bubbleView(chart, model, ctx.evaluateRef);
|
|
14558
15497
|
if (type === "treemap" || type === "sunburst") hierarchyView(chart, model, ctx.evaluateRef);
|
|
@@ -14561,23 +15500,31 @@ function chartSummaryView(chart, theme, options2 = {}) {
|
|
|
14561
15500
|
chartExtraView(chart, model, ctx, total, collect);
|
|
14562
15501
|
if (type === "waterfall") waterfallView(chart, model, ctx);
|
|
14563
15502
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
14564
|
-
applyDataLabels(model, chart.series, extra);
|
|
15503
|
+
applyDataLabels(model, chart.series, extra, ctx.drawingColor);
|
|
14565
15504
|
chartExtraAxes(model);
|
|
14566
15505
|
applyChartAxes(model, chart, ctx.drawingColor);
|
|
14567
15506
|
return model;
|
|
14568
15507
|
}
|
|
14569
15508
|
|
|
14570
15509
|
// chart/render/chart-svg-cartesian.ts
|
|
14571
|
-
function cartesianAxes(model, area, out) {
|
|
15510
|
+
function cartesianAxes(model, area, out, size) {
|
|
14572
15511
|
const scale = model.valueAxis;
|
|
14573
15512
|
if (!scale) return void 0;
|
|
15513
|
+
const table = chartTableMetrics(model);
|
|
15514
|
+
if (table)
|
|
15515
|
+
area = {
|
|
15516
|
+
...area,
|
|
15517
|
+
x: Math.max(area.x, table.keyW + 8),
|
|
15518
|
+
w: Math.max(1, area.w - Math.max(0, table.keyW + 8 - area.x)),
|
|
15519
|
+
h: Math.max(1, area.h - table.height)
|
|
15520
|
+
};
|
|
14574
15521
|
const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
|
|
14575
15522
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
14576
15523
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
14577
15524
|
const valueSize = valueAttrs.size ?? 10;
|
|
14578
15525
|
const categorySize = categoryAttrs.size ?? 10;
|
|
14579
15526
|
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
14580
|
-
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
15527
|
+
const categoryLabels = !table && chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
14581
15528
|
const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
14582
15529
|
const horizontal = model.horizontal;
|
|
14583
15530
|
const cats = Math.max(1, model.categories.length);
|
|
@@ -14588,7 +15535,7 @@ function cartesianAxes(model, area, out) {
|
|
|
14588
15535
|
const second = horizontal ? void 0 : model.secondaryAxis;
|
|
14589
15536
|
const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
|
|
14590
15537
|
const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
|
|
14591
|
-
const
|
|
15538
|
+
const auto = horizontal ? {
|
|
14592
15539
|
x: area.x + catW,
|
|
14593
15540
|
y: area.y,
|
|
14594
15541
|
w: Math.max(1, area.w - catW - 4),
|
|
@@ -14599,10 +15546,13 @@ function cartesianAxes(model, area, out) {
|
|
|
14599
15546
|
w: Math.max(1, area.w - labelW - 4 - secondW),
|
|
14600
15547
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
14601
15548
|
};
|
|
15549
|
+
const plot = chartPlotRect(model, auto, area, size);
|
|
14602
15550
|
const value = horizontal ? (v) => plot.x + chartAxisRatio(v, scale, model.axes?.value) * plot.w : (v) => plot.y + plot.h - chartAxisRatio(v, scale, model.axes?.value) * plot.h;
|
|
14603
|
-
const
|
|
15551
|
+
const dateMarkup = [];
|
|
15552
|
+
const dates = chartDateAxis(model, plot, dateMarkup);
|
|
15553
|
+
const bandSize = dates?.bandSize ?? (horizontal ? plot.h : plot.w) / cats;
|
|
14604
15554
|
const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
|
|
14605
|
-
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
|
|
15555
|
+
const band = dates?.band ?? (horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5));
|
|
14606
15556
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
14607
15557
|
out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
|
|
14608
15558
|
if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
|
|
@@ -14640,12 +15590,13 @@ function cartesianAxes(model, area, out) {
|
|
|
14640
15590
|
out.push(
|
|
14641
15591
|
axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
|
|
14642
15592
|
);
|
|
15593
|
+
out.push(...dateMarkup);
|
|
14643
15594
|
const step = Math.max(
|
|
14644
15595
|
1,
|
|
14645
15596
|
Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
|
|
14646
15597
|
);
|
|
14647
15598
|
model.categories.forEach((c, i) => {
|
|
14648
|
-
if (!categoryLabels || i % step !== 0) return;
|
|
15599
|
+
if (dates || !categoryLabels || i % step !== 0) return;
|
|
14649
15600
|
const p = band(i);
|
|
14650
15601
|
if (horizontal)
|
|
14651
15602
|
out.push(
|
|
@@ -14662,7 +15613,7 @@ function cartesianAxes(model, area, out) {
|
|
|
14662
15613
|
})
|
|
14663
15614
|
);
|
|
14664
15615
|
});
|
|
14665
|
-
const frame2 = { plot, value, band, bandSize };
|
|
15616
|
+
const frame2 = { plot, value, band, bandSize, ...dates ? { order: dates.order } : {} };
|
|
14666
15617
|
if (second) {
|
|
14667
15618
|
frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
|
|
14668
15619
|
out.push(
|
|
@@ -14709,7 +15660,7 @@ function linesAndAreas(model, frame2, out) {
|
|
|
14709
15660
|
model.series.forEach((s, si) => {
|
|
14710
15661
|
const points = [];
|
|
14711
15662
|
const lower = [];
|
|
14712
|
-
model.categories.
|
|
15663
|
+
(frame2.order ?? model.categories.map((_, i) => i)).forEach((i) => {
|
|
14713
15664
|
const v = values[si]?.[i] ?? null;
|
|
14714
15665
|
if (v === null && !area) {
|
|
14715
15666
|
points.push([NaN, NaN]);
|
|
@@ -14744,26 +15695,24 @@ function linesAndAreas(model, frame2, out) {
|
|
|
14744
15695
|
}
|
|
14745
15696
|
let segment2 = [];
|
|
14746
15697
|
const flush = () => {
|
|
14747
|
-
|
|
14748
|
-
out.push(
|
|
14749
|
-
`<polyline points="${segment2.join(" ")}" fill="none" stroke="${color}" stroke-width="2.25" stroke-linejoin="round"${filter}/>`
|
|
14750
|
-
);
|
|
15698
|
+
out.push(chartLineSvg(segment2, series));
|
|
14751
15699
|
segment2 = [];
|
|
14752
15700
|
};
|
|
14753
15701
|
for (const [x, y] of points) {
|
|
14754
15702
|
if (Number.isNaN(x)) flush();
|
|
14755
|
-
else segment2.push(
|
|
15703
|
+
else segment2.push({ x, y });
|
|
14756
15704
|
}
|
|
14757
15705
|
flush();
|
|
14758
15706
|
points.forEach(([x, y], index) => {
|
|
14759
|
-
if (!Number.isNaN(x))
|
|
15707
|
+
if (!Number.isNaN(x))
|
|
15708
|
+
out.push(chartSeriesMarkerSvg(series, frame2.order?.[index] ?? index, x, y, 2.5));
|
|
14760
15709
|
});
|
|
14761
15710
|
}
|
|
14762
15711
|
pointLabels(model, marks, out);
|
|
14763
15712
|
}
|
|
14764
15713
|
|
|
14765
15714
|
// chart/render/chart-svg-xy.ts
|
|
14766
|
-
function scatter(model, area, out) {
|
|
15715
|
+
function scatter(model, area, out, size) {
|
|
14767
15716
|
const ys = model.valueAxis;
|
|
14768
15717
|
const xs = model.xAxis;
|
|
14769
15718
|
if (!ys || !xs) return;
|
|
@@ -14776,18 +15725,19 @@ function scatter(model, area, out) {
|
|
|
14776
15725
|
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
14777
15726
|
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
14778
15727
|
const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
14779
|
-
const
|
|
15728
|
+
const auto = {
|
|
14780
15729
|
x: area.x + labelW,
|
|
14781
15730
|
y: area.y + 4,
|
|
14782
15731
|
w: Math.max(1, area.w - labelW - 8),
|
|
14783
15732
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
14784
15733
|
};
|
|
15734
|
+
const plot = chartPlotRect(model, auto, area, size);
|
|
14785
15735
|
const bubble = model.type === "bubble" ? model.bubble : void 0;
|
|
14786
15736
|
const biggest = maxBubbleSize(
|
|
14787
15737
|
model.series.flatMap((s) => (s.sizes ?? []).filter((v) => v !== null))
|
|
14788
15738
|
);
|
|
14789
15739
|
const median = medianBubbleRadius(plot.w, plot.h);
|
|
14790
|
-
const radiusOf = (
|
|
15740
|
+
const radiusOf = (size2) => bubble && !(size2 !== void 0 && size2 < 0 && !bubble.showNegativeBubbles) ? computeBubbleRadius(size2, biggest, median, bubble) : void 0;
|
|
14791
15741
|
let reach = 0;
|
|
14792
15742
|
if (bubble)
|
|
14793
15743
|
for (const s of model.series)
|
|
@@ -14796,11 +15746,11 @@ function scatter(model, area, out) {
|
|
|
14796
15746
|
});
|
|
14797
15747
|
const widen = (s, length, axis) => {
|
|
14798
15748
|
if (axis?.range.logScale) return s;
|
|
14799
|
-
const
|
|
15749
|
+
const pad2 = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
|
|
14800
15750
|
return {
|
|
14801
15751
|
...s,
|
|
14802
|
-
min: axis?.source.scaling.min === void 0 ? s.min -
|
|
14803
|
-
max: axis?.source.scaling.max === void 0 ? s.max +
|
|
15752
|
+
min: axis?.source.scaling.min === void 0 ? s.min - pad2 : s.min,
|
|
15753
|
+
max: axis?.source.scaling.max === void 0 ? s.max + pad2 : s.max
|
|
14804
15754
|
};
|
|
14805
15755
|
};
|
|
14806
15756
|
const xView = widen(xs, plot.w, model.axes?.category);
|
|
@@ -14845,6 +15795,21 @@ function scatter(model, area, out) {
|
|
|
14845
15795
|
out.push(
|
|
14846
15796
|
axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
|
|
14847
15797
|
);
|
|
15798
|
+
if (!bubble)
|
|
15799
|
+
for (const series of model.series) {
|
|
15800
|
+
if (!series.showLine) continue;
|
|
15801
|
+
let run = [];
|
|
15802
|
+
const flush = () => {
|
|
15803
|
+
out.push(chartLineSvg(run, series));
|
|
15804
|
+
run = [];
|
|
15805
|
+
};
|
|
15806
|
+
series.values.forEach((value, i) => {
|
|
15807
|
+
const x = series.xValues?.[i];
|
|
15808
|
+
if (value === null || x === null || x === void 0) flush();
|
|
15809
|
+
else run.push({ x: px(x), y: py(value) });
|
|
15810
|
+
});
|
|
15811
|
+
flush();
|
|
15812
|
+
}
|
|
14848
15813
|
const marks = [];
|
|
14849
15814
|
for (const [si, s] of model.series.entries())
|
|
14850
15815
|
s.values.forEach((v, i) => {
|
|
@@ -14976,14 +15941,19 @@ function clusterLayers(layers) {
|
|
|
14976
15941
|
}
|
|
14977
15942
|
return out;
|
|
14978
15943
|
}
|
|
14979
|
-
function cartesianSvg(model, area) {
|
|
15944
|
+
function cartesianSvg(model, area, size) {
|
|
14980
15945
|
const out = [];
|
|
14981
15946
|
if (model.type === "scatter" || model.type === "bubble") {
|
|
14982
|
-
scatter(model, area, out);
|
|
15947
|
+
scatter(model, area, out, size);
|
|
14983
15948
|
return out.join("");
|
|
14984
15949
|
}
|
|
14985
|
-
const frame2 = cartesianAxes(model, area, out);
|
|
15950
|
+
const frame2 = cartesianAxes(model, area, out, size);
|
|
14986
15951
|
if (!frame2) return "";
|
|
15952
|
+
out.push(chartDataTableSvg(model, frame2.plot));
|
|
15953
|
+
if (model.type === "boxWhisker") {
|
|
15954
|
+
boxWhiskerSvg(model, frame2, out);
|
|
15955
|
+
return out.join("");
|
|
15956
|
+
}
|
|
14987
15957
|
if (model.type === "waterfall") {
|
|
14988
15958
|
waterfallBars(model, frame2, out);
|
|
14989
15959
|
return out.join("");
|
|
@@ -15016,6 +15986,83 @@ function cartesianSvg(model, area) {
|
|
|
15016
15986
|
return out.join("");
|
|
15017
15987
|
}
|
|
15018
15988
|
|
|
15989
|
+
// chart/render/chart-svg-slice-labels.ts
|
|
15990
|
+
var GAP2 = 3;
|
|
15991
|
+
function sliceLabels(model, marks, out) {
|
|
15992
|
+
const items = [];
|
|
15993
|
+
for (const mark of marks) {
|
|
15994
|
+
const label = mark.series.labels?.[mark.index];
|
|
15995
|
+
if (!label) continue;
|
|
15996
|
+
const m = measure(model, label);
|
|
15997
|
+
const mid = (mark.start + mark.end) / 2;
|
|
15998
|
+
const ux = Math.sin(mid);
|
|
15999
|
+
const uy = -Math.cos(mid);
|
|
16000
|
+
const place2 = (radius) => [
|
|
16001
|
+
mark.cx + radius * ux,
|
|
16002
|
+
mark.cy + radius * uy
|
|
16003
|
+
];
|
|
16004
|
+
const position = label.position ?? (model.type === "doughnut" ? "ctr" : "bestFit");
|
|
16005
|
+
let x;
|
|
16006
|
+
let y;
|
|
16007
|
+
if (position === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
|
|
16008
|
+
else if (position === "inEnd") {
|
|
16009
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
16010
|
+
[x, y] = place2(Math.max(0, mark.outer - GAP2 - extent));
|
|
16011
|
+
} else if (position === "outEnd") {
|
|
16012
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
16013
|
+
[x, y] = place2(mark.outer + GAP2 + extent);
|
|
16014
|
+
} else {
|
|
16015
|
+
const placed2 = placeBestFitLabel(
|
|
16016
|
+
{
|
|
16017
|
+
cx: mark.cx,
|
|
16018
|
+
cy: mark.cy,
|
|
16019
|
+
outerR: mark.outer,
|
|
16020
|
+
startAngle: mark.start - Math.PI / 2,
|
|
16021
|
+
endAngle: mark.end - Math.PI / 2
|
|
16022
|
+
},
|
|
16023
|
+
m.w,
|
|
16024
|
+
m.h
|
|
16025
|
+
);
|
|
16026
|
+
x = placed2.x;
|
|
16027
|
+
y = placed2.y;
|
|
16028
|
+
}
|
|
16029
|
+
items.push({
|
|
16030
|
+
mark,
|
|
16031
|
+
label,
|
|
16032
|
+
m,
|
|
16033
|
+
x,
|
|
16034
|
+
y,
|
|
16035
|
+
outside: Math.hypot(x - mark.cx, y - mark.cy) > mark.outer
|
|
16036
|
+
});
|
|
16037
|
+
}
|
|
16038
|
+
const first3 = marks[0];
|
|
16039
|
+
if (!first3) return;
|
|
16040
|
+
const nudges = nudgeOutsideLabels(
|
|
16041
|
+
items.flatMap(
|
|
16042
|
+
(item, id) => item.outside && !item.label.layout ? [{ id, x: item.x, y: item.y, w: item.m.w, h: item.m.h }] : []
|
|
16043
|
+
),
|
|
16044
|
+
{ cx: first3.cx, cy: first3.cy, r: first3.outer },
|
|
16045
|
+
first3.cy - first3.outer,
|
|
16046
|
+
first3.cy + first3.outer
|
|
16047
|
+
);
|
|
16048
|
+
for (const [id, item] of items.entries()) {
|
|
16049
|
+
const { mark, label, m } = item;
|
|
16050
|
+
const nudge = nudges.find((n2) => n2.id === id);
|
|
16051
|
+
let point = { x: item.x + (nudge?.dx ?? 0), y: item.y + (nudge?.dy ?? 0) };
|
|
16052
|
+
if (model.frameSize) point = applyLabelManualLayout(label.layout, model.frameSize, point);
|
|
16053
|
+
const moved = point.x !== item.x || point.y !== item.y;
|
|
16054
|
+
if (label.showLeaderLines !== false && (item.outside || moved)) {
|
|
16055
|
+
const mid = (mark.start + mark.end) / 2;
|
|
16056
|
+
const stroke = label.leaderLine ?? { color: "#94a3b8", width: 0.75 };
|
|
16057
|
+
out.push(
|
|
16058
|
+
`<line x1="${n(mark.cx + mark.outer * Math.sin(mid))}" y1="${n(mark.cy - mark.outer * Math.cos(mid))}" x2="${n(point.x)}" y2="${n(point.y)}" ${strokeAttributes(stroke)} data-chart-part="leaderLine"/>`
|
|
16059
|
+
);
|
|
16060
|
+
}
|
|
16061
|
+
const { layout: _layout, ...fixed } = label;
|
|
16062
|
+
draw(m, fixed, point.x, point.y, "middle", out);
|
|
16063
|
+
}
|
|
16064
|
+
}
|
|
16065
|
+
|
|
15019
16066
|
// chart/render/chart-svg-radial.ts
|
|
15020
16067
|
var polar = (cx, cy, r, angle) => [
|
|
15021
16068
|
cx + r * Math.sin(angle),
|
|
@@ -15498,9 +16545,9 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
15498
16545
|
),
|
|
15499
16546
|
{ breakWords: true }
|
|
15500
16547
|
);
|
|
15501
|
-
const { spaceBefore, spaceAfter, ...
|
|
16548
|
+
const { spaceBefore, spaceAfter, ...properties } = line3;
|
|
15502
16549
|
return wrapped.map((runs, index) => ({
|
|
15503
|
-
...
|
|
16550
|
+
...properties,
|
|
15504
16551
|
runs,
|
|
15505
16552
|
...index === 0 && spaceBefore ? { spaceBefore } : {},
|
|
15506
16553
|
...index === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
|
|
@@ -15587,7 +16634,7 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
15587
16634
|
// chart/render/chart-svg.ts
|
|
15588
16635
|
function renderChartSvg(model, width, height, options2 = {}) {
|
|
15589
16636
|
const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
|
|
15590
|
-
model = paint2.model;
|
|
16637
|
+
model = { ...paint2.model, frameSize: { width: Math.max(1, width), height: Math.max(1, height) } };
|
|
15591
16638
|
const w = Math.max(1, width);
|
|
15592
16639
|
const h = Math.max(1, height);
|
|
15593
16640
|
const out = [];
|
|
@@ -15643,10 +16690,11 @@ function renderChartSvg(model, width, height, options2 = {}) {
|
|
|
15643
16690
|
if (!legend.foreground) out.push(legend.markup);
|
|
15644
16691
|
if (area.w > 4 && area.h > 4) {
|
|
15645
16692
|
if (model.type === "pie" || model.type === "doughnut") out.push(pieSvg(model, area));
|
|
16693
|
+
else if (model.type === "funnel") out.push(funnelSvg(model, area));
|
|
15646
16694
|
else if (model.type === "radar") out.push(radarSvg(model, area));
|
|
15647
16695
|
else if (model.type === "treemap") out.push(treemapSvg(model, area));
|
|
15648
16696
|
else if (model.type === "sunburst") out.push(sunburstSvg(model, area));
|
|
15649
|
-
else out.push(cartesianSvg(model, area));
|
|
16697
|
+
else out.push(cartesianSvg(model, area, { width: w, height: h }));
|
|
15650
16698
|
}
|
|
15651
16699
|
if (legend.foreground) out.push(legend.markup);
|
|
15652
16700
|
if (foregroundTitle) out.push(foregroundTitle);
|
|
@@ -15669,7 +16717,9 @@ var DRAWN_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
|
15669
16717
|
"bubble",
|
|
15670
16718
|
"stock",
|
|
15671
16719
|
"treemap",
|
|
15672
|
-
"sunburst"
|
|
16720
|
+
"sunburst",
|
|
16721
|
+
"funnel",
|
|
16722
|
+
"boxWhisker"
|
|
15673
16723
|
]);
|
|
15674
16724
|
function chartThemePalette(theme, fonts = {}) {
|
|
15675
16725
|
return {
|
|
@@ -15774,10 +16824,10 @@ function hasUnexpectedAttributes(element, allowed, allowDateUtc = false) {
|
|
|
15774
16824
|
}
|
|
15775
16825
|
return false;
|
|
15776
16826
|
}
|
|
15777
|
-
function runPropertiesHaveUnknownContent(
|
|
15778
|
-
if (!
|
|
15779
|
-
if (hasUnexpectedAttributes(
|
|
15780
|
-
for (const node of Array.from(
|
|
16827
|
+
function runPropertiesHaveUnknownContent(properties) {
|
|
16828
|
+
if (!properties) return false;
|
|
16829
|
+
if (hasUnexpectedAttributes(properties, [])) return true;
|
|
16830
|
+
for (const node of Array.from(properties.childNodes)) {
|
|
15781
16831
|
if (node.nodeType !== 1) {
|
|
15782
16832
|
if (node.nodeType === 3 && node.textContent?.trim()) return true;
|
|
15783
16833
|
continue;
|
|
@@ -15964,9 +17014,9 @@ function resolveNumberingLevel(catalog, numId, level2) {
|
|
|
15964
17014
|
let base = override?.lvl ?? abstract;
|
|
15965
17015
|
if (!base) return void 0;
|
|
15966
17016
|
if (override?.lvl) {
|
|
15967
|
-
const { lvlRestart: _ignored, ...
|
|
17017
|
+
const { lvlRestart: _ignored, ...properties } = base;
|
|
15968
17018
|
base = {
|
|
15969
|
-
...
|
|
17019
|
+
...properties,
|
|
15970
17020
|
...abstract?.lvlRestart !== void 0 ? { lvlRestart: abstract.lvlRestart } : {}
|
|
15971
17021
|
};
|
|
15972
17022
|
}
|
|
@@ -16619,7 +17669,7 @@ function paragraphWithResults(paragraph, evaluate) {
|
|
|
16619
17669
|
}
|
|
16620
17670
|
function tableWithResults(table, evaluate) {
|
|
16621
17671
|
let changed = false;
|
|
16622
|
-
const
|
|
17672
|
+
const rows2 = table.rows.map(
|
|
16623
17673
|
(row2) => row2.map((cell) => {
|
|
16624
17674
|
const paragraphs = cell.paragraphs.map((item) => paragraphWithResults(item, evaluate));
|
|
16625
17675
|
const sourceBlocks = cell.sourceBlocks?.map(
|
|
@@ -16631,7 +17681,7 @@ function tableWithResults(table, evaluate) {
|
|
|
16631
17681
|
return { ...cell, paragraphs, ...sourceBlocks ? { sourceBlocks } : {} };
|
|
16632
17682
|
})
|
|
16633
17683
|
);
|
|
16634
|
-
return changed ? { ...table, rows } : table;
|
|
17684
|
+
return changed ? { ...table, rows: rows2 } : table;
|
|
16635
17685
|
}
|
|
16636
17686
|
function withStyleRefResults(blocks, evaluate) {
|
|
16637
17687
|
let changed = false;
|
|
@@ -16872,20 +17922,20 @@ function restoreParagraphFormatting(paragraph) {
|
|
|
16872
17922
|
throw new Error(
|
|
16873
17923
|
"Cannot reject a paragraph formatting revision without its prior properties snapshot."
|
|
16874
17924
|
);
|
|
16875
|
-
const
|
|
17925
|
+
const properties = parsePropertiesSnapshot(xml, "pPr");
|
|
16876
17926
|
if (paragraph.sourceParagraphPropertiesXml) {
|
|
16877
17927
|
const current = parsePropertiesSnapshot(paragraph.sourceParagraphPropertiesXml, "pPr");
|
|
16878
17928
|
for (const name of ["rPr", "sectPr"]) {
|
|
16879
17929
|
const element = first2(current, name);
|
|
16880
|
-
if (element && !first2(
|
|
16881
|
-
|
|
17930
|
+
if (element && !first2(properties, name))
|
|
17931
|
+
properties.appendChild(properties.ownerDocument.importNode(element, true));
|
|
16882
17932
|
}
|
|
16883
|
-
orderParagraphProperties(
|
|
17933
|
+
orderParagraphProperties(properties);
|
|
16884
17934
|
}
|
|
16885
|
-
const previous = parseDirectParagraphProperties(
|
|
17935
|
+
const previous = parseDirectParagraphProperties(properties);
|
|
16886
17936
|
for (const key of PARAGRAPH_FORMAT_KEYS) delete paragraph[key];
|
|
16887
17937
|
Object.assign(paragraph, previous);
|
|
16888
|
-
paragraph.restoredParagraphPropertiesXml = buildXml(
|
|
17938
|
+
paragraph.restoredParagraphPropertiesXml = buildXml(properties);
|
|
16889
17939
|
if (paragraph.sourceParagraphPropertiesXml)
|
|
16890
17940
|
paragraph.sourceParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
|
|
16891
17941
|
delete paragraph.formatRevision;
|
|
@@ -16943,20 +17993,20 @@ function datePicture(instr) {
|
|
|
16943
17993
|
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
|
|
16944
17994
|
function formatWordDate(date, picture, locale = "en-US") {
|
|
16945
17995
|
const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
|
|
16946
|
-
const
|
|
17996
|
+
const pad2 = (value) => String(value).padStart(2, "0");
|
|
16947
17997
|
const hours12 = date.getHours() % 12 || 12;
|
|
16948
17998
|
return picture.replace(TOKENS, (token) => {
|
|
16949
17999
|
switch (token) {
|
|
16950
18000
|
case "yyyy":
|
|
16951
18001
|
return String(date.getFullYear());
|
|
16952
18002
|
case "yy":
|
|
16953
|
-
return
|
|
18003
|
+
return pad2(date.getFullYear() % 100);
|
|
16954
18004
|
case "MMMM":
|
|
16955
18005
|
return name({ month: "long" });
|
|
16956
18006
|
case "MMM":
|
|
16957
18007
|
return name({ month: "short" });
|
|
16958
18008
|
case "MM":
|
|
16959
|
-
return
|
|
18009
|
+
return pad2(date.getMonth() + 1);
|
|
16960
18010
|
case "M":
|
|
16961
18011
|
return String(date.getMonth() + 1);
|
|
16962
18012
|
case "dddd":
|
|
@@ -16964,21 +18014,21 @@ function formatWordDate(date, picture, locale = "en-US") {
|
|
|
16964
18014
|
case "ddd":
|
|
16965
18015
|
return name({ weekday: "short" });
|
|
16966
18016
|
case "dd":
|
|
16967
|
-
return
|
|
18017
|
+
return pad2(date.getDate());
|
|
16968
18018
|
case "d":
|
|
16969
18019
|
return String(date.getDate());
|
|
16970
18020
|
case "HH":
|
|
16971
|
-
return
|
|
18021
|
+
return pad2(date.getHours());
|
|
16972
18022
|
case "H":
|
|
16973
18023
|
return String(date.getHours());
|
|
16974
18024
|
case "hh":
|
|
16975
|
-
return
|
|
18025
|
+
return pad2(hours12);
|
|
16976
18026
|
case "h":
|
|
16977
18027
|
return String(hours12);
|
|
16978
18028
|
case "mm":
|
|
16979
|
-
return
|
|
18029
|
+
return pad2(date.getMinutes());
|
|
16980
18030
|
case "ss":
|
|
16981
|
-
return
|
|
18031
|
+
return pad2(date.getSeconds());
|
|
16982
18032
|
case "am/pm":
|
|
16983
18033
|
return date.getHours() < 12 ? "am" : "pm";
|
|
16984
18034
|
case "AM/PM":
|
|
@@ -17095,7 +18145,20 @@ function wrapShapeText(lines, widthPx) {
|
|
|
17095
18145
|
function shapeSvg(spec, widthPx, heightPx, theme) {
|
|
17096
18146
|
const w = Math.max(1, widthPx);
|
|
17097
18147
|
const h = Math.max(1, heightPx);
|
|
17098
|
-
const
|
|
18148
|
+
const customPaths = spec.customGeometryXml ? parseCustomGeometry(
|
|
18149
|
+
parseXml(spec.customGeometryXml).documentElement,
|
|
18150
|
+
w * EMU_PER_PIXEL,
|
|
18151
|
+
h * EMU_PER_PIXEL
|
|
18152
|
+
) : void 0;
|
|
18153
|
+
const geometry = customPaths ? {
|
|
18154
|
+
paths: customPaths.map((path) => ({
|
|
18155
|
+
d: drawingPathData(path, w, h),
|
|
18156
|
+
fill: path.fill,
|
|
18157
|
+
stroke: path.stroke
|
|
18158
|
+
})),
|
|
18159
|
+
fillNone: false,
|
|
18160
|
+
textRect: void 0
|
|
18161
|
+
} : lookupPresetShape(spec.preset) ? evaluatePresetShape(spec.preset, w, h, spec.adjustments) : void 0;
|
|
17099
18162
|
if (!geometry) return void 0;
|
|
17100
18163
|
const look = shapeAppearance(spec, theme);
|
|
17101
18164
|
const paths = geometry.paths.map((path) => {
|
|
@@ -17990,7 +19053,7 @@ function clipTableFrames(tables, start, end, inset = 0) {
|
|
|
17990
19053
|
const top = Math.max(start, table.yPx);
|
|
17991
19054
|
const bottom = Math.min(end, table.yPx + table.heightPx);
|
|
17992
19055
|
if (bottom <= top) return [];
|
|
17993
|
-
const
|
|
19056
|
+
const rows2 = table.rows.flatMap((row2) => {
|
|
17994
19057
|
const rowTop = table.yPx + row2.yPx;
|
|
17995
19058
|
const a = Math.max(top, rowTop), b = Math.min(bottom, rowTop + row2.heightPx);
|
|
17996
19059
|
if (b <= a) return [];
|
|
@@ -18007,11 +19070,11 @@ function clipTableFrames(tables, start, end, inset = 0) {
|
|
|
18007
19070
|
}
|
|
18008
19071
|
];
|
|
18009
19072
|
});
|
|
18010
|
-
if (table.fragmentEdges &&
|
|
19073
|
+
if (table.fragmentEdges && rows2.length) {
|
|
18011
19074
|
const edges = table.fragmentEdges;
|
|
18012
19075
|
for (const [row2, side] of [
|
|
18013
|
-
[
|
|
18014
|
-
[
|
|
19076
|
+
[rows2[0], "top"],
|
|
19077
|
+
[rows2.at(-1), "bottom"]
|
|
18015
19078
|
]) {
|
|
18016
19079
|
if (row2.geometry)
|
|
18017
19080
|
row2.geometry = row2.geometry.map((cell, index) => ({
|
|
@@ -18020,7 +19083,7 @@ function clipTableFrames(tables, start, end, inset = 0) {
|
|
|
18020
19083
|
}));
|
|
18021
19084
|
}
|
|
18022
19085
|
}
|
|
18023
|
-
return [{ ...table, yPx: top - start + inset, heightPx: bottom - top, rows }];
|
|
19086
|
+
return [{ ...table, yPx: top - start + inset, heightPx: bottom - top, rows: rows2 }];
|
|
18024
19087
|
});
|
|
18025
19088
|
}
|
|
18026
19089
|
|
|
@@ -20158,6 +21221,351 @@ function layoutSections(input, measurer, exclusions) {
|
|
|
20158
21221
|
return { pages, approximations: [...approximations] };
|
|
20159
21222
|
}
|
|
20160
21223
|
|
|
21224
|
+
// text/font-substitution-map.ts
|
|
21225
|
+
var FONT_SUBSTITUTION_MAP = {
|
|
21226
|
+
// Microsoft Office default fonts. The Aptos family became the Office
|
|
21227
|
+
// default and its metrics were drawn to sit close to Calibri, so falling
|
|
21228
|
+
// back through Calibri keeps authored line counts; the generic sans-serif
|
|
21229
|
+
// chain is wider and re-wraps one-line titles.
|
|
21230
|
+
Aptos: ["Calibri", "Carlito", "Liberation Sans", "Arial", "sans-serif"],
|
|
21231
|
+
"Aptos Display": ["Calibri Light", "Calibri", "Carlito", "Arial", "sans-serif"],
|
|
21232
|
+
"Aptos Narrow": ["Calibri", "Liberation Sans Narrow", "Arial", "sans-serif"],
|
|
21233
|
+
"Aptos Serif": ["Cambria", "Caladea", "Liberation Serif", "Times New Roman", "serif"],
|
|
21234
|
+
"Aptos Mono": ["Consolas", "Liberation Mono", "Courier New", "monospace"],
|
|
21235
|
+
Calibri: ["Carlito", "Liberation Sans", "Arial", "sans-serif"],
|
|
21236
|
+
"Calibri Light": ["Carlito", "Liberation Sans", "Arial", "sans-serif"],
|
|
21237
|
+
Cambria: ["Caladea", "Liberation Serif", "Times New Roman", "serif"],
|
|
21238
|
+
"Cambria Math": ["STIX Two Math", "Latin Modern Math", "Times New Roman", "serif"],
|
|
21239
|
+
Consolas: ["Liberation Mono", "Courier New", "monospace"],
|
|
21240
|
+
// Selawik is Microsoft's own metric-compatible open substitute for Segoe
|
|
21241
|
+
// UI (github.com/microsoft/Selawik); it is not on Google Fonts, so the
|
|
21242
|
+
// webfont loader (google-webfonts.ts) cannot fetch it automatically, but
|
|
21243
|
+
// listing it first still wins for a reader who has it installed or a
|
|
21244
|
+
// deployment that self-hosts it.
|
|
21245
|
+
"Segoe UI": ["Selawik", "Liberation Sans", "Arimo", "Helvetica Neue", "Arial", "sans-serif"],
|
|
21246
|
+
"Segoe UI Light": [
|
|
21247
|
+
"Selawik Light",
|
|
21248
|
+
"Liberation Sans",
|
|
21249
|
+
"Arimo",
|
|
21250
|
+
"Helvetica Neue",
|
|
21251
|
+
"Arial",
|
|
21252
|
+
"sans-serif"
|
|
21253
|
+
],
|
|
21254
|
+
"Segoe UI Semibold": [
|
|
21255
|
+
"Selawik Semibold",
|
|
21256
|
+
"Liberation Sans",
|
|
21257
|
+
"Arimo",
|
|
21258
|
+
"Helvetica Neue",
|
|
21259
|
+
"Arial",
|
|
21260
|
+
"sans-serif"
|
|
21261
|
+
],
|
|
21262
|
+
// Classic Windows fonts → cross-platform equivalents. Arimo/Tinos/Cousine
|
|
21263
|
+
// are Google's metric-compatible clones of Arial/Times New Roman/Courier
|
|
21264
|
+
// New (the same project that produced Carlito/Caladea) and, unlike
|
|
21265
|
+
// Liberation Sans/Serif/Mono, are served by Google Fonts, so listing them
|
|
21266
|
+
// is what lets the webfont loader actually fetch a matching face when the
|
|
21267
|
+
// reader's system has neither the original nor the Liberation family.
|
|
21268
|
+
"Times New Roman": ["Liberation Serif", "Tinos", "Times", "serif"],
|
|
21269
|
+
Arial: ["Liberation Sans", "Arimo", "Helvetica", "sans-serif"],
|
|
21270
|
+
"Arial Black": ["Liberation Sans", "Arimo", "Helvetica", "sans-serif"],
|
|
21271
|
+
"Arial Narrow": ["Liberation Sans Narrow", "Arimo", "Helvetica Neue", "sans-serif"],
|
|
21272
|
+
Helvetica: ["Liberation Sans", "Arimo", "Arial", "sans-serif"],
|
|
21273
|
+
"Helvetica Neue": ["Liberation Sans", "Arimo", "Arial", "sans-serif"],
|
|
21274
|
+
"Courier New": ["Liberation Mono", "Cousine", "Courier", "monospace"],
|
|
21275
|
+
Verdana: ["DejaVu Sans", "Bitstream Vera Sans", "sans-serif"],
|
|
21276
|
+
// Gelasio is Google's metric-compatible clone of Georgia (built the same
|
|
21277
|
+
// way as Carlito/Caladea from Georgia's own hmtx table); Liberation Serif
|
|
21278
|
+
// is not metrically close to Georgia and stays only as a further fallback.
|
|
21279
|
+
Georgia: ["Gelasio", "Liberation Serif", "Times New Roman", "serif"],
|
|
21280
|
+
Tahoma: ["DejaVu Sans", "Liberation Sans", "sans-serif"],
|
|
21281
|
+
Trebuchet: ["Liberation Sans", "sans-serif"],
|
|
21282
|
+
"Trebuchet MS": ["Liberation Sans", "sans-serif"],
|
|
21283
|
+
"Comic Sans MS": ["Comic Neue", "cursive"],
|
|
21284
|
+
Impact: ["Charcoal", "sans-serif"],
|
|
21285
|
+
"Lucida Console": ["Liberation Mono", "monospace"],
|
|
21286
|
+
"Lucida Sans Unicode": ["Lucida Grande", "Liberation Sans", "sans-serif"],
|
|
21287
|
+
Palatino: ["Palatino Linotype", "Book Antiqua", "serif"],
|
|
21288
|
+
"Palatino Linotype": ["Palatino", "Book Antiqua", "serif"],
|
|
21289
|
+
"Book Antiqua": ["Palatino Linotype", "Palatino", "serif"],
|
|
21290
|
+
// CJK fonts
|
|
21291
|
+
"MS PGothic": ["Noto Sans CJK JP", "Hiragino Sans", "Yu Gothic", "sans-serif"],
|
|
21292
|
+
"MS PMincho": ["Noto Serif CJK JP", "Hiragino Mincho ProN", "Yu Mincho", "serif"],
|
|
21293
|
+
"MS Gothic": ["Noto Sans CJK JP", "Hiragino Sans", "Yu Gothic", "sans-serif"],
|
|
21294
|
+
"MS Mincho": ["Noto Serif CJK JP", "Hiragino Mincho ProN", "Yu Mincho", "serif"],
|
|
21295
|
+
SimSun: ["Noto Serif CJK SC", "STSong", "serif"],
|
|
21296
|
+
SimHei: ["Noto Sans CJK SC", "STHeiti", "sans-serif"],
|
|
21297
|
+
"Microsoft YaHei": ["Noto Sans CJK SC", "PingFang SC", "sans-serif"],
|
|
21298
|
+
NSimSun: ["Noto Serif CJK SC", "STSong", "serif"],
|
|
21299
|
+
FangSong: ["Noto Serif CJK SC", "STFangsong", "serif"],
|
|
21300
|
+
KaiTi: ["Noto Serif CJK SC", "STKaiti", "serif"],
|
|
21301
|
+
DengXian: ["Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "sans-serif"],
|
|
21302
|
+
\u7B49\u7EBF: ["DengXian", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "sans-serif"],
|
|
21303
|
+
\u5B8B\u4F53: ["SimSun", "Songti SC", "STSong", "Noto Serif CJK SC", "serif"],
|
|
21304
|
+
\u65B0\u5B8B\u4F53: ["NSimSun", "Songti SC", "STSong", "Noto Serif CJK SC", "serif"],
|
|
21305
|
+
\u9ED1\u4F53: ["SimHei", "Heiti SC", "STHeiti", "PingFang SC", "Noto Sans CJK SC", "sans-serif"],
|
|
21306
|
+
\u4EFF\u5B8B: ["FangSong", "STFangsong", "Songti SC", "Noto Serif CJK SC", "serif"],
|
|
21307
|
+
\u6977\u4F53: ["KaiTi", "Kaiti SC", "STKaiti", "Noto Serif CJK SC", "serif"],
|
|
21308
|
+
Batang: ["Noto Serif CJK KR", "AppleMyungjo", "serif"],
|
|
21309
|
+
Dotum: ["Noto Sans CJK KR", "AppleGothic", "sans-serif"],
|
|
21310
|
+
Gulim: ["Noto Sans CJK KR", "AppleGothic", "sans-serif"],
|
|
21311
|
+
Malgun: ["Noto Sans CJK KR", "Apple SD Gothic Neo", "sans-serif"],
|
|
21312
|
+
"Malgun Gothic": ["Noto Sans CJK KR", "Apple SD Gothic Neo", "sans-serif"],
|
|
21313
|
+
// Source Han Sans (Adobe/Google) ships the same glyphs as Noto Sans CJK;
|
|
21314
|
+
// the zh-CN name 思源黑体 is how decks authored in Chinese reference it.
|
|
21315
|
+
"\u601D\u6E90\u9ED1\u4F53 CN": [
|
|
21316
|
+
"Source Han Sans CN",
|
|
21317
|
+
"Noto Sans CJK SC",
|
|
21318
|
+
"Noto Sans SC",
|
|
21319
|
+
"Microsoft YaHei",
|
|
21320
|
+
"sans-serif"
|
|
21321
|
+
],
|
|
21322
|
+
\u601D\u6E90\u9ED1\u4F53: [
|
|
21323
|
+
"Source Han Sans SC",
|
|
21324
|
+
"Noto Sans CJK SC",
|
|
21325
|
+
"Noto Sans SC",
|
|
21326
|
+
"Microsoft YaHei",
|
|
21327
|
+
"sans-serif"
|
|
21328
|
+
],
|
|
21329
|
+
"Source Han Sans CN": [
|
|
21330
|
+
"\u601D\u6E90\u9ED1\u4F53 CN",
|
|
21331
|
+
"Noto Sans CJK SC",
|
|
21332
|
+
"Noto Sans SC",
|
|
21333
|
+
"Microsoft YaHei",
|
|
21334
|
+
"sans-serif"
|
|
21335
|
+
],
|
|
21336
|
+
\u5FAE\u8F6F\u96C5\u9ED1: ["Microsoft YaHei", "Noto Sans CJK SC", "PingFang SC", "sans-serif"],
|
|
21337
|
+
// Complex script fonts
|
|
21338
|
+
"Arabic Typesetting": ["Noto Naskh Arabic", "serif"],
|
|
21339
|
+
"Simplified Arabic": ["Noto Sans Arabic", "sans-serif"],
|
|
21340
|
+
"Traditional Arabic": ["Noto Naskh Arabic", "serif"],
|
|
21341
|
+
Mangal: ["Noto Sans Devanagari", "sans-serif"],
|
|
21342
|
+
Vrinda: ["Noto Sans Bengali", "sans-serif"],
|
|
21343
|
+
Raavi: ["Noto Sans Gurmukhi", "sans-serif"],
|
|
21344
|
+
Shruti: ["Noto Sans Gujarati", "sans-serif"],
|
|
21345
|
+
Tunga: ["Noto Sans Kannada", "sans-serif"],
|
|
21346
|
+
Kartika: ["Noto Sans Malayalam", "sans-serif"],
|
|
21347
|
+
Iskoola: ["Noto Sans Sinhala", "sans-serif"],
|
|
21348
|
+
"Iskoola Pota": ["Noto Sans Sinhala", "sans-serif"],
|
|
21349
|
+
Leelawadee: ["Noto Sans Thai", "sans-serif"],
|
|
21350
|
+
"Leelawadee UI": ["Noto Sans Thai", "sans-serif"],
|
|
21351
|
+
"Cordia New": ["Noto Sans Thai", "sans-serif"],
|
|
21352
|
+
DokChampa: ["Noto Sans Lao", "sans-serif"],
|
|
21353
|
+
Nyala: ["Noto Sans Ethiopic", "sans-serif"],
|
|
21354
|
+
MoolBoran: ["Noto Sans Khmer", "sans-serif"],
|
|
21355
|
+
// Decorative / Display
|
|
21356
|
+
// Condensed display faces: decks often reference the FULL style name
|
|
21357
|
+
// ("Bebas Neue Regular"); the suffix-stripped base resolves here. The
|
|
21358
|
+
// fallbacks must stay condensed, or short numeric labels sized to the
|
|
21359
|
+
// narrow face overflow their text boxes and wrap (issue #132, "77%").
|
|
21360
|
+
"Bebas Neue": ["Oswald", "Arial Narrow", "Impact", "sans-serif"],
|
|
21361
|
+
// Office stores named Source Sans weights as separate family names (e.g. a
|
|
21362
|
+
// theme authored with "Source Sans Pro ExtraLight" as its own face), while
|
|
21363
|
+
// Google Fonts and most local installs expose the base family with a
|
|
21364
|
+
// weight axis instead. Keep the authored face first for a browser that
|
|
21365
|
+
// does have it installed under that exact name, then fall back to the
|
|
21366
|
+
// metrically compatible base family before generic sans-serif.
|
|
21367
|
+
"Source Sans Pro ExtraLight": [
|
|
21368
|
+
"Source Sans Pro",
|
|
21369
|
+
"Calibri Light",
|
|
21370
|
+
"Segoe UI Light",
|
|
21371
|
+
"Arial",
|
|
21372
|
+
"sans-serif"
|
|
21373
|
+
],
|
|
21374
|
+
"Century Gothic": ["URW Gothic", "Futura", "sans-serif"],
|
|
21375
|
+
Oswald: ["Agency FB", "Arial Narrow", "sans-serif"],
|
|
21376
|
+
"Franklin Gothic": ["Liberation Sans", "Helvetica Neue", "sans-serif"],
|
|
21377
|
+
"Franklin Gothic Medium": ["Liberation Sans", "Helvetica Neue", "sans-serif"],
|
|
21378
|
+
Garamond: ["EB Garamond", "Cormorant Garamond", "serif"],
|
|
21379
|
+
"Tw Cen MT": ["Century Gothic", "Futura", "sans-serif"],
|
|
21380
|
+
Rockwell: ["Roboto Slab", "Rockwell", "serif"],
|
|
21381
|
+
Candara: ["Liberation Sans", "Optima", "sans-serif"],
|
|
21382
|
+
Constantia: ["Liberation Serif", "Palatino", "serif"],
|
|
21383
|
+
Corbel: ["Liberation Sans", "Lucida Grande", "sans-serif"]
|
|
21384
|
+
};
|
|
21385
|
+
|
|
21386
|
+
// text/font-substitution.ts
|
|
21387
|
+
new Map(
|
|
21388
|
+
Object.entries(FONT_SUBSTITUTION_MAP).map(([name, fonts]) => [name.toLowerCase(), fonts])
|
|
21389
|
+
);
|
|
21390
|
+
var CSS_GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
21391
|
+
"serif",
|
|
21392
|
+
"sans-serif",
|
|
21393
|
+
"monospace",
|
|
21394
|
+
"cursive",
|
|
21395
|
+
"fantasy",
|
|
21396
|
+
"system-ui",
|
|
21397
|
+
"ui-serif",
|
|
21398
|
+
"ui-sans-serif",
|
|
21399
|
+
"ui-monospace",
|
|
21400
|
+
"ui-rounded",
|
|
21401
|
+
"math",
|
|
21402
|
+
"emoji",
|
|
21403
|
+
"fangsong"
|
|
21404
|
+
]);
|
|
21405
|
+
function buildFontFamilyString(primary, fallbacks) {
|
|
21406
|
+
const parts = [quoteFontName(primary)];
|
|
21407
|
+
for (const fb of fallbacks) {
|
|
21408
|
+
const quoted = quoteFontName(fb);
|
|
21409
|
+
if (!parts.includes(quoted)) {
|
|
21410
|
+
parts.push(quoted);
|
|
21411
|
+
}
|
|
21412
|
+
}
|
|
21413
|
+
return parts.join(", ");
|
|
21414
|
+
}
|
|
21415
|
+
function quoteFontName(name) {
|
|
21416
|
+
const trimmed = name.trim();
|
|
21417
|
+
if (CSS_GENERIC_FAMILIES.has(trimmed.toLowerCase())) {
|
|
21418
|
+
return trimmed;
|
|
21419
|
+
}
|
|
21420
|
+
return `"${trimmed.replace(/["\\\r\n\f]/g, "")}"`;
|
|
21421
|
+
}
|
|
21422
|
+
|
|
21423
|
+
// text/unicode-script-detection.ts
|
|
21424
|
+
function detectFontScript(codePoint) {
|
|
21425
|
+
if (codePoint >= 11904 && codePoint <= 40959 || // CJK radicals, unified ideographs
|
|
21426
|
+
codePoint >= 44032 && codePoint <= 55215 || // Hangul syllables
|
|
21427
|
+
codePoint >= 63744 && codePoint <= 64255 || // CJK compatibility ideographs
|
|
21428
|
+
codePoint >= 65072 && codePoint <= 65103 || // CJK compatibility forms
|
|
21429
|
+
codePoint >= 131072 && codePoint <= 195103 || // CJK extension B-F
|
|
21430
|
+
codePoint >= 12288 && codePoint <= 12351 || // CJK symbols & punctuation
|
|
21431
|
+
codePoint >= 12352 && codePoint <= 12447 || // Hiragana
|
|
21432
|
+
codePoint >= 12448 && codePoint <= 12543 || // Katakana
|
|
21433
|
+
codePoint >= 12784 && codePoint <= 12799 || // Katakana extensions
|
|
21434
|
+
codePoint >= 65280 && codePoint <= 65519) {
|
|
21435
|
+
return "eastAsia";
|
|
21436
|
+
}
|
|
21437
|
+
if (codePoint >= 1424 && codePoint <= 1535 || // Hebrew
|
|
21438
|
+
codePoint >= 1536 && codePoint <= 1791 || // Arabic
|
|
21439
|
+
codePoint >= 1792 && codePoint <= 1871 || // Syriac
|
|
21440
|
+
codePoint >= 1872 && codePoint <= 1919 || // Arabic Supplement
|
|
21441
|
+
codePoint >= 1920 && codePoint <= 1983 || // Thaana
|
|
21442
|
+
codePoint >= 1984 && codePoint <= 2047 || // NKo
|
|
21443
|
+
codePoint >= 2048 && codePoint <= 2111 || // Samaritan
|
|
21444
|
+
codePoint >= 2304 && codePoint <= 2431 || // Devanagari
|
|
21445
|
+
codePoint >= 2432 && codePoint <= 2559 || // Bengali
|
|
21446
|
+
codePoint >= 2560 && codePoint <= 2687 || // Gurmukhi
|
|
21447
|
+
codePoint >= 2688 && codePoint <= 2815 || // Gujarati
|
|
21448
|
+
codePoint >= 2816 && codePoint <= 2943 || // Oriya
|
|
21449
|
+
codePoint >= 2944 && codePoint <= 3071 || // Tamil
|
|
21450
|
+
codePoint >= 3072 && codePoint <= 3199 || // Telugu
|
|
21451
|
+
codePoint >= 3200 && codePoint <= 3327 || // Kannada
|
|
21452
|
+
codePoint >= 3328 && codePoint <= 3455 || // Malayalam
|
|
21453
|
+
codePoint >= 3456 && codePoint <= 3583 || // Sinhala
|
|
21454
|
+
codePoint >= 3584 && codePoint <= 3711 || // Thai
|
|
21455
|
+
codePoint >= 3712 && codePoint <= 3839 || // Lao
|
|
21456
|
+
codePoint >= 3840 && codePoint <= 4095 || // Tibetan
|
|
21457
|
+
codePoint >= 4096 && codePoint <= 4255 || // Myanmar
|
|
21458
|
+
codePoint >= 4256 && codePoint <= 4351 || // Georgian
|
|
21459
|
+
codePoint >= 6016 && codePoint <= 6143 || // Khmer
|
|
21460
|
+
codePoint >= 64336 && codePoint <= 65023 || // Arabic Presentation Forms-A
|
|
21461
|
+
codePoint >= 65136 && codePoint <= 65279) {
|
|
21462
|
+
return "complexScript";
|
|
21463
|
+
}
|
|
21464
|
+
if (codePoint >= 8592 && codePoint <= 8703 || // Arrows
|
|
21465
|
+
codePoint >= 8704 && codePoint <= 8959 || // Mathematical operators
|
|
21466
|
+
codePoint >= 8960 && codePoint <= 9215 || // Misc technical
|
|
21467
|
+
codePoint >= 9472 && codePoint <= 9599 || // Box drawing
|
|
21468
|
+
codePoint >= 9600 && codePoint <= 9631 || // Block elements
|
|
21469
|
+
codePoint >= 9632 && codePoint <= 9727 || // Geometric shapes
|
|
21470
|
+
codePoint >= 9728 && codePoint <= 9983 || // Misc symbols
|
|
21471
|
+
codePoint >= 9984 && codePoint <= 10175 || // Dingbats
|
|
21472
|
+
codePoint >= 57344 && codePoint <= 63743 || // Private Use Area
|
|
21473
|
+
codePoint >= 126976 && codePoint <= 129535) {
|
|
21474
|
+
return "symbol";
|
|
21475
|
+
}
|
|
21476
|
+
return "latin";
|
|
21477
|
+
}
|
|
21478
|
+
function segmentByScript(text2) {
|
|
21479
|
+
if (!text2) {
|
|
21480
|
+
return [];
|
|
21481
|
+
}
|
|
21482
|
+
const runs = [];
|
|
21483
|
+
let currentScript = null;
|
|
21484
|
+
let currentStart = 0;
|
|
21485
|
+
let currentText = "";
|
|
21486
|
+
for (let i = 0; i < text2.length; i++) {
|
|
21487
|
+
const codePoint = text2.codePointAt(i);
|
|
21488
|
+
if (codePoint === void 0) {
|
|
21489
|
+
continue;
|
|
21490
|
+
}
|
|
21491
|
+
const charLength = codePoint > 65535 ? 2 : 1;
|
|
21492
|
+
const char = text2.substring(i, i + charLength);
|
|
21493
|
+
const isNeutral = codePoint <= 127 && !/[a-zA-Z0-9]/u.test(char);
|
|
21494
|
+
const script = isNeutral ? currentScript ?? "latin" : detectFontScript(codePoint);
|
|
21495
|
+
if (script !== currentScript && currentScript !== null) {
|
|
21496
|
+
runs.push({
|
|
21497
|
+
text: currentText,
|
|
21498
|
+
script: currentScript,
|
|
21499
|
+
startIndex: currentStart
|
|
21500
|
+
});
|
|
21501
|
+
currentStart = i;
|
|
21502
|
+
currentText = "";
|
|
21503
|
+
}
|
|
21504
|
+
currentScript = script;
|
|
21505
|
+
currentText += char;
|
|
21506
|
+
if (charLength === 2) {
|
|
21507
|
+
i++;
|
|
21508
|
+
}
|
|
21509
|
+
}
|
|
21510
|
+
if (currentText && currentScript) {
|
|
21511
|
+
runs.push({
|
|
21512
|
+
text: currentText,
|
|
21513
|
+
script: currentScript,
|
|
21514
|
+
startIndex: currentStart
|
|
21515
|
+
});
|
|
21516
|
+
}
|
|
21517
|
+
return runs;
|
|
21518
|
+
}
|
|
21519
|
+
function resolveFontForScript(script, fonts) {
|
|
21520
|
+
switch (script) {
|
|
21521
|
+
case "latin":
|
|
21522
|
+
return fonts.latin;
|
|
21523
|
+
case "eastAsia":
|
|
21524
|
+
return fonts.eastAsia || fonts.latin;
|
|
21525
|
+
case "complexScript":
|
|
21526
|
+
return fonts.complexScript || fonts.latin;
|
|
21527
|
+
case "symbol":
|
|
21528
|
+
return fonts.symbol || fonts.latin;
|
|
21529
|
+
}
|
|
21530
|
+
}
|
|
21531
|
+
|
|
21532
|
+
// text/script-fonts.ts
|
|
21533
|
+
function segmentByFont(text2, fonts) {
|
|
21534
|
+
const result = [];
|
|
21535
|
+
for (const run of segmentByScript(text2)) {
|
|
21536
|
+
const fontFamily = resolveFontForScript(run.script, fonts) ?? fonts.latin;
|
|
21537
|
+
const previous = result.at(-1);
|
|
21538
|
+
if (previous?.fontFamily === fontFamily) previous.text += run.text;
|
|
21539
|
+
else result.push({ text: run.text, startIndex: run.startIndex, fontFamily });
|
|
21540
|
+
}
|
|
21541
|
+
return result;
|
|
21542
|
+
}
|
|
21543
|
+
|
|
21544
|
+
// docx/layout/script-fonts.ts
|
|
21545
|
+
function scriptLayoutRuns(run, formatting, theme) {
|
|
21546
|
+
if (!run.text || run.hidden || run.object || run.footnoteReferenceId || run.sourceLength !== void 0 && run.sourceLength !== run.text.length)
|
|
21547
|
+
return [run];
|
|
21548
|
+
const latin = run.fontFamily || DEFAULT_FONT_FAMILY;
|
|
21549
|
+
const eaRole = formatting.fontTheme?.eastAsia;
|
|
21550
|
+
const csRole = formatting.fontTheme?.cs;
|
|
21551
|
+
const fonts = {
|
|
21552
|
+
latin,
|
|
21553
|
+
eastAsia: formatting.fontFamilyEastAsia || eaRole && theme?.fonts[eaRole]?.eastAsia || latin,
|
|
21554
|
+
complexScript: formatting.fontFamilyComplexScript || csRole && theme?.fonts[csRole]?.complexScript || latin,
|
|
21555
|
+
symbol: latin
|
|
21556
|
+
};
|
|
21557
|
+
const pieces = segmentByFont(run.text, fonts);
|
|
21558
|
+
if (pieces.length === 1 && pieces[0]?.fontFamily === latin) return [run];
|
|
21559
|
+
const { breakAfter, ...style } = run;
|
|
21560
|
+
return pieces.map((piece, index) => ({
|
|
21561
|
+
...style,
|
|
21562
|
+
text: piece.text,
|
|
21563
|
+
fontFamily: piece.fontFamily,
|
|
21564
|
+
sourceLength: piece.text.length,
|
|
21565
|
+
...breakAfter && index === pieces.length - 1 ? { breakAfter } : {}
|
|
21566
|
+
}));
|
|
21567
|
+
}
|
|
21568
|
+
|
|
20161
21569
|
// docx/layout/adapt-floats.ts
|
|
20162
21570
|
function paragraphFloats(paragraph, theme) {
|
|
20163
21571
|
const floats = [];
|
|
@@ -20635,14 +22043,14 @@ function matrixEnvFor(open, close) {
|
|
|
20635
22043
|
return env !== "array" && env !== "matrix" && envOpen === open && envClose === close;
|
|
20636
22044
|
});
|
|
20637
22045
|
}
|
|
20638
|
-
function rowsToLatex(emit,
|
|
20639
|
-
return
|
|
22046
|
+
function rowsToLatex(emit, rows2) {
|
|
22047
|
+
return rows2.map((row2) => emit.children(row2)).join(" \\\\ ");
|
|
20640
22048
|
}
|
|
20641
22049
|
function matrixToLatex(emit, node, env) {
|
|
20642
|
-
const
|
|
22050
|
+
const rows2 = ensureArr(node["m:mr"]).map(
|
|
20643
22051
|
(row2) => ensureArr(row2["m:e"]).map((cell) => emit.children(cell)).join(" & ")
|
|
20644
22052
|
);
|
|
20645
|
-
return `\\begin{${env}}${
|
|
22053
|
+
return `\\begin{${env}}${rows2.join(" \\\\ ")}\\end{${env}}`;
|
|
20646
22054
|
}
|
|
20647
22055
|
function eqArrToLatex(emit, node) {
|
|
20648
22056
|
return `\\begin{aligned}${rowsToLatex(emit, ensureArr(node["m:e"]))}\\end{aligned}`;
|
|
@@ -21092,25 +22500,25 @@ function delimiter(node, style, ctx) {
|
|
|
21092
22500
|
return row([open, content, close], style.size * 0.04);
|
|
21093
22501
|
}
|
|
21094
22502
|
function matrix(node, style, ctx) {
|
|
21095
|
-
const
|
|
22503
|
+
const rows2 = ensureArray(node["m:mr"]).map(
|
|
21096
22504
|
(mr) => ensureArray(mr["m:e"]).map((cell) => ctx.layout(cell, style))
|
|
21097
22505
|
);
|
|
21098
|
-
const columns = Math.max(0, ...
|
|
22506
|
+
const columns = Math.max(0, ...rows2.map((cells) => cells.length));
|
|
21099
22507
|
const widths = Array.from(
|
|
21100
22508
|
{ length: columns },
|
|
21101
|
-
(_, c) => Math.max(0, ...
|
|
22509
|
+
(_, c) => Math.max(0, ...rows2.map((cells) => cells[c]?.width ?? 0))
|
|
21102
22510
|
);
|
|
21103
22511
|
const gapX = style.size * 0.8;
|
|
21104
22512
|
const gapY = style.size * 0.3;
|
|
21105
22513
|
const result = emptyBox();
|
|
21106
22514
|
let y = 0;
|
|
21107
|
-
const heights =
|
|
22515
|
+
const heights = rows2.map((cells) => ({
|
|
21108
22516
|
a: Math.max(style.size * 0.78, ...cells.map((cell) => cell.ascent)),
|
|
21109
22517
|
d: Math.max(style.size * 0.22, ...cells.map((cell) => cell.descent))
|
|
21110
22518
|
}));
|
|
21111
|
-
const total = heights.reduce((sum, h) => sum + h.a + h.d, 0) + gapY * Math.max(0,
|
|
22519
|
+
const total = heights.reduce((sum, h) => sum + h.a + h.d, 0) + gapY * Math.max(0, rows2.length - 1);
|
|
21112
22520
|
y = -(total / 2) + style.size * AXIS;
|
|
21113
|
-
|
|
22521
|
+
rows2.forEach((cells, r) => {
|
|
21114
22522
|
const h = heights[r];
|
|
21115
22523
|
y += h.a;
|
|
21116
22524
|
let x = 0;
|
|
@@ -21285,11 +22693,11 @@ function layoutStructure(tag, node, style, ctx) {
|
|
|
21285
22693
|
}
|
|
21286
22694
|
case "m:borderBox": {
|
|
21287
22695
|
const inner = arg2("m:e");
|
|
21288
|
-
const
|
|
21289
|
-
const box = placed(inner,
|
|
21290
|
-
box.width = inner.width +
|
|
21291
|
-
box.ascent +=
|
|
21292
|
-
box.descent +=
|
|
22696
|
+
const pad2 = style.size * 0.15;
|
|
22697
|
+
const box = placed(inner, pad2, 0);
|
|
22698
|
+
box.width = inner.width + pad2 * 2;
|
|
22699
|
+
box.ascent += pad2;
|
|
22700
|
+
box.descent += pad2;
|
|
21293
22701
|
box.prims.push({
|
|
21294
22702
|
kind: "rect",
|
|
21295
22703
|
x: 0,
|
|
@@ -21332,15 +22740,15 @@ function layoutRun(node, style, atStart) {
|
|
|
21332
22740
|
const spaced = style.level > 0 ? 0 : isRelation(ch) ? 0.28 : isBinary(ch) && !unary ? 0.22 : 0;
|
|
21333
22741
|
previous = ch;
|
|
21334
22742
|
const width = glyphEm(ch, bold) * style.size;
|
|
21335
|
-
const
|
|
22743
|
+
const pad2 = spaced * style.size;
|
|
21336
22744
|
const box = emptyBox();
|
|
21337
|
-
box.width = width +
|
|
22745
|
+
box.width = width + pad2 * 2;
|
|
21338
22746
|
box.ascent = style.size * 0.78;
|
|
21339
22747
|
box.descent = style.size * 0.22;
|
|
21340
22748
|
if (ch !== " " || width)
|
|
21341
22749
|
box.prims.push({
|
|
21342
22750
|
kind: "text",
|
|
21343
|
-
x:
|
|
22751
|
+
x: pad2,
|
|
21344
22752
|
y: 0,
|
|
21345
22753
|
text: ch,
|
|
21346
22754
|
size: style.size,
|
|
@@ -21389,12 +22797,12 @@ function layoutElement(tag, node, style, atStart) {
|
|
|
21389
22797
|
}
|
|
21390
22798
|
function layoutEquation(root, sizePx) {
|
|
21391
22799
|
const box = layoutChildren(root, { level: 0, size: sizePx });
|
|
21392
|
-
const
|
|
21393
|
-
const ascent = Math.max(box.ascent, sizePx * 0.78) +
|
|
21394
|
-
const descent = Math.max(box.descent, sizePx * 0.22) +
|
|
22800
|
+
const pad2 = 1;
|
|
22801
|
+
const ascent = Math.max(box.ascent, sizePx * 0.78) + pad2;
|
|
22802
|
+
const descent = Math.max(box.descent, sizePx * 0.22) + pad2;
|
|
21395
22803
|
return {
|
|
21396
|
-
box: { ...box, prims: shifted(box.prims,
|
|
21397
|
-
widthPx: round2(Math.max(box.width, sizePx * 0.5) +
|
|
22804
|
+
box: { ...box, prims: shifted(box.prims, pad2, 0), ascent, descent },
|
|
22805
|
+
widthPx: round2(Math.max(box.width, sizePx * 0.5) + pad2 * 2),
|
|
21398
22806
|
heightPx: round2(ascent + descent),
|
|
21399
22807
|
descentPx: round2(descent)
|
|
21400
22808
|
};
|
|
@@ -21841,7 +23249,12 @@ function adaptDocumentModel(model, note = () => {
|
|
|
21841
23249
|
const label = labels.get(paragraph.id);
|
|
21842
23250
|
const ownFirstLine = resolved.firstLineTwips !== void 0 || resolved.hangingTwips !== void 0;
|
|
21843
23251
|
const runs = paragraph.runs.flatMap(
|
|
21844
|
-
(run) => symbolSegments(run).
|
|
23252
|
+
(run) => symbolSegments(run).flatMap((segment2) => {
|
|
23253
|
+
const adapted = adaptRun(segment2, paragraph.style, markLabel);
|
|
23254
|
+
if (segment2.field || segment2.noteReference || segment2.noteMark || symbolOnly(segment2))
|
|
23255
|
+
return [adapted];
|
|
23256
|
+
return scriptLayoutRuns(adapted, effective(segment2, paragraph.style).formatting, theme);
|
|
23257
|
+
})
|
|
21845
23258
|
);
|
|
21846
23259
|
const visible = visibleReviewParagraph(paragraph, reviewMode);
|
|
21847
23260
|
const footnotes = paragraphFootnotes(visible, visibleModel, noteLabel, adaptParagraph);
|
|
@@ -22144,8 +23557,8 @@ function layoutDocumentModel(model, measurer, options2 = {}, layout = layoutDocu
|
|
|
22144
23557
|
};
|
|
22145
23558
|
}
|
|
22146
23559
|
|
|
22147
|
-
//
|
|
22148
|
-
var
|
|
23560
|
+
// text/metric-font-family.ts
|
|
23561
|
+
var METRIC_FONT_SUBSTITUTES = {
|
|
22149
23562
|
calibri: { fallbacks: ["Carlito"], generic: "sans-serif" },
|
|
22150
23563
|
"calibri light": { fallbacks: ["Carlito"], generic: "sans-serif" },
|
|
22151
23564
|
cambria: { fallbacks: ["Caladea"], generic: "serif" },
|
|
@@ -22158,13 +23571,15 @@ var SUBSTITUTES = {
|
|
|
22158
23571
|
georgia: { fallbacks: ["Gelasio"], generic: "serif" },
|
|
22159
23572
|
consolas: { fallbacks: ["Inconsolata"], generic: "monospace" }
|
|
22160
23573
|
};
|
|
22161
|
-
|
|
23574
|
+
function metricFontFamily(name) {
|
|
23575
|
+
const key = name.trim();
|
|
23576
|
+
const known = Object.hasOwn(METRIC_FONT_SUBSTITUTES, key.toLowerCase()) ? METRIC_FONT_SUBSTITUTES[key.toLowerCase()] : void 0;
|
|
23577
|
+
return buildFontFamilyString(key, [...known?.fallbacks ?? [], known?.generic ?? "sans-serif"]);
|
|
23578
|
+
}
|
|
23579
|
+
|
|
23580
|
+
// docx/layout/fonts.ts
|
|
22162
23581
|
function cssFontStack(family) {
|
|
22163
|
-
|
|
22164
|
-
const known = SUBSTITUTES[name.toLowerCase()];
|
|
22165
|
-
return [quote(name), ...(known?.fallbacks ?? []).map(quote), known?.generic ?? "sans-serif"].join(
|
|
22166
|
-
", "
|
|
22167
|
-
);
|
|
23582
|
+
return metricFontFamily(family?.trim() || DEFAULT_FONT_FAMILY);
|
|
22168
23583
|
}
|
|
22169
23584
|
|
|
22170
23585
|
// docx/layout/incremental-layout.ts
|