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:
Before we get into the weeds, these 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. Don't bang your head against the wall formatting dates in Excel.
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 the Upload Data stage in the drop-down menu. (Follow along by creating a new chart and using the sample data!)
First, you'll notice when uploading this dataset, the date format is populated as Q3 2000. Next, on the Check and Describe step, it appears in the table as 2000 Q3.
If you upload your date column in the correct format, it will appear in the Check and Describe step 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.
Then when you 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 date/tick labels on the horizontal axis appear on your chart. As you can see in the video, when I changed the tick format from "2018, 2019" to "2019 Q1, 2019 Q2," the horizontal axis labels changed. Tick format controls the way your date appears on your chart. 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 video below for examples of how letter combinations create different date formats. Look at how the horizontal axis changes:
As you can see in the video, the letter tokens represent different date formats. A custom tick format that may not be obvious is the last one in the above video, which uses the vertical bar (aka pipe). The custom format "YYYY|Q", 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.
As mentioned in the beginning of the article, if you leave the custom ticks field blank, ticks will default to the earliest unit of the time period (e.g. the 1st of the month, January, or Quarter 1). If you are working with just years, this isn't a big deal. But say you want to show 6 month intervals or specific dates, then you'll want to use custom ticks.
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 video, 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 video 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.