New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added custom events click, hover and focus #221
Conversation
|
||
```js | ||
$scope.onClick = function(d, i){ | ||
conosole.log(d, i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, conosole
is not well-supported. Let's use console
instead, if you don't mind :-)
Very good PR, thank you for your contribution. |
d3.events are very nice, clean and robust for dispatching (a lot of) events, maybe the initialHandler can be replaced with d3 events at one point. |
The glass layer somehow blocks the click events, so that the dots beneath don't get triggered. There is for sure also an easy way to propagate the click event through this layer - but I haven't looked into this yet. |
Yeah, and the point about the scrubber mode sounds good, let me add a third parameter to the callback of the focus event |
what do you think about for sending an array containing the inverted x and y positions from the mouse cursor? xInvert = axes.xScale.invert(x)
yInvert = axes.yScale.invert(y)
dispatch.focus(v, series.values.indexOf(v), [xInvert, yInvert]) |
I updated the demo, actually this additional value can be very useful too. http://plnkr.co/edit/vUOa1v4UFRlbPZINCZ6X?p=preview |
🍗 |
Added custom events click, hover and focus
Is there a reason the click event an hover events only work on tooltip mode axes and none? I was hoping it work on scrubber as well. |
Hi @dorlandode |
awesome, thanks for the update. What is the ETA on version 2? |
Added custom events click, hover and focus
Hi n3-chart team,
I added 3 custom events to the chart directive. Due to the glass g-element displayed for the scrubber tooltip, I was not able to implement click and hover in scrubber mode.
Every event handler is called with the data element d and the position i in the array of values of a series.
I used this syntax for now, let me know if we can find something better:
Here is an example for click and hover: http://plnkr.co/edit/PTxVo3qKEnooK1PcsXMX
Here is an example for focus: http://plnkr.co/edit/vUOa1v4UFRlbPZINCZ6X
Best,
Christoph