Introduction
The following IronPython scripts loops all visualizations in an analysis and finds the referenced data tables. This can be useful to see where the data tables are used.
Code Samples
# Copyright © 2021. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from Spotfire.Dxp.Application.Visuals import Visualization for page in Document.Pages: for vis in page.Visuals: visualization = vis.As[Visualization]() if visualization != None: print visualization.Title + ", " + visualization.Data.DataTableReference.Name
The script generates a printout like this:
Population Change by Region, World Bank Data Largest 10 Countries by Population, World Bank Data Map Chart, Another data table |
With a slight modification the script can be used with the Application Profiler tool in Spotfire Analyst to add an extra "Data Table" column to the "Visualizations" result file. Note: in this case the script will be called by the Application Profiler runtime for each visualization (with the argument "Visual"), so we don't loop the visualizations in the script. For more information about how to use Application Profiler, see the Spotfire Analyst User's Guide.
# Copyright © 2021. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from Spotfire.Dxp.Application.Visuals import Visualization visual = Visual.As[Visualization]() if visual != None: OutputColumns["Data Table"] = visualization.Data.DataTableReference.Name
You also need an extra script to add the "Visualizations" output column:
from System import Tuple, String from Spotfire.Dxp.Data import DataType OutputColumnDataTypes.Add(Tuple.Create[string,DataType]("Data Table", DataType.String))
Here is how it looks like in the Application Profiler UI:
The result is put in the added "Visualizations" column in the DataTables table:
License: TIBCO BSD-Style License
Recommended Comments
There are no comments to display.