2014-09-25 38 views
1

我發現信息如何添加/刪除表格可視化中的列。 http://www.bearonspotfire.com/dynamic-tables-using-scripts-in-spotfire如何使用插入到按鈕的IronPython腳本在Spotfire中添加/刪除CrossTable可視化中的列?

from Spotfire.Dxp.Application.Visuals import VisualContent 
## we need to import this as it is an enum and we want to refer to it 
from Spotfire.Dxp.Application.Visuals import TablePlotColumnSortMode 

## get the table visualisation 
table = tableVisualisation.As[VisualContent]() 

## check what option user selected and remove column (if present) of other column(s) 
if selectedOrder == usagesName and table.TableColumns.Contains(dataTable.Columns[lastAccessedName]): 
    table.TableColumns.Remove(dataTable.Columns[lastAccessedName]) 
elif selectedOrder == lastAccessedName and table.TableColumns.Contains(dataTable.Columns[usagesName]): 
    table.TableColumns.Remove(dataTable.Columns[usagesName]) 

## add in new column assuming it isn't there already 
if not table.TableColumns.Contains(dataTable.Columns[selectedOrder]): 
    table.TableColumns.Add(dataTable.Columns[selectedOrder]) 

## set the sorting for the table 
table.SortInfos.Clear(); 
table.SortInfos.Add(dataTable.Columns[selectedOrder], TablePlotColumnSortMode.Descending) 

## changing the table resets the column size so lets fix it 
addedColumn = table.TableColumns.TryGetTableColumn(dataTable.Columns[selectedOrder])[1] 
addedColumn.Width = 120 

我需要爲交叉表可視化這樣做。

+0

我已經注意到,有可能修改ColumnAxis的表達式屬性,導致修改列的集合,所以它允許添加/刪除列,但它不是與表格可視化一樣整齊。 – 2014-09-25 20:52:57

+0

crossTable.ColumnAxis.Expression =「」 這段代碼正在修改Column Axis的內容以僅包含Clothing列。 – 2014-09-26 07:24:04

+0

表達的另一個例子是<[衣服] NEST [雜貨] NEST [玩具] NEST [購買的物品數量]>。我現在可以簡單地通過將屬性值發送到輸入文本值來獲取由工具創建的表達式。 – 2014-09-26 11:21:57

回答

0

我注意到有可能修改ColumnAxis的表達式屬性,這會導致對列集進行修改,因此它允許添加/刪除列,但它不像表格可視化那樣整齊。 - - Jacek Sierajewski 14年9月25日在20:52

crossTable.ColumnAxis.Expression =「」這段代碼是修改列軸的內容,只包含服裝列。 - Jacek Sierajewski 14年9月26日在7:24

表達的另一個例子是< [服裝]巢[雜貨]巢[玩具]巢[購買數量]>。我現在可以簡單地通過將屬性值發送到輸入文本值來獲取由工具創建的表達式。 - - Jacek Sierajewski 14年9月26日在11:21

相關問題