简体   繁体   English

R / d3heatmap /有光泽 - 有没有办法在d3工具提示中嵌入图像?

[英]R / d3heatmap / shiny - is there a way to embed images in d3 tooltip?

I'd like to embed images (rather than the default Row - Column - Value data) in the d3 tooltip when scrolling over a cell. 我想在滚动单元格时在d3工具提示中嵌入图像(而不是默认的行 - 列 - 值数据)。

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 1981丰田卡罗纳

One way to do this is to encode your image in base64 and then pass a matrix of those images to d3heatmap(..., cellnote = ) 一种方法是在base64中对图像进行编码,然后将这些图像的矩阵传递给d3heatmap(...,cellnote =)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM