html:
<b>Simple Javascript Widget:</b>
<div style='width:80%'><div id='myWidget'></div></div>
<hr/>
<b>(Hidden) Calculated Value passed to widget:</b>
<span id='myCV'>
<SpotfireControl id="6f842c14..." />
</span>
Javascript:
//this function gets the value from a Calculated Value
var oldValue=0
function updateValue() {
//get value from a Label Property Control or from a Calculated Value
newValue=$("#myCV").text()
//update widget (only when the value changes)
if(oldValue!=newValue){
$('#myWidget').css({
background:'gray'
,color:"navy"
,textAlign:"center"
,margin:"10px"
,padding:"5px"
,borderStyle:"outset"
,width:oldValue+"%"
}).text(newValue).animate({width:newValue+"%"},250)
}
oldValue=newValue
}
//run once
updateValue()
//run constantly
setInterval(updateValue,500)
No comments:
Post a Comment