@@ -79,7 +79,8 @@ plotChoropleth.plot = function(geo, choroplethData, geoLayout) {
7979 if ( trace . visible !== true ) return ;
8080
8181 var cdi = plotChoropleth . calcGeoJSON ( trace , geo . topojson ) ,
82- cleanHoverLabelsFunc = makeCleanHoverLabelsFunc ( geo , trace ) ;
82+ cleanHoverLabelsFunc = makeCleanHoverLabelsFunc ( geo , trace ) ,
83+ eventDataFunc = makeEventDataFunc ( trace ) ;
8384
8485 function handleMouseOver ( pt , ptIndex ) {
8586 if ( ! geo . showHover ) return ;
@@ -95,6 +96,12 @@ plotChoropleth.plot = function(geo, choroplethData, geoLayout) {
9596 } , {
9697 container : geo . hoverContainer . node ( )
9798 } ) ;
99+
100+ geo . graphDiv . emit ( 'plotly_hover' , eventDataFunc ( pt , ptIndex ) ) ;
101+ }
102+
103+ function handleClick ( pt , ptIndex ) {
104+ geo . graphDiv . emit ( 'plotly_click' , eventDataFunc ( pt , ptIndex ) ) ;
98105 }
99106
100107 d3 . select ( this )
@@ -103,6 +110,7 @@ plotChoropleth.plot = function(geo, choroplethData, geoLayout) {
103110 . enter ( ) . append ( 'path' )
104111 . attr ( 'class' , 'choroplethlocation' )
105112 . on ( 'mouseover' , handleMouseOver )
113+ . on ( 'click' , handleClick )
106114 . on ( 'mouseout' , function ( ) {
107115 Plotly . Fx . loneUnhover ( geo . hoverContainer ) ;
108116 } )
@@ -187,6 +195,18 @@ function makeCleanHoverLabelsFunc(geo, trace) {
187195 if ( hasText ) thisText . push ( pt . tx ) ;
188196
189197 pt . textLabel = thisText . join ( '<br>' ) ;
198+ } ;
199+ }
190200
201+ function makeEventDataFunc ( trace ) {
202+ return function ( pt , ptIndex ) {
203+ return { points : [ {
204+ data : trace . _input ,
205+ fullData : trace ,
206+ curveNumber : trace . index ,
207+ pointNumber : ptIndex ,
208+ location : pt . id ,
209+ z : pt . z
210+ } ] } ;
191211 } ;
192212}
0 commit comments