How to change mark color in signal callback function?

110 views
Skip to first unread message

Tharik Kanaka

unread,
Mar 1, 2016, 12:17:42 AM3/1/16
to vega-js
At the moment i am using on signal callback functions to get data bound item information by using item.datum.. In firebug i noticed that item object has consist of mark details such as type and fill color. Can we use change mark color or do any changes on callback functions? Please refer following callback function i am using and fiddle code for sample scenario.
https://jsfiddle.net/kcm4d9pv/1/

var callbackmethod = function(event, item) { 
       
if (item != null) {
            item
.fill = "red";
             
var div = document.getElementById("details");
                   div
.innerHTML = "<p> Torque : "+item.datum.torque+"</p>"
                 
+  "<p> RPM : "+item.datum.rpm+"</p>"
                 
+  "<p> Engine Type : "+item.datum.EngineType+"</p>";
         
}
     
};

 vg
.parse.spec(spec, function(error, chart) {
 
var view  = chart({el:"#dChart"}).update();
 view
.on("click", callbackmethod);
 
});


Roy I

unread,
Mar 1, 2016, 2:43:29 PM3/1/16
to vega-js
For a parameter value that you want to change in Vega Runtime, first define a signal in the Vega spec and use that signal value in marks properties etc.

Vega Signals
Example:

Vega Runtime -- View Component API

  signal(): get or set value for a Vega signal
  onSignal(): Vega signal listener and event handler
  on(): DOM event listener and event handler

Note: While Vega signals are DOM events, do not refer to any event as a "signal" unless it is a defined signal in the Vega spec.

Tharik Kanaka

unread,
Mar 8, 2016, 1:14:34 AM3/8/16
to vega-js

Thank you very much i was able to resolve it by including signals in the vega spec.
Reply all
Reply to author
Forward
0 new messages