Coupling tooltips on hover between subplots using r and plotly
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 would like to do a plot like this one: https://www.somesolvedproblems.com/2020/03/how-to-link-plotly-events-between-plots.html
Here is what I have tried:
library(tidyverse)
library(htmlwidgets)
library(ggplot2)
library(plotly)
library(shiny)
x <- seq(0,1, 0.001)
y <- sin(2*pi*x)
z <- cos(2*pi*x)
df <- data.frame(x = x, y = y, z = z)
p <- ggplot(df, aes(x, y)) + geom_line()
q <- ggplot(df, aes(x, z)) + geom_line()
r <- subplot(p
, q
, nrows =1
, titleX = FALSE
, titleY = FALSE)
r$elementId <- "rt"
s <- r %>%
onRender("
function(el) {
el.on('plotly_hover', function (eventdata){
console.log(eventdata.xvals);
Plotly.Fx.hover('rt',
[
{ curveNumber: 0, pointNumber:eventdata.points[0].pointNumber },
{ curveNumber: 1, pointNumber:eventdata.points[0].pointNumber },
]
);
}
")
with hints from: https://community.plotly.com/t/coupling-hover-events-for-side-by-side-subplots/2049 and https://plotly-r.com/js-event-handlers.html
However, this does not work yet. Primarily, because of my lack of understanding of the javascript issues. Is such bidirectional trigger possible? Can this be done using plotly package and related tools such as htmlwidgets and htmltools package for r? Thanks.
This issue is also posted on stackoverflow:
Link to issue on Stackoverflow
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
Issue không cung cấp tệp nào trong repository hoặc điểm bắt đầu của test. Trước tiên, hãy tái hiện ví dụ R bằng subplot(), htmlwidgets::onRender() và Plotly.Fx.hover(), sau đó xác định hành vi hover hai chiều được hỗ trợ và một ví dụ hoặc test có thể thực thi làm tiêu chí hoàn thành.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, r
- Lĩnh vực
- data-visualization
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100