简体   繁体   中英

How to change infowindow captions in d3heatmap in R from the default?

I have made the below heatmap in R using the d3heatmap package. Is it possible to change Row, Column, Value to custom labels? 在此输入图像描述

I can't find in the libary info regarding editing the background colo/transparency/font etc.

I had the same problem. The solution is "hacky", however will get you what you want. You need to find heatmapcore.js file within the d3heatmap library: d3heatmap/htmlwidgets/lib/d3heatmapcore/heatmapcore.js

Find the following lines:

var tip = d3.tip()
        .attr('class', 'd3heatmap-tip')
        .html(function(d, i) {
          return "<table>" +
            "<tr><th align=\"right\">Row</th><td>" + htmlEscape(data.rows[d.row]) + "</td></tr>" +
            "<tr><th align=\"right\">Column</th><td>" + htmlEscape(data.cols[d.col]) + "</td></tr>" +
          "<tr><th align=\"right\">Value</th><td>" + htmlEscape(d.label) + "</td></tr>" +
            "</table>";
        })
        .direction("se")
        .style("position", "fixed");

You can replace "Row", "Column" and "Value" with the text you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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