owid / owid-grapher

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

Enable server-side csv download for all charts #3648

Open danyx23 opened 4 months ago

danyx23 commented 4 months ago

Context

Our mission is to make the data we need to make progress on the world’s biggest problems accessible. For most people, accessibility means working with data tools – but getting data from our website to those tools is currently quite annoying.

It’s currently hard to quickly reuse data from a chart in an analytics environment. This is because the current CSV download is created in the browser, making it impossible to offer a single-line code snippet for analytics environments.

Solution

We want to create the ability to download the data for a chart. Technically, this will re-use the infrastructure that we created to render dynamic thumbnails to render a CSV.

The URL scheme should be https://ourworldindata.org/grapher/life-expectancy.csv - for the data https://ourworldindata.org/grapher/life-expectancy.metadata.json - for the metadata https://ourworldindata.org/grapher/life-expectancy.zip - for a zip file of csv, metadata.json and a README.md

and maybe https://ourworldindata.org/grapher/life-expectancy.xlsx - for an excel file with 3 sheets, one with description text, one with metadata and one with the data

Additionally, we want to offer two download options:

These two options should be presented in the download tab as a toggle UI element. In the CF function that serves this this should be a query param - the default should probably be the full data.

We also want to have two options for the column names:

In the download tab, in the data section, we want to show the “data source” line from the grapher screen so that people know who created the data and also add something like “learn more about this data” that links you to the sources tab so you can see the citation info etc

The download button should download data form the csv url as well instead of creating the file client side.

Under the download button we should add code snippets for how to get this data into the following tools:

The URL to fetch the data in the code snippets should reflect the choice the user made in terms of full data download or only the data relevant for the current view.

Must have

Can have

Checklist before publishing