plotly / plotly/plotly.R

config modeBarButtonsToRemove fails if length is 1

オープン
#1,433 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

1要素およびスカラーの modeBarButtonsToRemove 値を使用して、R の例で失敗を再現します。ブラウザーのスタックトレースに示されている renderValue エントリーポイントから開始し、単一ボタンの構成がエラーなしでレンダリングされる一方で、既存の複数ボタンの動作が維持されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, r
領域
data-visualization, frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。