3 Replies Latest reply on Mar 7, 2018 5:08 PM by Peter Fakan

    Dynamically show/hide legends on a dashboard

    Mariusz Musiał

      Hi,

       

      I'm using a dashboard where I have 3 map views displayed in the same container and selected by a parameter. This technique was described in several places, e.g. here : Tableau Tip: Switch between views dynamically on a dashboard - The Data School.

      The problem is, that if one of the chart uses continuous measure for which the color legend is displayed, this legend is not "emptied" when the chart in question is hidden (observe Profit color legend in the example in the link above changing to pale green and with NULL description). If the measure in question is discrete, the legend becomes empty container with transparent background, which plays nicely with this technique. I'd like to show/hide this continuous measure legend, as I'm switching between charts, due to aesthetical reasons, but couldn't find a method to to this so far. I'm using floating legends laid over the map charts.

       

      I've tried putting the "continuous" legend  behind "discrete" legends with white background, but the "discrete" legends are only emptied, not hidden. I've played with a dummy worksheet with dynamic title being either empty string or a string of adjacent white rectangles, but the title background cannot be set to transparent. Making a new calculated field to display different measures on the same chart instead of switching charts wouldn't work either, as the discrete/continuous setting is done on that new calculated field.

       

      I'm running out of ideas... I'd appreciate any help.

       

      Cheers,

       

      Mariusz

        • 1. Re: Dynamically show/hide legends on a dashboard
          Simon Runc

          Hi Mariusz,

           

          So I have a couple of option for you...the first one is to use a technique called "sheet popping", and below you can find an excellent video from Joe and Matt

           

          Sheet Swap and Pop in Tableau on Vimeo

           

          As an alternative, I've also come up with this...

           

          So in the attached, I've created the legend as a sheet (I've used squares, state in the VizLoD [sorted low to high], and index() to get them to line up). As this is a sheet, I can use the "Sheet Swapping" technique so this sheet is also swapped in and out with the map.

           

          Hope these help, and make sense, but let me know if not.

          • 2. Re: Dynamically show/hide legends on a dashboard
            Mariusz Musiał

            Great! Pushing from behind an opaque object did the trick!

            Thanks!

            • 3. Re: Dynamically show/hide legends on a dashboard
              Peter Fakan

              Reviving this old thread because this is where google is taking people - we've come up with an additional workaround but would still encourage everybody to vote here - https://community.tableau.com/ideas/6016#comment-31987 for a real fix.

               

              What we are doing in the attached viz is replacing the legend with a picture of the legend, and then using this with sheet swapping. The reason it works is because each element as a sheet can be controlled by the sheet swap parameter, where you don't have these controls on a normal legend.

               

              To setup the background image, you will need to create a x and y axis with the most complicated calculated field in history;

               

              and then place these on the sheet columns and rows shelf and convert to AVG. Note in the below pic you can see the sheet swap filter on the filters shelf, which controls which view is displayed as the parameters are changed. The picture shows what is displayed after the image has been loaded.

               

               

              Next onto the images, simply load them by browsing to the file location they are stored, and give them the same axis details as your calculated fields (i.e. 1) as pictured.

               

              10.5 attached.

               

              Peter

              1 of 1 people found this helpful