I use this wrapper of MorrisJs Chart in one project. This works very well, but I cannot find a way to get the result of click event.
With the original Morris.js using jQuery, it is possible to get the click event like this:
Morris.Line({
...
}).on('click', function(i, row) {
console.log(i);
console.log(row);
});
Do you know how to intercept that click with Angular? Thanks!
Today I found the solution. 3 changes should be brought to the directive:
import Output, EventEmitter
@Output() clickChart = new
EventEmitter();
let my_this = this;
this.chartInstance.on('click', function(i, row) {
my_this.clickChart.emit({ event, i, row });
});
Then the click event can be caught in the component through the method (clickChart)
.
Example:
<div mk-morris-js
type='Bar'
[options]='options'
[data]='datas'
(clickChart)='test($event)'
></div>
The full source of the directive can be seen in my pull request.