question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customized Click, Hover, and Selection Styles or Traces

See original GitHub issue

Plotly.js has default styles for hovering (tooltips) and for selection (dimmed traces).

In Dash, users want to be able to customize these styles. While they can customize these styles themselves through Dash callbacks, it’s slow (roundtrip to server). And while I could write this behaviour into the Dash Graph component, it would be great if this was standard behaviour that everyone could benefit from.

Here are some examples that customized interaction styles or traces could enable.


As requested in the Dash community forum

d3827b8cd525b5f9b5111d4b93f1e336534043c5

For this example, there was some “animation fading” implemented, this is, why the line seems to be slightly behind the mouse. But I guess it’s clear to see what kind of performance, I was hoping to get by Dash. I think, it would be really nice, if there are efforts to improve these kind of animations, because I think they are used in many data visualization tools (having a moving maker I mean). There is this built-in Plotly “Toggle Spike Lines” function in each Graph, that does nearly what I want and is pretty fast, but not customizable.

In addition to this example, users might want to:

  • Make the points larger
  • Make the lines that they’re hovering over thicker
  • Add text to the points they’re hovering over
  • Add shapes the points their hovering over (vertical or horizontal line shapes)
  • Outline countries in maps

capture d ecran 2017-07-04 a 13 04 29


In this Uber Rides Dash demo created by @alishobeiri, the selected bars are replotted to be white. This persistent style informs the user which bars are selected and also matches the color palette of app itself.

selected-bars

While selected markers have a “dimming” effect, some users will want to customize the style of the selected points and the unselected points. For example, they might want to:

  • Hide the unselected points
  • Display text to the selected points (mode: "markers+text")
  • Modify the colors of either selection
  • Add an outline to points or countries instead of fading

selected-regions


In BI platforms, “clicking” is often used for drill downs. While we support click events, we don’t modify the look and feel of the graph after clicking. For example, users might want to display constant text when clicking on a point.

In addition, there are a few other default style changes for clickable points (this could be a separate issue):

  • Modify the hover interaction of the point to make it seem more “clickable”: adding cursor: pointer and making the point a little bit larger
  • Displaying an “x” over the point so that the user can “unclick” a point

capture d ecran 2017-07-04 a 13 05 19 capture d ecran 2017-07-04 a 13 05 16 capture d ecran 2017-07-04 a 13 05 51


I’m sure there are many more examples out there.

cc @alexcjohnson @etpinard @cpsievert @monfera @jackparmer

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:29
  • Comments:31 (18 by maintainers)

github_iconTop GitHub Comments

6reactions
chriddypcommented, Jul 4, 2017

Example from @cpsievert 's work. In this case, highlighting across subplots. That type of linking hover across traces might be out of the scope of this.

https://plotcon17.cpsievert.me/workshop/day2/#18

highlight

5reactions
scottlittlecommented, Sep 12, 2019

Are there any examples of highlighting a trace upon hover in plotly for python? Or has this functionality not been added to python yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

hover - CSS: Cascading Style Sheets - MDN Web Docs
The :hover CSS pseudo-class matches when the user interacts with an element with a pointing device, but does not necessarily activate it.
Read more >
Hover text and formatting in Python - Plotly
The hovermode is a property of the figure layout, so you can select a ... scatter plot using Plotly Express with custom hover...
Read more >
What Are CSS Hover Animations & How Can You Use Them?
Only in that state will the element change from one style to another. Pseudo-classes include: :hover, when a user hovers over the element;...
Read more >
Change Hover and Select Effects for WebUI Charts
To customize the styles for these states, you'll need to add a CSS file in the folder MainProject\WebUI\resources\css . You can use the...
Read more >
Webflow - Hover, pressed, and focused states - YouTube
As you're styling an element, clicking the States menu lets you toggle between the various states, like Hover and Pressed, you can access ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found