Spotfire IronPython脚本可滚动浏览过滤器并更新每个步骤的可视化效果(日期范围内的播放按钮) [英] Spotfire IronPython Script to Scroll through a Filter and Update a Visualization Each Step (Play Button through Date Ranges)

查看:72
本文介绍了Spotfire IronPython脚本可滚动浏览过滤器并更新每个步骤的可视化效果(日期范围内的播放按钮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家早上好

我已经在这个问题上工作了几天,但找不到解决方法.我已经研究过,但没有用谷歌搜索.任何帮助/见解将不胜感激.我正在尝试创建一个按钮,当单击该按钮时,它将自动通过日期过滤器(从1/1/15开始),并通过1/2 -1/5,随着新过滤的标记层逐步通过,从而更新地图功能.我已经使过滤器逐步通过了1/1-1/5;但是,它不会随着进度的进行而更新地图的可视化效果,因此用户看到的只是从1/1跳到1/5,中间有一个暂停(每个步骤都有一个睡眠计时器).我已经包含了以下代码,我只是在学习IronPython,并且不确定刷新可视化需要调用什么. Visualization.Refresh()不起作用.非常感谢!

I've been working on this issue for a couple of days and I can't figure out a fix. I've researched and googled to no avail. Any help/insight would be greatly appreciated. I am trying to create a button that when clicked will automatically go through a Date filter (starting on 1/1/15 say) and go through 1/2 -1/5 updating a map with the newly filtered marker layer as it steps through the function. I have gotten the filter to step through 1/1-1/5; however, it doesn't update the map visualization as it progresses so all the user sees is a jump from 1/1 to 1/5 with a pause in between (I have a sleep timer in for each step). I've included the code below, I'm just learning IronPython and I'm not sure what I need to call to refresh a visualization. Visualization.Refresh() does not work. Thanks so much!

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来完成.尼科从他对类似问题的回答中引用了我的话:在Tibco Spotfire中动画化数据更改 "IronPython引擎会锁定Spotfire,直到执行完成为止." 因此,我以与尝试制作散点图动画相同的方式来处理您的问题...使用JS而不是IP.由于我无权访问正在使用的数据集,因此我使用了一个随机数据集,其id列的范围是1-100(而不是日期).我设置了一个数据限制自定义表达式[id] = $ {FilterValue},其中{FilterValue}是一个文档属性,其整数类型设置为默认值1.然后,我使用以下HTML和JS从1迭代该属性. 100注意:我在SF 7.0中使用深色"视觉主题进行了此操作.在浅色"主题或SF 6.X中,您将需要在HTML和JS中为按钮定义不同的颜色.根据要求,我可以将.dxp上传到保管箱并在此处共享.我希望这有帮助. HTML:

From my understanding, this cannot be done using IronPython. Quoting niko from his answer to a similar question I had: Animating Data Changes in Tibco Spotfire "the IronPython engine locks Spotfire until execution is completed." So I approached your issue in the same fashion I approached my attempt to animate a scatterplot... using JS instead of IP. Since I don't have access to the dataset you are working with, I used a random dataset with an id column that ran from 1-100 instead of dates. I set a data limiting custom expression [id]=${FilterValue} where {FilterValue} is a document property with type of integer set to a default value of 1. I then used the following HTML and JS to iterate the property from 1-100. Note: I did this in SF 7.0 using the "dark" visual theme. In the "light" theme, or in SF 6.X, you will need to define different colors for the button in both the HTML and JS. Upon request I can upload the .dxp to dropbox and share it here. I hope this helps. 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;
})

这篇关于Spotfire IronPython脚本可滚动浏览过滤器并更新每个步骤的可视化效果(日期范围内的播放按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