I have a small javascript in a spotfire Text area. It was working as designed. I saved and closed spotfire. On re-open it does not show at all. My code is below. Any help would be appreciated.
resource = [
"//cdn.rawgit.com/toorshia/justgage/master/raphael-2.1.4.min.js",
"//cdnjs.cloudflare.com/ajax/libs/justgage/1.2.8/justgage.js"
]
//add scripts to head
$.getScript(resource[0], function() {
$.getScript(resource[1], init)
})
var init = function() {
var g = new JustGage({
id: "gauge",
min: 0,
max: 100,
customSectors: [{
"lo": 0,
"hi": 89.999,
"color": "#f05050"
},
{
"lo": 90,
"hi": 92.999,
"color": "#DD7502"
},
{
"lo": 93,
"hi": 100,
"color": "#41c572"
}
],
levelColorsGradient: false
});
//refresh gauge when calcvalue changes
$(calcValue).on('DOMSubtreeModified', function() {
g.refresh($(this).text())
})
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id=calcValue><SpotfireControl id="3321e4c9003142ad83fdb753e6f66605" />
</span>
<DIV id=gauge></DIV>
I looked at the examples, it should be:
resource = [
"//cdn.rawgit.com/toorshia/justgage/master/raphael-2.1.4.min.js",
"//cdnjs.cloudflare.com/ajax/libs/justgage/1.2.8/justgage.js"
]
//add scripts to head
$.getScript(resource[0], function() {
$.getScript(resource[1], init)
})
var init = function() {
var g = new JustGage({
id: "gauge",
min: 0,
max: 100,
customSectors: {ranges: [{
"lo": 0,
"hi": 89.999,
"color": "#f05050"
},
{
"lo": 90,
"hi": 92.999,
"color": "#DD7502"
},
{
"lo": 93,
"hi": 100,
"color": "#41c572"
}
]},
levelColorsGradient: false
});
//refresh gauge when calcvalue changes
//$(calcValue).on('DOMSubtreeModified', function() {
// g.refresh($(this).text())
//})
window.setInterval( () => {
g.refresh(Math.random()*100)
}, 1000)
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id=calcValue><SpotfireControl id="3321e4c9003142ad83fdb753e6f66605" />
</span>
<DIV id=gauge></DIV>