1. Hex map is quite popular for representing US geography in Tableau. Some asked how to create one for their own country or region. So here we will show the basic steps.

    Hex map is a simplified way to represent a real map. It's an approximation. Some would say, even the "true map" is just an approximate representation of the reality, not the exact one.

    Tableau Zen Master Matt Chambers proposed a Hex Map approach to US map. It looks great and seems better than tiled maps, because it tightly weaves all the State pieces together, thus looks a lot better. In a hex map, one state is neighbor to 6 states while in a tiled map, one state is neighboring 4 states.

    But the hexagons are not close enough when using Tableau shapes. There left some gaps between states, especially when we resize the map.

    Zen Master Rody Zakovich created a polygon based hex map, which is easy to resize while keeping the pieces always together. Zen Master Joshua Mulligan proposed a Spatial File based approach which also fixes the resize problem. But it is made with Alteryx which is a luxury not everyone can afford.

    I made some improvement on Rody's polygon approach by eliminating the extra 51 rows for labeling.

    Here I will show you the steps of creating a polygon-based hex map.

    1. Understanding the data set
    Load the hex map file (credit to Matt Chambers) to Tableau. It has got 51 rows of data. Each row contains one US state and its coordinates. For those who want to create your own Hex map, you need to create a data set like the one by Matt.

    Horizontally between two neighboring data points, the distance is 2. Between two row of States, there is a horizontal shift of 1.

    Vertically, the distance is 3.

    2.Calculating the vertices of each hexagon
    The above data set actually defines the center of each hexagon.

    For a polygon-based hexagon, we need to define 6 vertices. Then a polygon is defined. For each of the 6 vertices, there will be one corresponding data row.

    Given the horizontal and vertical distances, we derive the distances between each vertex and the center. Note that the horizontal and the vertical scales of a hexagon is different. So the calculation of the two coordinates are different too in scale.

    //X is the horizontal coordinate of the center of a hexagon.
    [X]
    +COS(-[Pi]/2+[Table Index]*[Pi]/3)*2/SQRT(3)

    //Y is the vertical coordinate of the center of a hexagon.
    [Y]
    +SIN(-[Pi]/2+[Table Index]*[Pi]/3)*2
    3.Labeling
    Labeling tiled map or hex map has not been a big issue but there lacked a systematic approach to it.

    In our design, we used AVG() to the coordinates. When using dual axis for the labeling, we removed the vertex dimension and the AVG() of vertices will point to the center of the hexagon, thus very well positioned for labeling.

    Voila, those are the main steps to creating a scalable and tightly woven hex map for any region on the earth. View the video for more details. Download the workbook here. You can use the map to blend with other data sets as you wish.
    0

    Add a comment

  2. A few days ago, the Viz of the Day on 3/13/2019 is made of Joy Plot, authored by David Velleca. Quite a joy to look at for sure. After some digging, I found that it is based on an approach proposed by Ken Flerlage. It uses data scaffolding techniques with a few extra tables. Here I propose a new approach without extra scaffolding. Just the original data set will suffice.
    The Data Set
    Here I will use the same data set of Ken's. The data set is a simple time series with 3 columns: Dimension, Time and Value. Ignore other columns.

    There are 7 elements in Dimension in the sample data set. Therefore we will see 7 area charts with some overlapping area.

    Step 1: Union the data set with itself.
    Load the data into Tableau and drag the 'Data' sheet to the data source editing canvas. Union the 'Data' sheet with itself. Note that a new column is created: [Table Name] with two values Data and Data1 specifying two tables respectively.

    Step 2: Create Keys
    Create the keys for the dimension elements. The key is equivalent to index for the dimension elements without the complexity of table calculations.

    Step 3: Create the following calculated fields
    All these calculations below are based on Ken's approach.
    [Path]: the path for creating the area chart polygon.
    [Max Time]: for each dimension.
    [Size of Dimension]: Using LOD instead of Size() to avoid table calculations.
    [Value Adjusted]: Keep the original values and make the values in the Data1 table to be 0.
    [Value Adjusted for Dimension]: Elevate the values of the dimension elements to different heights. Tunable with the parameter Spacing.

    Step 4: Charting
    Drag [Time] and [Value Adjusted for Dimension] to Columns and Rows shelves. Drag Dimension to the Color shelf. Set the marks to Polygon and drag Path to the Path shelf.

    Sort the Dimension by the field of Maximum(Dimension) in descending order.

    We are done. The new approach is mainly different in data preparation which has fewer steps.

    Additional cosmetic steps 
    Add dual axis line charts with tool tips, labels and borders if you wish.

    A different approach is included which fully automates the creation of keys. It requires some table calculations. Also it requires custom sorting of IndexD and Dimension. Please look into the details of the workbook if you are curious.

    That's all. Enjoy the Joy Plot! Download the workbook here.
    0

    Add a comment

Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.