gitbrent / PptxGenJS

Create PowerPoint presentations with a powerful, concise JavaScript API.
https://gitbrent.github.io/PptxGenJS/
MIT License
2.84k stars 625 forks source link

Fix category display in Google Slides #1273

Open christiankiely opened 1 year ago

christiankiely commented 1 year ago

This fixes an issue when importing generated PPTX files with charts into Google Slides.

It appears Google Slides' importer does not like the use of multiLvlStrRef, and displays categories as simple numbers.


For example, using this code to generate a pptx file:

  const pres = new pptxgen();
  const slide = pres.addSlide();
  slide.addChart(
    pres.ChartType.bar,
    [
      {
        name: "Categories",
        labels: ["Category A", "Category B", "Category C"],
        values: [500, 200, 350],
      },
    ],
    {
      x: 1,
      y: 1,
      w: 5,
      h: 3,
    }
  );

Appears like this in PowerPoint vs Google Slides:

Microsoft PowerPoint Google Slides
CleanShot 2023-07-10 at 16 20 53@2x CleanShot 2023-07-10 at 16 22 33@2x

Using strRef instead of multiLvlStrRef when there is only one set of labels appears to fix this issue.