ooxml-ui 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -36
- package/custom-elements.json +372 -4
- package/dist/chrome/ruler.d.ts +60 -2
- package/dist/chrome/ruler.d.ts.map +1 -1
- package/dist/chrome/status-bar.d.ts +3 -1
- package/dist/chrome/status-bar.d.ts.map +1 -1
- package/dist/{chunk-JFJXBYRD.js → chunk-2WLRFPMW.js} +9 -0
- package/dist/{chunk-X7RINDJQ.js → chunk-56A2JK63.js} +1 -1
- package/dist/{chunk-KVKKXRL7.js → chunk-5OFAJDMQ.js} +93 -14
- package/dist/{chunk-M5DTJSOV.js → chunk-723JC3OC.js} +461 -16
- package/dist/{chunk-USDLALB5.js → chunk-IY7QJLQG.js} +1 -1
- package/dist/{chunk-BOX43CZD.js → chunk-M6GF5ED2.js} +2 -1
- package/dist/{chunk-BEN3453I.js → chunk-NYRRH2MD.js} +1 -1
- package/dist/{chunk-3FPW7M6U.js → chunk-TWQ45BFL.js} +1 -1
- package/dist/{chunk-ZU7GX4SY.js → chunk-V6P6KZCO.js} +7 -5
- package/dist/comments/comments-pane.d.ts +116 -0
- package/dist/comments/comments-pane.d.ts.map +1 -0
- package/dist/comments/types.d.ts +80 -0
- package/dist/comments/types.d.ts.map +1 -0
- package/dist/controls.d.ts +6 -2
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +5 -5
- package/dist/docx/comments-panel.d.ts +8 -1
- package/dist/docx/editor-chrome.d.ts +8 -1
- package/dist/docx/file-commands.d.ts +1 -1
- package/dist/docx/image-media.d.ts +1 -1
- package/dist/docx/locales/en-app.d.ts +1 -0
- package/dist/docx/locales/en-ribbon.d.ts +1 -0
- package/dist/docx/locales/en.d.ts +2 -0
- package/dist/docx/localization-strings.d.ts +2 -0
- package/dist/docx/localization.d.ts +7 -0
- package/dist/docx/print-layout.d.ts +2 -2
- package/dist/docx/print-picture.d.ts +12 -0
- package/dist/docx/review-controller.d.ts +2 -0
- package/dist/docx/ribbon-actions.d.ts +22 -0
- package/dist/docx/ruler.d.ts +7 -10
- package/dist/docx/title-bar.d.ts +3 -5
- package/dist/docx.js +342 -362
- package/dist/form/gradient-preset-gallery.d.ts +2 -2
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/pptx/{chart-3d-view-scene-2KRQ5667.mjs → chart-3d-view-scene-OYJ4CDCO.mjs} +4 -5
- package/dist/pptx/{chart-3d-view-scene-36DMZWZ3.cjs → chart-3d-view-scene-SE2Y6QRE.cjs} +38 -39
- package/dist/pptx/{chunk-YOGDIDPB.mjs → chunk-CIVA3MLN.mjs} +8 -2
- package/dist/pptx/{chunk-KPZWYF44.cjs → chunk-FPE5PZMI.cjs} +789 -491
- package/dist/pptx/{chunk-AIL3BNZS.cjs → chunk-IURZJAWP.cjs} +529 -387
- package/dist/pptx/{chunk-YHA6XAB3.cjs → chunk-KRMMJUCO.cjs} +83 -1
- package/dist/pptx/{chunk-Y2W4SZER.mjs → chunk-MWHGUEIJ.mjs} +637 -348
- package/dist/pptx/{chunk-YARCML7O.mjs → chunk-STLXPKJJ.mjs} +519 -388
- package/dist/pptx/{chunk-ADOC5JLI.mjs → chunk-TC7HCF5M.mjs} +76 -2
- package/dist/pptx/{chunk-CJU4P5FT.cjs → chunk-WKLHJEPD.cjs} +18 -12
- package/dist/pptx/dom/element-styles.d.ts.map +1 -1
- package/dist/pptx/dom/elements/chart.d.ts +2 -3
- package/dist/pptx/dom/elements/chart.d.ts.map +1 -1
- package/dist/pptx/dom/elements/connector.d.ts.map +1 -1
- package/dist/pptx/dom/elements/shape-filter-defs.d.ts.map +1 -1
- package/dist/pptx/dom/elements/table.d.ts.map +1 -1
- package/dist/pptx/dom/index.cjs +272 -261
- package/dist/pptx/dom/index.mjs +46 -35
- package/dist/pptx/dom/slide-stage.d.ts.map +1 -1
- package/dist/pptx/export/html2canvas-clone.cjs +2 -2
- package/dist/pptx/export/html2canvas-clone.mjs +1 -1
- package/dist/pptx/index.cjs +3065 -2993
- package/dist/pptx/index.mjs +4 -4
- package/dist/pptx/render/chart-3d-oblique-layout.d.ts.map +1 -1
- package/dist/pptx/render/chart-3d-persp-bars.d.ts.map +1 -1
- package/dist/pptx/render/chart-3d-persp-layout.d.ts.map +1 -1
- package/dist/pptx/render/chart-axis-range.d.ts +7 -0
- package/dist/pptx/render/chart-axis-range.d.ts.map +1 -1
- package/dist/pptx/render/chart-axis-render.d.ts +3 -1
- package/dist/pptx/render/chart-axis-render.d.ts.map +1 -1
- package/dist/pptx/render/chart-axis-style.d.ts +5 -0
- package/dist/pptx/render/chart-axis-style.d.ts.map +1 -1
- package/dist/pptx/render/chart-axis.d.ts +1 -1
- package/dist/pptx/render/chart-axis.d.ts.map +1 -1
- package/dist/pptx/render/chart-bar-cluster-geometry.d.ts +1 -1
- package/dist/pptx/render/chart-bar-cluster-geometry.d.ts.map +1 -1
- package/dist/pptx/render/chart-cartesian-area.d.ts.map +1 -1
- package/dist/pptx/render/chart-cartesian-axes.d.ts.map +1 -1
- package/dist/pptx/render/chart-cartesian-bars.d.ts +3 -3
- package/dist/pptx/render/chart-cartesian-line-area.d.ts.map +1 -1
- package/dist/pptx/render/chart-cartesian-percent-stacked.d.ts.map +1 -1
- package/dist/pptx/render/chart-cartesian-stacked-labels.d.ts +11 -7
- package/dist/pptx/render/chart-cartesian-stacked-labels.d.ts.map +1 -1
- package/dist/pptx/render/chart-cartesian.d.ts.map +1 -1
- package/dist/pptx/render/chart-combo-stock.cjs +3 -3
- package/dist/pptx/render/chart-combo-stock.mjs +1 -1
- package/dist/pptx/render/chart-combo.d.ts.map +1 -1
- package/dist/pptx/render/chart-data-label-anchor.d.ts +4 -1
- package/dist/pptx/render/chart-data-label-anchor.d.ts.map +1 -1
- package/dist/pptx/render/chart-gridlines-toggle.d.ts +13 -1
- package/dist/pptx/render/chart-gridlines-toggle.d.ts.map +1 -1
- package/dist/pptx/render/chart-helpers.d.ts +13 -13
- package/dist/pptx/render/chart-helpers.d.ts.map +1 -1
- package/dist/pptx/render/chart-horizontal-bars-helpers.d.ts +7 -3
- package/dist/pptx/render/chart-horizontal-bars-helpers.d.ts.map +1 -1
- package/dist/pptx/render/chart-horizontal-bars.d.ts.map +1 -1
- package/dist/pptx/render/chart-interaction-stacked.d.ts.map +1 -1
- package/dist/pptx/render/chart-line-path.d.ts +9 -0
- package/dist/pptx/render/chart-line-path.d.ts.map +1 -1
- package/dist/pptx/render/chart-overlays.cjs +7 -7
- package/dist/pptx/render/chart-overlays.mjs +1 -1
- package/dist/pptx/render/chart-palette.d.ts +5 -14
- package/dist/pptx/render/chart-palette.d.ts.map +1 -1
- package/dist/pptx/render/chart-plot-clip.d.ts +37 -0
- package/dist/pptx/render/chart-plot-clip.d.ts.map +1 -0
- package/dist/pptx/render/chart-quick-action-styles.d.ts +5 -3
- package/dist/pptx/render/chart-quick-action-styles.d.ts.map +1 -1
- package/dist/pptx/render/chart-scatter-x-axis.d.ts.map +1 -1
- package/dist/pptx/render/chart-style-palette.d.ts +52 -0
- package/dist/pptx/render/chart-style-palette.d.ts.map +1 -0
- package/dist/pptx/render/chart-surface-treemap.cjs +4 -4
- package/dist/pptx/render/chart-surface-treemap.mjs +1 -1
- package/dist/pptx/render/chart-view-model-bars.d.ts +32 -1
- package/dist/pptx/render/chart-view-model-bars.d.ts.map +1 -1
- package/dist/pptx/render/chart-view-model-build.d.ts.map +1 -1
- package/dist/pptx/render/chart-view-model.cjs +53 -41
- package/dist/pptx/render/chart-view-model.mjs +1 -1
- package/dist/pptx/render/chart-waterfall-map.cjs +6 -6
- package/dist/pptx/render/chart-waterfall-map.mjs +1 -1
- package/dist/pptx/render/device-pixel-stroke.d.ts +101 -0
- package/dist/pptx/render/device-pixel-stroke.d.ts.map +1 -0
- package/dist/pptx/render/export-clone.d.ts +4 -0
- package/dist/pptx/render/export-clone.d.ts.map +1 -1
- package/dist/pptx/render/foreign-object-svg-document.d.ts +12 -0
- package/dist/pptx/render/foreign-object-svg-document.d.ts.map +1 -1
- package/dist/pptx/render/index.d.ts +3 -0
- package/dist/pptx/render/index.d.ts.map +1 -1
- package/dist/pptx/render/stroke-outline.d.ts +6 -0
- package/dist/pptx/render/stroke-outline.d.ts.map +1 -1
- package/dist/pptx/render/stroke-style.d.ts +8 -2
- package/dist/pptx/render/stroke-style.d.ts.map +1 -1
- package/dist/pptx/render/tab-row-actions.d.ts +40 -0
- package/dist/pptx/render/tab-row-actions.d.ts.map +1 -0
- package/dist/pptx/render/table-cell-css.d.ts +3 -2
- package/dist/pptx/render/table-cell-css.d.ts.map +1 -1
- package/dist/pptx/render/table-cell-edit.d.ts +1 -1
- package/dist/pptx/render/table-cell-edit.d.ts.map +1 -1
- package/dist/pptx/render/table-cell-paragraphs.d.ts +29 -0
- package/dist/pptx/render/table-cell-paragraphs.d.ts.map +1 -0
- package/dist/pptx/render/table-style-borders.d.ts.map +1 -1
- package/dist/pptx/render/table-style.d.ts +2 -0
- package/dist/pptx/render/table-style.d.ts.map +1 -1
- package/dist/pptx/render/title-bar.d.ts +5 -0
- package/dist/pptx/render/title-bar.d.ts.map +1 -1
- package/dist/pptx/render/viewer-root-options.d.ts +11 -3
- package/dist/pptx/render/viewer-root-options.d.ts.map +1 -1
- package/dist/pptx/web-components/index.d.ts.map +1 -1
- package/dist/pptx/web-components/office-token-bridge.d.ts +1 -1
- package/dist/pptx/web-components/office-token-bridge.d.ts.map +1 -1
- package/dist/pptx/web-components/ribbon-actions.d.ts +8 -0
- package/dist/pptx/web-components/ribbon-actions.d.ts.map +1 -0
- package/dist/presence.js +3 -3
- package/dist/ribbon/ribbon-actions.d.ts +119 -0
- package/dist/ribbon/ribbon-actions.d.ts.map +1 -0
- package/dist/ribbon/ribbon-tabs.d.ts +2 -1
- package/dist/ribbon/ribbon-tabs.d.ts.map +1 -1
- package/dist/smartart/smartart-svg.d.ts +3 -2
- package/dist/smartart.js +3 -3
- package/dist/suite/attachment-store.d.ts +13 -0
- package/dist/suite/document-store.d.ts +31 -0
- package/dist/suite/index.d.ts +2 -0
- package/dist/suite.js +132 -1
- package/dist/teams/app/channel-tab.d.ts +5 -0
- package/dist/teams/chat-composer.d.ts +3 -0
- package/dist/teams.js +7 -7
- package/dist/theme.js +2 -2
- package/dist/tokens.d.ts +9 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/visio/styles/index.d.ts +2 -0
- package/dist/visio/styles/theme.d.ts +11 -0
- package/dist/visio/styles.d.ts +2 -2
- package/dist/visio.js +66 -21
- package/dist/xlsx/backstage/index.d.ts +4 -1
- package/dist/xlsx/backstage/pages-share.d.ts +19 -0
- package/dist/xlsx/backstage/parts.d.ts +3 -0
- package/dist/xlsx/calc-preparation.d.ts +44 -0
- package/dist/xlsx/chart-fill-binding.d.ts +2 -2
- package/dist/xlsx/chart-series-gradient-type.d.ts +3 -2
- package/dist/xlsx/collaboration-session.d.ts +9 -0
- package/dist/xlsx/collaboration-types.d.ts +41 -0
- package/dist/xlsx/collaboration.d.ts +56 -0
- package/dist/xlsx/component.d.ts +8 -0
- package/dist/xlsx/dialogs/comments-list.d.ts +4 -0
- package/dist/xlsx/dialogs/help-dialogs.d.ts +1 -1
- package/dist/xlsx/editor-core.d.ts +6 -0
- package/dist/xlsx/element-api.d.ts +19 -1
- package/dist/xlsx/events.d.ts +4 -1
- package/dist/xlsx/grid/remote-layer.d.ts +3 -0
- package/dist/xlsx/grid/sparkline.d.ts +3 -0
- package/dist/xlsx/grid/styles.d.ts +1 -1
- package/dist/xlsx/index.d.ts +1 -0
- package/dist/xlsx/ribbon-actions.d.ts +22 -0
- package/dist/xlsx/shell-commands.d.ts +1 -1
- package/dist/xlsx/title-bar.d.ts +4 -2
- package/dist/xlsx.js +801 -92
- package/package.json +2 -2
- package/dist/pptx/web-components/status-bar-styles.d.ts +0 -3
- package/dist/pptx/web-components/status-bar-styles.d.ts.map +0 -1
- package/dist/pptx/web-components/title-bar-styles.d.ts +0 -7
- package/dist/pptx/web-components/title-bar-styles.d.ts.map +0 -1
|
@@ -3,8 +3,8 @@ import { colorWithOpacity, clampUnitInterval, normalizeHexColor, hexToRgbChannel
|
|
|
3
3
|
export { clampUnitInterval, colorWithOpacity, hexToRgbChannels, normalizeHexColor } from 'ooxml-core/color';
|
|
4
4
|
import { buildRectPathGradientImage } from 'ooxml-core/diagram';
|
|
5
5
|
export { buildRectPathGradientImage, buildRectPathGradientSvg } from 'ooxml-core/diagram';
|
|
6
|
-
import { niceValueAxisBounds, axisTargetIntervals, hasManualLayoutFields, resolveManualLayoutRect, groupRowsByCategory, computeBoxStats, computeHistogramBins as computeHistogramBins$1, aggregateByCategory, radarRingPoints, radarAngle, computeRadarPoints,
|
|
7
|
-
export { axisTargetIntervals, computeBoxStats, computeLinearRegression, computeRSquared, computeRadarPoints, computeStackedSeriesPlots, fitPolynomial, hasManualLayoutFields, niceValueAxisBounds, radarAngle, radarRingPoints, resolveManualLayoutRect } from 'ooxml-core/chart';
|
|
6
|
+
import { niceValueAxisBounds, axisTargetIntervals, clusteredBarGeometry, hasManualLayoutFields, resolveManualLayoutRect, groupRowsByCategory, computeBoxStats, computeHistogramBins as computeHistogramBins$1, aggregateByCategory, radarRingPoints, radarAngle, computeRadarPoints, resolveBlankDisplay, computeStackedSeriesPlots, visibleRuns, placeBestFitLabel, nudgeOutsideLabels, buildChartGradientDef, fitPolynomial, formatPolynomialEquation, computeRSquared, computeLinearRegression, formatPowerEquation, formatLogarithmicEquation, formatExponentialEquation, formatLinearEquation, squarify } from 'ooxml-core/chart';
|
|
7
|
+
export { DEFAULT_BAR_GAP_WIDTH, axisTargetIntervals, computeBoxStats, computeLinearRegression, computeRSquared, computeRadarPoints, computeStackedSeriesPlots, fitPolynomial, hasManualLayoutFields, niceValueAxisBounds, radarAngle, radarRingPoints, resolveManualLayoutRect } from 'ooxml-core/chart';
|
|
8
8
|
|
|
9
9
|
// src/pptx/render/chart-font.ts
|
|
10
10
|
var CHART_PX_PER_PT = 4 / 3;
|
|
@@ -1533,6 +1533,88 @@ function formatChartNumber(value, formatCode) {
|
|
|
1533
1533
|
return formatChartNumberWithColor(value, formatCode)?.text;
|
|
1534
1534
|
}
|
|
1535
1535
|
|
|
1536
|
+
// src/pptx/render/chart-style-palette.ts
|
|
1537
|
+
function hexToRgb(hex) {
|
|
1538
|
+
const h = hex.replace("#", "");
|
|
1539
|
+
return [
|
|
1540
|
+
parseInt(h.substring(0, 2), 16),
|
|
1541
|
+
parseInt(h.substring(2, 4), 16),
|
|
1542
|
+
parseInt(h.substring(4, 6), 16)
|
|
1543
|
+
];
|
|
1544
|
+
}
|
|
1545
|
+
function rgbToHex(r, g, b) {
|
|
1546
|
+
const clamp3 = (v) => Math.max(0, Math.min(255, Math.round(v)));
|
|
1547
|
+
return `#${clamp3(r).toString(16).padStart(2, "0")}${clamp3(g).toString(16).padStart(2, "0")}${clamp3(b).toString(16).padStart(2, "0")}`;
|
|
1548
|
+
}
|
|
1549
|
+
function tint(hex, amount) {
|
|
1550
|
+
const [r, g, b] = hexToRgb(hex);
|
|
1551
|
+
return rgbToHex(r + (255 - r) * amount, g + (255 - g) * amount, b + (255 - b) * amount);
|
|
1552
|
+
}
|
|
1553
|
+
function shade(hex, amount) {
|
|
1554
|
+
const [r, g, b] = hexToRgb(hex);
|
|
1555
|
+
return rgbToHex(r * (1 - amount), g * (1 - amount), b * (1 - amount));
|
|
1556
|
+
}
|
|
1557
|
+
var OFFICE_ACCENTS = [
|
|
1558
|
+
"#4472C4",
|
|
1559
|
+
"#ED7D31",
|
|
1560
|
+
"#A5A5A5",
|
|
1561
|
+
"#FFC000",
|
|
1562
|
+
"#5B9BD5",
|
|
1563
|
+
"#70AD47"
|
|
1564
|
+
];
|
|
1565
|
+
var DEFAULT_EXTRAS = ["#FF0000", "#00B0F0"];
|
|
1566
|
+
var DEFAULT_CHART_PALETTE = [...OFFICE_ACCENTS, ...DEFAULT_EXTRAS];
|
|
1567
|
+
function monochromaticRamp(base) {
|
|
1568
|
+
return [
|
|
1569
|
+
shade(base, 0.5),
|
|
1570
|
+
shade(base, 0.35),
|
|
1571
|
+
shade(base, 0.15),
|
|
1572
|
+
base,
|
|
1573
|
+
tint(base, 0.2),
|
|
1574
|
+
tint(base, 0.4),
|
|
1575
|
+
tint(base, 0.6),
|
|
1576
|
+
tint(base, 0.8)
|
|
1577
|
+
];
|
|
1578
|
+
}
|
|
1579
|
+
var GREY = "#7F7F7F";
|
|
1580
|
+
function buildPalette(column, accents) {
|
|
1581
|
+
if (column === 0) {
|
|
1582
|
+
return monochromaticRamp(GREY);
|
|
1583
|
+
}
|
|
1584
|
+
if (column === 1) {
|
|
1585
|
+
return [...accents, ...accents.map((accent) => shade(accent, 0.4))];
|
|
1586
|
+
}
|
|
1587
|
+
return monochromaticRamp(accents[column - 2]);
|
|
1588
|
+
}
|
|
1589
|
+
function usableAccents(accents) {
|
|
1590
|
+
return accents?.length === 6 && accents.every((accent) => /^#[0-9a-f]{6}$/iu.test(accent)) ? accents : OFFICE_ACCENTS;
|
|
1591
|
+
}
|
|
1592
|
+
var paletteCache = /* @__PURE__ */ new Map();
|
|
1593
|
+
function getChartStylePalette(styleId, themeAccents) {
|
|
1594
|
+
const accents = usableAccents(themeAccents);
|
|
1595
|
+
const valid = styleId !== void 0 && styleId >= 1 && styleId <= 48;
|
|
1596
|
+
if (!valid && accents === OFFICE_ACCENTS) {
|
|
1597
|
+
return DEFAULT_CHART_PALETTE;
|
|
1598
|
+
}
|
|
1599
|
+
const column = valid ? (Math.trunc(styleId) - 1) % 8 : -1;
|
|
1600
|
+
const key = `${column}:${accents.join(",")}`;
|
|
1601
|
+
let palette = paletteCache.get(key);
|
|
1602
|
+
if (!palette) {
|
|
1603
|
+
palette = column < 0 ? [...accents, ...DEFAULT_EXTRAS] : buildPalette(column, accents);
|
|
1604
|
+
paletteCache.set(key, palette);
|
|
1605
|
+
}
|
|
1606
|
+
return palette;
|
|
1607
|
+
}
|
|
1608
|
+
function resolveChartPalette(chartData) {
|
|
1609
|
+
if (chartData.colorPalette && chartData.colorPalette.length > 0) {
|
|
1610
|
+
return [...chartData.colorPalette];
|
|
1611
|
+
}
|
|
1612
|
+
return [...getChartStylePalette(chartData.style?.styleId, chartData.themeAccentColors)];
|
|
1613
|
+
}
|
|
1614
|
+
function withResolvedPalette(chartData) {
|
|
1615
|
+
return chartData.colorPalette && chartData.colorPalette.length > 0 ? chartData : { ...chartData, colorPalette: resolveChartPalette(chartData) };
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1536
1618
|
// src/pptx/render/chart-style-defaults.ts
|
|
1537
1619
|
var DEFAULT_LABEL_COLOR = "#334155";
|
|
1538
1620
|
var DEFAULT_TITLE_TEXT_PX = 12;
|
|
@@ -1717,114 +1799,6 @@ function withChartTitleBand(vm, chartData) {
|
|
|
1717
1799
|
}
|
|
1718
1800
|
|
|
1719
1801
|
// src/pptx/render/chart-helpers.ts
|
|
1720
|
-
var ACCENT1 = "#4472C4";
|
|
1721
|
-
var ACCENT2 = "#ED7D31";
|
|
1722
|
-
var ACCENT3 = "#A5A5A5";
|
|
1723
|
-
var ACCENT4 = "#FFC000";
|
|
1724
|
-
var ACCENT5 = "#5B9BD5";
|
|
1725
|
-
var ACCENT6 = "#70AD47";
|
|
1726
|
-
var ACCENTS = [ACCENT1, ACCENT2, ACCENT3, ACCENT4, ACCENT5, ACCENT6];
|
|
1727
|
-
var DEFAULT_CHART_PALETTE = [
|
|
1728
|
-
"#4472C4",
|
|
1729
|
-
"#ED7D31",
|
|
1730
|
-
"#A5A5A5",
|
|
1731
|
-
"#FFC000",
|
|
1732
|
-
"#5B9BD5",
|
|
1733
|
-
"#70AD47",
|
|
1734
|
-
"#FF0000",
|
|
1735
|
-
"#00B0F0"
|
|
1736
|
-
];
|
|
1737
|
-
function hexToRgb(hex) {
|
|
1738
|
-
const h = hex.replace("#", "");
|
|
1739
|
-
return [
|
|
1740
|
-
parseInt(h.substring(0, 2), 16),
|
|
1741
|
-
parseInt(h.substring(2, 4), 16),
|
|
1742
|
-
parseInt(h.substring(4, 6), 16)
|
|
1743
|
-
];
|
|
1744
|
-
}
|
|
1745
|
-
function rgbToHex(r, g, b) {
|
|
1746
|
-
const clamp3 = (v) => Math.max(0, Math.min(255, Math.round(v)));
|
|
1747
|
-
return `#${clamp3(r).toString(16).padStart(2, "0")}${clamp3(g).toString(16).padStart(2, "0")}${clamp3(b).toString(16).padStart(2, "0")}`;
|
|
1748
|
-
}
|
|
1749
|
-
function tint(hex, amount) {
|
|
1750
|
-
const [r, g, b] = hexToRgb(hex);
|
|
1751
|
-
return rgbToHex(r + (255 - r) * amount, g + (255 - g) * amount, b + (255 - b) * amount);
|
|
1752
|
-
}
|
|
1753
|
-
function shade(hex, amount) {
|
|
1754
|
-
const [r, g, b] = hexToRgb(hex);
|
|
1755
|
-
return rgbToHex(r * (1 - amount), g * (1 - amount), b * (1 - amount));
|
|
1756
|
-
}
|
|
1757
|
-
function colorfulSequential(offset) {
|
|
1758
|
-
const out = [];
|
|
1759
|
-
for (let i = 0; i < 8; i++) {
|
|
1760
|
-
out.push(ACCENTS[(i + offset) % ACCENTS.length]);
|
|
1761
|
-
}
|
|
1762
|
-
return out;
|
|
1763
|
-
}
|
|
1764
|
-
function monochromaticRamp(base) {
|
|
1765
|
-
return [
|
|
1766
|
-
shade(base, 0.5),
|
|
1767
|
-
shade(base, 0.35),
|
|
1768
|
-
shade(base, 0.15),
|
|
1769
|
-
base,
|
|
1770
|
-
tint(base, 0.2),
|
|
1771
|
-
tint(base, 0.4),
|
|
1772
|
-
tint(base, 0.6),
|
|
1773
|
-
tint(base, 0.8)
|
|
1774
|
-
];
|
|
1775
|
-
}
|
|
1776
|
-
function colorfulVariant(offset, tintAmount) {
|
|
1777
|
-
return ACCENTS.map((_, i) => {
|
|
1778
|
-
const idx = (i + offset) % ACCENTS.length;
|
|
1779
|
-
return tintAmount > 0 ? tint(ACCENTS[idx], tintAmount) : shade(ACCENTS[idx], -tintAmount);
|
|
1780
|
-
}).concat([
|
|
1781
|
-
tint(ACCENTS[offset % ACCENTS.length], 0.4),
|
|
1782
|
-
shade(ACCENTS[(offset + 1) % ACCENTS.length], 0.2)
|
|
1783
|
-
]);
|
|
1784
|
-
}
|
|
1785
|
-
function darkPalette(offset, shadeAmount) {
|
|
1786
|
-
return colorfulSequential(offset).map((c) => shade(c, shadeAmount));
|
|
1787
|
-
}
|
|
1788
|
-
function tonedPalette(offset, tintAmount) {
|
|
1789
|
-
return colorfulSequential(offset).map((c) => tint(c, tintAmount));
|
|
1790
|
-
}
|
|
1791
|
-
function buildPalette(styleId) {
|
|
1792
|
-
const id = Math.max(1, Math.min(48, styleId));
|
|
1793
|
-
if (id <= 8) {
|
|
1794
|
-
return colorfulSequential(id - 1);
|
|
1795
|
-
}
|
|
1796
|
-
if (id <= 16) {
|
|
1797
|
-
const accentIdx = (id - 9) % ACCENTS.length;
|
|
1798
|
-
return monochromaticRamp(ACCENTS[accentIdx]);
|
|
1799
|
-
}
|
|
1800
|
-
if (id <= 24) {
|
|
1801
|
-
const sub2 = id - 17;
|
|
1802
|
-
const tintAmt = sub2 < 4 ? sub2 * 0.1 : -(sub2 - 4) * 0.1;
|
|
1803
|
-
return colorfulVariant(sub2, tintAmt);
|
|
1804
|
-
}
|
|
1805
|
-
if (id <= 32) {
|
|
1806
|
-
const sub2 = id - 25;
|
|
1807
|
-
return darkPalette(sub2, 0.25 + sub2 % 4 * 0.1);
|
|
1808
|
-
}
|
|
1809
|
-
if (id <= 40) {
|
|
1810
|
-
const sub2 = id - 33;
|
|
1811
|
-
return tonedPalette(sub2, 0.15 + sub2 % 4 * 0.08);
|
|
1812
|
-
}
|
|
1813
|
-
const sub = id - 41;
|
|
1814
|
-
return tonedPalette(sub, 0.4 + sub % 4 * 0.1);
|
|
1815
|
-
}
|
|
1816
|
-
var paletteCache = /* @__PURE__ */ new Map();
|
|
1817
|
-
function getChartStylePalette(styleId) {
|
|
1818
|
-
if (styleId === void 0 || styleId < 1 || styleId > 48) {
|
|
1819
|
-
return DEFAULT_CHART_PALETTE;
|
|
1820
|
-
}
|
|
1821
|
-
let palette = paletteCache.get(styleId);
|
|
1822
|
-
if (!palette) {
|
|
1823
|
-
palette = buildPalette(styleId);
|
|
1824
|
-
paletteCache.set(styleId, palette);
|
|
1825
|
-
}
|
|
1826
|
-
return palette;
|
|
1827
|
-
}
|
|
1828
1802
|
function seriesColor(series, index, styleId, colorPalette) {
|
|
1829
1803
|
const explicit = series.color ?? series.marker?.spPr?.fillColor;
|
|
1830
1804
|
if (explicit) {
|
|
@@ -2091,7 +2065,7 @@ function buildLegend(series, colorPalette, svgWidth, legendPos, svgHeight, plotT
|
|
|
2091
2065
|
|
|
2092
2066
|
// src/pptx/render/chart-view-model-bars.ts
|
|
2093
2067
|
function computeBarRects(series, catCount, layout, range, colorPalette) {
|
|
2094
|
-
const rects = [], seriesCount = Math.max(series.length, 1), barGroupWidth = layout.plotWidth / Math.max(catCount, 1), singleBarWidth = barGroupWidth
|
|
2068
|
+
const rects = [], seriesCount = Math.max(series.length, 1), barGroupWidth = layout.plotWidth / Math.max(catCount, 1), { singleBarWidth, clusterWidth } = clusteredBarGeometry(barGroupWidth, seriesCount, {}), groupOffset = (barGroupWidth - clusterWidth) / 2;
|
|
2095
2069
|
for (let ci = 0; ci < catCount; ci++) {
|
|
2096
2070
|
for (let si = 0; si < series.length; si++) {
|
|
2097
2071
|
const val = series[si].values[ci] ?? 0, x = layout.plotLeft + barGroupWidth * ci + groupOffset + singleBarWidth * si, zeroY = valueToY2(0, range, layout.plotTop, layout.plotBottom), valY = valueToY2(val, range, layout.plotTop, layout.plotBottom), y = Math.min(zeroY, valY), h = Math.max(Math.abs(zeroY - valY), 1);
|
|
@@ -2106,46 +2080,56 @@ function computeBarRects(series, catCount, layout, range, colorPalette) {
|
|
|
2106
2080
|
}
|
|
2107
2081
|
return rects;
|
|
2108
2082
|
}
|
|
2109
|
-
function
|
|
2110
|
-
|
|
2083
|
+
function stackedBarWidth(slotWidth, gapWidth) {
|
|
2084
|
+
return clusteredBarGeometry(slotWidth, 1, gapWidth === void 0 ? {} : { barGapWidth: gapWidth }).singleBarWidth;
|
|
2085
|
+
}
|
|
2086
|
+
function clipStackedSegment(base, value, range) {
|
|
2087
|
+
const low = Math.max(Math.min(base, base + value), range.min), high = Math.min(Math.max(base, base + value), range.max);
|
|
2088
|
+
return high > low ? { low, high } : void 0;
|
|
2089
|
+
}
|
|
2090
|
+
function stackedSegmentExtent(baseCoord, tipCoord, minSize) {
|
|
2091
|
+
const size = Math.max(Math.abs(tipCoord - baseCoord), minSize);
|
|
2092
|
+
return { start: tipCoord < baseCoord ? baseCoord - size : baseCoord, size };
|
|
2093
|
+
}
|
|
2094
|
+
function computeStackedBarRects(series, catCount, layout, range, colorPalette, gapWidth) {
|
|
2095
|
+
const rects = [], slot = layout.plotWidth / Math.max(catCount, 1), barW = stackedBarWidth(slot, gapWidth), barOffset = (slot - barW) / 2;
|
|
2111
2096
|
for (let ci = 0; ci < catCount; ci++) {
|
|
2112
|
-
let
|
|
2097
|
+
let posTotal = 0, negTotal = 0;
|
|
2113
2098
|
for (let si = 0; si < series.length; si++) {
|
|
2114
2099
|
const val = series[si].values[ci] ?? 0;
|
|
2115
2100
|
if (val === 0) {
|
|
2116
2101
|
continue;
|
|
2117
2102
|
}
|
|
2118
|
-
const
|
|
2119
|
-
Math.abs(
|
|
2120
|
-
valueToY2(val, range, layout.plotTop, layout.plotBottom) - valueToY2(0, range, layout.plotTop, layout.plotBottom)
|
|
2121
|
-
),
|
|
2122
|
-
1
|
|
2123
|
-
);
|
|
2103
|
+
const base = val > 0 ? posTotal : negTotal;
|
|
2124
2104
|
if (val > 0) {
|
|
2125
|
-
|
|
2126
|
-
rects.push({
|
|
2127
|
-
x,
|
|
2128
|
-
y,
|
|
2129
|
-
w: barW,
|
|
2130
|
-
h,
|
|
2131
|
-
fill: seriesColor2(series[si], si, colorPalette),
|
|
2132
|
-
seriesIndex: si,
|
|
2133
|
-
pointIndex: ci
|
|
2134
|
-
});
|
|
2135
|
-
posTop = y;
|
|
2105
|
+
posTotal += val;
|
|
2136
2106
|
} else {
|
|
2137
|
-
|
|
2138
|
-
rects.push({
|
|
2139
|
-
x,
|
|
2140
|
-
y,
|
|
2141
|
-
w: barW,
|
|
2142
|
-
h,
|
|
2143
|
-
fill: seriesColor2(series[si], si, colorPalette),
|
|
2144
|
-
seriesIndex: si,
|
|
2145
|
-
pointIndex: ci
|
|
2146
|
-
});
|
|
2147
|
-
negBottom = y + h;
|
|
2107
|
+
negTotal += val;
|
|
2148
2108
|
}
|
|
2109
|
+
const segment = clipStackedSegment(base, val, range);
|
|
2110
|
+
if (!segment) {
|
|
2111
|
+
continue;
|
|
2112
|
+
}
|
|
2113
|
+
const baseY = valueToY2(
|
|
2114
|
+
val > 0 ? segment.low : segment.high,
|
|
2115
|
+
range,
|
|
2116
|
+
layout.plotTop,
|
|
2117
|
+
layout.plotBottom
|
|
2118
|
+
), tipY = valueToY2(
|
|
2119
|
+
val > 0 ? segment.high : segment.low,
|
|
2120
|
+
range,
|
|
2121
|
+
layout.plotTop,
|
|
2122
|
+
layout.plotBottom
|
|
2123
|
+
), { start, size } = stackedSegmentExtent(baseY, tipY, 1);
|
|
2124
|
+
rects.push({
|
|
2125
|
+
x: layout.plotLeft + slot * ci + barOffset,
|
|
2126
|
+
y: start,
|
|
2127
|
+
w: barW,
|
|
2128
|
+
h: size,
|
|
2129
|
+
fill: seriesColor2(series[si], si, colorPalette),
|
|
2130
|
+
seriesIndex: si,
|
|
2131
|
+
pointIndex: ci
|
|
2132
|
+
});
|
|
2149
2133
|
}
|
|
2150
2134
|
}
|
|
2151
2135
|
return rects;
|
|
@@ -2384,28 +2368,6 @@ function resolveDataPointPictureFill(series, pointIndex, seriesIndex, face) {
|
|
|
2384
2368
|
};
|
|
2385
2369
|
}
|
|
2386
2370
|
|
|
2387
|
-
// src/pptx/render/chart-palette.ts
|
|
2388
|
-
function hexToRgb2(hex) {
|
|
2389
|
-
const h = hex.replace("#", "");
|
|
2390
|
-
return [
|
|
2391
|
-
parseInt(h.substring(0, 2), 16),
|
|
2392
|
-
parseInt(h.substring(2, 4), 16),
|
|
2393
|
-
parseInt(h.substring(4, 6), 16)
|
|
2394
|
-
];
|
|
2395
|
-
}
|
|
2396
|
-
function rgbToHex2(r, g, b) {
|
|
2397
|
-
const clamp3 = (v) => Math.max(0, Math.min(255, Math.round(v)));
|
|
2398
|
-
return `#${clamp3(r).toString(16).padStart(2, "0")}${clamp3(g).toString(16).padStart(2, "0")}${clamp3(b).toString(16).padStart(2, "0")}`;
|
|
2399
|
-
}
|
|
2400
|
-
function tint2(hex, amount) {
|
|
2401
|
-
const [r, g, b] = hexToRgb2(hex);
|
|
2402
|
-
return rgbToHex2(r + (255 - r) * amount, g + (255 - g) * amount, b + (255 - b) * amount);
|
|
2403
|
-
}
|
|
2404
|
-
function shade2(hex, amount) {
|
|
2405
|
-
const [r, g, b] = hexToRgb2(hex);
|
|
2406
|
-
return rgbToHex2(r * (1 - amount), g * (1 - amount), b * (1 - amount));
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
2371
|
// src/pptx/render/chart-picture-pattern-def.ts
|
|
2410
2372
|
function polygonBoundingBox(points) {
|
|
2411
2373
|
const coords = points.trim().split(/\s+/u).map((pair) => pair.split(",").map(Number));
|
|
@@ -2434,7 +2396,7 @@ function buildPictureFillPatternDef(id, href, format, box, tileHeightPx) {
|
|
|
2434
2396
|
|
|
2435
2397
|
// src/pptx/render/chart-bar3d-face-picture.ts
|
|
2436
2398
|
function resolveUntargetedBarFaceFill(face, baseColor) {
|
|
2437
|
-
return face === "end" ?
|
|
2399
|
+
return face === "end" ? tint(baseColor, 0.22) : shade(baseColor, 0.25);
|
|
2438
2400
|
}
|
|
2439
2401
|
function resolveExtrusionFaceFill(facePoints, face, resolvedColor, rect, picture, defs) {
|
|
2440
2402
|
const fallback = resolveUntargetedBarFaceFill(face, resolvedColor);
|
|
@@ -2634,8 +2596,8 @@ function pieExtrusion(paths, depth) {
|
|
|
2634
2596
|
return paths.map((p) => ({
|
|
2635
2597
|
kind: "path",
|
|
2636
2598
|
d: translateSlicePath(p.d, 0, offsetY),
|
|
2637
|
-
fill:
|
|
2638
|
-
stroke:
|
|
2599
|
+
fill: shade(p.fill, 0.32),
|
|
2600
|
+
stroke: shade(p.fill, 0.4),
|
|
2639
2601
|
strokeWidth: 0.5
|
|
2640
2602
|
}));
|
|
2641
2603
|
}
|
|
@@ -2647,7 +2609,7 @@ function ribbonExtrusion(prims, depth) {
|
|
|
2647
2609
|
out.push({
|
|
2648
2610
|
...pl,
|
|
2649
2611
|
points: shiftPoints(pl.points, depth.dx, depth.dy),
|
|
2650
|
-
stroke:
|
|
2612
|
+
stroke: shade(pl.stroke, 0.3),
|
|
2651
2613
|
fill: "none",
|
|
2652
2614
|
part: void 0
|
|
2653
2615
|
});
|
|
@@ -2656,7 +2618,7 @@ function ribbonExtrusion(prims, depth) {
|
|
|
2656
2618
|
out.push({
|
|
2657
2619
|
...pg,
|
|
2658
2620
|
points: shiftPoints(pg.points, depth.dx, depth.dy),
|
|
2659
|
-
fill:
|
|
2621
|
+
fill: shade(pg.fill === "none" ? "#888888" : pg.fill, 0.3),
|
|
2660
2622
|
part: void 0
|
|
2661
2623
|
});
|
|
2662
2624
|
}
|
|
@@ -2794,6 +2756,39 @@ function computeValueRangeForAxis(series, axis, plotHeightPx) {
|
|
|
2794
2756
|
const requestedLogBase = axis?.logBase ?? 10;
|
|
2795
2757
|
const logBase = axis?.logScale && Number.isFinite(requestedLogBase) && requestedLogBase > 1 ? requestedLogBase : axis?.logScale ? 10 : void 0;
|
|
2796
2758
|
const automatic = logBase ? computeLogValueRange(series, logBase) : computeValueRange(series, plotHeightPx);
|
|
2759
|
+
return withAxisBounds(automatic, axis, logBase);
|
|
2760
|
+
}
|
|
2761
|
+
function computeStackedValueRangeForAxis(series, catCount, axis, isPercent, plotSizePx) {
|
|
2762
|
+
if (isPercent) {
|
|
2763
|
+
return {
|
|
2764
|
+
...percentStackedRange(series, catCount, plotSizePx),
|
|
2765
|
+
...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
return withAxisBounds(computeStackedValueRange(series, catCount, plotSizePx), axis);
|
|
2769
|
+
}
|
|
2770
|
+
function percentStackedRange(series, catCount, plotSizePx) {
|
|
2771
|
+
const shares = series.map((entry) => ({
|
|
2772
|
+
...entry,
|
|
2773
|
+
values: Array.from({ length: catCount }, (_, ci) => {
|
|
2774
|
+
const total = series.reduce((sum, s) => sum + Math.abs(s.values[ci] ?? 0), 0);
|
|
2775
|
+
return total > 0 ? (entry.values[ci] ?? 0) / total * 100 : 0;
|
|
2776
|
+
})
|
|
2777
|
+
}));
|
|
2778
|
+
const automatic = computeStackedValueRange(shares, catCount, plotSizePx);
|
|
2779
|
+
if (automatic.min >= 0) {
|
|
2780
|
+
return { min: 0, max: 100, span: 100 };
|
|
2781
|
+
}
|
|
2782
|
+
const min = Math.max(automatic.min, -100);
|
|
2783
|
+
const unit = automatic.majorUnit;
|
|
2784
|
+
return {
|
|
2785
|
+
min,
|
|
2786
|
+
max: 100,
|
|
2787
|
+
span: 100 - min,
|
|
2788
|
+
...unit !== void 0 && 100 % unit === 0 && min % unit === 0 ? { majorUnit: unit } : {}
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
function withAxisBounds(automatic, axis, logBase) {
|
|
2797
2792
|
const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
|
|
2798
2793
|
const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
|
|
2799
2794
|
const min = validMin ?? automatic.min;
|
|
@@ -3178,8 +3173,8 @@ function resolveMarkerLabelAnchor(position, point, offset = 7) {
|
|
|
3178
3173
|
return { x: point.x, y: point.y - offset, textAnchor: "middle" };
|
|
3179
3174
|
}
|
|
3180
3175
|
}
|
|
3181
|
-
function resolveBarLabelPlacement(chartData, series, pointIndex, rect, value, orientation, frame) {
|
|
3182
|
-
const point = findPointLabel(series, pointIndex), position = point?.position ?? series.dataLabelOptions?.position ?? chartData.style?.dataLabels?.position, anchor = resolveBarLabelAnchor(position, rect, value, orientation), shifted = applyLabelManualLayout(point?.layout, frame, anchor);
|
|
3176
|
+
function resolveBarLabelPlacement(chartData, series, pointIndex, rect, value, orientation, frame, defaultPosition) {
|
|
3177
|
+
const point = findPointLabel(series, pointIndex), position = point?.position ?? series.dataLabelOptions?.position ?? chartData.style?.dataLabels?.position ?? defaultPosition, anchor = resolveBarLabelAnchor(position, rect, value, orientation), shifted = applyLabelManualLayout(point?.layout, frame, anchor);
|
|
3183
3178
|
return { ...anchor, x: shifted.x, y: shifted.y };
|
|
3184
3179
|
}
|
|
3185
3180
|
function resolveMarkerLabelPlacement(chartData, series, pointIndex, point, frame, offset = 7, defaultPosition) {
|
|
@@ -3505,18 +3500,46 @@ function smoothLinePath(points) {
|
|
|
3505
3500
|
}
|
|
3506
3501
|
let d = `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)}`;
|
|
3507
3502
|
for (let i = 0; i < points.length - 1; i++) {
|
|
3508
|
-
const
|
|
3509
|
-
|
|
3510
|
-
const p2 = points[i + 1];
|
|
3511
|
-
const p3 = points[i + 2] ?? p2;
|
|
3512
|
-
const cp1x = p1.x + (p2.x - p0.x) / 6;
|
|
3513
|
-
const cp1y = p1.y + (p2.y - p0.y) / 6;
|
|
3514
|
-
const cp2x = p2.x - (p3.x - p1.x) / 6;
|
|
3515
|
-
const cp2y = p2.y - (p3.y - p1.y) / 6;
|
|
3516
|
-
d += ` C${cp1x.toFixed(2)},${cp1y.toFixed(2)} ${cp2x.toFixed(2)},${cp2y.toFixed(2)} ${p2.x.toFixed(2)},${p2.y.toFixed(2)}`;
|
|
3503
|
+
const [cp1, cp2, end] = smoothSegment(points, i);
|
|
3504
|
+
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)}`;
|
|
3517
3505
|
}
|
|
3518
3506
|
return d;
|
|
3519
3507
|
}
|
|
3508
|
+
function smoothSegment(points, i) {
|
|
3509
|
+
const p0 = points[i - 1] ?? points[i];
|
|
3510
|
+
const p1 = points[i];
|
|
3511
|
+
const p2 = points[i + 1];
|
|
3512
|
+
const p3 = points[i + 2] ?? p2;
|
|
3513
|
+
return [
|
|
3514
|
+
{ x: p1.x + (p2.x - p0.x) / 6, y: p1.y + (p2.y - p0.y) / 6 },
|
|
3515
|
+
{ x: p2.x - (p3.x - p1.x) / 6, y: p2.y - (p3.y - p1.y) / 6 },
|
|
3516
|
+
p2
|
|
3517
|
+
];
|
|
3518
|
+
}
|
|
3519
|
+
function sampleSmoothLine(points, stepsPerSegment = 16) {
|
|
3520
|
+
if (points.length < 3) {
|
|
3521
|
+
return [...points];
|
|
3522
|
+
}
|
|
3523
|
+
const out = [points[0]];
|
|
3524
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
3525
|
+
const start = points[i], [cp1, cp2, end] = smoothSegment(points, i);
|
|
3526
|
+
for (let step = 1; step <= stepsPerSegment; step++) {
|
|
3527
|
+
const t = step / stepsPerSegment, u = 1 - t, a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
|
|
3528
|
+
out.push(
|
|
3529
|
+
step === stepsPerSegment ? end : {
|
|
3530
|
+
x: a * start.x + b * cp1.x + c * cp2.x + d * end.x,
|
|
3531
|
+
y: a * start.y + b * cp1.y + c * cp2.y + d * end.y
|
|
3532
|
+
}
|
|
3533
|
+
);
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
return out;
|
|
3537
|
+
}
|
|
3538
|
+
function polylineRunsPath(runs) {
|
|
3539
|
+
return runs.map(
|
|
3540
|
+
(run) => run.map((p, i) => `${i === 0 ? "M" : "L"}${p.x.toFixed(2)},${p.y.toFixed(2)}`).join(" ")
|
|
3541
|
+
).join(" ");
|
|
3542
|
+
}
|
|
3520
3543
|
|
|
3521
3544
|
// src/pptx/render/chart-axis-style.ts
|
|
3522
3545
|
var DEFAULT_COLOR = "#64748b";
|
|
@@ -3555,6 +3578,9 @@ function unitsLabelTextStyle(axis, baseStyle) {
|
|
|
3555
3578
|
...fontFamily ? { fontFamily } : {}
|
|
3556
3579
|
};
|
|
3557
3580
|
}
|
|
3581
|
+
function isNoLine(shape) {
|
|
3582
|
+
return shape?.lineNoFill === true && shape.strokeColor === void 0;
|
|
3583
|
+
}
|
|
3558
3584
|
function chartLineStyle(shape, fallbackColor = DEFAULT_COLOR, fallbackWidth = 1) {
|
|
3559
3585
|
const strokeWidth = shape?.strokeWidth ?? fallbackWidth;
|
|
3560
3586
|
return {
|
|
@@ -3566,7 +3592,7 @@ function chartLineStyle(shape, fallbackColor = DEFAULT_COLOR, fallbackWidth = 1)
|
|
|
3566
3592
|
|
|
3567
3593
|
// src/pptx/render/chart-axis-primitives.ts
|
|
3568
3594
|
function buildVerticalTickMark(axisX, y, placement, side, length, shape) {
|
|
3569
|
-
if (!placement || placement === "none") {
|
|
3595
|
+
if (!placement || placement === "none" || isNoLine(shape)) {
|
|
3570
3596
|
return void 0;
|
|
3571
3597
|
}
|
|
3572
3598
|
const inward = side === "left" ? 1 : -1;
|
|
@@ -3582,7 +3608,7 @@ function buildVerticalTickMark(axisX, y, placement, side, length, shape) {
|
|
|
3582
3608
|
};
|
|
3583
3609
|
}
|
|
3584
3610
|
function buildVerticalAxisLine(axis, axisX, layout) {
|
|
3585
|
-
return axis?.spPr ? {
|
|
3611
|
+
return axis?.spPr && !isNoLine(axis.spPr) ? {
|
|
3586
3612
|
kind: "line",
|
|
3587
3613
|
x1: axisX,
|
|
3588
3614
|
y1: layout.plotTop,
|
|
@@ -3678,7 +3704,7 @@ function primaryCategoryAxis(axes) {
|
|
|
3678
3704
|
return categoryAxes2?.find((axis) => axis.axPos !== "t") ?? categoryAxes2?.[0];
|
|
3679
3705
|
}
|
|
3680
3706
|
function tickLine(x, y, placement, topAxis, length, axis) {
|
|
3681
|
-
if (!placement || placement === "none") {
|
|
3707
|
+
if (!placement || placement === "none" || isNoLine(axis.spPr)) {
|
|
3682
3708
|
return void 0;
|
|
3683
3709
|
}
|
|
3684
3710
|
const inward = topAxis ? length : -length;
|
|
@@ -3700,7 +3726,7 @@ function buildTickMarks(axis, sourceCount, layout, spacing, axisY) {
|
|
|
3700
3726
|
const result = [];
|
|
3701
3727
|
const topAxis = axis.axPos === "t";
|
|
3702
3728
|
const y = axisY ?? (topAxis ? layout.plotTop : layout.plotBottom);
|
|
3703
|
-
if (axis.spPr) {
|
|
3729
|
+
if (axis.spPr && !isNoLine(axis.spPr)) {
|
|
3704
3730
|
result.push({
|
|
3705
3731
|
kind: "line",
|
|
3706
3732
|
x1: layout.plotLeft,
|
|
@@ -3787,6 +3813,41 @@ function chartDataInCategoryOrder(chartData, sourceIndices2) {
|
|
|
3787
3813
|
};
|
|
3788
3814
|
}
|
|
3789
3815
|
|
|
3816
|
+
// src/pptx/render/chart-gridlines-toggle.ts
|
|
3817
|
+
function primaryValueAxis(axes) {
|
|
3818
|
+
if (!axes) {
|
|
3819
|
+
return void 0;
|
|
3820
|
+
}
|
|
3821
|
+
return axes.find((axis) => axis.axisType === "valAx" && axis.axPos === "l") ?? axes.find((axis) => axis.axisType === "valAx");
|
|
3822
|
+
}
|
|
3823
|
+
function chartGridlinesState(chartData) {
|
|
3824
|
+
const axis = primaryValueAxis(chartData.axes);
|
|
3825
|
+
if (axis) {
|
|
3826
|
+
return axis.majorGridlines ?? false;
|
|
3827
|
+
}
|
|
3828
|
+
return chartData.style?.hasGridlines ?? true;
|
|
3829
|
+
}
|
|
3830
|
+
var shouldRenderMajorGridlines = chartGridlinesState;
|
|
3831
|
+
function axisShowsMajorGridlines(axis) {
|
|
3832
|
+
return axis ? axis.majorGridlines === true : true;
|
|
3833
|
+
}
|
|
3834
|
+
function chartGridlinesPatch(chartData, show) {
|
|
3835
|
+
const axes = chartData.axes ? [...chartData.axes] : [];
|
|
3836
|
+
let index = axes.findIndex((axis) => axis.axisType === "valAx" && axis.axPos === "l");
|
|
3837
|
+
if (index === -1) {
|
|
3838
|
+
index = axes.findIndex((axis) => axis.axisType === "valAx");
|
|
3839
|
+
}
|
|
3840
|
+
if (index === -1) {
|
|
3841
|
+
axes.push({ axisType: "valAx", majorGridlines: show });
|
|
3842
|
+
} else {
|
|
3843
|
+
axes[index] = { ...axes[index], majorGridlines: show };
|
|
3844
|
+
}
|
|
3845
|
+
return {
|
|
3846
|
+
axes,
|
|
3847
|
+
style: { ...chartData.style, hasGridlines: show }
|
|
3848
|
+
};
|
|
3849
|
+
}
|
|
3850
|
+
|
|
3790
3851
|
// src/pptx/render/chart-scatter-x-axis.ts
|
|
3791
3852
|
var GRIDLINE_COLOR = "#e2e8f0";
|
|
3792
3853
|
var TICK_COUNT = 5;
|
|
@@ -3807,7 +3868,7 @@ function buildScatterXAxisPlan(chartData, layout) {
|
|
|
3807
3868
|
}));
|
|
3808
3869
|
const range = computeValueRangeForAxis(pseudoSeries, xAxis, layout.plotWidth);
|
|
3809
3870
|
const toPixelX = (value) => valueToY2(value, range, layout.plotRight, layout.plotLeft);
|
|
3810
|
-
const showGridlines = xAxis
|
|
3871
|
+
const showGridlines = axisShowsMajorGridlines(xAxis) && !isNoLine(xAxis?.majorGridlinesSpPr);
|
|
3811
3872
|
const gridlines = [];
|
|
3812
3873
|
const labels = [];
|
|
3813
3874
|
const textStyle = chartAxisTextStyle(xAxis, DEFAULT_CHART_TEXT_PX);
|
|
@@ -3957,9 +4018,113 @@ function buildScatter(chartData, layout, range) {
|
|
|
3957
4018
|
return { primitives: [...primitives, ...labelBoxes], dataLabels };
|
|
3958
4019
|
}
|
|
3959
4020
|
|
|
4021
|
+
// src/pptx/render/chart-plot-clip.ts
|
|
4022
|
+
var EPSILON = 1e-6;
|
|
4023
|
+
function plotBand(layout) {
|
|
4024
|
+
return {
|
|
4025
|
+
top: Math.min(layout.plotTop, layout.plotBottom),
|
|
4026
|
+
bottom: Math.max(layout.plotTop, layout.plotBottom)
|
|
4027
|
+
};
|
|
4028
|
+
}
|
|
4029
|
+
function insideBand(point, band) {
|
|
4030
|
+
return point.y >= band.top - EPSILON && point.y <= band.bottom + EPSILON;
|
|
4031
|
+
}
|
|
4032
|
+
function clipSegment(a, b, band) {
|
|
4033
|
+
const dy = b.y - a.y;
|
|
4034
|
+
if (Math.abs(dy) < EPSILON) {
|
|
4035
|
+
return insideBand(a, band) ? [a, b] : void 0;
|
|
4036
|
+
}
|
|
4037
|
+
const tTop = (band.top - a.y) / dy, tBottom = (band.bottom - a.y) / dy, low = Math.max(0, Math.min(tTop, tBottom)), high = Math.min(1, Math.max(tTop, tBottom));
|
|
4038
|
+
if (high - low < EPSILON) {
|
|
4039
|
+
return void 0;
|
|
4040
|
+
}
|
|
4041
|
+
const at = (t) => t <= 0 ? a : t >= 1 ? b : { x: a.x + (b.x - a.x) * t, y: a.y + dy * t };
|
|
4042
|
+
return [insideBand(a, band) ? a : at(low), insideBand(b, band) ? b : at(high)];
|
|
4043
|
+
}
|
|
4044
|
+
function clipPolylineToBand(points, band) {
|
|
4045
|
+
if (points.every((point) => insideBand(point, band))) {
|
|
4046
|
+
return points.length >= 2 ? [[...points]] : [];
|
|
4047
|
+
}
|
|
4048
|
+
const runs = [];
|
|
4049
|
+
let run = [];
|
|
4050
|
+
const flush = () => {
|
|
4051
|
+
if (run.length >= 2) {
|
|
4052
|
+
runs.push(run);
|
|
4053
|
+
}
|
|
4054
|
+
run = [];
|
|
4055
|
+
};
|
|
4056
|
+
for (let i = 0; i + 1 < points.length; i++) {
|
|
4057
|
+
const clipped = clipSegment(points[i], points[i + 1], band);
|
|
4058
|
+
if (!clipped) {
|
|
4059
|
+
flush();
|
|
4060
|
+
continue;
|
|
4061
|
+
}
|
|
4062
|
+
const [start, end] = clipped;
|
|
4063
|
+
if (run[run.length - 1] !== start) {
|
|
4064
|
+
flush();
|
|
4065
|
+
run.push(start);
|
|
4066
|
+
}
|
|
4067
|
+
run.push(end);
|
|
4068
|
+
if (end !== points[i + 1]) {
|
|
4069
|
+
flush();
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
flush();
|
|
4073
|
+
return runs;
|
|
4074
|
+
}
|
|
4075
|
+
function crossAt(a, b, y) {
|
|
4076
|
+
const t = (y - a.y) / (b.y - a.y);
|
|
4077
|
+
return { x: a.x + (b.x - a.x) * t, y };
|
|
4078
|
+
}
|
|
4079
|
+
function clipPolygonEdge(polygon, keep, y) {
|
|
4080
|
+
const out = [];
|
|
4081
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
4082
|
+
const current = polygon[i], previous = polygon[(i + polygon.length - 1) % polygon.length];
|
|
4083
|
+
if (keep(current)) {
|
|
4084
|
+
if (!keep(previous)) {
|
|
4085
|
+
out.push(crossAt(previous, current, y));
|
|
4086
|
+
}
|
|
4087
|
+
out.push(current);
|
|
4088
|
+
} else if (keep(previous)) {
|
|
4089
|
+
out.push(crossAt(previous, current, y));
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
return out;
|
|
4093
|
+
}
|
|
4094
|
+
function clipPolygonToBand(polygon, band) {
|
|
4095
|
+
if (polygon.every((point) => insideBand(point, band))) {
|
|
4096
|
+
return [...polygon];
|
|
4097
|
+
}
|
|
4098
|
+
const top = clipPolygonEdge(polygon, (point) => point.y >= band.top - EPSILON, band.top);
|
|
4099
|
+
return clipPolygonEdge(top, (point) => point.y <= band.bottom + EPSILON, band.bottom);
|
|
4100
|
+
}
|
|
4101
|
+
function visibleSpanCentre(y1, y2, band) {
|
|
4102
|
+
const low = Math.max(Math.min(y1, y2), band.top), high = Math.min(Math.max(y1, y2), band.bottom);
|
|
4103
|
+
if (high < low - EPSILON) {
|
|
4104
|
+
return void 0;
|
|
4105
|
+
}
|
|
4106
|
+
return (low + high) / 2;
|
|
4107
|
+
}
|
|
4108
|
+
function clippedSeriesLine(points, smooth, style, band) {
|
|
4109
|
+
if (points.every((point) => insideBand(point, band))) {
|
|
4110
|
+
return [
|
|
4111
|
+
smooth ? { kind: "path", d: smoothLinePath(points), ...style } : { kind: "polyline", points: linePointsToSvgString(points), ...style }
|
|
4112
|
+
];
|
|
4113
|
+
}
|
|
4114
|
+
if (smooth) {
|
|
4115
|
+
const runs = clipPolylineToBand(sampleSmoothLine(points), band);
|
|
4116
|
+
return runs.length > 0 ? [{ kind: "path", d: polylineRunsPath(runs), ...style }] : [];
|
|
4117
|
+
}
|
|
4118
|
+
return clipPolylineToBand(points, band).map((run) => ({
|
|
4119
|
+
kind: "polyline",
|
|
4120
|
+
points: linePointsToSvgString(run),
|
|
4121
|
+
...style
|
|
4122
|
+
}));
|
|
4123
|
+
}
|
|
4124
|
+
|
|
3960
4125
|
// src/pptx/render/chart-cartesian-area.ts
|
|
3961
4126
|
function buildAreas(chartData, catCount, layout, range, sourceIndices2, xPositions, stacking = "clustered") {
|
|
3962
|
-
const primitives = [], dataLabels = [], labelBoxes = [], showLabels = chartData.style?.hasDataLabels, isStackedMode = stacking !== "clustered", isPercent = stacking === "percentStacked", baselineY = valueToY2(0, range, layout.plotTop, layout.plotBottom), allDisplayValues = chartData.series.map(
|
|
4127
|
+
const primitives = [], dataLabels = [], labelBoxes = [], showLabels = chartData.style?.hasDataLabels, isStackedMode = stacking !== "clustered", isPercent = stacking === "percentStacked", baselineY = valueToY2(0, range, layout.plotTop, layout.plotBottom), band = plotBand(layout), allDisplayValues = chartData.series.map(
|
|
3963
4128
|
(series) => series.values.length === 0 ? void 0 : sourceIndices2.map((sourceIndex) => series.values[sourceIndex] ?? 0)
|
|
3964
4129
|
), stackedPlots = isStackedMode ? computeStackedSeriesPlots(
|
|
3965
4130
|
allDisplayValues.map((values) => values ?? []),
|
|
@@ -3974,44 +4139,33 @@ function buildAreas(chartData, catCount, layout, range, sourceIndices2, xPositio
|
|
|
3974
4139
|
const plot = stackedPlots?.[si], topValues = plot ? plot.cumulative : displayValues, pts = computeLinePoints(topValues, catCount, layout, range).map((point, index) => ({
|
|
3975
4140
|
...point,
|
|
3976
4141
|
x: xPositions?.[index] ?? point.x
|
|
3977
|
-
})), c = seriesColor2(series, si, chartData.colorPalette),
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
...point,
|
|
3983
|
-
x: xPositions?.[index] ?? point.x
|
|
3984
|
-
}))
|
|
3985
|
-
].reverse()
|
|
3986
|
-
);
|
|
3987
|
-
primitives.push({
|
|
3988
|
-
kind: "polyline",
|
|
3989
|
-
points: `${lineStr} ${baseStr}`,
|
|
3990
|
-
stroke: "none",
|
|
3991
|
-
strokeWidth: 0,
|
|
3992
|
-
fill: c,
|
|
3993
|
-
part: { role: "series", seriesIndex: si }
|
|
3994
|
-
});
|
|
3995
|
-
} else if (firstPt && lastPt) {
|
|
4142
|
+
})), c = seriesColor2(series, si, chartData.colorPalette), firstPt = pts[0], lastPt = pts[pts.length - 1], fillPolygon = plot ? [
|
|
4143
|
+
...pts,
|
|
4144
|
+
...computeLinePoints(plot.base, catCount, layout, range).map((point, index) => ({ ...point, x: xPositions?.[index] ?? point.x })).reverse()
|
|
4145
|
+
] : firstPt && lastPt ? [{ x: firstPt.x, y: baselineY }, ...pts, { x: lastPt.x, y: baselineY }] : [], clippedFill = clipPolygonToBand(fillPolygon, band);
|
|
4146
|
+
if (clippedFill.length > 0) {
|
|
3996
4147
|
primitives.push({
|
|
3997
4148
|
kind: "polyline",
|
|
3998
|
-
points:
|
|
4149
|
+
points: linePointsToSvgString(clippedFill),
|
|
3999
4150
|
stroke: "none",
|
|
4000
4151
|
strokeWidth: 0,
|
|
4001
4152
|
fill: c,
|
|
4002
|
-
opacity: 0.25,
|
|
4153
|
+
...plot ? {} : { opacity: 0.25 },
|
|
4003
4154
|
part: { role: "series", seriesIndex: si }
|
|
4004
4155
|
});
|
|
4005
4156
|
}
|
|
4006
|
-
primitives.push(
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4157
|
+
primitives.push(
|
|
4158
|
+
...clippedSeriesLine(
|
|
4159
|
+
pts,
|
|
4160
|
+
false,
|
|
4161
|
+
{ stroke: c, strokeWidth: 2, fill: "none", part: { role: "series", seriesIndex: si } },
|
|
4162
|
+
band
|
|
4163
|
+
)
|
|
4164
|
+
);
|
|
4014
4165
|
pts.forEach((pt, displayIndex) => {
|
|
4166
|
+
if (!insideBand(pt, band)) {
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
4015
4169
|
const idx = sourceIndices2[displayIndex] ?? displayIndex, part = { role: "dataPoint", seriesIndex: si, pointIndex: idx };
|
|
4016
4170
|
pushMarker(
|
|
4017
4171
|
primitives,
|
|
@@ -4042,11 +4196,18 @@ function buildAreas(chartData, catCount, layout, range, sourceIndices2, xPositio
|
|
|
4042
4196
|
if (val === 0) {
|
|
4043
4197
|
return;
|
|
4044
4198
|
}
|
|
4045
|
-
const baseVal = plot?.base[displayIndex] ?? 0, topVal = plot?.cumulative[displayIndex] ?? val,
|
|
4199
|
+
const baseVal = plot?.base[displayIndex] ?? 0, topVal = plot?.cumulative[displayIndex] ?? val, centreY = visibleSpanCentre(
|
|
4200
|
+
valueToY2(baseVal, range, layout.plotTop, layout.plotBottom),
|
|
4201
|
+
valueToY2(topVal, range, layout.plotTop, layout.plotBottom),
|
|
4202
|
+
band
|
|
4203
|
+
);
|
|
4204
|
+
if (centreY === void 0) {
|
|
4205
|
+
return;
|
|
4206
|
+
}
|
|
4046
4207
|
dataLabels.push({
|
|
4047
4208
|
kind: "text",
|
|
4048
4209
|
x: pt.x,
|
|
4049
|
-
y:
|
|
4210
|
+
y: centreY,
|
|
4050
4211
|
text: `${Math.round(val)}%`,
|
|
4051
4212
|
fontSize: DEFAULT_CHART_DATA_LABEL_PX,
|
|
4052
4213
|
fill: "#ffffff",
|
|
@@ -4067,7 +4228,11 @@ function buildAreas(chartData, catCount, layout, range, sourceIndices2, xPositio
|
|
|
4067
4228
|
if (label === void 0) {
|
|
4068
4229
|
return;
|
|
4069
4230
|
}
|
|
4070
|
-
const bandBase = plot ? valueToY2(plot.base[displayIndex] ?? 0, range, layout.plotTop, layout.plotBottom) : baselineY,
|
|
4231
|
+
const bandBase = plot ? valueToY2(plot.base[displayIndex] ?? 0, range, layout.plotTop, layout.plotBottom) : baselineY, midY = visibleSpanCentre(pt.y, bandBase, band);
|
|
4232
|
+
if (midY === void 0) {
|
|
4233
|
+
return;
|
|
4234
|
+
}
|
|
4235
|
+
const mid = { x: pt.x, y: midY }, anchor = resolveMarkerLabelPlacement(
|
|
4071
4236
|
chartData,
|
|
4072
4237
|
series,
|
|
4073
4238
|
pointIndex,
|
|
@@ -4161,10 +4326,11 @@ function buildPrimaryAxis(range, layout, axis, axisX = layout.plotLeft, showMajo
|
|
|
4161
4326
|
const tickVals = generateAxisTicks(range, axis, TICK_COUNT2);
|
|
4162
4327
|
const minorTickVals = generateMinorAxisTicks(range, axis);
|
|
4163
4328
|
const axisLine = buildVerticalAxisLine(axis, axisX, layout);
|
|
4329
|
+
const drawMajorGridlines = showMajorGridlines && !isNoLine(axis?.majorGridlinesSpPr);
|
|
4164
4330
|
if (axisLine) {
|
|
4165
4331
|
gridlines.push(axisLine);
|
|
4166
4332
|
}
|
|
4167
|
-
if (axis?.minorGridlines) {
|
|
4333
|
+
if (axis?.minorGridlines && !isNoLine(axis.minorGridlinesSpPr)) {
|
|
4168
4334
|
for (const val of minorTickVals) {
|
|
4169
4335
|
const y = valueToY2(val, range, layout.plotTop, layout.plotBottom);
|
|
4170
4336
|
gridlines.push(
|
|
@@ -4188,7 +4354,7 @@ function buildPrimaryAxis(range, layout, axis, axisX = layout.plotLeft, showMajo
|
|
|
4188
4354
|
}
|
|
4189
4355
|
for (const val of tickVals) {
|
|
4190
4356
|
const y = valueToY2(val, range, layout.plotTop, layout.plotBottom);
|
|
4191
|
-
if (
|
|
4357
|
+
if (drawMajorGridlines) {
|
|
4192
4358
|
gridlines.push(
|
|
4193
4359
|
buildStyledGridline(
|
|
4194
4360
|
y,
|
|
@@ -4244,18 +4410,19 @@ function buildPrimaryAxis(range, layout, axis, axisX = layout.plotLeft, showMajo
|
|
|
4244
4410
|
}
|
|
4245
4411
|
return { gridlines, axisLabels };
|
|
4246
4412
|
}
|
|
4247
|
-
function buildSecondaryAxis(range, layout, axis, axisX = layout.plotRight) {
|
|
4413
|
+
function buildSecondaryAxis(range, layout, axis, axisX = layout.plotRight, showMajorGridlines = true) {
|
|
4248
4414
|
const gridlines = [];
|
|
4249
4415
|
const axisLabels = [];
|
|
4250
4416
|
const textStyle = chartAxisTextStyle(axis);
|
|
4251
4417
|
const captionStyle = chartAxisTextStyle(axis);
|
|
4252
4418
|
const axisLine = buildVerticalAxisLine(axis, axisX, layout);
|
|
4419
|
+
const drawMajorGridlines = showMajorGridlines && !isNoLine(axis?.majorGridlinesSpPr);
|
|
4253
4420
|
if (axisLine) {
|
|
4254
4421
|
gridlines.push(axisLine);
|
|
4255
4422
|
}
|
|
4256
4423
|
const tickValues = generateAxisTicks(range, axis, TICK_COUNT2 - 1);
|
|
4257
4424
|
const minorTickValues = generateMinorAxisTicks(range, axis);
|
|
4258
|
-
if (axis?.minorGridlines) {
|
|
4425
|
+
if (axis?.minorGridlines && !isNoLine(axis.minorGridlinesSpPr)) {
|
|
4259
4426
|
for (const val of minorTickValues) {
|
|
4260
4427
|
const y = valueToY2(val, range, layout.plotTop, layout.plotBottom);
|
|
4261
4428
|
gridlines.push(
|
|
@@ -4287,17 +4454,19 @@ function buildSecondaryAxis(range, layout, axis, axisX = layout.plotRight) {
|
|
|
4287
4454
|
}
|
|
4288
4455
|
for (const val of tickValues) {
|
|
4289
4456
|
const y = valueToY2(val, range, layout.plotTop, layout.plotBottom);
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4457
|
+
if (drawMajorGridlines) {
|
|
4458
|
+
gridlines.push(
|
|
4459
|
+
buildStyledGridline(
|
|
4460
|
+
y,
|
|
4461
|
+
layout,
|
|
4462
|
+
axis?.majorGridlinesSpPr,
|
|
4463
|
+
SECONDARY_GRID_COLOR,
|
|
4464
|
+
0.5,
|
|
4465
|
+
"2 3",
|
|
4466
|
+
0.5
|
|
4467
|
+
)
|
|
4468
|
+
);
|
|
4469
|
+
}
|
|
4301
4470
|
const tick = buildVerticalTickMark(
|
|
4302
4471
|
axisX,
|
|
4303
4472
|
y,
|
|
@@ -4352,38 +4521,6 @@ function buildSecondaryAxis(range, layout, axis, axisX = layout.plotRight) {
|
|
|
4352
4521
|
return { gridlines, axisLabels };
|
|
4353
4522
|
}
|
|
4354
4523
|
|
|
4355
|
-
// src/pptx/render/chart-gridlines-toggle.ts
|
|
4356
|
-
function primaryValueAxis(axes) {
|
|
4357
|
-
if (!axes) {
|
|
4358
|
-
return void 0;
|
|
4359
|
-
}
|
|
4360
|
-
return axes.find((axis) => axis.axisType === "valAx" && axis.axPos === "l") ?? axes.find((axis) => axis.axisType === "valAx");
|
|
4361
|
-
}
|
|
4362
|
-
function chartGridlinesState(chartData) {
|
|
4363
|
-
const axis = primaryValueAxis(chartData.axes);
|
|
4364
|
-
if (axis) {
|
|
4365
|
-
return axis.majorGridlines ?? false;
|
|
4366
|
-
}
|
|
4367
|
-
return chartData.style?.hasGridlines ?? true;
|
|
4368
|
-
}
|
|
4369
|
-
var shouldRenderMajorGridlines = chartGridlinesState;
|
|
4370
|
-
function chartGridlinesPatch(chartData, show) {
|
|
4371
|
-
const axes = chartData.axes ? [...chartData.axes] : [];
|
|
4372
|
-
let index = axes.findIndex((axis) => axis.axisType === "valAx" && axis.axPos === "l");
|
|
4373
|
-
if (index === -1) {
|
|
4374
|
-
index = axes.findIndex((axis) => axis.axisType === "valAx");
|
|
4375
|
-
}
|
|
4376
|
-
if (index === -1) {
|
|
4377
|
-
axes.push({ axisType: "valAx", majorGridlines: show });
|
|
4378
|
-
} else {
|
|
4379
|
-
axes[index] = { ...axes[index], majorGridlines: show };
|
|
4380
|
-
}
|
|
4381
|
-
return {
|
|
4382
|
-
axes,
|
|
4383
|
-
style: { ...chartData.style, hasGridlines: show }
|
|
4384
|
-
};
|
|
4385
|
-
}
|
|
4386
|
-
|
|
4387
4524
|
// src/pptx/render/chart-cartesian-axes.ts
|
|
4388
4525
|
function hasRicherAxisFeatures(chartData) {
|
|
4389
4526
|
return Boolean(
|
|
@@ -4435,7 +4572,8 @@ function buildCartesianAxes(chartData, layout, primaryRange, secondaryRange, cat
|
|
|
4435
4572
|
secondaryRange,
|
|
4436
4573
|
layout,
|
|
4437
4574
|
secondaryAxis,
|
|
4438
|
-
axisX(secondaryAxis?.crossAxisId, "right")
|
|
4575
|
+
axisX(secondaryAxis?.crossAxisId, "right"),
|
|
4576
|
+
axisShowsMajorGridlines(secondaryAxis)
|
|
4439
4577
|
);
|
|
4440
4578
|
return {
|
|
4441
4579
|
...primary,
|
|
@@ -4452,7 +4590,7 @@ function categoryTotals(series, catCount) {
|
|
|
4452
4590
|
);
|
|
4453
4591
|
}
|
|
4454
4592
|
function buildPercentStackedBars(chartData, catCount, layout, primaryRange, sourceIndices2, invertNegativeFill2) {
|
|
4455
|
-
const primitives = [], dataLabels = [], series = chartData.series, palette = chartData.colorPalette, showLabels = chartData.style?.hasDataLabels, barGroupWidth = layout.plotWidth / Math.max(catCount, 1), barW = barGroupWidth
|
|
4593
|
+
const primitives = [], dataLabels = [], series = chartData.series, palette = chartData.colorPalette, showLabels = chartData.style?.hasDataLabels, barGroupWidth = layout.plotWidth / Math.max(catCount, 1), barW = stackedBarWidth(barGroupWidth, chartData.barGapWidth), barOffset = (barGroupWidth - barW) / 2, displaySeries = series.map((entry) => ({
|
|
4456
4594
|
...entry,
|
|
4457
4595
|
values: sourceIndices2.map((sourceIndex) => entry.values[sourceIndex] ?? 0)
|
|
4458
4596
|
})), totals = categoryTotals(displaySeries, catCount);
|
|
@@ -4460,7 +4598,17 @@ function buildPercentStackedBars(chartData, catCount, layout, primaryRange, sour
|
|
|
4460
4598
|
let posRunning = 0, negRunning = 0;
|
|
4461
4599
|
const catTotal = totals[ci] || 1;
|
|
4462
4600
|
for (let si = 0; si < series.length; si++) {
|
|
4463
|
-
const sourceIndex = sourceIndices2[ci] ?? ci, rawVal = series[si].values[sourceIndex] ?? 0, val = catTotal > 0 ? rawVal / catTotal * 100 : 0,
|
|
4601
|
+
const sourceIndex = sourceIndices2[ci] ?? ci, rawVal = series[si].values[sourceIndex] ?? 0, val = catTotal > 0 ? rawVal / catTotal * 100 : 0, base = val < 0 ? negRunning : posRunning;
|
|
4602
|
+
if (val < 0) {
|
|
4603
|
+
negRunning += val;
|
|
4604
|
+
} else {
|
|
4605
|
+
posRunning += val;
|
|
4606
|
+
}
|
|
4607
|
+
const segment = clipStackedSegment(base, val, primaryRange);
|
|
4608
|
+
if (!segment) {
|
|
4609
|
+
continue;
|
|
4610
|
+
}
|
|
4611
|
+
const x = layout.plotLeft + barGroupWidth * ci + barOffset, toY = (value) => valueToY2(value, primaryRange, layout.plotTop, layout.plotBottom), { start: y, size: h } = val < 0 ? stackedSegmentExtent(toY(segment.high), toY(segment.low), 0.5) : stackedSegmentExtent(toY(segment.low), toY(segment.high), 0.5), pctBaseFill = resolveDataPointFill(series[si], sourceIndex, paletteColor2(si, palette)) ?? seriesColor2(series[si], si, palette);
|
|
4464
4612
|
primitives.push({
|
|
4465
4613
|
kind: "rect",
|
|
4466
4614
|
x,
|
|
@@ -4489,52 +4637,43 @@ function buildPercentStackedBars(chartData, catCount, layout, primaryRange, sour
|
|
|
4489
4637
|
...dataLabelFontOverride(resolveDataLabelTextStyle(chartData, series[si], sourceIndex))
|
|
4490
4638
|
});
|
|
4491
4639
|
}
|
|
4492
|
-
if (isNeg) {
|
|
4493
|
-
negRunning += val;
|
|
4494
|
-
} else {
|
|
4495
|
-
posRunning += val;
|
|
4496
|
-
}
|
|
4497
4640
|
}
|
|
4498
4641
|
}
|
|
4499
4642
|
return { primitives, dataLabels };
|
|
4500
4643
|
}
|
|
4501
4644
|
|
|
4502
4645
|
// src/pptx/render/chart-cartesian-stacked-labels.ts
|
|
4503
|
-
function
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
const val = series[si].values[sourceIndex] ?? 0, barX = layout.plotLeft + barGroupWidth * ci + groupOffset + singleBarWidth * si, zeroY = valueToY2(0, range, layout.plotTop, layout.plotBottom), valY = valueToY2(val, range, layout.plotTop, layout.plotBottom), barY = Math.min(zeroY, valY), barH = Math.max(Math.abs(zeroY - valY), 1), label = buildDataLabelText({
|
|
4509
|
-
chartData,
|
|
4510
|
-
series: series[si],
|
|
4511
|
-
pointIndex: sourceIndex,
|
|
4512
|
-
value: val
|
|
4513
|
-
});
|
|
4514
|
-
if (label === void 0) {
|
|
4515
|
-
continue;
|
|
4516
|
-
}
|
|
4517
|
-
const anchor = resolveBarLabelPlacement(
|
|
4518
|
-
chartData,
|
|
4519
|
-
series[si],
|
|
4520
|
-
sourceIndex,
|
|
4521
|
-
{ x: barX, y: barY, width: singleBarWidth, height: barH },
|
|
4522
|
-
val,
|
|
4523
|
-
"vertical",
|
|
4524
|
-
{ width: layout.svgWidth, height: layout.svgHeight }
|
|
4525
|
-
);
|
|
4526
|
-
dataLabels.push({
|
|
4527
|
-
kind: "text",
|
|
4528
|
-
x: anchor.x,
|
|
4529
|
-
y: anchor.y,
|
|
4530
|
-
text: label.text,
|
|
4531
|
-
fontSize: DEFAULT_CHART_DATA_LABEL_PX,
|
|
4532
|
-
fill: label.color ?? "#334155",
|
|
4533
|
-
textAnchor: anchor.textAnchor,
|
|
4534
|
-
...anchor.dominantBaseline ? { dominantBaseline: anchor.dominantBaseline } : {},
|
|
4535
|
-
...dataLabelFontOverride(resolveDataLabelTextStyle(chartData, series[si], sourceIndex))
|
|
4536
|
-
});
|
|
4646
|
+
function pushStackedBarLabels(chartData, series, sourceIndices2, rects, layout, dataLabels) {
|
|
4647
|
+
for (const rect of rects) {
|
|
4648
|
+
const entry = rect.seriesIndex === void 0 ? void 0 : series[rect.seriesIndex];
|
|
4649
|
+
if (!entry || rect.pointIndex === void 0) {
|
|
4650
|
+
continue;
|
|
4537
4651
|
}
|
|
4652
|
+
const sourceIndex = sourceIndices2[rect.pointIndex] ?? rect.pointIndex, val = entry.values[sourceIndex] ?? 0, label = buildDataLabelText({ chartData, series: entry, pointIndex: sourceIndex, value: val });
|
|
4653
|
+
if (label === void 0) {
|
|
4654
|
+
continue;
|
|
4655
|
+
}
|
|
4656
|
+
const anchor = resolveBarLabelPlacement(
|
|
4657
|
+
chartData,
|
|
4658
|
+
entry,
|
|
4659
|
+
sourceIndex,
|
|
4660
|
+
{ x: rect.x, y: rect.y, width: rect.w, height: rect.h },
|
|
4661
|
+
val,
|
|
4662
|
+
"vertical",
|
|
4663
|
+
{ width: layout.svgWidth, height: layout.svgHeight },
|
|
4664
|
+
"ctr"
|
|
4665
|
+
);
|
|
4666
|
+
dataLabels.push({
|
|
4667
|
+
kind: "text",
|
|
4668
|
+
x: anchor.x,
|
|
4669
|
+
y: anchor.y,
|
|
4670
|
+
text: label.text,
|
|
4671
|
+
fontSize: DEFAULT_CHART_DATA_LABEL_PX,
|
|
4672
|
+
fill: label.color ?? "#334155",
|
|
4673
|
+
textAnchor: anchor.textAnchor,
|
|
4674
|
+
...anchor.dominantBaseline ? { dominantBaseline: anchor.dominantBaseline } : {},
|
|
4675
|
+
...dataLabelFontOverride(resolveDataLabelTextStyle(chartData, entry, sourceIndex))
|
|
4676
|
+
});
|
|
4538
4677
|
}
|
|
4539
4678
|
}
|
|
4540
4679
|
|
|
@@ -4639,7 +4778,14 @@ function buildBars(chartData, catCount, layout, primaryRange, secondaryRange, se
|
|
|
4639
4778
|
const displaySeries = series.map((entry) => ({
|
|
4640
4779
|
...entry,
|
|
4641
4780
|
values: sourceIndices2.map((sourceIndex) => entry.values[sourceIndex] ?? 0)
|
|
4642
|
-
})), rects = computeStackedBarRects(
|
|
4781
|
+
})), rects = computeStackedBarRects(
|
|
4782
|
+
displaySeries,
|
|
4783
|
+
catCount,
|
|
4784
|
+
layout,
|
|
4785
|
+
primaryRange,
|
|
4786
|
+
palette,
|
|
4787
|
+
chartData.barGapWidth
|
|
4788
|
+
);
|
|
4643
4789
|
for (const r of rects) {
|
|
4644
4790
|
let fill = r.fill, part, title;
|
|
4645
4791
|
if (r.seriesIndex !== void 0 && r.pointIndex !== void 0) {
|
|
@@ -4658,15 +4804,7 @@ function buildBars(chartData, catCount, layout, primaryRange, secondaryRange, se
|
|
|
4658
4804
|
primitives.push({ kind: "rect", x: r.x, y: r.y, w: r.w, h: r.h, fill, rx: 1, part, title });
|
|
4659
4805
|
}
|
|
4660
4806
|
if (showLabels) {
|
|
4661
|
-
|
|
4662
|
-
chartData,
|
|
4663
|
-
series,
|
|
4664
|
-
sourceIndices2,
|
|
4665
|
-
catCount,
|
|
4666
|
-
layout,
|
|
4667
|
-
primaryRange,
|
|
4668
|
-
dataLabels
|
|
4669
|
-
);
|
|
4807
|
+
pushStackedBarLabels(chartData, series, sourceIndices2, rects, layout, dataLabels);
|
|
4670
4808
|
}
|
|
4671
4809
|
return { primitives, dataLabels };
|
|
4672
4810
|
}
|
|
@@ -4756,7 +4894,7 @@ function seriesLineStroke(chartData, series) {
|
|
|
4756
4894
|
|
|
4757
4895
|
// src/pptx/render/chart-cartesian-line-area.ts
|
|
4758
4896
|
function buildLines(chartData, catCount, layout, primaryRange, secondaryRange, secondaryIdx, sourceIndices2, xPositions, stacking = "clustered") {
|
|
4759
|
-
const primitives = [], dataLabels = [], labelBoxes = [], showLabels = chartData.style?.hasDataLabels, isStackedMode = stacking !== "clustered", isPercent = stacking === "percentStacked", resolved = chartData.series.map((series) => {
|
|
4897
|
+
const primitives = [], dataLabels = [], labelBoxes = [], showLabels = chartData.style?.hasDataLabels, isStackedMode = stacking !== "clustered", isPercent = stacking === "percentStacked", band = plotBand(layout), resolved = chartData.series.map((series) => {
|
|
4760
4898
|
if (series.values.length === 0) {
|
|
4761
4899
|
return void 0;
|
|
4762
4900
|
}
|
|
@@ -4780,41 +4918,21 @@ function buildLines(chartData, catCount, layout, primaryRange, secondaryRange, s
|
|
|
4780
4918
|
...point,
|
|
4781
4919
|
x: xPositions?.[index] ?? point.x
|
|
4782
4920
|
})), c = seriesColor2(series, si, chartData.colorPalette), seriesPart = { role: "series", seriesIndex: si }, allVisible = visible.every(Boolean);
|
|
4783
|
-
|
|
4921
|
+
for (const run of allVisible ? [pts] : visibleRuns(visible).map((r) => r.map((i) => pts[i]))) {
|
|
4922
|
+
if (!allVisible && run.length < 2) {
|
|
4923
|
+
continue;
|
|
4924
|
+
}
|
|
4784
4925
|
primitives.push(
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
stroke: c,
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
part: seriesPart
|
|
4792
|
-
} : {
|
|
4793
|
-
kind: "polyline",
|
|
4794
|
-
points: linePointsToSvgString(pts),
|
|
4795
|
-
stroke: c,
|
|
4796
|
-
...lineStroke,
|
|
4797
|
-
fill: "none",
|
|
4798
|
-
part: seriesPart
|
|
4799
|
-
}
|
|
4926
|
+
...clippedSeriesLine(
|
|
4927
|
+
run,
|
|
4928
|
+
allVisible && Boolean(series.smooth),
|
|
4929
|
+
{ stroke: c, ...lineStroke, fill: "none", part: seriesPart },
|
|
4930
|
+
band
|
|
4931
|
+
)
|
|
4800
4932
|
);
|
|
4801
|
-
} else {
|
|
4802
|
-
for (const run of visibleRuns(visible)) {
|
|
4803
|
-
if (run.length < 2) {
|
|
4804
|
-
continue;
|
|
4805
|
-
}
|
|
4806
|
-
primitives.push({
|
|
4807
|
-
kind: "polyline",
|
|
4808
|
-
points: linePointsToSvgString(run.map((i) => pts[i])),
|
|
4809
|
-
stroke: c,
|
|
4810
|
-
...lineStroke,
|
|
4811
|
-
fill: "none",
|
|
4812
|
-
part: seriesPart
|
|
4813
|
-
});
|
|
4814
|
-
}
|
|
4815
4933
|
}
|
|
4816
4934
|
pts.forEach((pt, displayIndex) => {
|
|
4817
|
-
if (!visible[displayIndex]) {
|
|
4935
|
+
if (!visible[displayIndex] || !insideBand(pt, band)) {
|
|
4818
4936
|
return;
|
|
4819
4937
|
}
|
|
4820
4938
|
const idx = sourceIndices2[displayIndex] ?? displayIndex, part = { role: "dataPoint", seriesIndex: si, pointIndex: idx };
|
|
@@ -4840,7 +4958,7 @@ function buildLines(chartData, catCount, layout, primaryRange, secondaryRange, s
|
|
|
4840
4958
|
const labelValues = stackedPlots ? stackedPlots[si].own : displayValues;
|
|
4841
4959
|
labelValues.forEach((val, displayIndex) => {
|
|
4842
4960
|
const pt = pts[displayIndex];
|
|
4843
|
-
if (!pt || !visible[displayIndex]) {
|
|
4961
|
+
if (!pt || !visible[displayIndex] || !insideBand(pt, band)) {
|
|
4844
4962
|
return;
|
|
4845
4963
|
}
|
|
4846
4964
|
if (isPercent) {
|
|
@@ -5329,7 +5447,7 @@ function addUnit(date, amount, unit) {
|
|
|
5329
5447
|
}
|
|
5330
5448
|
function tickLine2(x, y, axis, minor) {
|
|
5331
5449
|
const placement = minor ? axis.minorTickMark : axis.majorTickMark;
|
|
5332
|
-
if (!placement || placement === "none") {
|
|
5450
|
+
if (!placement || placement === "none" || isNoLine(axis.spPr)) {
|
|
5333
5451
|
return void 0;
|
|
5334
5452
|
}
|
|
5335
5453
|
const length = minor ? 2.5 : 4;
|
|
@@ -5422,7 +5540,7 @@ function buildDateAxisPlan(chartData, layout, selectedAxis, axisY) {
|
|
|
5422
5540
|
const line2 = tickLine2(x, y, axis, false);
|
|
5423
5541
|
return line2 ? [line2] : [];
|
|
5424
5542
|
});
|
|
5425
|
-
if (!axis.deleted && axis.spPr) {
|
|
5543
|
+
if (!axis.deleted && axis.spPr && !isNoLine(axis.spPr)) {
|
|
5426
5544
|
tickMarks.unshift({
|
|
5427
5545
|
kind: "line",
|
|
5428
5546
|
x1: layout.plotLeft,
|
|
@@ -5625,19 +5743,21 @@ function valueToX(val, range, leftX, rightX) {
|
|
|
5625
5743
|
}
|
|
5626
5744
|
return range.reverseOrder ? rightX - ratio * usable : leftX + ratio * usable;
|
|
5627
5745
|
}
|
|
5628
|
-
function buildTransposedValueAxis(range, layout) {
|
|
5629
|
-
const gridlines = [], axisLabels = [];
|
|
5746
|
+
function buildTransposedValueAxis(range, layout, axis, showMajorGridlines = true) {
|
|
5747
|
+
const gridlines = [], axisLabels = [], drawGridlines = showMajorGridlines && !isNoLine(axis?.majorGridlinesSpPr);
|
|
5630
5748
|
for (const val of axisTickValues(range)) {
|
|
5631
5749
|
const x = valueToX(val, range, layout.plotLeft, layout.plotRight);
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5750
|
+
if (drawGridlines) {
|
|
5751
|
+
gridlines.push(
|
|
5752
|
+
buildVerticalStyledGridline(
|
|
5753
|
+
x,
|
|
5754
|
+
layout,
|
|
5755
|
+
axis?.majorGridlinesSpPr,
|
|
5756
|
+
GRIDLINE_COLOR3,
|
|
5757
|
+
1,
|
|
5758
|
+
void 0)
|
|
5759
|
+
);
|
|
5760
|
+
}
|
|
5641
5761
|
axisLabels.push({
|
|
5642
5762
|
kind: "text",
|
|
5643
5763
|
x,
|
|
@@ -5687,7 +5807,12 @@ function barFill(chartData, series, seriesIndex, pointIndex) {
|
|
|
5687
5807
|
function buildHorizontalBarViewModel(element, chartData, categoryLabels) {
|
|
5688
5808
|
const layout = computePlotLayout(element.width, element.height, chartData, true, {
|
|
5689
5809
|
leftCategoryLabelWidth: widestCategoryLabelWidth(categoryLabels, DEFAULT_CHART_TEXT_PX)
|
|
5690
|
-
}), catCount = Math.max(categoryLabels.length, 1), series = chartData.series, grouping = chartData.grouping ?? "clustered", isStacked = grouping === "stacked" || grouping === "percentStacked", isPercent = grouping === "percentStacked",
|
|
5810
|
+
}), catCount = Math.max(categoryLabels.length, 1), series = chartData.series, grouping = chartData.grouping ?? "clustered", isStacked = grouping === "stacked" || grouping === "percentStacked", isPercent = grouping === "percentStacked", valueAxis = primaryValueAxis(chartData.axes), range = isStacked ? computeStackedValueRangeForAxis(series, catCount, valueAxis, isPercent, layout.plotWidth) : computeValueRangeForChart(series, chartData.axes, layout.plotWidth), { gridlines, axisLabels } = buildTransposedValueAxis(
|
|
5811
|
+
range,
|
|
5812
|
+
layout,
|
|
5813
|
+
valueAxis,
|
|
5814
|
+
shouldRenderMajorGridlines(chartData)
|
|
5815
|
+
), zeroX = valueToX(0, range, layout.plotLeft, layout.plotRight), zeroLine = range.min < 0 && range.max > 0 ? {
|
|
5691
5816
|
kind: "line",
|
|
5692
5817
|
x1: zeroX,
|
|
5693
5818
|
y1: layout.plotTop,
|
|
@@ -5746,7 +5871,7 @@ function buildHorizontalBarViewModel(element, chartData, categoryLabels) {
|
|
|
5746
5871
|
}
|
|
5747
5872
|
}
|
|
5748
5873
|
} else {
|
|
5749
|
-
const totals = isPercent ? categoryTotals2(series, catCount) : [], barH = band
|
|
5874
|
+
const totals = isPercent ? categoryTotals2(series, catCount) : [], barH = stackedBarWidth(band, chartData.barGapWidth), barOffset = (band - barH) / 2;
|
|
5750
5875
|
for (let ci = 0; ci < catCount; ci++) {
|
|
5751
5876
|
let posRunning = 0, negRunning = 0;
|
|
5752
5877
|
const catTotal = isPercent ? totals[ci] || 1 : 1;
|
|
@@ -5755,7 +5880,21 @@ function buildHorizontalBarViewModel(element, chartData, categoryLabels) {
|
|
|
5755
5880
|
if (val === 0) {
|
|
5756
5881
|
continue;
|
|
5757
5882
|
}
|
|
5758
|
-
const isNeg = val < 0, base = isNeg ? negRunning : posRunning
|
|
5883
|
+
const isNeg = val < 0, base = isNeg ? negRunning : posRunning;
|
|
5884
|
+
if (isNeg) {
|
|
5885
|
+
negRunning += val;
|
|
5886
|
+
} else {
|
|
5887
|
+
posRunning += val;
|
|
5888
|
+
}
|
|
5889
|
+
const segment = clipStackedSegment(base, val, range);
|
|
5890
|
+
if (!segment) {
|
|
5891
|
+
continue;
|
|
5892
|
+
}
|
|
5893
|
+
const y = layout.plotTop + band * ci + barOffset, { start: x, size: w } = stackedSegmentExtent(
|
|
5894
|
+
valueToX(isNeg ? segment.high : segment.low, range, layout.plotLeft, layout.plotRight),
|
|
5895
|
+
valueToX(isNeg ? segment.low : segment.high, range, layout.plotLeft, layout.plotRight),
|
|
5896
|
+
0.5
|
|
5897
|
+
);
|
|
5759
5898
|
primitives.push({
|
|
5760
5899
|
kind: "rect",
|
|
5761
5900
|
x,
|
|
@@ -5794,7 +5933,9 @@ function buildHorizontalBarViewModel(element, chartData, categoryLabels) {
|
|
|
5794
5933
|
{ x, y, width: w, height: barH },
|
|
5795
5934
|
rawVal,
|
|
5796
5935
|
"horizontal",
|
|
5797
|
-
{ width: layout.svgWidth, height: layout.svgHeight }
|
|
5936
|
+
{ width: layout.svgWidth, height: layout.svgHeight },
|
|
5937
|
+
// A stacked segment's label is centred unless c:dLblPos says otherwise.
|
|
5938
|
+
"ctr"
|
|
5798
5939
|
);
|
|
5799
5940
|
dataLabels.push({
|
|
5800
5941
|
kind: "text",
|
|
@@ -5809,11 +5950,6 @@ function buildHorizontalBarViewModel(element, chartData, categoryLabels) {
|
|
|
5809
5950
|
});
|
|
5810
5951
|
}
|
|
5811
5952
|
}
|
|
5812
|
-
if (isNeg) {
|
|
5813
|
-
negRunning += val;
|
|
5814
|
-
} else {
|
|
5815
|
-
posRunning += val;
|
|
5816
|
-
}
|
|
5817
5953
|
}
|
|
5818
5954
|
}
|
|
5819
5955
|
}
|
|
@@ -5845,12 +5981,6 @@ function buildHorizontalBarViewModel(element, chartData, categoryLabels) {
|
|
|
5845
5981
|
}
|
|
5846
5982
|
|
|
5847
5983
|
// src/pptx/render/chart-cartesian.ts
|
|
5848
|
-
function stackedRange(chartData, catCount, isPercent, plotHeightPx) {
|
|
5849
|
-
if (isPercent) {
|
|
5850
|
-
return { min: 0, max: 100, span: 100 };
|
|
5851
|
-
}
|
|
5852
|
-
return computeStackedValueRange(chartData.series, catCount, plotHeightPx);
|
|
5853
|
-
}
|
|
5854
5984
|
function buildCartesianViewModel(element, chartData, categoryLabels, kind) {
|
|
5855
5985
|
if (kind === "bar" && chartData.barDirection === "bar") {
|
|
5856
5986
|
return buildHorizontalBarViewModel(element, chartData, categoryLabels);
|
|
@@ -5866,13 +5996,13 @@ function buildCartesianViewModel(element, chartData, categoryLabels, kind) {
|
|
|
5866
5996
|
const useSecondary = !isStacked && secondaryIdx.size > 0;
|
|
5867
5997
|
const primaryPlotSeries = useSecondary ? chartData.series.filter((_s, i) => !secondaryIdx.has(i)) : chartData.series;
|
|
5868
5998
|
const secondaryPlotSeries = useSecondary ? chartData.series.filter((_s, i) => secondaryIdx.has(i)) : [];
|
|
5869
|
-
const
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5999
|
+
const primaryRange = isStacked ? computeStackedValueRangeForAxis(
|
|
6000
|
+
chartData.series,
|
|
6001
|
+
catCount,
|
|
6002
|
+
primaryValueAxis(chartData.axes),
|
|
6003
|
+
isPercent,
|
|
6004
|
+
layout.autoPlotHeight
|
|
6005
|
+
) : computeValueRangeForChart(
|
|
5876
6006
|
primaryPlotSeries.length > 0 ? primaryPlotSeries : chartData.series,
|
|
5877
6007
|
chartData.axes,
|
|
5878
6008
|
layout.autoPlotHeight
|
|
@@ -6433,7 +6563,8 @@ function buildComboViewModel(element, chartData, categoryLabels) {
|
|
|
6433
6563
|
layout,
|
|
6434
6564
|
"right",
|
|
6435
6565
|
chartData.dateCategories?.values
|
|
6436
|
-
)
|
|
6566
|
+
),
|
|
6567
|
+
axisShowsMajorGridlines(secondaryAxisFormatting)
|
|
6437
6568
|
) : void 0;
|
|
6438
6569
|
const zeroLine = primaryRange.logScale ? void 0 : buildZeroLine(primaryRange, layout);
|
|
6439
6570
|
const horizontalAxis = buildCartesianHorizontalAxis(
|
|
@@ -10265,7 +10396,7 @@ function buildChartViewModelInner(element) {
|
|
|
10265
10396
|
if (element.type !== "chart") {
|
|
10266
10397
|
return buildFallbackViewModel(element.width, element.height, "Chart");
|
|
10267
10398
|
}
|
|
10268
|
-
const chartEl = element, chartData = chartEl.chartData ? withChartTextDefaults(withAutoTitle(chartEl.chartData)) : chartEl.chartData;
|
|
10399
|
+
const chartEl = element, chartData = chartEl.chartData ? withResolvedPalette(withChartTextDefaults(withAutoTitle(chartEl.chartData))) : chartEl.chartData;
|
|
10269
10400
|
if (!chartData || chartData.series.length === 0) {
|
|
10270
10401
|
return buildFallbackViewModel(element.width, element.height, chartData?.title ?? "Chart");
|
|
10271
10402
|
}
|
|
@@ -10740,4 +10871,4 @@ function computeTrendlinePrimitives(chartData, catCount, layout, range, mode = "
|
|
|
10740
10871
|
return out;
|
|
10741
10872
|
}
|
|
10742
10873
|
|
|
10743
|
-
export { AXIS_LABEL_COLOR, CHART_PX_PER_PT, CHART_TITLE_FONT_PX, CHART_TITLE_TOP_INSET_PX, DATA_LABEL_LINE_HEIGHT, DATA_LABEL_PAD_X, DATA_LABEL_PAD_Y, DATA_TABLE_HEADER_H, DATA_TABLE_KEY_W, DATA_TABLE_PADDING, DATA_TABLE_ROW_H, DEFAULT_BODY_INSET_LR_PX, DEFAULT_BODY_INSET_TB_PX, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_CHART_AREA_FILL, DEFAULT_CHART_DATA_LABEL_PX, DEFAULT_CHART_PALETTE, DEFAULT_CHART_TEXT_PX, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_PALETTE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, GRIDLINE_COLOR3 as GRIDLINE_COLOR, HYPERLINK_COLOR, LEGACY_CHART_TITLE_BAND_PX, LEGEND_LINE_SWATCH_WIDTH, LEGEND_MARKER_RADIUS, OOXML_PATTERN_PRESETS, PIE_AUTO_INSET_PX, TEXT_ORIENTATION_IDENTITY, ZERO_LINE_COLOR, adjustFillForMode, applyDataPointPictureFills, applyLabelManualLayout, applyLegendEntryOverrides, applyParetoConversion, axisTickValues, buildBoxWhiskerViewModel, buildCartesianViewModel, buildCategoryLabels, buildChartViewModel, buildCirclePathGradient, buildComboViewModel, buildCssGradientFromShapeStyle, buildDashArray, buildDataLabelText, buildFallbackViewModel, buildFunnelViewModel, buildGradientCss, buildGridlinesAndLabels, buildHistogramViewModel, buildLegend, buildLineLegendSwatch, buildMarkTooltip, buildPatternFill, buildPatternFillCss, buildPieViewModel, buildPrimaryAxis, buildRadarViewModel, buildRectPathGradient, buildReflectedGradientStops, buildRegionMapEntries, buildRegionMapViewModel, buildSecondaryAxis, buildShapePathGradient, buildStockCloseLabel, buildStockViewModel, buildSubpathFillOverlay, buildSubpathPaints, buildSunburstViewModel, buildSurfaceViewModel, buildTreemapViewModel, buildTrendlineLegendSwatch, buildValueAxisGridlinesAndLabels, buildWaterfallViewModel, buildZeroLine, canvasFontFamily, chartAreaCornerRadius, chartAreaFill, chartFontPx, chartFrameToViewOffset, chartGridlinesPatch, chartGridlinesState, chartPreserveAspectRatio, chartTextFontFamily, chartTitleBand, chartTitleBandFor, chartTitleFontPx, chartTitleReservePx, clampCropValue, collapseChartTitleRunsForEdit, computeAxisTitlePrimitives, computeBarRects, computeBoxWhiskerGeometry, computeBubbleRadius, computeDataTableHeight, computeDataTablePrimitives, computeErrorBarPrimitives, computeFunnelSegments, computeGradientCenter, computeHierarchicalSunburstArcs, computeHistogramBars, computeHistogramBins, computeLayout, computeLayoutOptions, computeLinePoints, computeLogValueRange, computePieLayout, computePieSlicePath, computePieSlices, computePlotLayout, computeScatterDots, computeScatterXDomain, computeStackedBarRects, computeStackedValueRange, computeSunburstArcs, computeTrendlinePrimitives, computeValueRange, computeValueRange2, computeValueRangeForAxis, computeValueRangeForChart, convertOoxmlAngleToCss, createArrayBufferCopy, cumulativePercentOfTotal, dataLabelBox, dataLabelBoxSize, dataLabelFontOverride, decodeFirstPixelColor, ensureBarFacePicturePixelSampled, estimateChartTextWidth, estimateTextWidth, findDataPoint, findLogAxis, findPointLabel, findValueAxis, fitTitleBand, formatAxisValue, formatAxisValue2, formatAxisValueWithUnits, formatChartNumber, formatChartNumberWithColor, formatRegionMapValue, generateAxisTicks, generateLogTicks, generateMinorAxisTicks, getBarFacePicturePixelSampleVersion, getCachedBarFacePicturePixelColor, getChartStylePalette, getCompoundLineBorderWidth, getCompoundLineBoxShadow, getCompoundLineStyle, getComputedFillStyle, getCssBorderDashStyle, getDisplayUnitDivisor, getDisplayUnitLabel, getElementOrientationMatrix, getElementTransform, getElementTransformWithoutRotation, getGradientTileFlipCss, getGradientTileRectCss, getPatternSvg, getPatternTile, getPrimaryValueAxis, getPrimaryValueAxisId, getSecondaryCategoryAxis, getSecondaryValueAxis, getSecondaryValueAxisId, getSvgStrokeDasharray, getTextCompensationTransform, hasSecondaryCategoryAxis, hasSecondaryValueAxis, isParetoChart, isPrimaryCategoryAxisAtTop, isSeriesOnSecondaryAxis, isTextOrientationMatrix, linePointsToSvgString, manualLayoutOf, manualLegendAnchor, manualTitleAnchor, measureChartTextWidth, multiplyTextOrientationMatrices, normalizeStrokeDashType, normalizeValue, orderParetoEntries, paletteColor, paletteColor2, parseDrawingPercent, plotAreaFill, reserveLegendSpace, resetBarFacePicturePixelCacheForTests, resolveActiveDataPointPicture, resolveBarFacePicturePixelColor, resolveBarFaceTargets, resolveBarLabelAnchor, resolveBarLabelPlacement, resolveCategoryLabels, resolveChartKind, resolveChartStyleDefaults, resolveChartTitleRunSpans, resolveChartTitleTextStyle, resolveDataLabelContent, resolveDataLabelTextStyle, resolveDataPointExplosion, resolveDataPointFill, resolveDataPointMarker, resolveDataPointPictureFill, resolveDisplayedChartType, resolveExtrusionFaceFill, resolveLabelPosition, resolveLegendAnchorPosition, resolveLegendPlacement, resolveLegendSwatchKind, resolveMarkerLabelAnchor, resolveMarkerLabelPlacement, resolveRegionCode, resolveRegionEntityCode, resolveUntargetedBarFaceFill, resolveVaryColorFill, sanitizeGradientStops, sequentialColorScale, seriesColor, seriesColor2, seriesXValues, setChartTextMeasurer,
|
|
10874
|
+
export { AXIS_LABEL_COLOR, CHART_PX_PER_PT, CHART_TITLE_FONT_PX, CHART_TITLE_TOP_INSET_PX, DATA_LABEL_LINE_HEIGHT, DATA_LABEL_PAD_X, DATA_LABEL_PAD_Y, DATA_TABLE_HEADER_H, DATA_TABLE_KEY_W, DATA_TABLE_PADDING, DATA_TABLE_ROW_H, DEFAULT_BODY_INSET_LR_PX, DEFAULT_BODY_INSET_TB_PX, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_CHART_AREA_FILL, DEFAULT_CHART_DATA_LABEL_PX, DEFAULT_CHART_PALETTE, DEFAULT_CHART_TEXT_PX, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_PALETTE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, GRIDLINE_COLOR3 as GRIDLINE_COLOR, HYPERLINK_COLOR, LEGACY_CHART_TITLE_BAND_PX, LEGEND_LINE_SWATCH_WIDTH, LEGEND_MARKER_RADIUS, OOXML_PATTERN_PRESETS, PIE_AUTO_INSET_PX, TEXT_ORIENTATION_IDENTITY, ZERO_LINE_COLOR, adjustFillForMode, applyDataPointPictureFills, applyLabelManualLayout, applyLegendEntryOverrides, applyParetoConversion, axisShowsMajorGridlines, axisTickValues, buildBoxWhiskerViewModel, buildCartesianViewModel, buildCategoryLabels, buildChartViewModel, buildCirclePathGradient, buildComboViewModel, buildCssGradientFromShapeStyle, buildDashArray, buildDataLabelText, buildFallbackViewModel, buildFunnelViewModel, buildGradientCss, buildGridlinesAndLabels, buildHistogramViewModel, buildLegend, buildLineLegendSwatch, buildMarkTooltip, buildPatternFill, buildPatternFillCss, buildPieViewModel, buildPrimaryAxis, buildRadarViewModel, buildRectPathGradient, buildReflectedGradientStops, buildRegionMapEntries, buildRegionMapViewModel, buildSecondaryAxis, buildShapePathGradient, buildStockCloseLabel, buildStockViewModel, buildSubpathFillOverlay, buildSubpathPaints, buildSunburstViewModel, buildSurfaceViewModel, buildTreemapViewModel, buildTrendlineLegendSwatch, buildValueAxisGridlinesAndLabels, buildWaterfallViewModel, buildZeroLine, canvasFontFamily, chartAreaCornerRadius, chartAreaFill, chartFontPx, chartFrameToViewOffset, chartGridlinesPatch, chartGridlinesState, chartPreserveAspectRatio, chartTextFontFamily, chartTitleBand, chartTitleBandFor, chartTitleFontPx, chartTitleReservePx, clampCropValue, clipStackedSegment, collapseChartTitleRunsForEdit, computeAxisTitlePrimitives, computeBarRects, computeBoxWhiskerGeometry, computeBubbleRadius, computeDataTableHeight, computeDataTablePrimitives, computeErrorBarPrimitives, computeFunnelSegments, computeGradientCenter, computeHierarchicalSunburstArcs, computeHistogramBars, computeHistogramBins, computeLayout, computeLayoutOptions, computeLinePoints, computeLogValueRange, computePieLayout, computePieSlicePath, computePieSlices, computePlotLayout, computeScatterDots, computeScatterXDomain, computeStackedBarRects, computeStackedValueRange, computeStackedValueRangeForAxis, computeSunburstArcs, computeTrendlinePrimitives, computeValueRange, computeValueRange2, computeValueRangeForAxis, computeValueRangeForChart, convertOoxmlAngleToCss, createArrayBufferCopy, cumulativePercentOfTotal, dataLabelBox, dataLabelBoxSize, dataLabelFontOverride, decodeFirstPixelColor, ensureBarFacePicturePixelSampled, estimateChartTextWidth, estimateTextWidth, findDataPoint, findLogAxis, findPointLabel, findValueAxis, fitTitleBand, formatAxisValue, formatAxisValue2, formatAxisValueWithUnits, formatChartNumber, formatChartNumberWithColor, formatRegionMapValue, generateAxisTicks, generateLogTicks, generateMinorAxisTicks, getBarFacePicturePixelSampleVersion, getCachedBarFacePicturePixelColor, getChartStylePalette, getCompoundLineBorderWidth, getCompoundLineBoxShadow, getCompoundLineStyle, getComputedFillStyle, getCssBorderDashStyle, getDisplayUnitDivisor, getDisplayUnitLabel, getElementOrientationMatrix, getElementTransform, getElementTransformWithoutRotation, getGradientTileFlipCss, getGradientTileRectCss, getPatternSvg, getPatternTile, getPrimaryValueAxis, getPrimaryValueAxisId, getSecondaryCategoryAxis, getSecondaryValueAxis, getSecondaryValueAxisId, getSvgStrokeDasharray, getTextCompensationTransform, hasSecondaryCategoryAxis, hasSecondaryValueAxis, isParetoChart, isPrimaryCategoryAxisAtTop, isSeriesOnSecondaryAxis, isTextOrientationMatrix, linePointsToSvgString, manualLayoutOf, manualLegendAnchor, manualTitleAnchor, measureChartTextWidth, multiplyTextOrientationMatrices, normalizeStrokeDashType, normalizeValue, orderParetoEntries, paletteColor, paletteColor2, parseDrawingPercent, plotAreaFill, primaryValueAxis, reserveLegendSpace, resetBarFacePicturePixelCacheForTests, resolveActiveDataPointPicture, resolveBarFacePicturePixelColor, resolveBarFaceTargets, resolveBarLabelAnchor, resolveBarLabelPlacement, resolveCategoryLabels, resolveChartKind, resolveChartPalette, resolveChartStyleDefaults, resolveChartTitleRunSpans, resolveChartTitleTextStyle, resolveDataLabelContent, resolveDataLabelTextStyle, resolveDataPointExplosion, resolveDataPointFill, resolveDataPointMarker, resolveDataPointPictureFill, resolveDisplayedChartType, resolveExtrusionFaceFill, resolveLabelPosition, resolveLegendAnchorPosition, resolveLegendPlacement, resolveLegendSwatchKind, resolveMarkerLabelAnchor, resolveMarkerLabelPlacement, resolveRegionCode, resolveRegionEntityCode, resolveUntargetedBarFaceFill, resolveVaryColorFill, sanitizeGradientStops, sequentialColorScale, seriesColor, seriesColor2, seriesXValues, setChartTextMeasurer, shade, shouldRenderMajorGridlines, shouldRenderRegionLabel, splitLabelLines, splitSeriesByAxis, stackedBarWidth, stackedSegmentExtent, subscribeBarFacePicturePixelSamples, suppressesCssFill, surfaceColor, tint, titleBaselineFor, toCssGradientStop, unitsCaptionOffset, upsertDataPoint, valueToY, valueToY2, valueToYLog, withChartTitleBand, withManualLayouts, wrapTextByEstimatedWidth };
|