@@ -41,6 +41,9 @@ var ChartComponent = _react2.default.createClass({
41
41
42
42
propTypes : {
43
43
data : _react . PropTypes . object . isRequired ,
44
+ getDatasetAtEvent : _react . PropTypes . func ,
45
+ getElementAtEvent : _react . PropTypes . func ,
46
+ getElementsAtEvent : _react . PropTypes . func ,
44
47
height : _react . PropTypes . number ,
45
48
legend : _react . PropTypes . object ,
46
49
onElementsClick : _react . PropTypes . func ,
@@ -89,6 +92,7 @@ var ChartComponent = _react2.default.createClass({
89
92
var ignoredProperties = [ 'id' , 'width' , 'height' , 'onElementsClick' ] ;
90
93
var compareNext = this . _objectWithoutProperties ( nextProps , ignoredProperties ) ;
91
94
var compareNow = this . _objectWithoutProperties ( this . props , ignoredProperties ) ;
95
+
92
96
return ! ( 0 , _deepEqual2 . default ) ( compareNext , compareNow , { strict : true } ) ;
93
97
} ,
94
98
componentWillUnmount : function componentWillUnmount ( ) {
@@ -125,25 +129,32 @@ var ChartComponent = _react2.default.createClass({
125
129
options : options
126
130
} ) ;
127
131
} ,
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 ;
132
134
133
- onElementsClick ( elems ) ;
134
- }
135
- } ,
136
- render : function render ( ) {
137
135
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 ;
140
139
var onElementsClick = _props3 . onElementsClick ;
141
140
142
141
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
+
143
154
return _react2 . default . createElement ( 'canvas' , {
144
155
height : height ,
145
156
width : width ,
146
- onClick : typeof onElementsClick === 'function' ? this . handleOnClick : null
157
+ onClick : this . handleOnClick
147
158
} ) ;
148
159
}
149
160
} ) ;
@@ -368,7 +379,7 @@ Object.defineProperty(exports, "__esModule", {
368
379
value : true
369
380
} ) ;
370
381
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 ; } ;
372
383
373
384
var hasOwnProperty = Object . prototype . hasOwnProperty ;
374
385
0 commit comments