2

I am trying to get the chart click and mouse events to work on the NVD3 historical bar chart- but I'm failing to do so. Please see plnkr here http://plnkr.co/edit/Hnyi1A? I see here https://github.com/krispo/angular-nvd3/issues/36 that they recommend to use interactiveLayer property, however it does not seem to be working. Could be possibly be a bug?

    chart: {
      type: 'historicalBarChart',

      //None of these events work 
      interactiveLayer: {
        dispatch: {
          chartClick: function(e) {
            console.log("! chart Click !")
          },
          elementClick: function(e) {
            console.log("! element Click !")
          },
          elementDblClick: function(e) {
            console.log("! element Double Click !")
          },
          elementMouseout: function(e) {
            console.log("! element Mouseout !")
          },
          elementMouseover: function(e) {
            console.log("! element Mouseover !")
          }
        }
      }
...
}
user1142130
  • 1,617
  • 3
  • 20
  • 34
  • Yeah, the only events I can get to register are `stateChange` and `renderEnd`. Might be a bug... Sorry cannot be more helpful. – Bennett Adams Jun 04 '16 at 02:09

1 Answers1

1

NVD3's LiveEdit page in Extended mode gives all the documentation about what settings are available. Looks like you need bars instead of interactiveLayer to get the bar events on a historicalBarChart:

chart: {
  type: 'historicalBarChart',      
  bars: {
    dispatch: {          
      elementClick: function(e) {
        console.log("! element Click !")
      },
      elementDblClick: function(e) {
        console.log("! element Double Click !")
      },
      elementMouseout: function(e) {
        console.log("! element Mouseout !")
      },
      elementMouseover: function(e) {
        console.log("! element Mouseover !")
      }
    }
  }

I couldn't get chartClick to fire though. But as it's commented out in NVD3's own plnkr (of discreteBarChart type) I would be suspicious that something is wrong there.

Lesley
  • 1,395
  • 12
  • 11