owid / owid-grapher

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

We need a "Missing data strategy" in stacked discrete bar charts #2860

Open pabloarosado opened 8 months ago

pabloarosado commented 8 months ago

Core problem

We need to handle missing data in stacked discrete bar charts. Currently, the default behaviour is to treat missing data as zeros, but this causes lots of unacceptable chart views.

For example, Per capita energy from fossil fuels, nuclear and renewables chart shows that Norway and Sweden were 100% renewable in 1965. This happens simply because there is no data for fossil fuels until several years later. per-capita-energy-source-stacked

Proposed solution

Context

For more context and several examples of unacceptable chart views: see https://github.com/owid/owid-issues/issues/1257

danyx23 commented 5 months ago

@pabloarosado could you outline a bit more what you mean with missing data strategy? What should be the conditions to hide which kinds of data?

pabloarosado commented 5 months ago

Hi @danyx23, what I meant is that, while for stacked area charts we have a missing data strategy dropdown menu (e.g. this chart) Screenshot 2024-01-26 at 10 33 16 for stacked discrete bar charts (e.g. this chart) we don't have that menu.

Currently, in stacked discrete bar charts, nans are treated like zeros (which would be the expected behavior if you chose "Show entities with missing data"). However, you may not want that and would prefer to hide entities if they have nans.