Unable to index traces with a continuous legend using both add_trace and plotlyproxyinvoke "add_trace"
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, r
- Ambito
- data-visualization
Direzione di ricerca
Iniziare con l’esempio Shiny fornito usando renderPlotly, plotlyProxyInvoke("addTraces") e deleteTraces, quindi confrontare l’ordine delle trace quando la legenda continua viene creata durante il rendering rispetto a quando viene creata successivamente. Riprodurre gli indici differenti e verificare che l’aggiunta e l’eliminazione della trace evidenziata puntino in modo coerente alla trace prevista.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I have a number of plots that I am trying to synchronize and draw a highlighted point on in response to a users search. This works fine except when they are in tabs. Plotly proxy can't add a trace to graph that is not yet drawn, and in Shiny there isn't a good way to trigger an event after the plot is drawn. Subsequently I have added a manual add_trace check to see if a search has found a point that needs to be highlighted. However, when I add a trace directly to the figure. The traces are added in different orders, I gather the legend is added after both traces are defined. It appears that a continuous legend gets added as a trace, after all traces are drawn. So in a different order than when invokeProxy.
So in scenario one when a plot has been drawn and I add a trace the new trace has an index of 2, however if I draw the plot then add it within the same render function the legend has an index of 2.
It's really difficult to generate a reproducible example here, as I have done a number of tests, and things are pretty confusing. For example, if I add a name variable. name= ~SERIAL_NUM then for some reason each point gets it's own trace index. However, this obliterates the hover text for some reason.
library(shiny)
library(plotly)
ui <- fluidPage(
plotlyOutput("plot"),actionButton(label="add","addtrace"),actionButton(label="delete","deletetrace")
)
server <- function(input, output, session) {
plotproxy <- plotlyProxy("plot", session=session, deferUntilFlush=FALSE)
output$plot <- renderPlotly({
a = seq(1,10,1)
b = seq(100,1000,100)
c = seq(1,4.9,0.4)
data = tibble(a,b,c)
data <- data %>% mutate(res = a+b+c)
layout_details <- list(xaxis = list(title = 'a [-]'),
yaxis = list(title = 'b [-]'),
zaxis = list(title = 'c [-]'),
coloraxis=list(colorbar=list(title=list(text='Here are the results'))))
p = plot_ly(data, x = ~a, y = ~b , color = ~res, type = 'scatter',
mode = 'markers', text = ~res, showlegend = FALSE, scene = 'scene1',hovertemplate = paste('<b><b>SERIAL_NUM</b>: %{text}'))
p
})
observeEvent(input$addtrace, {
plotproxy%>%plotlyProxyInvoke("addTraces", list(list(
x = list(2),
y = list(2),
type = 'scatter',
mode = 'markers' ,
marker = list(size = 10,
color = 'rgba(255, 18 , 19 , .9)',
line = list(color = 'rgba(0, 0, 0, .3)',
width = 3))
)))
})
observeEvent(input$deletetrace, {
plotproxy%>%plotlyProxyInvoke("deleteTraces",2)
})
}
shinyApp(ui, server)
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di plotly/plotly.R
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
-
save_image Error Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
Tutte le issue di plotly/plotly.R
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pharmaverse/rtables#1123 · 1 commento ·
-
Trying to reassign a reactiveVal to the name of an existing reactiveVal doesn't overwrite the latter Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
RConsortium/rconsortium_website#649 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
posit-dev/r-shinylive#203 ·
-
add tidycjk and tidyEmoji Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100