ropensci / iheatmapr

Complex, interactive heatmaps in R
https://docs.ropensci.org/iheatmapr
Other
267 stars 35 forks source link

add_col_groups uses continuous scale if all groups are equal #43

Closed mschilli87 closed 5 years ago

mschilli87 commented 5 years ago

example from README (works fine):

library(iheatmapr)
data(measles, package = "iheatmapr")

main_heatmap(measles, name = "Measles<br>Cases", x_categorical = FALSE,
             layout = list(font = list(size = 8))) %>%
  add_col_groups(ifelse(1930:2001 < 1961,"No","Yes"),
                  side = "bottom", name = "Vaccine<br>Introduced?",
                  title = "Vaccine?",
                  colors = c("lightgray","blue"))

Assume vaccine came later (breaks labelling):

library(iheatmapr)
data(measles, package = "iheatmapr")

main_heatmap(measles, name = "Measles<br>Cases", x_categorical = FALSE,
             layout = list(font = list(size = 8))) %>%
  add_col_groups(ifelse(1930:2001 < 2002,"No","Yes"),
                  side = "bottom", name = "Vaccine<br>Introduced?",
                  title = "Vaccine?",
                  colors = c("lightgray","blue"))
AliciaSchep commented 5 years ago

Thanks for the reproducible example. I think I have found the underlying issue -- when the tickvals and ticktext are passed from R to JSON if the length is one it doesn't get passed as an array. The type being array is important on the JS side. Have implemented a fix with latest github version on master branch.

mschilli87 commented 5 years ago

I can confirm that this is fixed by 04bec9c741d0278a3c2e8a8eee2c271bbef213af.