How to work with dates in line charts, area charts, and scatter plots
One of the most common ways to visualize data is over time. This article will review the different ways to manipulate how dates show up on your chart, specifically using the tick format, custom ticks, and custom range fields:
Here are the two main takeaways of this article:
1) You can visualize dates in many different ways on your chart even though you uploaded it in only one format. Say you uploaded your date column in the format January 1st, 2000. It is easy to change it to other formats such as 1/1/2000, Jan '20, or even Q1 2000.
2) 'Tick format' controls how the date appears on your chart and 'custom ticks' controls which ticks appear on your chart. If you don't use the custom ticks field, ticks will default to the earliest unit of the time period (e.g. the 1st of the month, January, or Quarter 1).
For this article, we'll use the example dataset "How the iPhone Shaped Apple," which is available in step 1: Upload Data in the drop-down menu Sample data. (Follow along by creating a new chart and using the sample data!)
You'll notice when uploading this dataset that the date format is populated as Q3 2000. Next, in step 2: Check and Describe, it appears in the table as 2000 Q3.
If you upload your date column in the correct format, it will appear in step 2: Check and Describe as green text in the column. If it is not green, it is not being recognized as a date, and you need to reformat your data.
👉 For an in-depth table of accepted date formats, see this article.
When you then select Line Chart in step 3: Visualize and get to the Refine tab, the tick format has defaulted to 2018, 2019. So where did the quarters go?
Tick Format & Custom Date Formatting
Tick format controls the way your date appears on your chart.
As you can see in the GIF above, when I changed the tick format from "2018, 2019" to "2019 Q1, 2019 Q2," the horizontal axis labels changed. That's because line charts always default to "2018,2019,"; meaning, the date will appear only as the year.
By changing the tick format, you can change how the date appears on the horizontal axis. You can select date formats that include date types you didn't upload. In our example, even though we only uploaded quarter and year, Datawrapper can extrapolate the position of months.
Tick format: 2019, Q2,Q3 / 2019, Feb, March / April, 2, 3
Most of the tick formats are relatively straightforward, but there are a few worth explaining.
The formats "2019, Q2,Q3", "2019, Feb, March", and "April, 2, 3" are not inherently intuitive. These formats will show the first item on the horizontal axis (so 2019 or April in our examples), and the remaining elements will be seen in the hover tooltip and read as '2019 Q2' or '2019 Feb' or 'April 2'.
These options are ideal if you want the horizontal axis to be more general/less cluttered and the hover labels to be more informative.
Tick format: (custom)
In addition to the provided tick formats, there is also a custom option at the bottom of the drop-down menu. By selecting custom, a text field will appear in which you can write the format you'd like the date to appear.
👉 For an in-depth table of acceptable custom date formats, see this article.
See the GIF below for examples of how letter combinations create different date formats. Look at how the horizontal axis changes:
As you can see in the GIF, the letter tokens represent different date formats.
Note that the custom format "YYYY|Q" (with a pipe), does the same thing as the "2019, Q1,Q2" format discussed earlier.
Custom ticks lets you control which tick marks appear on the axis. If you use the custom ticks field, your chart's horizontal axis will only show what is in the text field.
An important limitation to be aware of is the space available on your horizontal axis for labels. If you try to squeeze in too many tick marks, Datawrapper will ignore some of them because they do no fit (e.g. on mobile screens). Readjust your custom ticks to be spaced far enough apart so that they show up on your chart.
In the following GIF, we'll show important dates such as the iPod's release, the iPhone's release, when the iPhone overtook the iPod, and the iPod's deprecation using custom ticks:
One thing to notice in the GIF is that you do not have to use the exact same format as the tick format you are using. Even though I wrote Nov 2010 in the field, it is still displayed as November 2010 on the chart as specified by the tick format field. You do, however, have to used recognized date formats in this field or else it will not be added to the chart.
The custom range should be used for two reasons:
1) Invert the axis. If you put a later date in the left box and earlier date in the right box, the time series will change direction.
2) Extend your timeline beyond the dates entered. It is not possible to truncate your time series using this feature. Datawrapper will always show the whole time range that it can find in your data. Even if you choose the time range 2013 to 2016, our tool will still show you the data (and therefore the time range) between 2000 and 2016. If you want to limit the time range, you need to delete data, e.g. in step 1: Upload data.