Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer



If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

Create a Visualization Programatically

Bar Chart Example

#Creates a BarChart visualization from the default table
from Spotfire.Dxp.Application.Visuals import BarChart

#gets a reference to the default data table
#dataTable = Document.Data.Tables["yourTable"]
dataTable = Document.Data.Tables.DefaultTableReference

#Creates a BarChart 
chart = Application.Document.ActivePageReference.Visuals.AddNew[BarChart]()

#Configure the BarChart 
chart.Data.DataTableReference = myDataTable
chart.Title = "Test Bar Chart1"
chart.XAxis.Expression = "<"+str(dataTable.Columns[1])+">"
chart.YAxis.Expression = "Count(" + str(dataTable.Columns[0]) + ")"
chart.Legend.Visible = False



Table Plot Example

#Creates a TablePlot visualization from the default table
from Spotfire.Dxp.Application.Visuals import TablePlot

#gets a reference to the (default) data table
#dataTable = Document.Data.Tables["yourTable"]
dataTableReference = Document.Data.Tables.DefaultTableReference

#Creates a TablePlot
tablePlot = Application.Document.ActivePageReference.Visuals.AddNew[TablePlot]()

#Configure the TablePlot
tablePlot.Data.DataTableReference = dataTableReference
tablePlot.Title = "${DataTable.DisplayName}"

Duplicate a Visualization
myPage.Visuals.AddDuplicate(vis)  #vis is a script parameter



No comments: