Trellis

These IronPython scripts below show how to modify any of the Bar Chart visualization settings found on the Trellis tab of the Bar Chart Properties dialog box in the Spotfire user interface.
Note

In each of the scripts below, it is assumed that the MyVis variable references the targeted visualization. See here for more information about referencing visualizations.

Change Bar Chart Trellis Tab Options:

This IronPython script shows how to change the following, in order from top to bottom in the user interface:

  1. Trellis by rows and columns or trellis by panels
  2. Set the “Rows” custom expression
  3. Set the “Columns” custom expression
  4. Set the “Pages” custom expression
  5. Set the “Split by” custom expression
  6. Set the manual layout max number of rows and columns
from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[Visualization]()


# 1. Trellis by rows and columns or trellis by panels
myVis.Trellis.TrellisMode = TrellisMode.RowsColumns
# OR
myVis.Trellis.TrellisMode = TrellisMode.Panels


# 2. Set the "Rows" custom expression ("Rows and columns" trellis type)
myVis.Trellis.RowAxis.Expression = "<[My Column 1]>"


# 3. Set the "Columns" custom expression ("Rows and columns" trellis type)
myVis.Trellis.ColumnAxis.Expression = "<[My Column 2]>"


# 4. Set the "Pages" custom expression ("Rows and columns" trellis type)
myVis.Trellis.PageAxis.Expression = "<[My Column 3]>"


# 5. Set the "Split by" custom expression ("Panels" trellis type)
myVis.Trellis.PanelAxis.Expression = "<[My Column 4]>"


# 6. Set the manual layout max number of rows and columns ("Panels" trellis type)
myVis.Trellis.ManualLayout = True
myVis.Trellis.ManualRowCount = 3
myVis.Trellis.ManualColumnCount = 5
Note

If you aren't sure how to write a specific custom expression correctly from scratch, start by building the expression interactively using the Spotfire user interface. Once your custom expression is working correctly, right-click on the custom expression input box selector(s) and choose Custom Expression. You can then copy the expression shown into your IronPython script.

Get or Set the Current Trellis Page

This IronPython script allows you to move to any trellis page programmatically or determine which trellis page the user is currently viewing.

Note that trellis pages have a zero-based index, so the first page is 0, the second page is 1, etc.

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[Visualization]()

# Move to a specific trellis page:
myVis.Trellis.ActivePageIndex = 0  #1st page
# OR, for example,
myVis.Trellis.ActivePageIndex = 5  #6th page

# Get the current trellis page:
print myVis.Trellis.ActivePageIndex

# Get the current total number of trellis pages:
print myVis.Trellis.PageCount

# Move to the last trellis page:
myVis.Trellis.ActivePageIndex = myVis.Trellis.PageCount - 1
Welcome!

The purpose of this website is to provide a comprehensive, accurate, and efficient IronPython reference for Spotfire developers.