7 Replies Latest reply on Apr 30, 2013 1:13 PM by Jon Grunow

    Shading polygons on top of Background Image

    Chris Sommers

      I wondering how to go about shading polygons based off of coordinates and a variable related to the polygon.


      I will be using a background image similar to the one attached.  What I would like to do is shade the various polygons different colors based on a variable such as revenue.


      I have in a file the four coordinates of each polygon.  This is similar to the teeth example that Tableau showed in a demonstration that I attended and is on their website.



      Thanks for your insights,


        • 1. Re: Shading polygons on top of Background Image
          Allan Walker
          1. Create a Parameter with "Revenue" and your other measures as a list.  Include "ALL" in this list.
          2. Create a CF that will swap your Measures - Case statement your parameter - and use WHEN "Revenue" THEN [Revenue].  Add the other Measures as necessary.
          3. Create a filter on the CF with the IFNULL([Calculated Field Name],'Null') = IF [Parameter] != 'ALL' THEN [Parameter name] ELSE IFNULL([Calculated Field Name], 'Null') END as the condition.
          4. Drop the CF into the color shelf.  If you need to customize the color palette, there are instructions here.
          • 2. Re: Shading polygons on top of Background Image
            Chris Sommers

            Hi Allan,


            I'm not sure that I was explicit enough in my request. 


            How would I shade in the polygons?  I know how to put single marks on a background image.  Instead of that, is there a way for me to fill in a polygon (I know the coordinates of each polygon)?





            • 3. Re: Shading polygons on top of Background Image
              Allan Walker

              Sorry Chris, I wasn't explicit in my answer, either!


              (Assuming 7E - 8J is [Polygon ID]), assign an integer value to each Polygon ID, so Polygon ID comes in as a measure.  Put that as one of the measures into the parameter list.  Then Place the CF in the color shelf .

              • 4. Re: Shading polygons on top of Background Image
                Noel Avison

                Here is a quick rundown on how to do polygons that I did for someone else.:


                While single point annotating can be useful, the main drawback is that the points lose perspective like you said when you zoom in and out. I faced a similar problem when doing my project. Polygons are definitely the way to go and are not as complicated as you might think. Here is a tutorial. http://kb.tableausoftware.com/articles/knowledgebase/polygon-shaded-maps


                While this tutorial is useful, I found it a bit hard to follow at first because I was new at this. Here is the basics for what you need to make polygons.

                1.Polygon Name

                2.Coordinates of at least 3 points to the polygon (otherwise you just end up making a point or a line if you only use 1 or 2 points respectively)

                3.Point Order    This determines how tableau connects the dots


                Since you already know how to obtain coordinate points on a background ill skip that step and use coordinate (0,0),(1,0),(1,1), and (0,1) (You can pick whatever coordinates you like for this base on the geography of your floor-plan)


                So the polygon data sheet should look this this


                Polygon NameXYPoint Order


                Now you just drop [X] and [Y] into column and row shelf,


                Then select polygon for mark type and drop [Point Order] into path


                Then put [Polygon Name] into the Level of detail below the marks tray and that will draw you a square with those coordinates as corners


                Now to add data to the shape "Square-1" you can either join this polygon sheet with your data sheet that has data you want to correspond to each shape.


                For instance


                This data sheet could be joined by [Area] to [Polygon Name] and the data would be linked to the shapes. Alternatively, if you are working in excel you could to a vlookup for you polygon data sheet so that you only bring in one table that isn't joined


                For instance you could do this


                Polygon NameXYPoint OrderStudentsCategory





                and that polygon would have all the associated data that you have on your data sheet that you want to correspond to your polygon.





                So all you need to change are the polygon names, the coordinates, and the data associated with those polygons.


                Edit- After you get the polygons to show up on the map, you might want to revisit what Allan was talking about to get a parameter selector to change between data fields easily.

                • 5. Re: Shading polygons on top of Background Image
                  Chris Sommers

                  Hi Noel,


                  This is awesome!



                  One last question,  how would I add labels to the polygon?  The label field is missing when you change to polygon.




                  • 6. Re: Shading polygons on top of Background Image
                    Allan Walker



                    As you've noticed, the label shelf isn't there.  A workaround is to use a tooltip.  Insert [BIN] into it.


                    Best Regards,



                    • 7. Re: Shading polygons on top of Background Image
                      Jon Grunow

                      What is the best way to initially generate the polygon coordinates and point order from something like Chris's graphic?


                      Nevermind, found http://kb.tableausoftware.com/articles/knowledgebase/background-image-coordinates


                      I guess I would recommend this be added to the online help...