plotly / plotly/plotly.R

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

オープン
#1,446 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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. リポジトリをフォークし、ブランチを切って変更します。
  4. 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 を短くまとめたダイジェスト。