tb11_Lollipop_Waterfall_Dumbbell_symbol_Marimekko_Spark_Step_Slope_SheetSelection_定义领地_背景spatial双map

     With a solid understanding of the fundamental principles, it is possible to push the limits with Tableau. In addition to exploring, discovering, analyzing, and communicating data, members of the Tableau community have used the software to create and do amazing things, such as simulate an enigma[ɪˈnɪɡmə] machine恩尼格玛密码机, play Tic-Tac-Toe or Battleship, generate fractals with only two records of data, and much more! You shouldn't feel pressure in a business setting to create anything so complex, but it is always good to know that Tableau really is a blank canvas. The only limits are your creativity and imagination.

     In this chapter, we'll take a look at some advanced techniques in a practical context. You'll learn things such as creating advanced visualizations, dynamically swapping views on a dashboard, using custom images, and advanced geographic visualizations. The goal of this chapter is not to provide a comprehensive list of every possible technique. Instead, we'll look at a few varied examples that demonstrate some possibilities. Many of the examples are designed to stretch your knowledge and challenge you.

We'll take a look at the following advanced techniques in this chapter:

  • Advanced visualizations
  • Sheet swapping and dynamic dashboards
  • Advanced mapping techniques
  • Using background images
  • Animation
  • Transparency

Advanced visualizations

     We took a look in Chapter 3, https://blog.csdn.net/Linli522362242/article/details/123116143, at variations of some fundamental visualizations, such as bar charts, time series, distributions, and scatterplots. Now, we'll consider some non-standard visualization types. These are only examples of Tableau's amazing flexibility and are meant to inspire you to think through new ways of seeing, understanding, and communicating your data. These are not designed as complex charts for the sake of complexity, but rather to spark creativity and interest to effectively communicate the data. 

     Each of the following visualizations are created using the supplied Superstore data. Instead of providing step-by-step instructions, we'll point out specific advanced techniques used to create each chart type. The goal is not to memorize steps but to understand how to creatively leverage Tableau's features.

     You can find completed examples in the Chapter 11 Complete workbook, or test your growing Tableau skills by building everything from scratch using the Chapter 11 Starter workbook.

Slope Charts

     A Slope Chart shows a change of values from one period or status to another. For example, here is a Slope Chart demonstrating the change in sales rank for each state in the South region from 2016 to 2017:

     Here are some features and techniques used to create the preceding Slope Chart:

  • The table calculation Rank(Sum(Sales) ) is computed by (addressed by) State,OR meaning that each state is ranked within the partition of a single Year. 
  • Grid Lines and Zero Lines for Rows have been set to None.
    • Right click on view.
    • Select Format.
    • Go to Format Lines.
    • Select None for both Grid Lines and Zero Lines.
  • The axis has been reversed (right-click the axis and select Edit, then check the option to reverse). This allows rank #1 to appear at the top and lower ranks to appear in descending order.
  • The axis has been hidden (right-click the axis and uncheck Show Header).
    ==>
  • Labels have been edited (by clicking on Label) to show on both ends of the line, to center vertically, and to position the rank number next to the state name.
  • The Year column headers have been moved from the bottom of the view to the top (from the top menu, select Analysis | TableLayout | Advanced and uncheck the option to show the innermost level at the bottom).
    and right click Order Date Field within the view to select Hide Field Labels for Columns
  • A data highlighter has been added (using the dropdown on the State field in the view, select Show Highlighter) to give the end user the ability to highlight one or more states.
  • Edit Title 
     

Warnings or important notes

     Data highlighters give the user the ability to highlight marks in a view by selecting values from the drop-down list or by typing (any match on any part of a value will highlight the mark; so, for example, typing Carolina would highlight North Carolina and South Carolina in the preceding view). Data highlighters can be shown for any field you use as discrete (blue) in the view and will function across multiple views in a dashboard as long as that same field is used in those views

     Slope Charts can use absolute values (for example, the actual values of Sales ) or relative values (for example, the rank of Sales , as shown in this example). If you were to show more than 2 years to observe the change in rankings over multiple periods of time, the resulting visualization might be called a Bump Chart凹凸图, like this:

Lollipop Charts棒棒糖图表

     A Lollipop[ˈlɑːlipɑːp]  Chart is very similar to a bar chart, but typically uses thinner lines ending in a circle. This allows for some stylistic interest as well as a place to show values or other labels. Here, for example, is a Lollipop Chart for Sales of Categories in the Technology department:

     Features and techniques used to create this chart include the following:

  • A synchronized dual axis for SUM(Sales) with one mark type set to Bar and the other mark type set to Circle.
           
  • Axes have been hidden (right-click and uncheck Show Header).
  • The size of the bars and circles have been adjusted (click Size on the Marks card).
    The bars have been set to be very thin,
    while the circles are large enough to accommodate the label.
  • Sales have been added to the label of the circle(put the Bold Text label in the circle) and formatted using a custom currency.
  • Grid lines have been hidden (use the formatting options opened from the menu Format | Lines). ==>
  • Hide field Label for row or unchecked show field label for row

