Products | Versions |
---|---|
Spotfire Analyst |
All Versions |
Introduction:
This article demonstrates how to utilize IronPython in Spotfire Analyst to enable the AutoAddNewColumns
property for a Table visualization to automatically load newly created calculated columns for a specific data table.
Code:
import System
import Spotfire.Dxp.Application
import Spotfire.Dxp.Data
from Spotfire.Dxp.Data import *
import Spotfire.Dxp.Data.AddColumnsSettings
import Spotfire.Dxp.Data.DataTableCollection
from Spotfire.Dxp.Data.Transformations import *
from Spotfire.Dxp.Application.Visuals import VisualContent
from Spotfire.Dxp.Data.Import import *
from System.IO import Directory, Path
from System.Collections.Generic import *
from System.Collections.Generic import Dictionary
from System.Collections import ArrayList
import re
def getDataTable(tableName):
try:
# Use Contains method for data table existence check
if not Document.Data.Tables.Contains(tableName):
raise ValueError("Error - cannot find data table with name: " + tableName)
return Document.Data.Tables[tableName]
except Exception as e:
raise Exception("Error retrieving data table: " + str(e))
def getVisual(visualTitle):
for vis in Document.ActivePageReference.Visuals:
if vis.Title == visualTitle:
return vis.As[VisualContent]()
raise Exception("Error - cannot find visual: " + visualTitle)
# Get the visual and data table
vis = getVisual("Dataset with issues")
data_table = getDataTable("Dataset with issues")
vis.AutoAddNewColumns = True
print("AutoAddNewColumns enabled and data table refreshed for Dataset with issues table")
Conclusion:
This updated script shows how to enable AutoAddNewColumns
which allows you to load newly created calculated columns in a visualization using IronPython., Remember to modify the script with your specific visual and data table names to implement this functionality for your analysis needs.
Specific API References for the script:
-
AutoAddNewColumns
: https://docs.tibco.com/pub/doc_remote/sfire-analyst/12.0.0/doc/api/TIB_sfire-analyst_api/Index.aspx
Comments
0 comments
Please sign in to leave a comment.