How to create a custom color key

This article explains how to create a custom color key in any chart, map or table type with HTML. To learn how to create a custom color key in Choropleth maps without code, visit this article.

In Datawrapper, you can use HTML to add a custom color key to any chart, your tables or your maps. Here we explain three options, but you can style them as you like.

Color key with rectangles

The first option is to create a thick border-right with a HTML <b> tag. Repeat the following line with the right values and colors in your Descripton field in the Annotate step:

<b style="border-right:18px solid #40B1C3;"></b>&nbsp;50 to 99&nbsp;

&nbsp; is a whitespace character to create some distance to the next element in the color key. 

Use the <br> HTML line break tag to create a line break before your color key:

Color key with circles

Another option is to use Unicode symbols like this circle ⬤ and color it according to your data.

<b style="color:#40B1C3; vertical-align:text-top;">⬤</b>&nbsp;50 to 99&nbsp;

Color key as text background

In this guest post on our blog, Christoph Wolf from German news outlet n-tv explains how they used HTML color keys in tables with a background color for text:

<b style="background:#0b7432; color:white; padding:1px 4px">Grüne/EFAb><br>
<b style="background:#c31618; color:white; padding:1px 4px">S&Db><br>
<b style="background:#0099ff; color:white; padding:1px 4px">Renew Europeb><br>
<b style="background:#2c4b8e; color:white; padding:1px 4px">EVPb><br>

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us