Search code examples
rshinyplotlyhoverheatmaply

Customising heatmaply hover in R Shiny app


I have a plotlyOutput heatmap in a R Shiny app, which I render through heatmaply.

When I hover the mouse on the heatmap I get a popup saying

Row - [rowname] 
Column - [columnname]
Value - xxxxx

How would I go about customising this to a custom string?


Solution

  • We can overwrite the default hovertemplate via style():

    library(heatmaply)
    library(datasets)
    
    heatmaply(mtcars) |> style(hovertemplate = paste0("X: %{x}<extra></extra>"))