代码之家  ›  专栏  ›  技术社区  ›  Mark P.

IPython脚本在Spotfire客户端上运行,而不是在Spotfire Web上运行

  •  1
  • Mark P.  · 技术社区  · 7 年前

    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)))'
    

    这个脚本(和其他脚本)在客户端运行得非常好。它不在网络上运行。网络会说“正在处理”,然后说“准备就绪”(在左下角),同时什么都不做(没有错误,什么都不做)。我在同一分析中使用的其他几个脚本运行得非常好。

    我们在聚光灯下7.6

    更新: if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79': 不幸的是,这是因为Web和客户端的ID不同。知道我的标题也变了,关于我可以引用什么可视化的想法在客户端和web之间保持不变吗?

    2 回复  |  直到 7 年前
        1
  •  1
  •   Mark P.    7 年前

    由于Spotfire会根据vis是否在web播放器和客户端上而更改其ID,因此脚本没有按预期工作。我只是将vis添加为一个参数,而不是依赖脚本来定位正确的vis。当vis的名称更改时,参数会正确更新,因此它仍然是动态的。

        2
  •  0
  •   Jamey Copeland    7 年前

    尝试以下操作:

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

    使用:

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