Script di esempio IronPython
Questo paragrafo elenca diversi script di esempio che possono essere eseguiti selezionando i collegamenti di azione o i pulsanti dell'area di testo.
Per ulteriori esempi e istruzioni dettagliate su come aggiungere script a un'area di testo, vedere Aggiunta di un'azione script a un'area di testo o a un elemento della visualizzazione; vedere anche IronPython Scripting in Spotfire nella Community per trovare molti altri esempi e guide sull'uso degli script in Spotfire.
Suggerimento: Se il parametro espressione è correlato a un valore della proprietà stringa, è possibile utilizzare un controllo proprietà (ad esempio un elenco a discesa) con diverse alternative di espressioni predefinite in modo da creare un'analisi in cui si possano assegnare facilmente espressioni complesse agli assi della visualizzazione. Vedere Aggiunta di un controllo proprietà a un'area di testo per informazioni su come aggiungere controlli di proprietà.
Aggiornare i calcoli, i dati su richiesta e le funzioni dati
# Example script that refreshes a table driven by
# a calculation, a data function
# or an information link loaded on demand.
# The script takes a parameter "table" of type DataTable
if table.IsRefreshable and table.NeedsRefresh:
table.Refresh()
Aggiungere colonne da un file SBDF a una tabella dati nel documento corrente
# This script adds columns from an sbdf file to a data
table
# in the current document.
#
# Four arguments are expected:
# table - The data table in the current document
# that columns will be added to.
# path - The path to the sbdf file with columns to add.
# ColumnNameInTable - A column in the data table.
# ColumnNameInFile - A matching column in the sbdf file.
# The columns are used to join new data to the current data.
from Spotfire.Dxp.Data.Import import SbdfFileDataSource
from Spotfire.Dxp.Data import AddColumnsSettings, JoinType,
DataColumnSignature, DataType
# Create the join condition map. The column with the name
# specified in ColumnNameInTable from the current data table
# will be joined with ColumnNameInFile in the sbdf file.
columnInTable =
DataColumnSignature(table.Columns[ColumnNameInTable])
columnInFile = DataColumnSignature(ColumnNameInFile,
DataType.String)
joinConditionMap = {columnInTable : columnInFile}
ignoredCols = [ ]
settings = AddColumnsSettings( joinConditionMap,
JoinType.InnerJoin, ignoredCols)
ds = SbdfFileDataSource(path)
table.AddColumns(ds, settings)
Utilizzare una visualizzazione specifica ("Visual") come input e in seguito modificare l'asse X della visualizzazione
# Sets the value of the XAxis Expression of a visual.
# This script expects two arguments:
# visual - The visual to the set the X-axis expression on.
# expression - The expression to set.
from Spotfire.Dxp.Application.Visuals import VisualContent
# Get the content of the visual. Use the most general type
# so that the script works for all VisualContent classes that
# have an X-axis property.
vc = visual.As[VisualContent]()
vc.XAxis.Expression = expression
Argomento principale: Aggiunta di un'azione script a un'area di testo o a un elemento della visualizzazione