owid-grapher
owid-grapher copied to clipboard
Stacked area chart offers entities for selection that have no data
Description
We now have MissingDataStrategy
, which can remove entities from selection if some series are missing.
However, we still have cases where entities are being shown that have no data at all.
Steps to reproduce
Steps to reproduce the behavior:
- Go to https://ourworldindata.org/grapher/energy-consumption-by-source-and-country
- Select "Low-income countries"
- You'll see "No matching data"
Screenshots
Additional context
tableForSelection
should filter out entities that have no data for any entity.
Ahh, this is actually quite interesting.
If relative mode is disabled, there is actually some data available for "Low-income countries" - albeit not very useful (it's just "Nuclear: 0 kWh").
But then in relative mode, because the Total is 0, toPercentageFromEachColumnForEachEntityAndTime
will set all columns to a DivideByZeroError
, making it so there is no data that can be plotted.