'R plotly waterfall with offset base: hovertext activated on hover at wrong position
Recently, when using an offset (a non-zero base
parameter) in a waterfall plot in plotly, I noticed that the boxes with hoverinfo were activated when the mouse pointer was in a completely wrong/unexpected place. Below I've pasted in screenshots to illustrate the problem.
Mouse pointer just to the left of the value in the
base
parameter:Mouse pointer inside the green box (same behavior to the right of the box):
Just found a similar question on the Plotly forum for the Python Dash users here, but it looks like it hasn't been answered.
Any ideas what might be wrong here?
I'm attaching the code below for reproducing the example shown in the pictures:
library(dplyr)
library(plotly)
set.seed(123)
test_x <- rnorm(10)
test_y <- c(LETTERS[1:10], "all") %>% factor(., levels = .)
test_base <- -15
test_data <- tibble(
x = c(test_x, 0),
y = test_y,
text = c(paste("test", 1:10), "all"),
measure = c(rep("relative", 10), "total")
)
plot_ly(
test_data,
type = "waterfall",
orientation = "h",
measure = ~measure,
x = ~x,
y = ~y,
base = test_base,
text = ~text,
textposition = "none",
hoverinfo = "text",
decreasing = list(marker = list(color = "orange"))
) %>%
layout(
yaxis = list(autorange = "reversed", title = "y"),
xaxis = list(title = "x")
)
Solution 1:[1]
I filed a detailed issue report on the plotly.js GitHub repo, and, unfortunately, it was recognized as a bug. As such, this doesn't seem to have much to do with SO, so I'm posting this answer in case anybody faces the same problem, and said bug hasn't been fixed yet.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | pharmhax |