blacklabel / custom_events

Custom events plugin for Highcharts by Black Label
http://blacklabel.github.io/custom_events/
Other
62 stars 50 forks source link

Mousedown event on chart object #48

Open jensaug opened 8 years ago

jensaug commented 8 years ago

This is def an enhancement request

Would it be possible to allow CustomEvents also on Chart object? I'd like to catch a mousedown event when zooming is initiated (mousedown on chart - so I can hide tooltip).

If I've understood this plugin correctly I cannot achieve this by adding mousedown event to any of the supported objects?

Thanks for a great plugin! Jens

manu-st commented 7 years ago

This is something that would actually be very useful. How does one tackle this?

pawelfus commented 7 years ago

Just an idea: why not using mousedown event on the container? Something like this: http://jsfiddle.net/4ktf1t6t/

In jQuery:

  $('#container').on('mousedown', function () {
    console.log(chart);
  });
manu-st commented 7 years ago

I've done that but there is no straightforward way to limit the events to the chart area. How do I get the chart area without going to deep in the highcharts layout?

pawelfus commented 7 years ago

Oh, so you want event on plotting area not chart object? There is internal method chart.isInsidePlot(x, y) which would be helpful, snippet which should help:

var chartEvent = chart.pointer.normalize(event, chart.pointer.chartPosition), 
    isInsidePlot = chart.isInsidePlot(
        chartEvent.chartX - chart.plotLeft,
        chartEvent.chartY - chart.plotTop
    );