gevgeny / angular2-highcharts

:bar_chart: :chart_with_upwards_trend: Highcharts for your Angular project
MIT License
379 stars 113 forks source link

events not firing in options.chart.events #182

Open shreyanshd opened 7 years ago

shreyanshd commented 7 years ago
chart: { 
         type: 'column',
         events: {
                 drilldown: function(e) { console.log("drilldown fired"); },
                 drillup: function(e) { console.log("drillup fired"); },
                 click: function(e) { console.log("click fired"); }
          }
}

This code is a part of my chart options. Why are the drilldown and drillup events not firing, whereas the click event fires correctly whenever i click on the canvas?

ryanrich commented 7 years ago

I noticed this as well, it looks like there is a bug in the deepAssign logic where the base object they merge with the user provided chart options overrides the event handlers you pass in.

joel00 commented 7 years ago

same issue here with 0.5.5, Could you make it work? I've already import the drilldown module

export function highchartsFactory() { let highcharts = require('highcharts'); let highchartsMore = require('highcharts/highcharts-more'); let gauge = require('highcharts/modules/solid-gauge'); let map = require('highcharts/modules/map'); let drilldown = require('highcharts/modules/drilldown');

highchartsMore(highcharts);
gauge(highcharts);
map(highcharts);
drilldown(highcharts);

return highcharts;

}

shreyanshd commented 7 years ago

@joel00 I was not able to get it to work in options.chart.events. However, in order to handle drilldown and drillup events, I did this in my template : <chart [options]="options" (drilldown)="onDrilldown()" (drillup)="onDrillup()"> </chart> and defined the onDrilldown() and onDrillup() methods in my component. Both events are firing correctly.

joel00 commented 7 years ago

@shreyanshd thanks I can trigger the drilldown and drillup events...... but cannot figure it out how to assign the new map/data as the example in: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/maps/demo/map-drilldown/

I'm trying:

drilldown(event: any) { const point = event.originalEvent.point; console.log(point.id);

this.chart.showLoading('Loading'); <=== works this.chart.addSeriesAsDrilldown(point.id, { data: this.data, mapData: newMap, <===== getting compiling error name: point.id, dataLabels: { <= getting compiling error enabled: true, format: '{point.name}' } }); }

Could you put me in the right path?