@@ -41,6 +41,9 @@ var ChartComponent = _react2.default.createClass({
4141
4242 propTypes : {
4343 data : _react . PropTypes . object . isRequired ,
44+ getDatasetAtEvent : _react . PropTypes . func ,
45+ getElementAtEvent : _react . PropTypes . func ,
46+ getElementsAtEvent : _react . PropTypes . func ,
4447 height : _react . PropTypes . number ,
4548 legend : _react . PropTypes . object ,
4649 onElementsClick : _react . PropTypes . func ,
@@ -89,6 +92,7 @@ var ChartComponent = _react2.default.createClass({
8992 var ignoredProperties = [ 'id' , 'width' , 'height' , 'onElementsClick' ] ;
9093 var compareNext = this . _objectWithoutProperties ( nextProps , ignoredProperties ) ;
9194 var compareNow = this . _objectWithoutProperties ( this . props , ignoredProperties ) ;
95+
9296 return ! ( 0 , _deepEqual2 . default ) ( compareNext , compareNow , { strict : true } ) ;
9397 } ,
9498 componentWillUnmount : function componentWillUnmount ( ) {
@@ -125,25 +129,32 @@ var ChartComponent = _react2.default.createClass({
125129 options : options
126130 } ) ;
127131 } ,
128- handleOnClick : function handleOnClick ( evt ) {
129- var elems = this . chart_instance . getElementsAtEvent ( evt ) ;
130- if ( elems . length ) {
131- var onElementsClick = this . props . onElementsClick ;
132+ handleOnClick : function handleOnClick ( event ) {
133+ var instance = this . chart_instance ;
132134
133- onElementsClick ( elems ) ;
134- }
135- } ,
136- render : function render ( ) {
137135 var _props3 = this . props ;
138- var height = _props3 . height ;
139- var width = _props3 . width ;
136+ var getDatasetAtEvent = _props3 . getDatasetAtEvent ;
137+ var getElementAtEvent = _props3 . getElementAtEvent ;
138+ var getElementsAtEvent = _props3 . getElementsAtEvent ;
140139 var onElementsClick = _props3 . onElementsClick ;
141140
142141
142+ getDatasetAtEvent && getDatasetAtEvent ( instance . getDatasetAtEvent ( event ) ) ;
143+ getElementAtEvent && getElementAtEvent ( instance . getElementAtEvent ( event ) ) ;
144+ getElementsAtEvent && getElementsAtEvent ( instance . getElementsAtEvent ( event ) ) ;
145+ onElementsClick && onElementsClick ( instance . getElementsAtEvent ( event ) ) ; // Backward compatibility
146+ } ,
147+ render : function render ( ) {
148+ var _props4 = this . props ;
149+ var height = _props4 . height ;
150+ var width = _props4 . width ;
151+ var onElementsClick = _props4 . onElementsClick ;
152+
153+
143154 return _react2 . default . createElement ( 'canvas' , {
144155 height : height ,
145156 width : width ,
146- onClick : typeof onElementsClick === 'function' ? this . handleOnClick : null
157+ onClick : this . handleOnClick
147158 } ) ;
148159 }
149160} ) ;
@@ -368,7 +379,7 @@ Object.defineProperty(exports, "__esModule", {
368379 value : true
369380} ) ;
370381
371- var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
382+ var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol ? "symbol" : typeof obj ; } ;
372383
373384var hasOwnProperty = Object . prototype . hasOwnProperty ;
374385
0 commit comments