Product: TIBCO Spotfire®
How to read marked values in a Treemap visualization and write them to a document property using an IronPython script.
Product: TIBCO Spotfire (desktop client / Analyst / Professional)
Version: All Supported Versions
OS: All Supported Operating Systems
--------------------
Sample IronPython script showing how to read marked items from a Treemap visualization and write them to a document property.
The following is a sample script that shows how to read marked items from a Treemap visualization and write them to a document property. Update the dataTable, markingName and columnName in the getSelection() function call to match the data table, marking name, and column names in your analysis file.
#####################################################
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection
from Spotfire.Dxp.Data import DataValueCursor
#####################################################
#Function that returns marked values from table
def getSelection(dataTable,markingName,columnName):
values=DataValueCursor.CreateFormatted(dataTable.Columns[columnName])
selection=Document.Data.Markings[markingName].GetSelection(dataTable).AsIndexSet()
returnList = []
for item, indexSet in enumerate(selection):
for index, row in enumerate(dataTable.GetRows(values)):
if indexSet==index:
returnList.append(values.CurrentValue)
return returnList
#####################################################
markedItems = getSelection(dataTable=Document.Data.Tables
["dataTableName"],markingName="MarkingName",columnName="Column-Region")
#Write List to Document Property
Document.Properties["docprop"] = markedItems
#####################################################
Disclaimer:
The script code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the script in accordance with your implementation specifications that best suit your business requirements. Refer to the API reference(s) cited in this article for usage of the classes and methods used in the script.
https://docs.tibco.com/pub/doc_remote/spotfire/7.0.1/doc/api/
IronPython, marking, document property, treemap, GetSelection, GetRows
Comments
0 comments
Article is closed for comments.