ironpython - Spotfire IronPython 脚本滚动过滤器并每一步更新可视化(通过日期范围播放按钮)

标签 ironpython spotfire

大家早上好,

我已经在这个问题上工作了几天,但我找不到解决办法。我已经研究并谷歌搜索无济于事。任何帮助/见解将不胜感激。我正在尝试创建一个按钮,单击该按钮时将自动通过日期过滤器(比如说从 1/1/15 开始)并通过 1/2 -1/5 更新带有新过滤的标记层的 map ,因为它逐步通过功能。我已经让过滤器逐步通过 1/1-1/5;但是,它不会随着 map 的进展而更新 map 可视化,因此用户看到的只是从 1/1 跳转到 1/5,中间有一个暂停(我每一步都有一个 sleep 计时器)。我已经包含了下面的代码,我只是在学习 IronPython,我不确定我需要调用什么来刷新可视化。 Visualization.Refresh() 不起作用。非常感谢!

import Spotfire.Dxp.Application.Filters as filters
import Spotfire.Dxp.Application.Filters.ItemFilter
import time
from Spotfire.Dxp.Application.Filters import FilterTypeIdentifiers
from Spotfire.Dxp.Data import DataProperty, DataType, DataPropertyAttributes, DataPropertyClass
from Spotfire.Dxp.Application.Visuals import MarkerLayer

myPanel = Document.ActivePageReference.FilterPanel
myFilter= myPanel.TableGroups[2].GetFilter("Date (Daily)")

myFilter.FilterReference.TypeId = FilterTypeIdentifiers.ItemFilter
itemFilter = myFilter.FilterReference.As[filters.ItemFilter]()

whichCol = itemFilter.DataColumnReference
count = 0
while count < 5:

    count = count +1
    if (whichCol.Properties.PropertyExists("CurrentStep") == False):
        myProp = DataProperty.CreateCustomPrototype("CurrentStep",0,DataType.Integer,DataPropertyAttributes.IsVisible|DataPropertyAttributes.IsEditable)
        Document.Data.Properties.AddProperty(DataPropertyClass.Column, myProp)
        whichCol.Properties.SetProperty("CurrentStep",0)
        Document.Properties["DateTest"] = "1/1/15" 
        time.sleep(1)

    else:
        time.sleep(1)
        whichVal = whichCol.Properties.GetProperty("CurrentStep")
        #print whichVal
        #print itemFilter.Values.Count
        if (whichVal == itemFilter.Values.Count):
            whichCol.Properties.SetProperty("CurrentStep",0)
            Document.Properties["DateTest"] = "1/1/15"
        else:
            itemFilter.Value = itemFilter.Values.Item[whichVal]
            whichCol.Properties.SetProperty("CurrentStep",whichVal+1)
            Document.Properties["DateTest"] =  itemFilter.Value

最佳答案

根据我的理解,这不能使用 IronPython 来完成。引用 niko 对我的类似问题的回答:Animating Data Changes in Tibco Spotfire
“IronPython 引擎会锁定 Spotfire,直到执行完成。”
因此,我以与尝试为散点图制作动画的尝试相同的方式解决了您的问题……使用 JS 而不是 IP。由于我无权访问您正在使用的数据集,因此我使用了一个随机数据集,该数据集的 id 列从 1 到 100 而不是日期。我设置了一个数据限制自定义表达式 [id]=${FilterValue},其中 {FilterValue} 是一个文档属性,整数类型设置为默认值 1。然后我使用以下 HTML 和 JS 从 1 迭代该属性- 100。注意:我在 SF 7.0 中使用“dark”视觉主题进行了此操作。在“light”主题中,或者在 SF 6.X 中,您需要为 HTML 和 JS 中的按钮定义不同的颜色。根据要求,我可以将 .dxp 上传到 dropbox 并在此处共享。我希望这有帮助。
HTML:

<div id="button1" style="padding: 2px; border: 3px outset grey; border-image: none; text-decoration: none; cursor:pointer;    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;position:relative;
    user-select: none;width:13em;display:block;;"><font color="white" size="2" style="margin:0px 0px 0px 1px">Cycle Filters</font>
</div>


<div id='FilterValue' style='display:none'>
<SpotfireControl id="b986fa43508a484da22f6b42d510061f" />
</div>

JS:
var button=document.getElementById(button1);
var doc=document.getElementById(doc);

t=0;
var CycleFilters = function(){
    if (t<=100)
    {       
        $("#FilterValue input").val(t).blur();
        t+=1;
    }

}




var mouseDown=function()
{
   button.style.background="#202020";
   button.style.border="3px inset grey";
   button.style.padding="4px 0px 0px 4px";
   button.onmouseup=mouseUp;
   button.onmouseout=mouseOut;
   button.onmouseover=mouseOver;

}

function mouseUp() {
    button.style.background="none";
    button.style.border="3px outset grey";
    button.style.padding="2px 2px 2px 2px";
    button.onmouseover=mouseOver2;
    t=0.00;
    setInterval(CycleFilters,1000)
    //document.getElementById('mySpotfireControlx').firstChild.value = 20;
    //$("#mySpotfireControlx input").val(20).blur();
    //document.getElementById('mySpotfireControly').firstChild.value = 10;
    //$("#mySpotfireControly input").val(10).blur();



}
function mouseOut()
{
    button.style.background="none";
    button.style.border="3px outset grey";
    button.style.padding="2px 2px 2px 2px";
}
function mouseOver()
{   
    button.style.background="#202020";
    button.style.border="3px inset grey";
    button.style.padding="4px 0px 0px 4px";
}
function mouseOver2()
{
    button.onmousedown=mouseDown;
}


button.onmouseover=mouseOver2;
button.onmouseout=mouseOut;

document.documentElement.addEventListener('mouseup', function(e)
{
button.onmouseover=mouseOver2;
})

关于ironpython - Spotfire IronPython 脚本滚动过滤器并每一步更新可视化(通过日期范围播放按钮),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29123962/

相关文章:

.net - F# 与 IronPython : When is one preferred to the other?

ironpython - 如何在 IronPython 中使用 C# dll

datatable - Spotfire - 如何对数据表列中唯一的未过滤值进行属性控制

python - 使用 Spotfire 的日期过滤器和相对日期输入框

ironpython - Spotfire 脚本不受信任

python - IronPython 2.7.1 beta 2 的外籍人士

python - 我可以将 IronPython 视为 C# 的 Pythonic 替代品吗?

c# - 如何创建仅向 C# 返回单个值的 IronPython 文件?

spotfire - SQL - 在最后一个正斜杠之后提取所有内容

ironpython - 用于在 spotfire 中创建过滤器的 Iron python 脚本