Skip to content

Commit

Permalink
Added data.onclick config option. This is related to #19
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyavf committed May 27, 2016
1 parent 79fd1a4 commit 5a2a617
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import ChartVM from './viewmodel';
* <bit-c3></bit-c3>
*
* <bit-c3 axis-x-type="category"></bit-c3>
*
* <bit-c3 onclick="true" (click)="clickHandler(%event)"></bit-c3>

This comment has been minimized.

Copy link
@kylegifford

kylegifford May 27, 2016

Contributor

I'd like to see if there'd be a way to implement this without having to use the onclick property. Or at least make it a boolean property like <bit-c3 hasOnclick ...>. There might be some way to determine if a click event handler has been attached the component and do that in place of line 58 - would need to look.

* ```
*/
can.Component.extend({
Expand All @@ -50,6 +52,15 @@ can.Component.extend({
}
}
}
/**
* C3 config data.onclick. If onclick is true then viewModel click event with data will be dispatched.
*/
if (this.viewModel.attr('onclick')){
let self = this;
config.data.onclick = function(d, element){

This comment has been minimized.

Copy link
@kylegifford

kylegifford May 27, 2016

Contributor

Would prefer to use => here if possible so we don't have to do the let self = this.

This comment has been minimized.

Copy link
@ilyavf

ilyavf Jul 12, 2016

Author Contributor

Sure. I didn't pay attention to the syntax in that experiment.

self.viewModel.dispatch({type:'click', data:d}, [d]);
}
}
this.viewModel.attr('chart', c3.generate(config));
},
removed: function() {
Expand Down

0 comments on commit 5a2a617

Please sign in to comment.