plotly / plotly/plotly.R

hovertemplate doesn't work for points in boxplots

Open
#1,636 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Using hovertemplate on a boxplot breaks the tooltips for data points, it simply doesn't appear at all:

image

# Using hoverinfo (works)
plot_ly() %>% add_trace(y = 1:10, type = "box", hoverinfo = "y", boxpoints = "all", pointpos = 0)

# Using hovertemplate (doesn't work)
plot_ly() %>% add_trace(y = 1:10, type = "box", hovertemplate = "%{y}", boxpoints = "all", pointpos = 0)

When inspecting the hovertemplate graph using my browser's dev tools I found that this appears in the console when I move the mouse over a data point:

test2.html:1820 Uncaught TypeError: t.replace is not a function
    at Object.l.hovertemplateString (test2.html:1820)
    at SVGGElement.<anonymous> (test2.html:1820)
    at test2.html:1820
    at ut (test2.html:1820)
    at Array.W.each (test2.html:1820)
    at A (test2.html:1820)
    at test2.html:1820
    at test2.html:1820
    at l (test2.html:1820)
    at Object.r.throttle (test2.html:1820)

hovertemplate works as expected for other graph types, like e.g.:

plot_ly() %>% add_trace(y = 1:10, type = "bar", hovertemplate = "%{y}")

plotly 4.9.0
R 3.4.4

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

Reproduce the two R examples with a boxplot using boxpoints and hovertemplate, then compare them with the working bar example. Start at the hovertemplateString call shown in the browser error and trace the boxplot point-hover path; done means hovertemplate renders for boxplot data points without the t.replace error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.