Create Filtered Line Chart with Tableau Public
One of the advantages of interactive visualizations over static (including printed) is the ability to store a lot more data, and show it only when required. In other words, an interactive visualization can be made into a data-exploration tool that won’t overwhelm the viewer at first sight, but will allow the viewer to “dig” and find specific data points and patterns.
In this tutorial, we will build an interactive filtered line chart with Tableau Public like is shown in Figure 5.40. The filter will be a collection of checkboxes that allow to add/remove lines from the chart. Viewers can hover over each line to identify the school name and data attached to it.
We will use % Population with Internet Access by the World Bank. You can download the dataset here.
We assume that you have Tableau installed. If not, see the previous tutorial, Create XY Scatter Chart with Tableau Public.
Connect Text File and Build a Line Chart
Open Tableau Public, and under Connect menu, choose Text file. Tableau may or may not have imported the table automatically. If you see the preview of the table with three columns: Country Name, Year, and Percent Internet Users, you can proceed to Sheet 1.
If not, drag and drop the file (under Files section in the left) to the Drag tables here area. Once you see the preview, go to Sheet 1.
Your variables will be listed under Tables in the left-hand side. The original variables are displayed in normal font, the generated variables will be shown in italics (such as Latitude and Longitude that Tableau guessed from the country names).
To build a line chart,
- Drag Year variable to Columns.
- Drag Percent Internet Users variable to Rows. The variable will change to
SUM(Percent Internet Users). You should see a single line chart that sums up percentages for each year. That is completely incorrect, so let’s fix it.
- In order to “break” aggregation, drag and drop Country Name to the Color box of the Marks card. Tableau will warn you that the recommended number of colors should not exceed 20. Since we will be adding filtering, we don’t care about it much. So go ahead and press Add all members button.
- Now you should see an absolute spaghetti plate of lines and colors. To add filtering, drag Country Name to the Filters card. In the Filter window, make sure all countries are checked, and click OK.
- Right-click on Country Name pill in Filters card, and check Show Filter (see Figure 5.41)
- You will see a list of options with all checkboxes on have appeared to the right of the visualization. Click (All) to add/remove all options, and add a few of your favorite countries to see how the interactive filtering works.
Congratulations on creating interactive charts that pull readers deeper into your story, and encourage them to explore the underlying data! As you continue to create more, always match the chart type to your data format and the story you wish to emphasize. Also, design your charts based on the principles and aesthetic guidelines in this chapter. While anyone can click a few buttons to quickly create a chart nowadays, your audiences will greatly appreciate well-designed charts that thoughtfully call their attention to meaningful patterns in the data.
The next chapter on Map Your Data follows a similar format to introduce different map types, design principles, and hands-on tutorials to create interactive visualizations with spatial data. Later you’ll learn how to embed interactive charts on your web in chapter 7.
To learn about more powerful charting tools, see Chart.js and Highcharts templates in chapter 9, which give you ever more control over how your design and display your data, but also require learning how to edit and host code templates with GitHub in chapter 8.