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