config modeBarButtonsToRemove fails if length is 1
未关闭
还没有人认领这个 Issue。
good-for-first-time-contribution
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用单元素和标量的 modeBarButtonsToRemove 值,通过 R 示例重现该故障。从浏览器堆栈跟踪中显示的 renderValue 入口点开始,然后验证单按钮配置能够无错误地渲染,同时现有的多按钮行为保持不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, r
- 领域
- data-visualization, frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100