13 Replies Latest reply on May 24, 2018 10:32 AM by Joe Oppelt

    Change Legend Dynamically on Dashboard with Map Layers

    Tara Anderson

      I recently added a property control that allows me to flip between various map layer views using Tableau's provided demographic layers (median income, median age, race, etc.).

      While the control changes my map view, it does not, however, change my legend. Is there a way this can be done? Each layer represents a significantly different scale. Note the two examples below show the same legend values. Without a correct legend there is no context. Thanks!

      example.jpg

        • 2. Re: Change Legend Dynamically on Dashboard with Map Layers
          Joe Oppelt

          Do you have different legends wen your layers change?  I can help you swap them if you do.

          • 3. Re: Change Legend Dynamically on Dashboard with Map Layers
            Peter Fakan

            Here's a mockup Joe - its been bugging me for ages. Only the relevant legend should display, not both.

             

            The issue extends to blended data - if the legend colour comes from the blend datasource, you can't seem to hide it

             

            2018.1 attached

             

            Peter

            • 4. Re: Change Legend Dynamically on Dashboard with Map Layers
              Joe Oppelt

              See attached.

               

              On Dashboard 1 I just floated everything.  (I like to do popping and swapping with floating objects.)

               

              For Dashboard 2 I created a new sheet that will pop out r disappear depending on the value of the parameter.  Play with the param and see what happens.  The container that's in (all three objects) is the centerpiece of what I'm going to do.

               

              On Dashboard 3 I floated a BLANK object behind the parameter, and floated the popping container below that.  The pop-out sheet gets hidden by the blank because I colored the blank white.  (If your actual dashboard has a background color, you want to color the blank the same color so that it looks invisible to the user.)  You can also pop thing out from behind sheets or other objects.  So I could have made this a horizontal container and placed the pop-out sheet behind the maps, for example.  Part of the secret here is to size the pop-out sheet to be approximately the size of whatever you're trying to pop-out.


              Additional note:  You can also position the popping container so that it starts at a negative value for the x-position or y-position.  In that case you are "hiding" the part you don't want the user to see out of the boundaries of the actual dashboard.

               

              Play with the param again and see the results.

               

              On Dashboard 4 I added one more opaque blank object over the second legend when sheet-1 legend is popped out.  In effect I made a little "stage" where the proper actor gets moved onto stage based on the condition that warrants him being there.

              • 5. Re: Change Legend Dynamically on Dashboard with Map Layers
                Peter Fakan

                Thanks Joe - unfortunately for us we are in a s508/WCAG environment and can't use floating objects.

                 

                Floating objects are problematic when the screen resolution can range from anywhere between 640x480 to 2048x1024 and higher. In essence, since Tableau doesn't know the eyeball relationship between the objects that you have floated over each other, when it needs to adjust the screen dimensions to each extreme we have found it places floating objects pretty much right over the most inconvenient place it can according to Murphy's Law of convenience.

                 

                I'm hoping that Tableau will show us some love for those of us who need to stay in tiled mode, just saying Patrick Van Der Hyde

                 

                 

                Peter

                • 6. Re: Change Legend Dynamically on Dashboard with Map Layers
                  Joe Oppelt

                  You can still do it in a tiled dashboard.  the only thing you would be floating are any "masking" objects (such as the opaque blanks I used in my example.)  You won't be able to use negative coordinates though.

                   

                  You would tile in a similar container with your three items:  the pop-out sheet, and the two legends.

                   

                  For me, the disappointing factor in your example is that Tableau doesn't empty the map legend when your sheet is blank.  If you had your own color legend, for example, and no rows were returned for the sheet, your color legend would be empty.  It would almost behave like sheet swapping if you then put the two legends in the same container.  (Note:  The titles would still remain, even if the legend were empty.  You can work around that too, and still get a title conditionally, FYI.)  But that's not the case here.  Tableau is pumping out that legend no matter what is (not) on the sheet.  Bummer, that.

                  • 7. Re: Change Legend Dynamically on Dashboard with Map Layers
                    Tara Anderson

                    Hey Joe, my apologies on the late reply. Yes there are different legends for each map. I want the legend to adjust when I change the drop down, right now only the map is changing.

                    Thanks!

                    • 8. Re: Change Legend Dynamically on Dashboard with Map Layers
                      Joe Oppelt

                      Tara -- Wait a minute.  Peter provided me a workbook and I modified it and uploaded an example in a previous reply.

                       

                      Are you and Peter coworkers?

                      • 9. Re: Change Legend Dynamically on Dashboard with Map Layers
                        ottame.oettam

                        I don't know if it can help, but you could use your own data layers, instead of the ones provided by Tableau. That way, you could change the measures showed in your map using a parameter and a custom calculation (as explained here: Example – Swap Measures Using Parameters. That way, the legend would dynamically change!

                        • 10. Re: Change Legend Dynamically on Dashboard with Map Layers
                          Peter Fakan

                          Hi Joe, no Tara and I aren't co-workers - hi from (not so this morning) sunny Australia !

                           

                          I picked up on the question because its been bugging me for ages, and you said in your reply that you could swap out the legends

                           

                          Peter

                          • 11. Re: Change Legend Dynamically on Dashboard with Map Layers
                            Joe Oppelt

                            Peter -- I'm just chuckling to myself now.  Your example had maps, and the same color schemes as Tara's screen shots, and I didn't look closely, and I just assumed they were all the same issue.

                             

                            OK, so Tara -- The example I uploaded for Peter is V2018.1,

                             

                            If you have your own sample that you would lime me to modify, upload yours.  Or, if you can open the sample I uploaded, take a look at that one.  Or, if you want it saved as any version as low as 10.2, let me know and I can downgrade it.

                            • 12. Re: Change Legend Dynamically on Dashboard with Map Layers
                              Tara Anderson

                              Hey Joe -

                              I have attached the workbook. Thanks!

                              • 13. Re: Change Legend Dynamically on Dashboard with Map Layers
                                Joe Oppelt

                                In the attached I made a copy of your dashboard to preserve your original.

                                 

                                On dashboard 2 I added a horizontal container.  I displayed two more of the legends, and I dragged them into the container.  (I'm adding them in reverse order.  Your first sheet's legend is at the bottom.  Second sheet is above that, etc.)

                                 

                                I created a pop out sheet called Pop Out Per Capita Income.  I sized it to be essentially the same height as a legend, and I use your [Data Overlay] calc to display it when Per Capita is chosen.  On dashboard 2 select per capita and see how it bounces the list of legends down one "bump".  On Dashboard 3 I moved the container to the x-coordinate I'll place it, and I added another pop-out sheet.  this one is sized twice as big as a legend.  it will push the pile down two "bumps".  You will make a string of these sheets for all the swapping choices on the dashboard.

                                 

                                On Dashboard 4 I shrunk the container for swapping the maps a bit.  I want to make a viewing port (I don't know what else to call it) where the proper legend will end up.  I'll explain later why I didn't user the area of water on the map where you were previously displaying the legend.  It needs to be in a place where the whole string of legends will not cover anything.  So I floated it to the bottom of the floating order.  Select Median Household Income here so that you can see what the final layout will look like.  I also colored the map-swapping container white so that it is opaque, and when the chain of legends gets popped down, you won't see the other ones bleeding through.

                                 

                                Go to dashboard 5.  Here I monkeyed with the y-coordinate for the start of the popping container.  Notice that it's a negative number.  Users don't see what's in negative space.  Mess with the first three swapping values and see how it works.

                                 

                                go to 6.  You noticed that pieces of the legend above the one we want to see were still bleeding through.  I made another container to hide that.  My usual practice is to do a text box that I color white, and I just type in text that explains why it is there, and I color the text white.  Users never see it, but the text will help you out a year from now when you come back to make modifications.

                                 

                                And there you have it.  You have homework to add in the rest.

                                 

                                Why can't I pop these things over the map?  In 10.3 you still could.  But starting in 10.4 they changed the published behavior that causes underlying objects to be blocked from access with the cursor.  So you wouldn't get tooltips, or click on a legend color to highlight those marks on the sheet.  (Actually in this case the map legends don't give you that capability but other legends do, or if you are popping out respective filters for the various sheets, etc.)  So that's why I did this "film strip" design.  In the past I would have had 8 different containers, each popping out one legend, and when one went away another would appear, and up until 10.3 the published behavior let you drill through to those underlying containers.  But starting in 10.4 only the topmost one gets cursor access. 

                                 

                                Let me know if you have questions.

                                1 of 1 people found this helpful