Introduction
Property controls are a way to control document properties through input elements. Think of document properties are variables that can be used almost everywhere in your analysis. For example, you can set a document property to manipulate the output of a calculated column, be part of a data function input parameter, or part of a custom expression. They can also be used as parameters to retrieve data on-demand or trigger a script when the document property changes to automate a set of actions.
Spotfire provides a set of powerful ways to control document properties through input fields, dropdowns, list boxes and sliders. These are called Property Controls in TIBCO Spotfire, but there are no check-boxes or radio buttons available out of the box as of yet. However we can easily create them with out of the box features
.
Requirements
To create radio buttons or checkbox property controls, we need:
-
A Boolean Document Property and optionally a script to run when this document property changes
-
A Calculated value that uses the Boolean Document Property as the custom expression and a script to change the state of the Boolean Document Property state.
For example, if we want to create a a checkbox that turns on or off the visualization gridlines, you create a "showGrids" Boolean document property and attach a script so when the document property changes, it triggers the script. Now we need another way change the Boolean document property. This can be done by using a calculated value that triggers the script that toggles the Boolean document property
Checkbox Property Control Example
This example demonstrate how to create a checkbox to turn on and off a visualization grid
-
Create a Boolean Document Property called "cb"
-
Create a script that triggers when Boolean Document Property changes
from Spotfire.Dxp.Application.Visuals import Visualization myVis = myVis.As[Visualization]() myVis.XAxis.Scale.ShowGridlines = Document.Properties["cb"] myVis.YAxis.Scale.ShowGridlines = Document.Properties["cb"]
-
Create a calculated value with custom expression and script
custom expression:
if(${cb},"[X]",[ ])
script
Document.Properties["cb"] = not Document.Properties["cb"]
Radio Button Property Control example
In this example we create 3 radio buttons so the user can only select one option to set the label visibility mode
-
Create a Boolean document property for each radio option. For example "op1", "op2", "op3"
-
Create a script that triggers when any of the Boolean document property changes
if Document.Properties["op1"]: myVis.LabelVisibility = LabelVisibility.All if Document.Properties["op2"]: myVis.LabelVisibility = LabelVisibility.Marked if Document.Properties["op3"]: myVis.LabelVisibility = LabelVisibility.None
-
Create a calculated value with custom expression and script
custom expression:
if(${cb},"(X)",( ))
Document.Properties["op1"] = False Document.Properties["op2"] = False Document.Properties["op3"] = False Document.Properties[dp] = True
Video Tutorial
Here is a video explaining what I mean in this article. Enjoy!
Recommended Comments
There are no comments to display.