4

大家早上好,

我已经在这个问题上工作了几天,但我无法找到解决办法。我已经研究和谷歌搜索无济于事。任何帮助/见解将不胜感激。我正在尝试创建一个按钮,单击该按钮时将自动通过日期过滤器(例如从 1/1/15 开始)并通过 1/2 -1/5 使用新过滤的标记层更新地图,因为它逐步通过功能。我已经让过滤器逐步通过 1/1-1/5;但是,它不会在地图可视化过程中更新,所以用户看到的只是从 1/1 到 1/5 的跳跃,中间有一个暂停(我在每个步骤中都有一个睡眠计时器)。我已经包含了下面的代码,我只是在学习 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
4

2 回答 2

5

据我了解,这不能使用 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 中使用“深色”视觉主题进行了此操作。在“light”主题或 SF 6.X 中,您需要在 HTML 和 JS 中为按钮定义不同的颜色。根据要求,我可以将 .dxp 上传到保管箱并在此处分享。 我希望这有帮助。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;
})
于 2015-09-11T14:33:46.730 回答
2

在此处输入图像描述

您可以在此处查看有关如何为 Spotfire 可视化设置动画的详细信息


  1. 创建一个动作控制按钮,应用过滤器设置、书签或使用 ironPython
  2. 创建一个反复触发动作控制按钮按钮的脚本(根据示例,可以选择启动和停止按钮)

html

<div id='spotfireButton' style='display:none'>
 <SpotfireControl id="y0ursp07f1r3c0n7r01IdH3r3" />
</div>

<SPAN id=startButton>Start</SPAN>
<SPAN id=stopButton style='display:none'>Stop</SPAN>

Python

#changes RangeFilter low and high bounds in small increments
from Spotfire.Dxp.Application.Filters import RangeFilter, ValueRange
from Spotfire.Dxp.Data import IndexSet

#get a reference to the range filter in question
filt=Document.FilteringSchemes[0].Item[myDataTable].Item[myDataTable.Columns.Item["b"]].As[RangeFilter]()

delta = .1
if(filt.ValueRange.High.ToString() == "High"): #reset filters
 idx = IndexSet(myDataTable.RowCount,True)
 min = myDataTable.Columns["b"].RowValues.GetMinValue(idx).Value
 filt.ValueRange = ValueRange(min,min+delta)
 print filt.ValueRange
else:
  filt.StepBodyUp()

javascript

var pid
var speed = .5 //change filter 2/second
start = function(){
 pid = setInterval(function(){
   $("#spotfireButton input").click()
 },speed*1000)
 $('#stopButton').show()
 $('#startButton').hide()
}

stop = function(){
 clearInterval(pid)
   $('#dd').text("stopped " + pid)
 $('#stopButton').hide()
 $('#startButton').show()
}
s
$("#stopButton").button().on('click',stop)

$("#startButton").button().on('click',start)
于 2016-02-04T18:02:43.180 回答