@office-kit/pptx-preview 0.8.1 → 0.9.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/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as MONO, c as TIMES, d as substituteFamily, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout } from "./src-BMb2-vud.js";
1
+ import { a as MONO, c as TIMES, d as substituteFamily, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout } from "./src-DPHsJGe1.js";
2
2
  export { ARIAL, MONO, SANS, SERIF, TIMES, auditTextLayout, defaultMeasurer, renderSlideSvg as renderSlideToSvg, substituteFamily };
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as MONO, c as TIMES, d as substituteFamily, i as AVG_GLYPH_W_RATIO, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout, u as isCjk } from "./src-BMb2-vud.js";
1
+ import { a as MONO, c as TIMES, d as substituteFamily, i as AVG_GLYPH_W_RATIO, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout, u as isCjk } from "./src-DPHsJGe1.js";
2
2
  import { getSlideSize } from "@office-kit/pptx";
3
3
  import { Resvg } from "@resvg/resvg-js";
4
4
  import * as fontkit from "fontkit";
@@ -2628,16 +2628,20 @@ const renderValueAxis = (f, axis) => {
2628
2628
  const tickLen = AXIS_TICK_LEN;
2629
2629
  for (const t of ticks) if (axis.orientation === "vertical") {
2630
2630
  const yp = f.plotY + f.plotH - (t - axis.min) / range * f.plotH;
2631
+ const onRight = axis.side === "right";
2632
+ const edgeX = onRight ? f.plotX + f.plotW : f.plotX;
2631
2633
  if (showGrid) out.push(`<line x1="${px(f.plotX)}" y1="${px(yp)}" x2="${px(f.plotX + f.plotW)}" y2="${px(yp)}" stroke="${gridStroke}" stroke-width="0.5"/>`);
2632
2634
  if (tickMark !== "none") {
2633
- const tx1 = tickMark === "in" ? f.plotX : f.plotX - tickLen;
2634
- const tx2 = tickMark === "out" ? f.plotX : tickMark === "cross" ? f.plotX + tickLen : f.plotX + tickLen;
2635
+ const outward = onRight ? tickLen : -5;
2636
+ const inward = onRight ? -5 : tickLen;
2637
+ const tx1 = tickMark === "in" ? edgeX : edgeX + outward;
2638
+ const tx2 = tickMark === "out" ? edgeX : edgeX + inward;
2635
2639
  out.push(`<line x1="${px(tx1)}" y1="${px(yp)}" x2="${px(tx2)}" y2="${px(yp)}" stroke="${axisColor}" stroke-width="1"/>`);
2636
2640
  }
2637
- const labelX = f.plotX - 4;
2641
+ const labelX = onRight ? edgeX + 4 : edgeX - 4;
2638
2642
  const rot = axis.labelRotationDeg ?? 0;
2639
2643
  const transform = rot ? ` transform="rotate(${rot} ${px(labelX)} ${px(yp)})"` : "";
2640
- out.push(`<text x="${px(labelX)}" y="${px(yp)}" text-anchor="end" dominant-baseline="middle" ${axisTickAttrs(axis.labelStyle)}${transform}>${escapeXml(fmtTick(t))}</text>`);
2644
+ out.push(`<text x="${px(labelX)}" y="${px(yp)}" text-anchor="${onRight ? "start" : "end"}" dominant-baseline="middle" ${axisTickAttrs(axis.labelStyle)}${transform}>${escapeXml(fmtTick(t))}</text>`);
2641
2645
  } else {
2642
2646
  const xp = f.plotX + (t - axis.min) / range * f.plotW;
2643
2647
  if (showGrid) out.push(`<line x1="${px(xp)}" y1="${px(f.plotY)}" x2="${px(xp)}" y2="${px(f.plotY + f.plotH)}" stroke="${gridStroke}" stroke-width="0.5"/>`);
@@ -3614,7 +3618,72 @@ const renderChart = (shape, x, y, w, h, transform, theme) => {
3614
3618
  for (const s of spec.series) for (const v of s.values) if (v !== null && Number.isFinite(v)) finiteCount++;
3615
3619
  let plot = "";
3616
3620
  let axes = "";
3617
- if (isCartesian) {
3621
+ const isCombo = isCartesian && spec.kind !== "bar" && spec.series.some((s) => s.chartKind !== void 0 && s.chartKind !== spec.kind || s.secondaryAxis === true);
3622
+ if (isCombo) {
3623
+ const baked = spec.series.map((s, i) => ({
3624
+ ...s,
3625
+ color: s.color ?? colors[i % colors.length] ?? "#888"
3626
+ }));
3627
+ const primarySeries = baked.filter((s) => s.secondaryAxis !== true);
3628
+ const secondarySeries = baked.filter((s) => s.secondaryAxis === true);
3629
+ const primaryScale = seriesMinMax({
3630
+ ...spec,
3631
+ series: primarySeries
3632
+ });
3633
+ const { valueAxis: _primaryOnlyAxis, ...specWithoutAxis } = spec;
3634
+ const secondaryScale = secondarySeries.length > 0 ? seriesMinMax({
3635
+ ...specWithoutAxis,
3636
+ series: secondarySeries
3637
+ }) : null;
3638
+ const N = pointCount(spec);
3639
+ if (!spec.valueAxisHidden) axes = renderValueAxis(f, {
3640
+ orientation: "vertical",
3641
+ min: primaryScale.min,
3642
+ max: primaryScale.max,
3643
+ majorUnit: spec.valueAxis?.majorUnit ?? primaryScale.step,
3644
+ ...spec.valueAxis?.numberFormat !== void 0 ? { numberFormat: spec.valueAxis.numberFormat } : {},
3645
+ ...spec.valueAxisMajorGridlines !== void 0 ? { majorGridlines: spec.valueAxisMajorGridlines } : {},
3646
+ ...spec.valueAxisLabelStyle !== void 0 ? { labelStyle: spec.valueAxisLabelStyle } : {}
3647
+ });
3648
+ if (secondaryScale) axes += renderValueAxis(f, {
3649
+ orientation: "vertical",
3650
+ side: "right",
3651
+ min: secondaryScale.min,
3652
+ max: secondaryScale.max,
3653
+ majorUnit: secondaryScale.step,
3654
+ majorGridlines: false,
3655
+ ...spec.valueAxisLabelStyle !== void 0 ? { labelStyle: spec.valueAxisLabelStyle } : {}
3656
+ });
3657
+ if (N > 0 && !(spec.categoryAxisHidden || spec.categoryAxisTickLabelPos === "none")) axes += renderCategoryAxis(f, "horizontal", spec.categories, N, spec.categoryAxisTickLabelSkip ?? 1, spec.categoryAxisLabelStyle, spec.categoryAxisLabelRotationDeg, spec.categoryAxisLabelAlign, spec.categoryAxisLineColor);
3658
+ const groups = /* @__PURE__ */ new Map();
3659
+ for (const s of baked) {
3660
+ const kind = s.chartKind ?? spec.kind;
3661
+ const secondary = s.secondaryAxis === true;
3662
+ const key = `${kind}|${secondary ? "1" : "0"}`;
3663
+ const group = groups.get(key);
3664
+ if (group) group.series.push(s);
3665
+ else groups.set(key, {
3666
+ kind,
3667
+ secondary,
3668
+ series: [s]
3669
+ });
3670
+ }
3671
+ const paintOrder = (g) => (g.secondary ? 2 : 0) + (g.kind === "line" || g.kind === "area" ? 1 : 0);
3672
+ for (const group of [...groups.values()].sort((a, b) => paintOrder(a) - paintOrder(b))) {
3673
+ const scale = group.secondary && secondaryScale ? secondaryScale : primaryScale;
3674
+ const groupSpec = {
3675
+ ...spec,
3676
+ series: group.series,
3677
+ valueAxis: {
3678
+ min: scale.min,
3679
+ max: scale.max
3680
+ }
3681
+ };
3682
+ if (group.kind === "line" || group.kind === "area") plot += renderLineChart(f, groupSpec, colors, group.kind === "area");
3683
+ else plot += renderColumnChart(f, groupSpec, colors);
3684
+ }
3685
+ }
3686
+ if (!isCombo && isCartesian) {
3618
3687
  const { min, max, step } = seriesMinMax(spec);
3619
3688
  const N = pointCount(spec);
3620
3689
  const majorUnit = spec.valueAxis?.majorUnit ?? step;
@@ -3648,7 +3717,7 @@ const renderChart = (shape, x, y, w, h, transform, theme) => {
3648
3717
  const labelsHidden = spec.categoryAxisHidden || spec.categoryAxisTickLabelPos === "none";
3649
3718
  if (N > 0 && !labelsHidden) axes += renderCategoryAxis(f, spec.kind === "bar" ? "vertical" : "horizontal", spec.categories, N, spec.categoryAxisTickLabelSkip ?? 1, spec.categoryAxisLabelStyle, spec.categoryAxisLabelRotationDeg, spec.categoryAxisLabelAlign, spec.categoryAxisLineColor);
3650
3719
  }
3651
- switch (spec.kind) {
3720
+ if (!isCombo) switch (spec.kind) {
3652
3721
  case "column":
3653
3722
  case "bar":
3654
3723
  plot = spec.kind === "column" ? renderColumnChart(f, spec, colors) : renderBarChart(f, spec, colors);
@@ -4591,4 +4660,4 @@ const auditTextLayout = (pres, options = {}) => {
4591
4660
  //#endregion
4592
4661
  export { MONO as a, TIMES as c, substituteFamily as d, AVG_GLYPH_W_RATIO as i, defaultMeasurer as l, renderSlideSvg as n, SANS as o, ARIAL as r, SERIF as s, auditTextLayout as t, isCjk as u };
4593
4662
 
4594
- //# sourceMappingURL=src-BMb2-vud.js.map
4663
+ //# sourceMappingURL=src-DPHsJGe1.js.map