How to combine line and bar charts in Datawrapper
👉 This tutorial assumes you already know a little bit about creating line charts in Datawrapper. If not, we suggest you read the following articles first: " How to create a line chart", " Customizing your line chart".
In this tutorial, we'll explain, step by step, how to create a chart that combines lines, columns, and dots. You'll be able to do so with the line chart as the chart type. We'll take the following chart as an example:
This chart shows the 7-day rolling average of COVID-19 cases in Berlin which you can read more about in this Weekly Chart blog post "The COVID-19 chart I wish I didn’t have to make". (Hover over the chart and click on "Edit this chart" in the top right corner to duplicate the chart into your own chart editor.)
While the 7-day moving average (green line) and the Loess trend (dashed line) are shown in curved lines, COVID-19 cases per day (light green bars) and deaths per day (purple) are both shown in bars.
These bars are created by the custom area fill feature. Here is how you can create them.
To create a bar chart in this particular COVID-19 chart, you need to fill the area between the x-axis and the line showing the daily case counts.
You can plot the x-axis (y=0) by creating a column in your dataset with zeros as the values. In this case, we've called the column "baseline" in step 1.
If you're not familiar with how to upload your data, read "How to upload data to Datawrapper".
Check that the column types are set to dates and numbers in step 2.
In step 3: Visualize, choose "Lines" as your chart type. This should give you a line chart that looks like this.
Let's start customizing the lines.
Under the Refine tab, go to the panel that says "Customize lines":
Right now, Datawrapper shows us all five columns as lines. But we only want to show the " 7-day average" and the "Loess prediction" as lines and the rest as columns. Let's start by customizing the two lines you want to show.
First, you can give some specific colors to the two lines you want to show. You can do this by clicking on the button " customize colors...":
Then for those you don't want to appear as lines but as bars - "Cases", "Deaths" - you can make them transparent by adding two zeros '00' at the end of its color hex code:
The last two digits of the hex code represent the alpha transparency. If you put 50, it sets the transparency to 50%. If you put 00, it makes it completely transparent, no matter what color it is. Making it transparent will not show the line, but will still show tooltips when you hover over the bars:
Now, the baseline. We don't want baseline appearing as lines or in the tooltips at all. In order to stop the baseline from displaying altogether, we can set the Line width to 0px:
You can change the style of the lines too. Let's change the " Loess prediction" to a dashed line. Do so by clicking on the line icons marked inside the box below.
We also want to show the lines as a curved interpolation. You can select this with the dropdown menu:
Once that's done, your chart should look like this:
Now, it's time for the area fills. Create an area fill between the baseline and the two lines "Cases" and "Deaths", give them each a color, and set an interpolation by clicking on the interpolation icon.
And voila, you've now created a line chart with columns!
As you can see, in the chart above we added some annotations to explain it. To learn how to create them yourself, visit the academy article " How to create text annotations".
How about combining a line chart with dots?
Here is another example of a chart showing a rolling average of daily COVID-19 cases, but for the US. This is a combination of a line and dots:
To create the chart above, go to step 3: Visualize.
In the Customize lines panel, set the "daily confirmed" and "base" line to 0px:
Then in the Customize symbols panel, select Line symbols. Choose " multiple" as the shape.
Click on the little icon next to "daily confirmed" to choose circle as the symbol shape, and select "every point". This will allow you to plot the values not as lines but as dots like on a scatterplot.
In this article, you learned how to bring columns and dots into your line charts. For more examples of line charts, you can create using Datawrapper, visit " Examples of Datawrapper line charts".