plotly / plotly/plotly.R

When calling on geom_area tooltip activates when hovering over line, not area

Open
#2,343 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

Calling ggplotly on ggplot invoking geom_area results in a plot in which the tooltip activates when hovering over the "lines" separating the areas. I would have expected the tooltip to activate when hovered over the filled area.

Here is some reprex

library("ggplot2")
library("plotly")

#create the data
data <- data.frame('year' = rep(1981:2020, 2),
           "type" = rep(c("a", "b"), 40),
           "value" = runif(80))

#Generate the plot
ggplotly(
  ggplot(data, 
         aes(x = year, y = value, fill = type)) +
    geom_area(col = "grey", size = 0.5) #set the line col so that you can see the activation when close to the line
)
  

I don't see any open or closed issues on this. Online, I only see this solution: https://stackoverflow.com/questions/47331323/ggplotly-and-geom-area-display-informations-when-hovering-over-an-area-not-a, which seems convoluted.

Regardless of that solution, I would still assume the expected behavior for geom_area is for the tooltip to activate over the area, not the line.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided reprex with R, ggplot2, and plotly, then inspect the ggplotly conversion for geom_area hover behavior. Done means the tooltip activates when hovering over the filled area rather than only along the lines separating areas.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.