Data

These IronPython scripts below show how to modify any of the Table visualization settings found on the Data tab of the Table 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 Table Data Tab Options:

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

  1. Change the data table
  2. Change the marking
  3. Limit data using specific markings
  4. Change “Rows must be included in:” option
  5. Change “If no items are marked in the master visualization, show:” option
  6. Change text for the “Message on empty background” option
  7. Limit data using specific filterings
  8. Limit data using an expression
from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Data import *

myVis = myVis.As[Visualization]()


# 1. Change the data table
newTable = Document.Data.Tables.Item['New Data Table Name']
myVis.Data.DataTableReference = newTable


# 2. Change the marking
newMarking = Document.Data.Markings["New Marking Name"]
myVis.Data.MarkingReference = newMarking


# 3. Limit data using specific markings
myVis.Data.Filterings.Add(Document.Data.Markings["Added Marking"])  #Add marking
myVis.Data.Filterings.Remove(Document.Data.Markings["Removed Marking"])  #Remove marking


# 4. Change "Rows must be included in:" option
# Equivalent to "All markings (AND)" option:
myVis.Data.MarkingCombinationMethod = DataSelectionCombinationMethod.Intersection
# OR
# Equivalent to "Any markings (OR)" option:
myVis.Data.MarkingCombinationMethod = DataSelectionCombinationMethod.Union


# 5. Change "If no items are marked in the master visualization, show:" option
# Equivalent to "All data" dropdown selection:
myVis.Data.LimitingMarkingsEmptyBehavior = LimitingMarkingsEmptyBehavior.ShowAll
# OR
# Equivalent to "Empty Visualization" dropdown selection:
myVis.Data.LimitingMarkingsEmptyBehavior = LimitingMarkingsEmptyBehavior.ShowEmpty
# OR
# Equivalent to "Message on empty background" dropdown selection:
myVis.Data.LimitingMarkingsEmptyBehavior = LimitingMarkingsEmptyBehavior.ShowMessage


# 6. Change text for the "Message on empty background" option
myVis.Data.LimitingMarkingsEmptyMessage = "New Message Text"


# 7. Limit data using specific filterings
# Add or remove specific filters:
myVis.Data.Filterings.Add(Document.Data.Filterings["Added Filter"]) #Add filter
myVis.Data.Filterings.Remove(Document.Data.Filterings["Removed Filter"]) #Remove filter
# Uncheck "Use the current filtering from the page (Default)" checkbox:
myVis.Data.UseActiveFiltering = False


# 8. Limit data using an expression
myVis.Data.WhereClauseExpression = "[State] = 'Texas'"
# OR - To stop limiting:
myVis.Data.WhereClauseExpression = ""
Welcome!

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