Jump to content
  • How to read marked values in a Treemap visualization and write them to a document property in Spotfire® using IronPython


    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.

    Introduction

    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.

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    #####################################################
    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
    #####################################################
     

    Note that the document property must be of type 'String List'.

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...