You might experiment with some variations, such as the following: 

  • Swapping Rows and Columns to flip the orientation
  • Sorting Categories
  • Using color or highlighting to call out certain values

Waterfall Charts瀑布图

     The trick with the waterfall chart is to create a calculated field that is the negative of the Measure you are charting. This will allow you to create columns that stretch from each current horizontal line down to the previous level.

     A Waterfall Chart is useful when you want to show how parts successively build up to a whole. In the following screenshot, for example, is a Waterfall Chart showing how profit builds up to a grand total across Departments and Categories of products. Sometimes profit is negative, so at that point the Waterfall Chart takes a dip, while positive values build up toward the total:

Here are the features and techniques used to build the chart: 

  • The SUM(Profit) field on Rows is a Running Total(accumulationtable calculation (created using a Quick Table Calculation from the drop-down menu) and is computed across the table.
  • Row Grand Totals have been added to the view (dragged and dropped from the Analytics pane).
  • The mark type is set to Gantt Bar and an ad hoc calculation is used with code:
    -1*SUM([Profit])
    ==>. This allows the Gantt Bars to be drawn back down (or up for negative profit) toward the end of the previous mark.
    ==>==>bar (0, 0-72,506(Profit)=-72,506)       ==>bar ( -72,506, -72,506-7,714(Profit)=-80,220)
    ==>bar height ( -80,220, -80,220+92,216(Profit)=11,996)
  • Category has been sorted Ascending by Sum of Profit so that the Waterfall Chart builds slowly (or negatively) at the left of each Department . You might want to experiment with the sort options to discover the impact on the presentation.

 

Step Lines and Jump Lines

     Step Lines are often useful when you want to show discrete change over time, as opposed to a standard line chart where angled lines might imply a gradual change. For example, the number of generators running at any given time is a discrete whole number and you may wish to emphasize this fact with a Step Lines chart.

     In the following example, we've taken the build-up of profit that was previously demonstrated with a Waterfall Chart and used Step Lines to show each successive step of profit:

     Overall, a Step Lines chart is very easy to create. Simply click the Path shelf and select the Step Lines from Line Type, as shown in the previous screenshot. Note that you have options for linear and Jump Lines as well.

     Linear is the default: angled lines that emphasize movement between values. Jump Lines are useful when you want to show values that indicate a certain state that may exist for a given period of time before jumping to another state. For example, you might wish to show

  • how many products are on the showroom floor over time,
  • or how many patient beds are filled day-to-day

Spark Lines

     Spark Lines refers to a visualization that uses multiple small line graphs that are designed to be read and compared quickly. The goal of Spark Lines is to give a visualization that can be understood at a glance. You aren't trying to communicate exact values, but rather give the audience the ability to quickly understand trends, movements, and patterns.

     Among various uses of this type of visualization, you may have seen Spark Lines used in financial publications to compare movement of stock prices. Recall, that in Chapter 1, https://blog.csdn.net/Linli522362242/article/details/122932763, we considered the initial start of a Spark Lines visualization as we looked at iterations of line charts. Here is a far more developed example:

     This chart was built using the following features and techniques:

  • Start with a simple view of the Sum(Sales) by Quarter of Order Date (as a date value) with Category on Rows.
  • 2 calculated fields have been created to show the minimum and maximum quarterly sales values for each category.
    • Min Sales has the code
      WINDOW_MIN(SUM([Sales]))
    • and Max Sales has the code
      WINDOW_MAX(SUM([Sales]))
    • Both have been added to Rows as discrete (blue) fields.
  • The calculation Last Sales with the code
    IF LAST() == 0
    THEN SUM([Sales])
    END
    has been placed on Rows and uses a synchronized dual axis with a circle mark type to emphasize the final value of sales for each timeline.
  • The axis for SUM(Sales) been edited to have Independent axis ranges for each row or column and then the axes have been hidden(unchecked Show Header). This allows the line movement to be emphasized. Remember: the goal is not to show the exact values, but to allow your audience to see the patterns and movement.
  • Grid lines and Zero lines have been hidden for Rows.
  • The view has been resized (horizontally compressed and set to Fit Height). This allows the Spark Lines to fit into a small space, facilitating[fəˈsɪlɪteɪtɪŋ]使便利,使更容易 quick understanding of patterns and movement.

Dumbbell Charts哑铃图

     A Dumbbell[ˈdʌmbel]哑铃 Chart is a variation of the circle plot that

  • compares two values for each slice of data,
  • emphasizing the distance between the two values

     Here for example, is a chart showing the Difference in Profit between East and West regions for each Category of products:

This chart was built using the following features and techniques:

  • A synchronized dual axis of SUM(Profit) has been used with one set to mark the type of Circle and the other set to Line.
  • Region has been placed on the Path shelf for the line to tell Tableau to draw a line between the two Regions
    • Warnings or important notes

           The Path shelf is available for Line and Polygon mark types. When you place a field on the Path shelf, it tells Tableau the order to connect the points (following the sort order of the field placed on Path). Paths are often used with geographic visualizations to connect origins and destinations on routes, but can be used with other visualization types.
  • Region is placed on Color for the circle mark type.

Unit chart/symbol charts单位图/符号图

     A unit chart can be used to show individual items, often using shapes or symbols to represent each individual. These charts can elicit[ɪˈlɪsɪt]引出,使(潜在的东西)显现 a powerful emotional response, because the representations of the data are less abstract and more easily identified as something real. For example, here is a chart showing how many customers had late shipments for each Region:

The view was created with the following techniques:

  • The view is filtered where Late Shipping is True. Late Shipping is a calculated field that determines if it took more than 14 days to ship and order. The code is as follows:
    DATEDIFF('day', [Order Date],[Ship Date]) > 14

  • Region has been sorted descending by the distinct count of Customer ID

  • Customer ID has been placed on Detail so that there is a mark for each distinct customer. 
  • The mark type has been changed to Shape and the shape has been changed to the included person shape in the Gender shape palette. To change shapes, click the Shape shelf and select the desired shape(s), as shown in the following screenshot:

     The preceding unit chart might elicit more of a response from regional managers than a standard bar chart when they are gently[ˈdʒentli]温柔地 reminded that poor customer service impacts real people. Granted, the shapes are still abstract, but more closely represent an actual person. You could also consider labeling the mark with the customer name or using other techniques to further engage your audience

TIP

     Remember that normally in Tableau, a mark is drawn for each distinct intersection of dimensional values. So it is rather difficult to draw, for example, 10 individual shapes for a single row of data that simply contains the value 10 for a field. This means that you will need to consider the shape of your data and include enough rows to draw the units you wish to represent

     Concrete shapes, in any type of visualization, can also dramatically reduce the amount of time it takes to comprehend the data. Contrast the amount of effort required to identify the departments in these two scatterplots:

Here's how to add image files to your repository:

     Shapes are images located in the My Tableau Repository\Shapes directory. You can include your own custom shapes in subfolders of that directory.

Save you images in a folder named Product within the Repository Location Folder (On Tableau Desktop ==> File ==> Repository Location ==> C:\Users\LlQ\Documents\My Tableau Repository\Shapes )

     Once you know the meaning of a shape, you no longer have to reference a legend.

     Placing a discrete field on the Shape shelf allows you to assign shapes to individual values of the field. 

Marimekko Charts

     A Marimekko Chart (sometimes also called a Mekko Chart) is similar to stacked bar chart, but additionally use varying widths of the bars to communicate additional information about the data. Here, for example, is a Marimekko Chart showing the breakdown of sales by region and department.

     Creating Marimekko Charts in Tableau leverages the ability to fix the width of bars according to the axis' units.

  • The width of the bars communicates the total sales for the Region
    • Sales for Region: the calculated field Sales for Region calculates the x axis location for the right-side position of each bar.
      // the view level of detail : Region/Department
      // in other word, Computational pointers are moved department by department 
      // if this is the first bar segment
      IF FIRST() == 0
          //the sum of Sales for the entire region instead of Department
          THEN MIN( {EXCLUDE [Department] : SUM([Sales]) } )
      // MIN([Region]) : Region name
      // LOOKUP( MIN([Region]), 0 ) : Current Region name OR NULL
      // LOOKUP( MIN([Region]), -1 ) : previous Region name OR NULL
      // LOOKUP( MIN([Region]), 1 ) : next Region name OR NULL
      ELSEIF LOOKUP( MIN([Region]), -1 ) <> MIN( [Region] )
      // When the calculation moves to a new Region
      // need to add the previous Region total to the new Region total
          THEN PREVIOUS_VALUE(0) + MIN( {EXCLUDE [Department] : SUM([Sales]) } )
      ELSE
      // the calculation is for another Department in the same Region
          PREVIOUS_VALUE(0)
      END
    • Compute Using(addressing) | Region
  • while the height of each segment gives you the percentage of sales for the Department within the Region: and 
    • SUM(Sales) has been placed on Rows
    • Quick Table Calculation | Percent of Total
    • Compute Using(addressing) | Department
    • so that we get the percentage of sales for each Department within the partition of the Region.
  • The mark type has been specifically set to Bar.
  • Region and Department have been placed on Color and Detail, respectively. They are the only dimensions in the view, so they define the view's level of detail.
  • Various fields have been copied to the Label shelf so that each bar segment more clearly communicates meaning to the viewer.
    Tip
         To add labels to each Region column, you might consider creating a second view(https://blog.csdn.net/Linli522362242/article/details/123366816) and placing both on a dashboard. Alternately, you might use annotations.
  • The field on Size is an ad hoc level of detail calculation with the code
    {EXCLUDE [Department]:SUM([Sales])}
    . As we mentioned earlier, this excludes Department and allows us to get the sum of sales at a Region level. This means that each bar is sized according to the total sales for the given Region
  • Clicking on the Size shelf gives the option to set the Alignment of the bars to Right. Since the preceding calculation gave the right position of the bar, we need to make certain the bars are drawn from that starting point.
    • Warnings or important notes

           Clicking the Size shelf when a continuous (green) field is on Columns (thus defining a horizontal axis) and the mark type is set to Bar reveals options for a fixed size. You can manually enter a Size and Alignment or drop a field on the Size shelf to vary the width of bars.

     In addition to allowing you to create Marimekko Charts, the ability to control the size of bars in axis units opens up all kinds of possibilities for creating additional visualizations, such as cascade charts or stepped area charts级联图或阶梯式面积图. The techniques are similar to those used here. You may also leverage the sizing feature with continuous bins (use the drop-down menu to change a bin field in the view to continuous from discrete). This allows you to have histograms without large spaces between bars. 

Warnings or important notes 

    For a more comprehensive discussion of Marimekko Charts, along with approaches that work with sparse data, see Jonathan Drummey's blog post at: https://www.tableau.com/about/blog/2016/8/how-build-marimekko-chart-tableau-58153?_ga=2.28829311.2128853229.1649316001-478017121.1644842449

Sheet swapping and dynamic dashboards

     Sheet swapping, sometimes also called sheet selection, is a technique in which views are dynamically shown and hidden on a dashboard, often with the appearance of swapping one view for another. The dynamic hiding and showing of views on a dashboard has an even broader application. When combined with floating objects and layout containers, this technique allows you to create rich and dynamic dashboards.

     The basic principles are simple:

  • A view Collapses[kəˈlæpsɪz]使倒塌,崩溃,价格下跌,折叠 on a dashboard when at least one field is on Rows or Columns and a combination of filters or hiding prevents any marks from being rendered
  • Titles and captions do not collapse but can be hidden so that the view collapses entirely

     Let's consider a simple example with a view showing profit by Department and Category with a Department quick filter.

     The dashboard has been formatted (from the menu, select Format | Dashboard) with a gray shading to help us see the effect:

                                                         

     Observe how filtering out all departments results in the view collapsing. The title remains, but it could have been hidden.

     In order to swap two different sheets, we simply take advantage of the collapsing behavior along with the properties of layout containers. We'll start by creating two different views filtered through a parameter and a calculated field. The parameter will allow us to determine which sheet is shown. Perform the following steps:

  • 1. Create a new sheet named Bar Chart , similar to the Profit by Department and Category view shown in the earlier screenshot.
  • 2. On the worksheet Bar Chart, right-click an empty area of the Data pane at left, and select Create Parameter.
    Create an integer parameter named Show Sheet with a list of String values set to Bar Chart and Map:
    ==>
  • 3. Since we want to filter based on the parameter selection and the parameters cannot be directly added to the Filters shelf, instead we'll create a calculated field named Show Sheet Filter to return the selected value of the parameter. (On any sheet, right-click an empty area of the Data pane at left, and select Create Calculated Field).The code is simply
    [Show Sheet]
    , which is the parameter name, and returns the current value of the parameter.
  • 4. Show the parameter control (right-click the parameter(Show Sheet) in the data window and select Show Parameter Control). Make sure the Bar Chart option is selected.==>
  • 5. Add the Show Sheet Filter field to the Filters shelf and check Bar Chart to keep that value.
  • 6. Create another sheet named Map that shows a filled map of states by profit:
  • 7. Show the parameter on this view and change the selection to Map.==>Remember that parameter selections are universal to the worksheet. If you were to switch back to the bar chart view, it should no longer be showing any data because of the filter.
  • 8. Add the Show Sheet Filter field to the Filters shelf and check Map as the value to keep.
  • 9. Using the drop-down menu on the Bar Chart view, ensure the view is set to fill the container (Fit | Entire View). You won't have to set the fill for the map because map visualizations automatically fill the container.

  • 10. Create a new dashboard named Sheet Swap
  • 11. Add a Horizontal layout container to the dashboard from the objects in the left window:
    • Warnings or important notes

           A Vertical layout container would work just as well in this case. The key is that a layout container will allow each view inside to expand to fill the container when the view is set to fit the entire view, or fit the width (for horizontal containers), or fit the height (for vertical containers). When one view collapses, the visible view will expand to fill the rest of the container.
  • 11. Add each sheet to the layout container in the dashboard.
         Add Map worksheet
         drag Bar Chart Worksheet to touch right edge of blue rectangle
    The parameter control(here is Show Sheet) should be added automatically since it was visible in each view.
  • 12. Hide the title for each view (right-click the title and select Hide Title) within the dashboad.
  • 13. Since I don't need Department filter in this dashboard
  • The dashboard has been formatted (from the menu, select Format | Dashboard) with a gray shading to help us see the effect, now let's remove the shading

     You now have a dashboard where changing the parameter results in one view or the other being shown. When Map is selected, the filter results in no data for the Bar Chart, so it collapses and the Map fills the container:

     Alternately, when Bar Chart is selected, the Map collapses due to the filter and the Bar Chart fills the container:

TIP

     The key to collapsing a view is to have a filter or set of filters that ensures no rows of data are shown. You do not have to use a parameter to control the filtering. You could use a regular filter or action filter to accomplish the same effect. This opens up all kinds of possibilities for dynamic behavior in dashboards. 

Dynamically showing and hiding other controls 

     Views will collapse when all data is filtered out. However, other controls, such as quick filters, parameters, images, legends, and textboxes, will not collapse and don't have an option to dynamically show or hide. Yet, very often, in a dynamic dashboard, you might want to show or hide these objects. Sometimes parameters don't apply when other selections have been made. Look at the simple example in the previous section. The color legend, which was automatically added to the dashboard by Tableau, applies to the map. But when the bar chart is shown, the legend is no longer applicable.

     Fortunately, we can extend the technique we used in the previous section to expand a view to push items we want to show out from under a floating object and then collapse the view to allow the items we want to hide to return to a position under the floating object.

     Let's extend the earlier sheet swapping example to show how to show and hide the color legend:

  • 1. Create a new sheet named Show/Hide Legend. This view is only used to show and hide the color legend.
  • 2. Create an ad hoc calculation by double-clicking on Rows and type MIN(1). ==>We must have a field on Rows or Columns for the view to collapse, so we'll use this field to give us a single axis for Rows and a single axis for Columns without any other headers.
  • 3. Duplicate the ad hoc calculation on Columns. You should now have a simple scatterplot with one mark.
  • 4. As this is a helper sheet and not anything we want the user to see, we don't want it to show any marks or lines. Format the view using
    • Format | Lines to remove Grid Lines from Rows and Columns, along with Axis Rulersand
    • Additionally, hide the axes (right-click each axis or field and uncheck Show Headers).
    • Also, set the Color to full transparency to hide the mark.
  • 5. We will want this view to show when the Map option is selected, so
    • show the parameter control(here is Show Sheet) and ensure it is set to Map==>
    • and then add the Show Sheet Filter to filters and check Map:
  • 6. On the Sheet Swap Dashboard, add the Show/Hide Legend sheet to the Layout Container between the Show Sheet parameter dropdown and the color legend. ==>==>Hide the title for the Show/Hide Legend sheet.
  • 7. Ensure that Map is selected. The color legend should be pushed all the way to the bottom.
  • 8. Add a Layout Container(Horizontal layout container OR Vertical layout container) as a floating object. Size and position it to completely cover the area where the color legend used to be. It should cover the whole Show/Hide Legend sheet including the title but not the Show Sheet parameter dropdown.


    TIP
         Objects and sheets can be added as floating objects by holding Shift while dragging, setting the New Objects option to Floating, or by using the drop-down menu on the object.
    You may also change the default behavior for new objects from Tiled to Floating in the dashboard pane.
  • 9. The Layout Container is transparent by default, but we want it to hide what is underneath隐藏下面的内容.
         Format the Layout ContainerFirst select it then go to Layout tab there you can see the option, we add white shading so it is indistinguishable from the background.==>

     At this point, you have a dynamic dashboard where the legend is shown when the Map is shown and it is applicable and hidden when the bar chart is visible.

     When Map is selected, the Show/Hide Legend sheet is shown and pushes the legend to the bottom of the Layout Container(expand the Show/Hide Legend view to push items(here is legend) we want to show out from under a floating object):

     When Bar Chart is selected, the Show/Hide Legend sheet collapses and the legend, which is no longer applicable to the view, falls under/hides behind the Floating Layout Container(still exist) (collapse the Show/Hide Legend view to allow the items(here is the legend) we want to hide to return to a position under the floating object):

Technical summary(Sheet swapping and dynamic dashboards)

  • Put the Map worksheet and Bar Chart worksheet(Both of them containing a worksheet filter and parameter controlinto the Layout container, selecting one of the worksheets will cause the other worksheet to collapse, and the selected worksheet will fill the entire Layout container
  • Overlay a floating Layout container on an additional worksheet(here is the Show/Hide Legend sheet) containing a worksheet filter (a worksheet has been selected) and parameter control (mainly used to select a worksheetBoth of them have been appending to all worksheets(Map, Bar Chart, Show/Hide Legend)).
    • If the selected worksheet(Map worksheet) within the dashboard corresponds to the filter option in this extra worksheet, This will cause this extra worksheet to show out in the floating Layout container.
    • If the selected worksheet does not correspond to the filter option in this extra worksheet, it will cause this extra worksheet to collapse in this floating Layout container, and some control (quick filters, parameters, images, legends, and textboxes) will move below the Layout container, thereby hiding these controls, if you remove this floating Layout container, you will be able to see these controls.

Mapping techniques

     We've touched on geographic visualization throughout the book. You've seen symbol maps and filled maps. Here, we'll take a look at supplying your own geocoded data, along with creating custom territories创建自定义区域territory[ˈterətɔːri].

Supplementing the standard in geographic data

     We saw in Chapter 1, https://blog.csdn.net/Linli522362242/article/details/122932763, that Tableau generates Latitude and Longitude fields when the data source contains geographic fields that Tableau can match with its internal geographic database. Fields such as country, state, zip code, MSA(Metropolitan[ˌmetrəˈpɑːlɪtən] Statistical Area大都市统计区, such as Washington metropolitan area华盛顿市区 ), and congressional district国会选区 are contained in Tableau's internal geography. As Tableau continues to add geographic capabilities, you'll want to consult the documentation to determine specifics on what the internal database contains.

     However, if you have latitude and longitude in your dataset or you are able to supplement your data source with that data, you can create geographic visualizations with great precision. There are several options for supplying latitude and longitude for use in Tableau:

  • Include Latitude and Longitude as fields in your data source. If possible, this option will provide the easiest approach to creating custom geographic visualizations because you can simply place Latitude on Rows and Longitude on Columns to get a geographic plot.
  • Create a calculated field for Latitude and another for longitude using IF/THEN logic or case statements to assign Latitude and Longitude values based on other values in your data. This would also be tedious and difficult to maintain with many locations.
  • Import a custom geographic file. From the menu, select Map | Geocoding | Import Custom Geocoding.... The import dialog contains a link to documentation describing the option in further detail.
  • Connect to the data containing your latitudes and longitudes as a secondary data source and use cross-database joins or data blending混合 to achieve geographic visualization.

          For example, here is a visualization that has been created by joining in a file containing exact latitudes and longitudes for each address: (Map Layers :)
  • Assign a field to a geographic role and assign unrecognized values to desired Latitude and Longitude locations. This option is most often used to correct unrecognized locations in standard geographic fields, such as city or zip code but can be used to create custom geographies as well, though it would be tedious and difficult to maintain with more than a few locations. You can assign unknown geographic locations, as described in the following section.

Manually assigning geographic locations

     Assign unknown locations by clicking the unknown indicator in the lower right of a geographic visualization, as shown here:

This will give you the following options:

  • Edit Locations
  • Filter out unknown locations
  • Plot at the default location ( Latitude and Longitude of 0, a location that is sometimes humorously referred to as Null Island, located just off the west coast of Africa). (纬度和经度为 0,该位置有时被幽默地称为空岛,位于非洲西海岸附近)。

     The indicator in the preceding screenshot shows 447 unknown locations. Clicking the indicator and selecting the Edit Locations option allows you to correct unmatched locations by selecting a known location or entering your own Latitude and Longitude information, as shownEdit Unknown or Ambiguous Locations - Tableau here: 

     The first three options allow you to specify the geographic context by which Tableau determines the location of a field value. You may specify a Country, State, and/or County.

     For example, Tableau may not recognize the city Mansfield until you specify the State (in the United States alone there is a

  • Mansfield, Texas;
  • Mansfield, Ohio;
  • Mansfield, Kansas;
  • and about a dozen more!)

In this example, you may specifically select a constant State or let Tableau know which field in the dataset defines State

     You may also set individual locations by clicking the Unrecognized label in the table and matching to a known location, or by entering a specific Latitude and Longitude

Creating custom territories创建自定义区域

     Custom territories are geographic areas or regions that you create (or that the data defines) as opposed to those that are built in (such as country or area code). Tableau gives you two options for creating custom territories:

  • Ad hoc custom territories
  • Field-defined custom territories

Ad hoc custom territories

     You can create custom territories in an ad hoc way by selecting and grouping marks on a map. Simply select one or more marks, hover over one, and then use the Group icon. Alternately, right-click one of the marks to find the option. You can create custom territories by grouping by any dimension if you have latitude and longitude in the data or any geographic dimension if you are using Tableau's generated latitude and longitude. Here, we'll consider an example using Zip Code:     You'll notice that Tableau creates a new field, Zip Code (group), in this example. The new field has a paperclip and globe icon in the Data pane, indicating it is a group and a geographic field. Tableau automatically includes the group field on color.

     Press Ctrl + seleted marks on Map, hover over one mark, and then use the Group icon

      You may continue to select and group marks until you have all the custom territories you'd like. With Zip Code still part of the view level of detail, you will have a mark for each Zip Code (and any measure will be sliced by Zip Code). However, when youremove Zip Code from the view, leaving only the Zip Code (group) field( rename it to Custom Territories, and give each group an alias, such as East, West, and Central), Tableau will draw the marks based on the new group: 

Warnings or important notes 

     With a filled map, Tableau will connect all contiguous[kənˈtɪɡjuəs]连续的​​​​​​​,邻近的,接触的 areas and still include disconnected areas as part of selections and highlighting. With a symbol map, Tableau will draw the mark in the geographic center of all grouped areas

Field-defined custom territories 

     Sometimes your data includes the definition of custom territories. For example, let's say your data had a field named Region that already grouped zip codes into various regions. That is, every zip code was contained in only one region. You might not want to take the time to select marks and group them manually. 

     Instead, you can tell Tableau the relationship already exists in the data. In this example, you'd use the drop-down menu of the Region field in the data pane and select Geographic Role | Create From... | Zip Code. Region is now a geographic field that defines custom territories:

TIP

     Use ad hoc custom territories to perform quick analysis, but consider field-defined custom territories for long-term solutions because you can then redefine the territories in the data without manually editing any groups in the Tableau data source.

Leveraging spatial objects利用空间对象

     Spatial objects define geographic areas that can be as simple as a point and as complex as multi-sided polygons. This allows you to render everything from custom trade areas to rivers, roads, and historic boundaries of counties and countries. Spatial objects can be stored in spatial files and are supported by some relational databases as well.

     Tableau supports numerous spatial file formats, such as ESRI, MapInfo, KML, GeoJSON, and TopoJSON. Additionally, you may connect directly to ESRI databases as well as relational databases with geospatial support, such as SQL Server. If you create an extract, the spatial objects will be included in the extract.

     Many applications, such as Alteryx, Google Earth, and ArcGIS, can be used to generate spatial files. Spatial files are also readily available for download from numerous organizations. This gives you a lot of flexibility when it comes to geospatial analysis.

     Here, for example, is a map of US railroads:In fact, you will find that it is very difficult to operate on this large data set.

     To replicate this example, download the Shapefile from here:https://www2.census.gov/geo/tiger/TIGER2015/RAILS/tl_2015_us_rails.zip
==>Update Now

     Once you have downloaded and unzipped the files, connect to the tl_2015_us_rails.shp file. In the preview, you'll see records of data with Linearid fields and railway names. The Geometry field is the spatial object that defines the linear shape of the railroad segment: 

     On a blank sheet, simply double-click the Geometry field. Tableau will include the geographic collection in the detail and introduce automatically generated Latitude and Longitude fields to complete the rendering. Experiment with including the Linearid field in the detail and with filtering based on Fullname.

TIP

     Consider using cross-database joins to supplement existing data with custom spatial data. Additionally, Tableau supports spatial joins, which allows you to bring together data that is only related spatially, even if no other relationships exist.

Some final map tips

     There are lots of ways to customize geographic visualizations and some options to note. First, you may notice the controls that appear when you hover over the map:

     These controls allow you to search the map, zoom in and out, pin the map to the current location, and use various types of selections. 

Additional options will appear when you select Map | Map Options from the top menu:

     These options give you the ability to set what map actions are allowed for the end user and whether to show a scale. Additionally, you can set the units displayed for the scale and radial selections. Options are Automatic (based on system configuration), Metric (meters and kilometers), and US (feet and miles). 

There are a few other tips to consider when working with geographic visualizations:

  • Use the top menu to select Map | Map Layers for numerous options for what layers of background to show as part of the map.
  • Other options for zooming include using the mouse wheel, double-clicking, Shift + Alt + click, and Shift + Alt + Ctrl + click.
  • You can click and hold for a few seconds to switch to the pan mode.
  • You can show or hide the zoom controls and/or map search by right-clicking the map and selecting the appropriate option.
  • Zoom controls can be shown on any visualization type that uses an axis.
  • The pushpin on the zoom controls alternately returns the map to the best fit of visible data or locks the current zoom and location.
  • You can create a dual axis map by duplicating (Ctrl + drag/drop) either the Latitude on Columns or Longitude on Rows and then using the field's dropdown menu to select Dual Axis. You can use this technique to combine multiple mark types on a single map:
    Dual Axis ==>
  • When using filled maps, consider setting the Washout to 100% in the Map Layers window for clean-looking maps. However, only filled shapes will show, so any missing states (or counties, countries, and others) will not be drawn:
  • You can change the source of the background map image tiles[taɪlz]图块  using the menu and selecting Map | Background Maps. This allows you to choose between None, Offline (which is useful when you don't have an internet connection, but is limited in the detail that can be shown), or Tableau (the default).
  • Additionally, from the same menu option, you can specify Map Services... to use a WMS server or Mapbox.

Using background images

     Background images allow you to plot data on top of any image. Consider the possibilities! You could plot

  • ticket sales by seat on an image of a stadium[ˈsteɪdiəm]体育场,运动场,
  • room occupancy on the floor plan平面图 of an office building,
  • the number of errors by piece of equipment on a network diagram,
  • or meteor[ˈmiːtiər; ˈmiːtiɔːr]陨石 impacts on the surface of the moon. 

     In this example, we'll plot the number of patients per month in various rooms in a hospital. We'll use two images of floorplans for the ground floor and second floor of the hospital. The data source is located in the Chapter 11 directory and is named Hospital.xlsxhttps://github.com/PacktPublishing/Learning-Tableau-10/blob/master/Chapter%2010/Hospital.xlsx . It consists of two tabs: one for patient counts and another for room locations based on the x/y coordinates mapped to the images. We'll consider shortly how that works. You can view the completed example in the Chapter 11 Complete.twbx workbook or start from scratch using Chapter 11 Starter.twbx. 

     To specify a background image, use the top menu to select Map | Background Images and then click the data source to which the image applies (in this example, Hospitals). On the Background Images, screen you can add one or more images. 

Here, we'll start with Hospital - Ground Floor. png , located in the https://github.com/PacktPublishing/Learning-Tableau-2020/blob/master/Chapter%2012/Hospital%20-%20Ground%20Floor.png:

     You'll notice that we mapped the fields X and Y (from the Locations tab) and specified the Right at 800 and Bottom at 700. This is based on the size of the image in pixels.

TIP

     You don't have to use pixels, but most of the time it makes it far easier to map the locations for the data. In this case, we have a tab of an Excel file with the locations already mapped to the X and Y coordinates on the image (in pixels). With cross-database joins, you can create a simple text or Excel file containing mappings for your images and join them to an existing data source. You can map points manually (using a graphics application) or use one of many free online tools that allow you to quickly map coordinates on images. 

     We'll only want to show this blueprint for the ground floor, so switching to the Options tab, we'll ensure that the condition is set based on the data. We'll also make sure to check Always Show Entire Image:

       Next, repeating the preceding steps, we'll add the second image ( Hospital - 2nd Floor. png ) to the data source, ensuring it only shows for the 2nd Floor

     Once we have the images defined and mapped, we're ready to build a visualization. The basic idea is to build a scatterplot using the X and Y fields for axes. But we'll have to ensure that X and Y are not summed because if they are added together for multiple records, we'll no longer have a correct mapping to pixel locations. There are a couple of options:

  • Use X and Y as continuous dimensions.
  • Use MIN , MAX , or AVG instead of SUM , and ensure that Location is used to define the view level of detail.
  • Additionally, images are measured from 0 at the top to Y at the bottom, but scatterplots start with 0 at the bottom and values increase upward. So, initially, you may see your background images appear upside-down. To get around this, we'll edit the y axis (right-click and select Edit Axis) and check the option for Reversed.

     We also need to ensure that the Floor field is used in the view. This is necessary to tell Tableau which image should be displayed. At this point, we should be able to get a visualization like this:

     Here, we've plotted circles with size based on the number of patients in each room. We could clean up and modify the visualization in various ways:

  • Hide the x and y axes (right-click the axis and uncheck Show Header)
  • Hide the header for Floor(menu Analysis|Table Layout | Hide field labels for Columns) , as the image already includes the label
  • Add Floor to the Filter shelf so that the end user can choose to see one floor at a time

Animation

     Animated visualizations动画可视化 can bring data storytelling to life by revealing patterns that happen over time or emphasize dramatic events. Adding a field to the Pages shelf will show playback controls that allow you to page through each value of that field翻阅该字段的每个值. You can do this manually, or click the Play button to watch the visualization as values change automatically.

     The Chapter 11 Completed workbook contains an example that animates the hospital floorplan shown earlier. You can create the same effect by adding the Month field to the Pages shelf (as a month date value). Then watch as the circles change size month by month.

     Experiment with the Show History options to see how you can view marks for previous pages.(Fade[feɪd]逐渐消失,(使)褪色)

TIP

     When you use multiple views on a dashboard, each having the same combination of fields on the Pages shelf, you can synchronize the playback controls (using the caret drop-down menu on the playback controls) to create a fully-animated dashboard.

     Animations can be shared with other users of Tableau Desktop or Tableau Reader. At the time of writing, the automatic playback controls are not available for Tableau Server, Tableau Online, or Tableau Public. However, end users are able to manually page through手动翻阅 the values.

Transparency

     In newer versions of Tableau, you may set transparency for visualizations used on dashboards. This enables all kinds of innovative approaches, such as

  • layering visualizations on top of each other
  • or over background images.

     You'll find the following example in the Chapter 11 Complete workbook:

The dashboard consists of an image(Edit Image Object | Options : Fit Image), a transparent chart over the image(First add background Image then Floating layout to add the chart), and a title( Dashboard title==>Floating).

     To make a visualization transparent, go to menu then Format| Shading...==>Format Shading and set the Worksheet shading to None:

     Once you have set the shading to None, the visualization will be transparent when used on a dashboard. At this point, you can also achieve a semi-transparent effect by selecting the visualization on the dashboard, switching to the Layout tab, and adjusting the background to have a color with Opacity: (I used bar chart since I couldn't find the oil data set)

TIP

     Be careful that your use of transparency does not detract from the data story. Background images and overlapping visualizations may add intrigue[ɪnˈtriːɡ]激起……的兴趣,引发……的好奇心 and interest, but could just as easily add distraction and clutter[ˈklʌtər]也很容易增加分心和混乱. 

Summary

     We've covered a wide variety of techniques in this chapter! We looked at advanced visualizations, sheet swapping, dynamic dashboards, some advanced mapping techniques, including supplementing geographic data, custom territories, spatial objects, and using custom background images. We concluded by considering possibilities with animation and transparency.

     There is no way to cover every possible visualization type or technique or way of solving problems. Instead, the idea has been to demonstrate some of what can be accomplished using a few advanced techniques. The examples in this chapter build on the foundations laid in the preceding chapters. From here, you will be able to creatively modify and combine techniques in new and innovative ways to solve problems and achieve incredible results! Next, we'll turn our focus to how to share those results.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值