3

I'd like to embed images (rather than the default Row - Column - Value data) in the d3 tooltip when scrolling over a cell.

library(shiny)
library(d3heatmap)

ui <- shinyUI(fluidPage(

  titlePanel("Old Faithful Geyser Data"),
mainPanel(
  d3heatmapOutput("out")
)
  )
)

server <- shinyServer(function(input, output) {

  output$out <- renderD3heatmap({
   d3heatmap(x = mtcars,
          Colv = NULL,
          scale= "column",
          key = FALSE,
          yaxis_font_size = "10pt",
          xaxis_font_size = "10pt")
 })

})

shinyApp(ui = ui, server = server)

Default Tooltip

1981 Toyota Carona

Dr. Daniel
  • 73
  • 5
  • The tooltip is generated by d3 in the following file https://github.com/rstudio/d3heatmap/blob/5babdac713ba874889079ead4b800af1ac0c895b/inst/htmlwidgets/lib/d3heatmapcore/heatmapcore.js (line 238-248). One way would be to modify that file directly (you'll need to add your image url to the `data` javascript object somehow) – Xiongbing Jin Oct 14 '16 at 15:48

1 Answers1

1

One way to do this is to encode your image in base64 and then pass a matrix of those images to d3heatmap(..., cellnote = )

    var tip = d3.tip()
    .attr('class', 'd3heatmap-tip')
    .html(function(d, i) {
        return ('<img src="' + d.label + '"/>');
    })
Dr. Daniel
  • 73
  • 5