Jump to content

Gauge Chart in Spotfire


Sanandh C k

Recommended Posts

I am trying create the gauge chart in Spotfire using javascript and html. I used an existing script which is aviable in google and every script the target values are static. Is there any way to make the target values are dynamic.

the script i used ,calculated value:

 

Edited : Please see the attached dxp and also the chart shows empty values when we open the dashboard.

 

 

 

 

calculated value:

 

 

 

 

 

 

 

 

$(document).ready(function(){

var myvar=setTimeout(changeGuage,10);

});

 

function changeGuage(){

 

val4=document.getElementById('calcValue');

Target=document.getElementById('Target');

ActualTarget=parseInt(Target.innerText);

intTile4Value = parseInt(val4.innerText);

 

var js0 = "//cdn.jsdelivr.net/raphael/2.1.0/raphael-min.js";

var js1 = "//cdn.jsdelivr.net/justgage/1.0.1/justgage.min.js";

 

var scripts = [js1, js0];

 

function initGage() {

var g = new JustGage({

id: "gauge",

value: intTile4Value,

min: 0,

max: ActualTarget,

title: "Active Players",

label: "Current Month",

levelColors: ['#ff0000', '#ffff00', '#00fff00']

});

 

 

$(calcValue).on('DOMSubtreeModified',function(){

g.refresh($(this).text())

})

$(Target).on('DOMSubtreeModified',function(){

g.refresh($(this).text())

})

}

 

function getNextScript() {

if (scripts.length === 0) {

initGage();

} else {

$.getScript(scripts.pop(), getNextScript);

}

}

getNextScript();}

Link to comment
Share on other sites

Hi Sanandh,

Have you had a look at the JSViz package on the TIBCO Exchange sitehttps://community.spotfire.com/modules/jsviz-javascript-visualization-frame.... There is a Gauge chart in there, which you coudl use as an example. And maybe that one does the dynamic targeting that you want. Also, in Spotfire 11, you should be able to create a Gauge chart based on a 'mod' (maybe that is what you were actually doing already).

Kind regards,

David

Link to comment
Share on other sites

Hi Sanandh,

I see what you mean. Have a look at the attached Gauges.dxp. In there you will find a couple of examples. The Revenue gauge on the first page, has a dynamic target in it, all other gauges have a fixed min and max.

I have used the same calculated value for the Revenue gauge, so the revenue value will always be the same as the target value. But you can change that for another calculated value of course.

Kind regards,

David

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...