gitbrent / PptxGenJS

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

Charts with a single category axis discard values of zero #1331

Open MariusOpeepl opened 2 months ago

MariusOpeepl commented 2 months ago

Change Summary

Values of zero are now inserted in excel data cells for charts with a single category axis.

Change Description

The existing logic for inserting data values into Excel cells, simplified as

<c r="A1">
  <v>${dataValue || ''}</v>
</c>

would not add values of 0 to the Excel table, causing cutoff points for line charts that had this value in them. This was changed to only exclude nullish values:

<c r="A1">
  <v>${dataValue ?? ''}</v>
</c>

Change Type

Motivation and Context

Charts with explicitly one category axis (!IS_MULTI_CAT_AXES), particularly line charts, would get split in two at plot points with values of zero, because its respective Excel cell would have no value inside it, instead of the expected zero number. This would only happen upon opening the embedded Excel file, as the XML of the pptx chart was written correctly.

Checklist before requesting a review