Search code examples
ironpythonspotfire

Spotfire-IronPython: Fetch visualization from Document.Pages


Say I have a loop through every page is Spotfire, how can I fetch the visualization per page?

for pg in Document.Pages:
    print pg.Title
    myPanel = pg.ActiveFilteringSelectionReference
    print '\t' + myPanel.Name
    # How to fetch vis from a Page? Assume each page has only one visualization
    viz=vis.As[ScatterPlot]()

Best Regards,


Solution

  • Something like this?

    #loop through all pages and visualizations, and print the Type of each visualization
    for p in Document.Pages:
       print (p.Title)
       Document.Properties["scriptOutput"]+=p.Title+'\n'
       for v in p.Visuals: 
          print ('-' + v.Title + '('+ v.TypeId.Name +')')
          Document.Properties["scriptOutput"]+='-'+v.Title+'('+v.TypeId.Name+')\n'
    

    You have to set up Document Properties to show the results, unless you are in the console and reading the output.

    Please see this page for more information: https://community.tibco.com/wiki/loop-through-pages-and-visualization-tibco-spotfirer-using-ironpython-scripting