Adding a constant line

A constant line is simply a line we add to a graph that has a value that doesn't change. This value is typically hardcoded (or set) and is not determined by other values in the graph. For example, if we wanted to show the value of pi (3.1415927 – depending on the precision you want to show), we can use a constant line.

In this recipe, we will add constant reference lines to visualize players who, relatively, are earning less in salary but getting more in endorsements:

Adding a constant line

Getting ready

To follow this recipe, open B05527_06 – STARTER.twbx. Use the worksheet called Constant Line, and connect to the Top Athlete Salaries (Global Sport Finances) data source:

Getting ready

How to do it...

Here are the steps to create the graph:

  1. Click on the dropdown in the Marks card and change the mark to Circle.
  2. From Measures, drag Salary/Winnings $ to Columns.
  3. From Measures, drag Endorsements $ to Rows.
  4. From Dimensions, drag Sport to Color.
  5. From Dimensions, drag Athlete to Detail.
  6. On the side bar, click on the Analytics tab to activate it.
  7. Under Summarize, drag Constant Line from the Analytics tab and drop it on the SUM(Salary/Winnings $) placeholder:
    How to do it...
  8. Enter the value 20:
    How to do it...
  9. Right-click on the constant line that was added and select Edit.
  10. Set the Fill Above: color to None and the Fill Below: color to a light gray color:
    How to do it...
  11. Right-click on the constant line again and select Format.
  12. On the Format side bar, under the Reference Line Label section, select alignment. Set the Vertical alignment to Top.
  13. From the Analytics tab, drag the Constant Line again, this time placing it on SUM(Endorsements $) placeholder.
  14. Set the constant value to 40.
  15. Right-click on the new constant line and select Edit.
  16. Under Formatting, set the Fill Above color to a light gray color and the Fill Below color to None.
  17. Right-click on the constant line again and select Format.
  18. On the Format side bar, under the Reference Line Label section, select Alignment. Set the Vertical alignment to Bottom.

How it works...

A constant line is simply a reference line with a value that does not change. Reference lines are great at showing where values in a view are relative to that point of reference. In Tableau, adding a constant line simply requires dragging the Constant Line option from the Analytics pane onto your view. If your view has groups, you will be presented the Pane and Cell options as scope for the reference line, in addition to Table.

To edit a constant line, you can right-click on the constant line and choose Edit. Alternatively, you can right-click on the axis the reference line refers to, and choose Edit Reference Line:

How it works...

See also

  • Please refer to the Adding a reference line recipe in this chapter
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.210.102