plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.76k stars 1.84k forks source link

Add support for clickable hover text or a per pt onclick attribute #998

Open etpinard opened 7 years ago

etpinard commented 7 years ago

Users can put links inside hover labels, but when user try to click the link, the hover label obviously disappears. So perhaps we could add optional “sticky” hover labels, where you click and the hover label is persistent until you click again?

Defining what sticky means will be tricky. It probably doesn't apply to every situation. Maybe we could add it as a new layout.hovermode e.g. 'hovermode: 'sticky'.

So, maybe instead we could define a linkonclick attribute e.g. linkonclick: ['https://plot.ly/~empet/101', 'https://plot.ly', /* ... one link per data pt */] that way clicking on a data pt would open the link instead of hovering on the data pt -> move mouse over link in hover label -> click on it.

cc @jackparmer

john-soklaski commented 7 years ago

We definitely would have use for a hover label that the user can interact with. There is quite a bit of information in our hover labels (5-6 lines of text), and users would often like to copy and paste some text from the hover label, or potentially click a link.

jackparmer commented 7 years ago

@john-soklaski what do you think the right interaction is for allowing a user to select copy paste what is in a hover tag?

john-soklaski commented 7 years ago

@jackparmer I think persisting the hover label if a user moves the mouse cursor along the arrow to the hoverlabel makes sense (with hovermode: closest)

maresk commented 7 years ago

@jackparmer I will second this feature request in the python API. Our clients would like to be able to interact with content related to a particular data point so ss far as interaction goes, the text should persist, and a hyperlink placed in the text should be clickable.

latorrefabian commented 7 years ago

+1

dr-stringfellow commented 7 years ago

+1

jackparmer commented 7 years ago

@john-soklaski , @maresk , @latorrefabian , @maierbenedikt - you may be interested in discussion here, Annotations that show & hide on clicking data: https://github.com/plotly/plotly.js/issues/1266

alexcjohnson commented 7 years ago

And see the implementation of clicktoshow in #1265 - at some point we do intend to implement a way to generate "sticky" annotations programmatically on clicking a data point but for now, as long as you don't have too much data you can do it the other way around: pre-generate all the annotations you might want and link them to appear on clicking the appropriate data points.

slremy commented 7 years ago

Hello all! Am I missing something fundamental here? Is there a purpose of being able to have hyperlinks in the text if you can't click them?

image
alexcjohnson commented 7 years ago

Am I missing something fundamental here? Is there a purpose of being able to have hyperlinks in the text if you can't click them?

We support text in a lot of different contexts, and in most of the other contexts the links are clickable. So it would require special code to disable link creation within the unclickable contexts, and that extra complexity seemed unnecessary since really, is there a purpose to adding hyperlinks that you can't click? 😉

slremy commented 7 years ago

That makes sense!

PaNDanese commented 7 years ago

what do you think the right interaction is for allowing a user to select copy paste what is in a hover tag?

@jackparmer I think clicking on the marker itself would be ideal to toggle the stickiness of the hover tag.

+1 for utility

wroscoe commented 7 years ago

+1 for this. This would enable users to dig into the data by linking other related charts. I like the simple solution proposed by @pdanese

slremy commented 6 years ago

It seems as if there may already a solution in community.plot.ly

To me it seems that if you knew which datum was clicked, then you could window.open(datum.uri). It's probably not that easy.. but the fiddle is compelling.

I can't quite read tease it out of the docs what it's actually saying :(

newuser357 commented 5 years ago

Hello, has this been completed yet? Currently working on a project where I want users to be able to click the annotations and copy them to the clipboard.

nistrup commented 5 years ago

I would love to have this feature as well!

bill10 commented 4 years ago

looks like this is still open? any updates?

rusiano commented 4 years ago

+1

steffon-atg commented 4 years ago

+1

kamikaze942 commented 4 years ago

+1 need stickiness

jackparmer commented 4 years ago

This is not a large project but obviously hasn't found its way to the top of the priority queue for a while. If any company would like to partner with us on this, we'd be interested in discussing! https://plot.ly/products/consulting-and-oem/

AniWar commented 4 years ago

(For 3D chart) I was trying out some complex keyboard bindings (which didn’t work), and accidently I found this . Just double click on markers (which selects text) , then press ctrl+C. markerData

josemonsalve2 commented 4 years ago

+1

baddymaster commented 3 years ago

+1

This would be very useful for data analysis. And unfortunately the hack suggested by @AniWar doesn't seem to work anymore.

jackparmer commented 3 years ago

This issue has been tagged with NEEDS SPON$OR

A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.

Sponsorship range: $15k-$20k

What Sponsorship includes:

Please include the link to this issue when contacting us to discuss.

keseldude commented 3 years ago

In case this is useful for someone else, I worked around this by adding some 'postscript' javascript as part of writing my figure to HTML. https://gist.github.com/keseldude/4c3c2220f0aec13604a1e4836995e37c

This creates a new "info panel" div, whose contents become the hover text when the user clicks on a point matching some condition (in my case, if the hover text matches some regexp). Once the text is in the "info panel", the user can select the text there.

slremy commented 2 years ago

Super useful

blatchfordcc commented 1 year ago

Any updates/solutions to this issue?

leleogere commented 1 year ago

This would be very useful

lemetrec commented 1 year ago

+1

bmurtagh01 commented 1 year ago

+1

bschilder commented 1 year ago

+1

therhaag commented 1 year ago

Hi - stumbled upon this when looking for a way to follow a URL that's in the hover text. The workaround proposed by @keseldude looks like it could work for me, but I don't understand how to use it. Could anyone please elaborate?

GabeNicholson commented 1 year ago

Any update on this?

sebastien-plutniak commented 1 year ago

+1, I am also in need of this feature

philipjames44 commented 1 year ago

+1

JohnScolaro commented 1 year ago

+1

leijer commented 9 months ago

+1

jerpint commented 5 months ago

+1

Simply-Connected-LLC commented 4 months ago

+1

natearoe commented 1 month ago

+1

irialagoportela commented 1 month ago

+1

sudughonge commented 2 weeks ago

+1

bartosz-nawrotek-brainly commented 1 week ago

+1