Jump to content
We've recently updated our Privacy Statement, available here. ×

How to maximize column width in a table plot using script

Michael Kalada 2

Recommended Posts

To a certain extent, this script will help.

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Visuals import *


myTable = Document.Data.Tables["FILM"]

tablePlot = vis.As[TablePlot] ()# vis is a script parameter


for col in tablePlot.TableColumns:

if str(col.DataColumn.DataType) != "String":


myCursor = DataValueCursor.CreateFormatted(myTable.Columns[col.Name])


for row in myTable.GetRows(myCursor):

max_value = max(max_value,len(myCursor.CurrentValue))


This will calculate the length of a maximum value present in the string column and assign the column width for that column in the multiples of maximum value (since column width is measured in pixels).

This will change the width of the columns with data type as string since for other data types we do not really need to change the default width. If you want, you can modify it accordingly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...