简体   繁体   English

如何在默认情况下更改R中d3heatmap中的infowindow字幕?

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

I have made the below heatmap in R using the d3heatmap package. 我使用d3heatmap包在R中制作了下面的热图。 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. 解决方案是“hacky”,但是会得到你想要的。 You need to find heatmapcore.js file within the d3heatmap library: d3heatmap/htmlwidgets/lib/d3heatmapcore/heatmapcore.js 你需要在d3heatmap库中找到heatmapcore.js文件: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. 您可以将“行”,“列”和“值”替换为所需的文本。

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

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