plotly / plotly/plotly.R

selectedpoints for curvenumber > 0 invisible when using scattergl

Aperta
#2,482 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
R
Stelle
2.7k
Fork
641
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I'm not sure if this is an issue with the R library (latest CRAN version 4.12.0) or plotly.js however, when setting selectedpoints on a scattergl trace for curvenumbers > 0, the points turn invisible - for curvenumber 0 it works as it should. If you look closely, you can see that the points were faded out before they are selected and when selected they disappear.

Using a scatter trace instead everything works as expected.

Image

library(shiny)
library(plotly)

DF <- data.frame(
  x = rep(1:10, 3),
  y = c(
    seq(1, 5, length.out = 10),
    seq(1, 7, length.out = 10),
    seq(1, 10, length.out = 10)
  ),
  grp = rep(LETTERS[1:3], each = 10)
)

ui <- fluidPage(
  plotlyOutput("my_plot"),
  selectInput("plot_type", "Plot Type", choices = c("scatter", "scattergl"), selected = "scatter"),
  numericInput(
    inputId = "point_number",
    label = "Point Number",
    value = 0,
    min = 0,
    max = 9
  ),
  numericInput(
    inputId = "curve_number",
    label = "Curve Number",
    value = 0,
    min = 0,
    max = 2
  )
)

server <- function(input, output, session) {
  my_plot_proxy <- plotlyProxy(
    outputId = "my_plot"
  )
  
  observe({
    plotlyProxyInvoke(my_plot_proxy, "restyle", list(selectedpoints = -1)) # deselect all points for all traces
    plotlyProxyInvoke(my_plot_proxy, "restyle", list(selectedpoints = list(I(input$point_number))), input$curve_number)
  })
  
  output$my_plot <- renderPlotly({
    plot_ly(data = DF, type = input$plot_type, mode = "lines+markers", x = ~x, y = ~y, name = ~grp)
  })
}

shinyApp(ui, server)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione minima di Shiny nell’issue e confronta scatter con scattergl variando curve_number e selectedpoints. Traccia il percorso di restyle di plotlyProxyInvoke per le tracce diverse da zero; l’issue è completata quando i punti selezionati rimangono visibili per ogni curva, come nel comportamento di scatter.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, r
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.