plotly / plotly/plotly.R

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

未关闭
#1,446 9 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

plotly.js priority: low
主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

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)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 issue 中的最小 Shiny 应用开始,并在 Chrome 和 Firefox 中运行其 plot_ly 热力图复现。重点关注作为 z 传入的 matrix_heatmap,以及点击前后的不同表现。当提供的热力图无需点击即可一致地渲染时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
r
领域
data-visualization, frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。