artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

mouse coordinates

Hello again :)

Next question. Can I somehow obtain mouse coordinates in chart from a function? (especially chartX/Y attributes).
Or maybe there is a better way to do what I need :D
I'm trying to do dragdrop from external div to chart. And I have some points in this external div that when I drop on chart I calculate on which serie is mouse pointer, and then add a point to that serie. But for that I need chartX/Y and on dragDrop event from html5 or primeng (which i use) doesn't have chartX/Y :mrgreen:
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: mouse coordinates

Hi,
Thanks for contact with us again.

What I can suggest is to use events like mouseOut, mouseOver but I suspect that this may not be enough in your case.

It is also possible to use functions from wrap like mouseDownX and mouseDownY and you will get exact values.

Live demo:
https://jsfiddle.net/BlackLabel/fc3wgrta/

API References:
https://api.highcharts.com/gantt/series ... int.events

Let me know if that's it.
Best regards.
Sebastian Hajdus
Highcharts Developer
artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

Re: mouse coordinates

I had an error, cause I have something like:

Code: Select all

<div id="chart-container">
<highcharts-chart ...></highcharts-chart>
</div>
A I was trying to add OnDrop on #chart-container (cause there I have height and overflow-y set), but when i moved the OnDrop event to <highcharts-chart> i started to get proper values on offsetX/Y attribute :) So I just added chartX/Y attributes with the same values as offsetX/Y and everything is working :)
sebastian.h wrote: What I can suggest is to use events like mouseOut, mouseOver but I suspect that this may not be enough in your case.
Tried that, but when you are dragging something over the chart, mouseOut/Over doesn't work
sebastian.h wrote: It is also possible to use functions from wrap like mouseDownX and mouseDownY and you will get exact values.
Yeah, but then you will have to click the mouse, not just drop :)

But thanks for support :)
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: mouse coordinates

You're welcome! :)
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Gantt”