2017-08-07 80 views
1

我有以下的python腳本(減少了,但它的其餘部分進行類似的行動):IPython的腳本運行在Spotfire中的客戶端,不Spotfire中的Web

from Spotfire.Dxp.Application.Visuals import * 
from Spotfire.Dxp.Data import * 

#assign default values for prompts if needed 
if Document.Properties['cannedKPISelected'].isspace(): 
    Document.Properties['cannedKPISelected'] = 'GS' 
if Document.Properties['cannedTimeSelected'].isspace(): 
    Document.Properties['cannedTimeSelected'] = 'Month' 

#determine which type of viz needs displayed based on a flag in the data 
tableName='PrimaryDataTable' 
columnToFetch='displayPercentageFlag' 
activeTable=Document.Data.Tables[tableName] 
rowCount = activeTable.RowCount 
rowsToInclude = IndexSet(rowCount,True) 
cursor1 = DataValueCursor.CreateFormatted(activeTable.Columns[columnToFetch]) 
for row in activeTable.GetRows(rowsToInclude,cursor1): 
    rowIndex = row.Index 
    percentageNeeded = cursor1.CurrentValue 
    break 

#create consumer report 
for page in Document.Pages: 
    for viz in page.Visuals: 
     if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79': 
      if Document.Properties['coffeeReportSelected'] == 'Brand Category by Market': 
       if Document.Properties['cannedKPISelected'] == 'GS' and Document.Properties['cannedTimeSelected'] == 'Month' and percentageNeeded == 'Y': 
        visualContentObject = viz.As[VisualContent]() 
        visualContentObject.MeasureAxis.Expression = 'Sum([GS Month]) as [GS Mnth]' 
        visualContentObject.RowAxis.Expression = '<[BRAND] as [Brand Category] NEST [MARKET] as [Market]>' 
        visualContentObject.ColumnAxis.Expression = '<[Axis.Default.Names] as [Measure Names]>' 
        visualContentObject.ShowColumnGrandTotal = True 
        visualContentObject.ShowColumnSubtotals = True 
        visualContentObject.ShowRowGrandTotal = False 
        visualContentObject.Title = 'Monthly GS by Brand, Market' 
        visualContentObject.Data.WhereClauseExpression = '[NAME] = "CANADA"' 
        visualContentObject.CellWidth = 125 
        Document.Properties['cannedReportHideRows'] = 'Sum(Abs(SN([GS Month],0)))' 
       elif Document.Properties['cannedKPISelected'] == 'GS' and Document.Properties['cannedTimeSelected'] == 'Quarter' and percentageNeeded == 'Y': 
        visualContentObject = viz.As[VisualContent]() 
        visualContentObject.MeasureAxis.Expression = 'Sum([GS Quarter]) as [GS Qtr]' 
        visualContentObject.RowAxis.Expression = '<[BRAND] as [Brand] NEST [MARKET] as [Market]>' 
        visualContentObject.ColumnAxis.Expression = '<[Axis.Default.Names] as [Measure Names]>' 
        visualContentObject.ShowColumnGrandTotal = True 
        visualContentObject.ShowColumnSubtotals = True 
        visualContentObject.ShowRowGrandTotal = False 
        visualContentObject.Title = 'Quarterly GS by Brand, Market' 
        visualContentObject.Data.WhereClauseExpression = '[NAME] = "CANADA"' 
        visualContentObject.CellWidth = 125 
        Document.Properties['cannedReportHideRows'] = 'Sum(Abs(SN([GS Quarter],0)))' 

等等等等等等。

這個腳本(和其他)在客戶端運行得很好。它不在網上運行。網絡會說處理,然後說準備好(在左下角),同時什麼也不做(沒有錯誤,什麼都不做)。我在同一分析中使用的其他幾個腳本運行得非常好。

爲了安全起見,我知道網上的IPython腳本存在一些限制,但我只是建立一個表。這不能被限制嗎? Web服務器日誌沒有捕獲任何不尋常的東西。

我們對的Spotfire 7.6

UPDATE:這似乎是由於這樣的:if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':。這是因爲遺憾的是Web和Client之間的ID不同。瞭解我的標題更改,關於我可以引用可視化的任何想法在客戶端和Web之間保持不變?

回答

1

由於Spotfire根據其是否位於網絡播放器或客戶端上來更改vis的ID,因此該腳本未按預期工作。我只是將vis添加爲參數,而不是依靠腳本去找到正確的vis。當vis的名稱改變時,該參數被正確更新,因此它仍然是動態的。

0

你能找出當前視覺上的索引是什麼嗎?

試着這麼做: 替換此行:

if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79': 

有了:

if viz[0] (or whatever the index is) 

不知道這是你腦子裏想的是什麼,但我相信這會給你一個辦法參考可視化而無需使用ID。