owid / owid-grapher

A platform for creating interactive data visualizations
https://ourworldindata.org
MIT License
1.36k stars 228 forks source link

Stacked area chart offers entities for selection that have no data #3498

Open marcelgerber opened 3 months ago

marcelgerber commented 3 months ago

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:

  1. Go to https://ourworldindata.org/grapher/energy-consumption-by-source-and-country
  2. Select "Low-income countries"
  3. You'll see "No matching data"

Screenshots

CleanShot 2024-04-16 at 09 50 50

Additional context

tableForSelection should filter out entities that have no data for any entity.

marcelgerber commented 3 months ago

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.