Search code examples
pythonspotfire

Accessing Calculated Value in Text Area Spotfire


I am trying to access a calculated value sitting in a text area with the API. My python skills are not that good, but I believe I am pretty close, and that this will probably be an easy question for someone more experienced. I have looked around a good bit and haven't found a solution.

So far this is what I have:

from Spotfire.Dxp.Application.Visuals import Miniatures

val1 = Miniatures.CalculatedValueMiniatureVisualizationDetails.Value


print val1

This gives me the following: 

property# Value on CalculatedValueMiniatureVisualizationDetails>.

The real question is how do I extract the value from this property?

Thanks,

Jamey


Solution

  • I ended up ditching this way and solved this problem by using jQuery:

    I ended up figuring this one out. Here is the html:

    <body >
    <div id = wrapper>
    <div id = thisyear><SpotfireControl id="d644de4c97c440fbb78c561f190e5a47" />   </div>
    
    <div id = lastyear ><SpotfireControl id="f98415c74eb34cedbab057f763788bc6" /></div>
    </div>
    </body>
    

    And the jQuery that gets this done:

    setInterval(function() {
       var thisyearval = parseInt($("#thisyear").text(),10)
       var lastyearval = parseInt($("#lastyear").text(),10)
    
    
       if (thisyearval > lastyearval){
          $("#wrapper").css("background-color", "#009900")
       } else{$("#wrapper").css("background-color", "#FF0000")}
    }, 500);
    

    It turns out that spotfire doesnt support the change function in jQuery, so I used setInterval() to essentially call the function over and over.

    Hopefully this will help someone else out too.