plotly / plotly/plotly.R

Targeting/Adding traces in subplot

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

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

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

説明

Hi - I'm trying to add/change traces in a graph with subplots. Below the example code.

It looks like each subplot becomes one trace (based on playing with the restyle section), but it is unclear to me how to add/remove traces. I changed the addTraces number at the end to 0-3 but it always adds it to the first subplot.

Any help would be appreciated.


data <- tibble(runmonth=c(1,1,1,1,4,4,4,4),variable=c('a','a','b','b','a','a','b','b'),x=c(1:8),y=c(8:1),keyname=paste0('k',c(1:8)))

p <- data %>% group_by(runmonth,variable) %>%
  do(
    p = highlight_key(., ~keyname,group='scattergroup') %>%
      plot_ly(showlegend = FALSE) %>%
      add_markers(
        x = ~x, y = ~y
      )
  ) %>%
  subplot(
    nrows = 2, margin = 0.01,
    shareY = TRUE, shareX = TRUE, titleY = FALSE
  ) %>% toWebGL() %>%
  highlight(
    on = "plotly_selected",
    off = c('plotly_relayout')
  )


ui <- function(id) {
  div(
    actionButton('go','go'),
    plotlyOutput("scattergr")
  )
}

server <- function(input,output,session) {
  
  output$scattergr <- renderPlotly({p})
  
  observeEvent(input$go,{
    plotlyProxy("scattergr", session) %>%
      plotlyProxyInvoke(
        "restyle",
        list(
          'marker.symbol' = list(c(rep('triangle-up',1),'circle'))
        ),
        list(0,1,2,3)
      ) %>%
      plotlyProxyInvoke(
        "addTraces",
        list(
          x = c(50,60),
          y = c(50,60),
          mode = "scatter"
        ),1
      ) %>%
      plotlyProxyInvoke(
        "moveTraces",
        -1,0
      )
  })
  

}

runApp(shinyApp(ui, server))

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

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

はじめの一歩

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

調査の方向性

提供された Shiny 再現例を出発点として使用し、subplot の例における restyle、addTraces、moveTraces の plotlyProxyInvoke 呼び出しに注目してください。subplot における trace のインデックス付けの想定される動作と、結果がコードの修正になるべきか、より明確なドキュメントになるべきかを判断してください。完了の条件は、要求された trace を予測可能な形で対象にできることです。

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

評価

技術スタック
javascript, r
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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