highlight() fails in lineplots after crosstalk filter if plot_ly()'s "color" argument matches highlight_key()'s key
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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)
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)
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với bản tái hiện R tối thiểu bằng cách sử dụng plot_ly(), add_lines(), highlight_key() và filter_select(), so sánh color = ~country với color = ~continent. Theo dõi cách biểu đồ đường xử lý việc lọc và làm nổi bật của crosstalk, sau đó xác minh rằng các mục đã lọc vẫn có thể được làm nổi bật khi color khớp với biến của highlight_key().
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- r
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100

