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.

Change Cross Table properties

#Script to change row header, cell widths and row sorting
#viz is a Cross Table visualization script parameter
from Spotfire.Dxp.Application.Visuals import CrossTablePlot, CategoryKey 

from Spotfire.Dxp.Data import SortOrder 

#Get a reference of the cross table from viz param
crossTable = viz.As[CrossTablePlot]()

#Change the second RowHeader
crossTable.RowHeaderWidths[1]=150

#Resize cells
crossTable.CellWidth=100

#sort 

#Change sorting
categoryKey = CategoryKey("cellValueColumnToSort") 
crossTable.SortRowsCategory = categoryKey 
crossTable.SortColumnsOrder = SortOrder.Descending
crossTable.SortRowsOrder = SortOrder.Descending

#Reset sorting
crossTable.SortRowsCategory  = None

See CrossTablePlot Members


1 comment:

Mohanvel Rajendran said...

Hi,

I have applied the same script below where i need to sort column "RefrenceDate_Month" but it is not getting sorted

#Script to change row header, cell widths and row sorting
#viz is a Cross Table visualization script parameter
from Spotfire.Dxp.Application.Visuals import CrossTablePlot, CategoryKey

from Spotfire.Dxp.Data import SortOrder

#Get a reference of the cross table from viz param
crossTable = viz.As[CrossTablePlot]()

#Change the second RowHeader
crossTable.RowHeaderWidths[1]=150

#Resize cells
crossTable.CellWidth=100

#Change sorting
categoryKey = CategoryKey("RefrenceDate_Month")
crossTable.SortRowsCategory = categoryKey
crossTable.SortColumnsOrder = SortOrder.Descending