@@ -76,7 +76,7 @@ define([
7676
7777 var domNode = null ;
7878
79- // Activate chartJS (and clone it).
79+ // Activate chartJS (and clone it, making sure globals are not overwritten for other instances ).
8080 this . _chartJS = lang . clone ( _charts ) ;
8181
8282 // Fonts
@@ -313,8 +313,31 @@ define([
313313 console . error ( "_createChart: This is placeholder function that should be overwritten by the implementing widget." , data ) ;
314314 } ,
315315
316- _onClickChart : function ( ) {
316+ _onClickChart : function ( evt ) {
317317 logger . debug ( this . id + "._onClickChart" ) ;
318+
319+ var elements = this . _chart . getElementAtEvent ( evt ) ;
320+
321+ if ( elements . length ) {
322+ var el = elements [ 0 ] ,
323+ datasetIndex = el . _datasetIndex ,
324+ pointIndex = el . _index ,
325+ dataset = this . _data . datasets [ datasetIndex ] ,
326+ datasetObject = dataset ? dataset . dataset : null ,
327+ dataPointObject = dataset && dataset . points ? dataset . points [ pointIndex ] : null ;
328+
329+ if ( this . onclickDataSetMf && datasetObject ) {
330+ this . _executeMicroflow ( this . onclickDataSetMf , null , datasetObject ) ;
331+ }
332+
333+ if ( this . onclickDataPointMf && dataPointObject ) {
334+ this . _executeMicroflow ( this . onclickDataPointMf , null , dataPointObject ) ;
335+ }
336+
337+ console . log ( JSON . stringify ( datasetObject . jsonData ) ) ;
338+ console . log ( JSON . stringify ( dataPointObject . jsonData ) ) ;
339+ }
340+
318341 if ( this . onclickmf ) {
319342 this . _executeMicroflow ( this . onclickmf ) ;
320343 }
@@ -569,7 +592,7 @@ define([
569592 caller : this . mxform
570593 } ,
571594 callback : lang . hitch ( this , function ( obj ) {
572- if ( typeof callback !== "undefined ") {
595+ if ( typeof callback === "function ") {
573596 callback ( obj ) ;
574597 }
575598 } ) ,
0 commit comments