HomepageBlogHow to show or hide labels in Tibco Spotfire using IronPython
How to show or hide labels in Tibco Spotfire using IronPython
IronPython scripts are always the favorite topic, therefore I would like to show one script, which is quite handy, especially when you try to create a clean dashboard, but still want to keep the possibility to show a lot of information. You can do a lot of things to accomplish that. What I like is to show or hide labels on certain charts.
And how to do that? You can follow my video. If you know how to add a button and where to add IronPython script, use the following snippet:
from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers,LineChart,BarChart, LabelVisibility
#loop visuals in active page
for vis in Document.ActivePageReference.Visuals:
#only line charts
#check which option is selected and choose the other one
vis.LabelVisibility = LabelVisibility.Marked
vis.LabelVisibility = LabelVisibility.All
My code is written for my special use case. I work only with the active page and with line charts. You can change it quite easily to any other chart (which can have labels). I toggle between showing all labels and showing labels when a user marks data. It is also possible to change it to LabelVisibility.None in order to not show any labels even when a user marks something.
To stay up to date with my latest videos and Spotfire tips, make sure to subscribe to our Spotfire Youtube channel. Feel free to connect with me through LinkedIn and we can discuss what’s the best BI reporting tool, and why it is the Spotfire :)
Author: Filip Prochazka
Spotfire Version: 10.10