Highcharter树形图能显示百分比吗?

时间:2017-12-13 21:22:46

标签: javascript r highcharts

如何将百分比信息添加到highcarter treemap工具提示?

我尝试将{point.percentage:.0f}添加到hc_tooltip,但它无效。

require(treemap)
require(highcharter)
data("GNI2014")

tm <-  treemap(
  GNI2014,
  index = c("continent", "iso3"),
  vSize = "population",
  vColor = "GNI",
      type = "value"
    )

hctreemap(tm = tm) %>% 
hc_tooltip(
pointFormat = "<b>{point.name}</b><br> {point.value:.0f} <br>{point.percentage:.0f}")

enter image description here

1 个答案:

答案 0 :(得分:1)

以下是使用tooltip.pointFormatter函数在 JS 中执行此操作的示例:http://jsfiddle.net/kkulig/chdn4r0d/

可以在 Highcharter 中完成,如下所示:

hc_tooltip(pointFormatter = JS("function(){/* function body goes here*/}")