IPython 脚本在 Spotfire 客户端而非 Spotfire Web 上运行
IPython script runs on Spotfire Client, not Spotfire Web
我有以下 python 脚本(减少了,但其余部分执行类似的操作):
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)))'
依此类推。
此脚本(和其他脚本)运行 在客户端中完全没问题。它在网络中没有 运行。 Web 会说正在处理,然后说准备就绪(在左下角),同时什么都不做(没有错误,什么也没有)。我在同一分析中使用的其他一些脚本 运行 非常好。
我知道出于安全原因,网络上的 IPython 脚本存在一些限制,但我只是构建一个 table。这个不能限制可以吗? Web 服务器日志未捕获任何异常。
我们使用的是 Spotfire 7.6
更新: 似乎是因为:if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':
。不幸的是,这是因为 Web 和客户端之间的 ID 不同。知道我的标题也改变了,关于我可以参考可视化的内容的任何想法在客户端和 Web 之间保持不变吗?
您能否找出当前视觉对象上的索引并以此方式引用它?
试试这样的东西:
替换此行:
if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':
与:
if viz[0] (or whatever the index is)
不确定这是否是您想要的,但我相信这将为您提供一种无需使用 ID 即可引用可视化的方法。
因为 Spotfire 会根据它是在网络播放器上还是在客户端上更改 vis 的 ID,所以脚本没有按预期工作。我只是将 vis 作为参数添加,而不是依赖脚本来定位正确的 vis。当vis的名称改变时,参数会正确更新,因此它仍然是动态的。
我有以下 python 脚本(减少了,但其余部分执行类似的操作):
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)))'
依此类推。
此脚本(和其他脚本)运行 在客户端中完全没问题。它在网络中没有 运行。 Web 会说正在处理,然后说准备就绪(在左下角),同时什么都不做(没有错误,什么也没有)。我在同一分析中使用的其他一些脚本 运行 非常好。
我知道出于安全原因,网络上的 IPython 脚本存在一些限制,但我只是构建一个 table。这个不能限制可以吗? Web 服务器日志未捕获任何异常。
我们使用的是 Spotfire 7.6
更新: 似乎是因为:if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':
。不幸的是,这是因为 Web 和客户端之间的 ID 不同。知道我的标题也改变了,关于我可以参考可视化的内容的任何想法在客户端和 Web 之间保持不变吗?
您能否找出当前视觉对象上的索引并以此方式引用它?
试试这样的东西: 替换此行:
if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':
与:
if viz[0] (or whatever the index is)
不确定这是否是您想要的,但我相信这将为您提供一种无需使用 ID 即可引用可视化的方法。
因为 Spotfire 会根据它是在网络播放器上还是在客户端上更改 vis 的 ID,所以脚本没有按预期工作。我只是将 vis 作为参数添加,而不是依赖脚本来定位正确的 vis。当vis的名称改变时,参数会正确更新,因此它仍然是动态的。