[英]Python Scripting in TIBCO Spotfire to show custom Messages
I am loading a data table on demand and have linked it to markings in a previous tab. 我正在按需加载数据表,并将其链接到上一个选项卡中的标记。 The Data table look like:
数据表如下所示:
ID Values
1 365
2 65
3 32
3 125
4 74
5 98
6 107
I want to limit the data that is brought into this new visualization based on distinct count of ID. 我想根据ID的不同计数来限制引入此新可视化的数据。
I am currently doing it using "Limit Data by Expression" section in the properties. 我目前正在使用属性中的“按表达式限制数据”部分进行此操作。 Where my expression is
我的表情在哪里
UniqueCount(ID) <= 1000
This works perfectly, however, I'd also like it to display a message like "Too many IDs selected. Max Limit is 1000" 这很完美,但是,我也希望它显示一条消息,例如“选择的ID太多。最大限制为1000”。
I was thinking of doing this using a property control where the property control triggers an iron python script. 我正在考虑使用属性控件来执行此操作,其中该属性控件会触发一个python脚本。 Any suggestions on how to write that script ?
关于如何编写该脚本有什么建议吗?
One work-around would be use of a small Text Area on the page (perhaps as a header). 一种解决方法是在页面上使用一个小的文本区域(也许作为标题)。 You can
Insert Dynamic Item
-> Calculated Value or Icon and have it perform a count or unique count based on marking (selection). 您可以
Insert Dynamic Item
->计算值或图标,并使其根据标记(选择)执行计数或唯一计数。 For example, once the Count(ID) is > 1000, the text can change to red, or the icon can change color. 例如,一旦Count(ID)> 1000,则文本可以更改为红色,或者图标可以更改颜色。 This is a processing-light alternative which won't necessarily create a pop-up, but can still provide instant notification to a user that too many rows have been selected.
这是一种处理轻量级的选择,它不一定会创建一个弹出窗口,但仍可以向用户提供已选择太多行的即时通知。
Edit below: 编辑如下:
<!-- Invisible span to contain a copy of your value -->
<span style="display:none;" id="stores-my-count"><span id="seek-ender"></span></span>
\\Javascript below to grab dynamic item element's value and put it into a span
\\To be executed every time the dynamic value changes
$("#DynamicItemSpotfireID").onchange = function() {
var myCount = $("#DynamicItemSpotfireID").text();
$("#stores-my-count").append(myCount);
}
#IronPython script to locate the value placed into the span by the JS above
#and put only that portion of the page's HTML (only the value) into a document property
parentSpan = '<span id="stores-my-count">'
endingSpan = '<span id="seek-ender">'
startingHTML = myTextArea.As[VisualContent]().HtmlContent
startVal = startingHTML.find(parentSpan, startingIndex, endingIndex) + len(parentSpan)
endVal = startingHTML.find(endingSpan, startingIndex, endingIndex)
Document.Properties["myMarkingCount"] = startingHTML[startVal:endVal]
I haven't tested most of this code and I provide it as a place to start thinking about the problem, rather than a turnkey solution. 我还没有测试过大部分代码,而是将其作为开始思考问题的地方,而不是交钥匙解决方案。 Hopefully it works with only minor tweaking necessary.
希望它只需要很小的调整即可工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.