.on( evtName, fn)

Bind event handler functions to the chart.

chart.on(event, fn)


Name Type Required Description
event string yes Name of the interaction event to bind the function. (mouseover)
fn function yes Function(event, data) that is called when the event occurs.

Available Events

Name Description
mouseover fires when the mouse moves over elements on the chart
mouseout fires when the mouse leaves an elements on the chart
click fires when on clicking an element on the chart
update-start fires on chart.update();
update-end fires when chart finishes rendering

Handler Parameters

When a handler is fired, the data associated with the chart element is passed along.

Example Code

<div class="row">
  <div class="col-lg-12" id="chart"></div>


   //define a handler for chart events 
  function showItem(event,data){
    //dump event to console such as mouse location...
    //dump data to console...

  //setup a chart using a json file that is the complete definition
  var chart = new Cedar({

  //render the chart
    elementId: "#chart"

  //attach handler (can also be done before .show())
  chart.on('click', showItem);

  window.onresize = function() { chart.update() }


Edit this page on GitHub