-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added data.onclick config option. This is related to #19
- Loading branch information
Showing
1 changed file
with
11 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.
Sorry, something went wrong. |
||
* ``` | ||
*/ | ||
can.Component.extend({ | ||
|
@@ -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.
Sorry, something went wrong.
kylegifford
Contributor
|
||
self.viewModel.dispatch({type:'click', data:d}, [d]); | ||
} | ||
} | ||
this.viewModel.attr('chart', c3.generate(config)); | ||
}, | ||
removed: function() { | ||
|
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.