Skip to content

Heatmap: how to specify the cell base color instead of white? #34

@u909090

Description

@u909090

Is there a way to change the color of the cells reaching the minimum value (white by default) when using a color gradient?

Example:

library(shiny)
library(apexcharter)

data("vaccines", package = "highcharter")
df <- vaccines %>% subset(year <= 1946)

ui <- fluidPage(
  apexchartOutput("heatmap")
)

server <- function(input, output) {
  output$heatmap <- renderApexchart({
    apex(df,
         aes(year, state, fill = count),
         type = "heatmap") %>% 
      ax_chart(animations = list(enabled = FALSE)) %>%
      ax_dataLabels(enabled=F) %>%
      ax_colors("#0000FF") %>%
      ax_plotOptions(heatmap = heatmap_opts(colorScale = list(min = min(df$count), max = max(df$count))))
  })  
}

shinyApp(ui = ui, server = server)

Submitting a minimum value below the actual dataset minimum value does not do the trick neither:

ax_plotOptions(heatmap = heatmap_opts(colorScale = list(min = min(df$count) - 1000, max = max(df$count))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions