plotly / plotly/plotly.R

distinguish links and nodes in sankeyPlot using event_data

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

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

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

説明

I am building a sankey plot using plotly package with R within a Shiny application.
At some point, I use event_data function which returns an index pointNumber which is an integer ranging from 0 to the number of pairwise nodes relationships.
When performing sankeyPlot in plotly you have to specify the node and link arguments. The problem is that pointNumber provides an index which I cannot distinguish between the node or the link.
I would like the app could identify if the user clicks on a node or on a link.

Here is a toy example. Note that when clicking on node "A", pointNumber returns 0, and the same when clicking on link connecting node "A" and node "B".

library(plotly); library(shiny)
ui <- fluidPage(
  plotlyOutput("plot"),
  verbatimTextOutput("index")
)
server <- function(input, output){
  output$index <- renderPrint({
    event_data("plotly_click", source="sankeyPlot")
  })
  output$plot <- renderPlotly({
    plot_ly(
      source = "sankeyPlot",
      type = "sankey",
      arrangement = "fixed",
      node = list(label = c("A","B","C","D"), hoverinfo="none"),
      link = list(source=c(0,0,1,2), target=c(1,2,3,3), value=c(2,5,2,1), hoverinfo="none")
    )
  })
}
shinyApp(ui, server)

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

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

はじめの一歩

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

調査の方向性

sankey プロットで event_data("plotly_click") を使用する toy Shiny 例から始め、ノードとリンクのクリックに対して返される pointNumber を調べます。sankeyPlot イベントがどのように表現されるかを追跡し、返されるデータによってクリックされた要素をどのように区別できるかを判断します。アプリがクリックの対象がノードかリンクかを確実に識別できれば完了です。

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

評価

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

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

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