plotly / plotly/plotly.R

highlight() fails in lineplots after crosstalk filter if plot_ly()'s "color" argument matches highlight_key()'s key

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

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

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

説明

I am making an interactive plotly plot with R using highlight() and crosstalk filter_select() functions. However, when the argument "color" of plotly's lines match highlight_key(), it becomes impossible to highlight any light of the filtered data in the plot.

Let's say you pick up the example in "Interactive web-based data visualization with R, plotly, and shiny" by Carson Sievert, in the Figure 16.10 of the chapter 16.1 "Graphical queries"
The example provided by the book works fine, you can highlight an item after filtering data:

library(gapminder)
g <- highlight_key(gapminder, ~country)
continent_filter <- filter_select("filter", "Select a country", g, ~continent)

p <- plot_ly(g) %>%
  group_by(country) %>%
  add_lines(x = ~year, y = ~lifeExp, color = ~continent) %>%
  layout(xaxis = list(title = "")) %>%
  highlight(selected = attrs_selected(showlegend = FALSE))

bscols(continent_filter, p, widths = 12)

enter image description here

However, when "color" argument of add_lines() matches highlight_key() variable (in this case, ~country) it is not possible to filter AND highlight the filtered data

library(gapminder)
g <- highlight_key(gapminder, ~country)
continent_filter <- filter_select("filter", "Select a country", g, ~continent)

p <- plot_ly(g) %>%
  group_by(country) %>%
  # Please mind that in the next line IS NOT "color = ~continent" as in the last example
  add_lines(x = ~year, y = ~lifeExp, color = ~country) %>%
  layout(xaxis = list(title = "")) %>%
  highlight(selected = attrs_selected(showlegend = FALSE))

bscols(continent_filter, p, widths = 12)

enter image description here

Is it possible to highlight items in an interactive plot_ly lineplot (because I've checked in boxplot and it works) when the color argument of plotly's plot matches the highlight_key?
I've also tried with geom_line() + ggplotly() but won't work neither

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

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

はじめの一歩

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

調査の方向性

plot_ly()、add_lines()、highlight_key()、filter_select()を使用した最小限のR再現から始め、color = ~countryとcolor = ~continentを比較します。折れ線グラフがcrosstalkのフィルタリングとハイライトをどのように処理するかを追跡し、その後、colorがhighlight_key()変数と一致する場合に、フィルタリングされた項目も引き続きハイライトできることを確認します。

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

評価

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

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

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