config modeBarButtonsToRemove fails if length is 1
Open
Nobody has claimed this yet.
good-for-first-time-contribution
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
The plot silently fails to render and throws a javascript error when listing only 1 button for removal with config(modeBarButtonsToRemove = c(...))
# Basic failure
plot_ly(data = mtcars, x = ~mpg, y = ~wt) %>%
config(modeBarButtonsToRemove = c("hoverCompareCartesian"))
plot_ly(data = mtcars, x = ~mpg, y = ~wt) %>%
config(modeBarButtonsToRemove = c("zoom2d"))
# Fails even when button is superfluous ("zoom3d" not needed for a 2d plot)
plot_ly(data = mtcars, x = ~mpg, y = ~wt) %>%
config(modeBarButtonsToRemove = c("zoom3d"))
# Fails when passed as a scalar
plot_ly(data = mtcars, x = ~mpg, y = ~wt) %>%
config(modeBarButtonsToRemove = "hoverCompareCartesian")
// javscript error from browser
Uncaught TypeError: x.config.modeBarButtonsToRemove.push is not a function
at Object.renderValue (plotly.js:155)
at exports.OutputBinding.shinyBinding.renderValue (htmlwidgets.js:516)
at exports.OutputBinding.onValueChange (output_binding.js:16)
at exports.OutputBinding.delegator.(:7541/anonymous function) [as onValueChange] (http://127.0.0.1:7541/htmlwidgets-1.3/htmlwidgets.js:112:23)
at OutputBindingAdapter.onValueChange (output_binding_adapter.js:21)
at ShinyApp.receiveOutput (shinyapp.js:332)
at ShinyApp.<anonymous> (shinyapp.js:544)
at ShinyApp._sendMessagesToHandlers (shinyapp.js:529)
at ShinyApp.dispatchMessage (shinyapp.js:515)
at WebSocket.c.onmessage (shinyapp.js:112)
renderValue @ plotly.js:155
shinyBinding.renderValue @ htmlwidgets.js:516
onValueChange @ output_binding.js:16
delegator.(anonymous function) @ htmlwidgets.js:112
onValueChange @ output_binding_adapter.js:21
receiveOutput @ shinyapp.js:332
(anonymous) @ shinyapp.js:544
_sendMessagesToHandlers @ shinyapp.js:529
dispatchMessage @ shinyapp.js:515
c.onmessage @ shinyapp.js:112
Adding a second, even irrelevant value, fixes the error.
# Remove 2 buttons
plot_ly(data = mtcars, x = ~mpg, y = ~wt) %>%
config(modeBarButtonsToRemove = c("hoverCompareCartesian","zoom2d"))
# zoom3d would not appear by default because this is a 2d plot, but adding it to the argument prevents the error
plot_ly(data = mtcars, x = ~mpg, y = ~wt) %>%
config(modeBarButtonsToRemove = c("hoverCompareCartesian","zoom3d"))
I am using plotly 4.8.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the R examples using one-element and scalar modeBarButtonsToRemove values. Start at the plotly.js renderValue entry point shown in the browser stack trace, then verify that single-button configurations render without errors while the existing multi-button behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, r
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100