Spotfire Iron Python
Wednesday, November 26, 2025
❓ Why do we need to set up the Spotfire Database before installing the Spotfire Server?
Thursday, June 27, 2024
How to Toggle Label Visibility in Spotfire Using IronPython Script
Are you looking to enhance your Spotfire visualizations by dynamically toggling label visibility? This blog will guide you through using IronPython scripts to switch labels on and off in your Spotfire dashboards. Whether you're a beginner or an advanced user, you'll find this tutorial helpful for making your visualizations more interactive and user-friendly.
Introduction
TIBCO Spotfire is a powerful analytics tool that enables users to create insightful data visualizations. One of the features that can make your visualizations more dynamic is the ability to control label visibility using IronPython scripts. In this tutorial, we'll show you how to write a script that toggles the visibility of labels for all visualizations in a Spotfire dashboard.
Step-by-Step Guide
Prerequisites
- Basic understanding of Spotfire and IronPython scripting
- Spotfire installed on your machine
- Access to a Spotfire analysis file (.dxp)
Script Overview
The IronPython script provided below will iterate through all the pages and visualizations in your Spotfire document and toggle the label visibility. If labels are currently hidden, the script will make them visible, and vice versa.
The Script
Here’s the IronPython script to achieve this:
for page in Application.Document.Pages:
for vis in page.Visuals:
myVis = vis.As[VisualContent]()
if(myVis.TypeId != VisualTypeIdentifiers.HtmlTextArea and myVis.TypeId != VisualTypeIdentifiers.PieChart):
print(myVis.TypeId)
if(myVis.LabelVisibility == LabelVisibility.None):
myVis.LabelVisibility = LabelVisibility.All
elif(myVis.LabelVisibility != LabelVisibility.None):
myVis.LabelVisibility = LabelVisibility.None
How the Script Works
Import the necessary module: The script begins by importing the
Visualsmodule fromSpotfire.Dxp.Application.Iterate through all pages: The script loops through each page in the Spotfire document.
Iterate through all visualizations on each page: For each page, the script loops through all the visualizations.
Check visualization type: The script checks if the visualization type is not
HtmlTextAreaorPieChart. These visualizations are excluded from label toggling.Toggle label visibility: The script toggles the label visibility. If the labels are currently hidden (
LabelVisibility.None), it makes them visible (LabelVisibility.All). If the labels are visible, it hides them.
Running the Script
To run the script in Spotfire:
- Open your Spotfire analysis file (.dxp).
- Go to the
Editmenu and selectIronPython Script.... - Copy and paste the script into the script editor.
- Click
Run Script.
Conclusion
By following this tutorial, you can easily toggle the visibility of labels in your Spotfire visualizations using IronPython scripts. This feature is especially useful for creating more interactive and user-friendly dashboards. We hope you found this guide helpful. Stay tuned for more Spotfire tips and tricks!
Don't forget to share this blog, leave your comments, and subscribe for more updates on Spotfire and data visualization techniques.
Saturday, June 22, 2024
Most Common IronPython Scripts
1. How to Change the Title of a Visualization
A frequent task is dynamically updating the title of a visualization based on certain conditions or user inputs. Here's a basic script to change the title of the first visualization in your analysis:
❓ Why do we need to set up the Spotfire Database before installing the Spotfire Server?
Because the Spotfire Server depends on the database to store its core operational data. Without the DB, the server has nowhere to save: 🔹 U...
-
Are you looking to enhance your Spotfire visualizations by dynamically toggling label visibility? This blog will guide you through using Iro...
-
1. How to Change the Title of a Visualization A frequent task is dynamically updating the title of a visualization based on certain conditio...
