Coupling tooltips on hover between subplots using r and plotly
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Der Issue enthält keine Repository-Datei und keinen Test-Einstiegspunkt. Beginne damit, das R-Beispiel mit subplot(), htmlwidgets::onRender() und Plotly.Fx.hover() zu reproduzieren, und definiere anschließend ein unterstütztes bidirektionales Hover-Verhalten sowie ein ausführbares Beispiel oder einen Test als Abschlusskriterien.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, r
- Bereich
- data-visualization
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100