How to create a live-updating table with mini-columns, sparklines and heatmaps
In Datawrapper tables, you can add tiny columns, lines (sparklines), and even turn columns into heatmaps. But for those of you who've used these features together with live-updating data may have run into a particular problem - new columns from updated data are added as separate columns and are NOT part of the tiny-columns, sparklines, and heatmaps:
You may have worked around this by manually ungrouping the columns, and regrouping them again to include the additional columns that have been updated in the dataset, then hitting republish. This misses the entire point of having a live-updating table - which is that you don't have to republish the chart every time the data is updated.
Well, we're here to show you a slightly better workaround:
Here you have a dataset that updates daily, a 7-day average number of COVID confirmed cases in selected countries, with data until 2021-02-24. What you want to do is to create a sparkline that automatically updates every day.
In our live-updating CSV, we'll create extra date columns for dates we want to eventually add data to. Then, fill them with any number (e.g. zeros) like in the image below:
These columns will act as placeholders for those upcoming dates you'll be filling with real data and add that information to the metadata of the chart. The reason why you have to fill them up with numbers is so that they are registered as "Number" columns (and not Text or Date columns) which will allow Datawrapper to turn them into sparklines (or tiny-columns /heatmaps).
If you're going to be updating them irregularly and do not know which dates to assign to columns, you can either replace those future dates with ordinal numbers or remove this row entirely. If you do remove the first row (header), remember to un-check "First row as labels" option in Step 2:
Now, go back into Datawrapper Step 3: Visualize > Customize columns and convert the data points for all these dates into sparklines:
Now, the sparklines will show data until 2021-03-06 (which is in the future from the date this article is being written) and will show zeros that you've entered, instead of real values. You'll fix this in a minute so don't worry:
Go back to the CSV and delete numbers from all those future date columns:
And voila, our sparkline will have data until 2021-02-24 as it should but will update automatically until 2021-03-06 with real data. This means that updated data in the CSV will be automatically implemented as part of the sparkline without us having to manually do so every day.Make sure that when you're updating the CSV data every day, you use the same column header name you've used when creating the placeholders. In this case, the dates. They should be exactly the same. This is why you'd have to have unique column header names when you're first creating the placeholder columns at the beginning. (Be careful not to include the same header name in a dataset.)
That's it! This little workaround can be used for tiny columns and heatmaps too. If you still have questions, reach out to us at email@example.com.