I have a basic pie chart with 3 wedges. When you click on a wedge of the pie, a tooltip will display. My intent is to have the same functionality for a keydown event.
Scenario: When a pie slice has focus, a user can hit a key (ex: enter) which will display the tooltip exactly how the click event does.
I figured this will require 2 steps.
- Make each pie wedge (.nv-slice) focusable by adding a 'tabindex = 0' attribute
- Add an event listener that triggers the tooltip similar to how a click event does.
Here is the plunkr that shows the described behavior: http://plnkr.co/edit/7WkFK2LqzDyDmnIt2xlf?p=preview (thanks to @ThanasisGrammatopoulos)
First things first, how can I add a tabindex attribute to each pie wedge? When I try the following code it does not seem to appear:
d3.selectAll('.nv-slice').setAttribute("tabindex", "0");
Any ideas?