plotly / plotly/plotly.R

Inconsistent behavior with numeric/non-numeric z values in heatmap

Aperta
#1,446 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

plotly.js priority: low
Lingua principale
R
Stelle
2.7k
Fork
641
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi,
I have a problem with a plotly heatmap in a shiny app, it is ok in Chrome but wrong in Firefox (Windows 10). And it happens until you click the heatmap. Here is the built app where I got the problem: https://violetr.shinyapps.io/tidytuesdaytweets/. Any idea?

Code to generate an app with only the heatmap:

library(shiny)
library(plotly)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout
library(tidyverse)
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#> 
#>     date

# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(

  # Application title
  title = "example_firefox",
  h2("The graph:"),
  plotlyOutput("distPlot", height = "160px", width = "550px"),
  hr()
))


server <- shinyServer(function(input, output) {
  all_dates_period <-
    tibble(gen_date = as_date(as_date("2018-04-01"):as_date("2018-12-22"))) %>%
    mutate(
      month_name = month(gen_date, TRUE),
      week_num = epiweek(gen_date), # to  start on Sun
      week_day = wday(gen_date, TRUE),
      n = 0
    )

  base_to_heatmap <- all_dates_period %>%
    select(-month_name, -gen_date)

  output$distPlot <- renderPlotly({
    to_heatmap <-
      base_to_heatmap %>%
      spread(key = week_num, value = n) %>%
      as.data.frame()

    matrix_heatmap <- as.matrix(to_heatmap)
    matrix_heatmap <- matrix_heatmap[ nrow(matrix_heatmap):1, ]

    mycols <- c("#ebedf0", "#c6e48b", "#7bc96f", "#239a3b", "#196127")
    mypalette <- colorRamp(mycols)
    library(plotly)
    plot_ly(
      z = matrix_heatmap,
      type = "heatmap",
      colors = mypalette, xgap = 0.5, ygap = 0.5,
      showscale = FALSE
    ) %>%
      layout(
        yaxis = list(
          ticks = "",
          # ticktext = lab_row_days,
          tickmode = "array",
          tickfont = list(color = "86888A"),
          tickvals = 0:6,
          zeroline = FALSE
        ),
        xaxis = list(
          side = "top",
          # ticktext = lab_column_months,
          ticks = "",
          tickmode = "array", tickangle = 0,
          tickfont = list(color = "86888A"),
          tickvals = 0:38,
          zeroline = FALSE
        )
      ) %>%
      config(displayModeBar = FALSE)
  })
})

# Run the application
shinyApp(ui = ui, server = server)

Shiny applications not supported in static R Markdown documents

Created on 2019-01-08 by the reprex package (v0.2.1)

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 l’app Shiny minima dell’issue ed esegui la riproduzione della heatmap plot_ly in Chrome e Firefox. Concentrati sulla matrix_heatmap passata come z e sul comportamento differente prima e dopo il clic. Il lavoro è completato quando la heatmap fornita viene visualizzata in modo coerente senza richiedere un clic.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.