talgalili / d3heatmap

A D3.js-based heatmap htmlwidget for R
Other
236 stars 95 forks source link

Customize Tooltip Field Names #14

Closed iankloo closed 7 years ago

iankloo commented 9 years ago

The 'on hover' feature of the tooltip currently displays 'Row', 'Column', and 'Value' as labels within the box. It would be helpful to be able to change these to match the specific case.

mcjudd commented 9 years ago

I would appreciate such functionality as well. However, you can work around it for the time being by going to where your R libraries are installed, finding the folder "d3heatmap" and then navigating to "htmlwidgets/lib/d3heatmapcore" and editing heatmap.js -- the statements after the following line dictate the formatting of the tooltip:

var tip = d3.tip()
        .attr('class', 'd3heatmap-tip')
        .html(function(d, i) { // edit after here!
})

Note that, of course, this will permanently change the formatting and will need to be changed for each d3heatmap you wish to produce. Re-install the library to reset the code, or a keep a separate copy.

mcjudd commented 9 years ago

Just an update to note that the argument cellnote for the d3heatmap function allows you to supply a matrix the same size as the data.frame being visualized with the text you'd like each cell to display on hover. More details via ?d3heatmap

zhangz19 commented 7 years ago

I have exactly the same concern. Is it possible to change "row", "col" and "value" into specific dimension names? Which would be very helpful. Not sure if this could be done in shiny when rendering d3heatmap.

talgalili commented 7 years ago

Hi @iankloo

The heatmaply R package is a new implementation of interactive cluster heatmaps in R which relies on the plotly R package. This is based on a fork of my work in d3heatmap.

The package is availabale from CRAN: https://cran.r-project.org/package=heatmaply

The feature you've requested is now available by using the following code:

library(heatmaply)
heatmaply(mtcars, label_names = c("x_name", "y_name", "some_value"))

image

iankloo commented 7 years ago

Looks like there are enough good ways around this to close this down. Thanks for the responsiveness and help!

kaixis commented 7 years ago

I have R version 3.2.5 and plotly version 4.7.0, why can't I import heatmaply package?