Skip to content

Conversation

@Tom-Magill
Copy link
Contributor

@Tom-Magill Tom-Magill commented Dec 16, 2025

Description

Currently, passing null in a chart series converts it to 0 or an empty string, which plots as zero.

This PR allows null values to be charted as missing or empty data. Converting them to 0 will impact graphs such as the Line graph and others that need to display each data point's value (or lack thereof). It updates the Writer to respect null values in the data series.

In addition, this PR adds the setDisplayBlanksAs option to the Chart Style, allowing users to choose how to display null values. These options are 'gap' (break the line chart), 'span' (connect lines over the null values to show trends), or 'zero' (display nulls as zero, as it the current default).

I considered setting 'zero' as the default as this is the current behaviour, but can't think of a use-case where null should be converted to 0. Happy to be corrected on this!

Fixes # (issue)

When you provide a null value in the chart series, it was converted to 0 in the chart.
This will now respect this value and omit the data point on any graph. This is especially useful for any time series data in line graphs, where there may be gaps in the data. This enables you to set how you'd like these to be plotted.

Checklist:

  • My CI is 🟢
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes
  • I have updated the changelog

@Tom-Magill Tom-Magill marked this pull request as draft December 16, 2025 17:51
@Tom-Magill Tom-Magill marked this pull request as ready for review December 16, 2025 18:02
@coveralls
Copy link

Coverage Status

coverage: 96.76% (+0.003%) from 96.757%
when pulling 3694d87 on Tom-Magill:feature/chart-null-handling
into 0ab0b49 on PHPOffice:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants