通过IPython在viz上设置标记

时间:2017-06-07 12:47:07

标签: spotfire

与此问题类似,但不完全相同:Spotfire: "limit data using markings" by python script

我的脚本目前看起来像这样:

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

#Remove the current Marking Filter
for filtering in vis.As[VisualContent]().Data.Filterings:
    vis.As[VisualContent]().Data.Filterings.Remove(filtering)

#Set the new Marking Filter
vis.As[VisualContent]().Data.Filterings.Add(Document.Data.Markings["Marking (4)"])

#Set the new Marking
#Need code here

我需要为可视化设置一个新标记,以便我可以将其用于另一个可视化。具体来说,我需要设置此框:enter image description here

更新 我可以使用这段代码设置标记:

vc = vis.As[VisualContent]()
marking = vc.Data.MarkingReference
marking.SetSelection(marking.GetSelection(dataTable),dataTable)

这会标记我想要的记录,但由于它不会更改“标记”框中的设置,因此不会让我进一步向下钻取(过滤到与设置相同的标记)。

1 个答案:

答案 0 :(得分:0)

这个脚本最终对我有用:

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

if Document.Properties['KPIHierLevel'] == '<[SBA_NAME] NEST [MARKET_NAME]>':
    Document.Properties['KPIHierLevel'] = '<[MARKET_NAME] NEST [BRAND]>'
    for filtering in vis.As[VisualContent]().Data.Filterings:
        vis.As[VisualContent]().Data.Filterings.Remove(filtering)
    vis.As[VisualContent]().Data.Filterings.Add(Document.ActiveMarkingSelectionReference)
    vis.As[VisualContent]().Data.MarkingReference = (Document.Data.Markings["Marking (7)"])
elif Document.Properties['KPIHierLevel'] == '<[MARKET_NAME] NEST [BRAND]>':
    Document.Properties['KPIHierLevel'] = '<[BRAND] NEST [PRODUCT]>'
    for filtering in vis.As[VisualContent]().Data.Filterings:
        vis.As[VisualContent]().Data.Filterings.Remove(filtering)
    vis.As[VisualContent]().Data.Filterings.Add(Document.ActiveMarkingSelectionReference)
    vis.As[VisualContent]().Data.MarkingReference = (Document.ActiveMarkingSelectionReference)

我还创建了一个与此类似的重置脚本,但将标记设置回标记(7)以外的其他内容。