plotly / plotly/plotly.R

Update Button badly mixes legenditems of plot (`updatemenus`)

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

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

主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi, I´ve come across a weird thing:

I tried the plotly "Update Button" on a plot with a legend. At first everything seems as expected. But as soon as you toggle the plot with help of the update button, the legend is mixed in odd ways. Sometimes the legend even does not correspond to the data at all (e.g. change sensors to 4 in reprex).

example

Heres an example to play around

library(plotly)

df <- data.frame(
  car =    c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), # two cars
  sensor = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5), # with 5 sensors
  x =      c(1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2), # sensor data
  y =      c(2, 1, 3, 5, 6, 5, 3, 2, 1, 6, 7, 3, 8, 1, 5, 9, 2, 2, 5, 5)
)

updatemenus <- list(
  list(
    type = "buttons",
    buttons = list(
      list(
        label = "Car 1",
        method = "update",
        args = list(list(visible = list(T, F)))),
      list(
        label = "Car 2",
        method = "update",
        args = list(list(visible = list(F, T))))
    )
  )
)

fig <- plot_ly(type = 'scatter', mode = "lines")
fig <- fig |> add_lines(~x, ~y, data = df[df$car == 1,], name = ~sensor)
fig <- fig |> add_lines(~x, ~y, data = df[df$car == 2,], name = ~sensor, visible = FALSE)
fig <- fig |> layout(
  updatemenus = updatemenus,
  legend = list(title = list(text = "<b> Sensor </b>"))
  )

fig

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

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

はじめの一歩

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

調査の方向性

まず、提供された R reprex を plotly の更新ボタンとともに実行し、センサー数を変化させます。updatemenus の可視性更新が凡例にどのような影響を与えるかを追跡し、各ボタンによって現在表示されているデータに一致する凡例項目だけが残ること、また既存の例で混在した項目が表示されなくなっていることを確認します。

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

評価

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

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

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