The API for on() is different from the rest of the API. It doesn't return a handler { remove: function() } but instead requires calling off(). I like off() over the handler pattern but for consistancy, on() should return an handler.
The event is payload should be one object. with at least a target property, the one that emitted the event.
<div class="row">
<div class="col-lg-12" id="chart"></div>
</div>
<script>
//setup a chart using a json file that is the complete definition
var chart = new Cedar({
"definition":"../../../cedar/data/definitions/scatter-events.json"
});
//render the chart
chart.show({
elementId: "#chart"
});
//attach handler (can also be done before .show())
var hdl = chart.on('click', function (event){
hdl.remove();
//dump event to console such as mouse location...
console.dir(event.location);
//dump data to console...
console.dir(event.data);
});
window.onresize = function() { chart.update() }
</script>
Looks like implementation of
.off()
is incomplete.Also from @ycabon:
The API for
on()
is different from the rest of the API. It doesn't return a handler{ remove: function() }
but instead requires callingoff()
. I likeoff()
over the handler pattern but for consistancy, on() should return an handler. The event is payload should be one object. with at least a target property, the one that emitted the event.