How to use the 'Execute JavaScript Action' Click Action to Modify a Filter
My team and I are working on a presentation that contains an image and a discovery on a single slide. We would like to create a click action on the image that sets a filter on the discovery to a specific value.
How would we do this using the ' Execute JavaScript' Click Action ? Is this possible?
6 replies
-
Hi ,
When you say "sets a filter on the Discovery to a specific value", do you mean a slicer or a variable value filter on a measure?
Ian
-
Hi
“Execute JavaScript” is not the right way to go to achieve what you are after. This Jump Action is designed to run JavaScript code, typically to interact with something outside the Pyramid platform.
We can achieve what you are looking for, although it is a bit complicated and involved. It uses the “Jump to Slide” Action in tandem with the “Inject to Target” option. Targets are used to pass slicer values from one slide to another.
To demonstrate this, I’ve created a small data set consisting of a body part name and some dummy data. I’ve built a simple grid from this data. I’ve also sourced a body silhouette image. Both of these I’ve placed on a Present slide.
We now need to create the components that will take part in the solution.
In the Target panel, create a new Target and rename it to Body Parts.
Create a new slicer, using the Body Part attribute form your model, but have it only contain one value, Head. Rename the slicer to Head and make it hidden on the slide. It will appear in the slicer panel off slide. (We’ll hide it completely from the user later.)
Create a small rectangle from the shapes library and place it over the head of the silhouette and resize it so that it just obscures the head. Change its properties to have invisible fill and no stroke or outline. Right click on the rectangle and choose Click Action. In the dialogue, choose Jump to Slide option and set the jump to value to be 2. Check the “Inject to Target” checkbox and choose the Body Parts target.
Select the add interaction tool and create an interaction between the slicer and the rectangle. This will populate the click action inject to target with the value of the slicer, in this case Head. When clicked on, the slicer value of “Head” will be injected into the target Body Parts and then jump to slide 2.
Repeat the above procedure for each value of body part that is required, using shapes to cover the corresponding part.
Once the slide is complete, duplicate the slide. On slide 2, edit the click action Jump to Slide for each shape to jump to slide 1. This use of a duplicate slide that the user pings back and forth from is necessary because if the jump action jumps to its own slide, the filtering isn’t triggered.
So that the process is protected, remove any option to navigate between the slides, so that the only way to move between slides is via the jump buttons. Also hide the slicers so that they are not visible in the slide off menu panel.
I’ve attached a video showing this for Head and Torso body parts. Simply repeat the process for any other parts you may want.
Hope that helps.
Ian
-
Ian's great example can be found here on our Explore server.
-
Hi
If you use individual images of the separate parts of the body, those can be used directly rather than superimposing the transparent rectangles. In that instance, you could also change the colour of the image when selected to indicate what had been picked.
Ian