plotly / plotly/plotly.R

selectedpoints for curvenumber > 0 invisible when using scattergl

Offen
#2,482 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

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'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)

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der minimalen Shiny-Reproduktion im Issue und vergleiche scatter mit scattergl, während du curve_number und selectedpoints variierst. Verfolge den plotlyProxyInvoke-restyle-Pfad für Traces ungleich null; das Issue ist erledigt, wenn ausgewählte Punkte für jede Kurve sichtbar bleiben und dem Verhalten von scatter entsprechen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.