Spotfire: Show/Hide Legend and Switch View Type

Posted on Updated on

In some cases (for ex. Trellis view), to get more visualization space, we could simply hide the legend.

For this, on change of View Type (using a drop down property control – ViewType), I am invoking a script to show or hide the legend.

Below, creating the property control ViewType:

ShowHide_Legend_4

Script executed on change of drop down value: ShowHide_Legend_3

IronPython Code:

from Spotfire.Dxp.Application import Visuals
from Spotfire.Dxp.Application.Visuals import LineChart
from Spotfire.Dxp.Application.Visuals import Legend
for vis in Application.Document.ActivePageReference.Visuals:
if vis.Title == "Sales - Trellis View":
vis.As[LineChart]().Legend.Visible = False
if vis.Title == "Sales - Full View":
vis.As[LineChart]().Legend.Visible = True

In Full View, Color by legend is shown. ShowHide_Legend_2

Disabling the legend in Trellis view.ShowHide_Legend_1

Analyses (dxp) for reference from TibCommunity

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s