0

I produced a little interactive with D3 which shows some tooltip text when hovering over the datapoints. I would like to allow users to copy the text in the tooltip (or simply use all of it) to share via Twitter. The problem is that I can not fix one datapoint because it changes when I move over the graphic. So I would either like to freeze the tooltip text for a couple of seconds, so that it doesn't immediatly change on hover OR have another option (maybe on click or rightclick) to share the sentence via Twitter. Any idea?

Here is my working code so far:

http://bl.ocks.org/sytpp/3a070a6ed6834169a85b
Sylvia
  • 365
  • 2
  • 16
  • Sounds like you could play around with toggling `pointer-events`? See [this](http://bl.ocks.org/d3noob/c37cb8e630aaef7df30d). – goblin-esque Mar 09 '15 at 13:49
  • yes but the problem is that my points are so close to each other, there is no chance to move your mouse out towards the tooltip without mousing-over another data point (and thereby changing the dsiplayed text) – Sylvia Mar 09 '15 at 13:56
  • Make the points smaller (via `.attr("r",...)`? The graph bigger (via `scale`)? – goblin-esque Mar 09 '15 at 13:58
  • no, I really want to keep the layout as it is - I chose the aestetic to be kind of 'crowded' - is there no other way to overcome that, maybe by delaying some response in the transition? – Sylvia Mar 09 '15 at 14:00
  • Not a transition - that only works on something that has data appended to it (and your tooltips don't, necessarily). The way I'd do it is to do something like, when a user clicks (`.on(click)`), make a function that copies the relevant text (presumably based on `d`) to the user's clipboard. And then obviously inform the users somewhere on the page that that's possible. Here's a [SO post on how to send plaintext to the clipboard using JS](https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript). – goblin-esque Mar 09 '15 at 14:03
  • Thanks Angela, I will try with that! – Sylvia Mar 09 '15 at 14:41

0 Answers0