Jump to content

Gauge Chart - linking to data in project


Byron Kelly

Recommended Posts

Hi All

I am trying to create a Gauge Chart in my Spotfire Analyst project. I have no prior experience using Java Script or HTML code so I am struggling here.

I am trying to link the Gauge Chart to the data in my project, so that when I mark a table/chart, the Gauge Chart will update with revelant data related to the marking.

I have implemented a basic gauge chart based on code I found here :

http://spotfired.blogspot.com/2016/03/custom-gauge-from-calc-value-70.html

This plots a static gauge chart, using a static number (#22 for 'visitors'); I would like to change the static number to a number based on my data.

1) How do I link the Gauge Chart to a calculated column in my dataset

2) How do I enable it to updated based on marking my data

I tried to modify the code and replace the #22 'value' with the name of the Calculate Column i want to chart, but it did not work.

I am trying to plot a % (one number divided by another, in this case production/capacity)

Here is what my modified JS looks like (which does not work)

html

calculated value:

 

 

 

 

 

 

js

resource=[

"//cdn.jsdelivr.net/raphael/2.1.0/raphael-min.js",

"//cdn.jsdelivr.net/justgage/1.0.1/justgage.min.js"

]

 

//add scripts to head

$.getScript(resource[0],function(){

$.getScript(resource[1],init)

})

 

init = function(){

var g = new JustGage({

id: "gauge",

value: "Production/Capacity",

min: 0,

max: 1.00

title: "Visitors"

});

 

//refresh gauge when calcvalue changes

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

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

})

 

}Any help would be GREATLY appreciated.

Thanks!

Byron

Link to comment
Share on other sites

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

Shandilyas example sometimes failsin 10.0.0 and later versions of Spotfire.

 

I'm attaching a modifiedexample where aMutationObserver is added, listening to two calculated values, and set the value and color of the gaugedepending on those two calculated values.

Link to comment
Share on other sites

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...