highcharter 在工具提示中将值转换为百分比

highcharter convert value to percent in tooltip

我在高章程中制作了一个树形图,我想打印乘以 100 的值并在末尾添加一个百分比符号。我目前有这段代码可以生成下面的图像

hchart(dout, type = "treemap")%>%
  hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
                             value: {point.value:.3f}%<br>")

我想我需要一个 JS 函数来将 {point.value:.3f} 乘以 100

我一直在尝试拼凑一些东西 但我只是不明白 higcharter 或 JS 是如何工作到足以得到它的。我什至不确定 JS 函数是否是处理它的正确方法?

是的,我认为最好使用 Highcharts JS API(格式化函数):https://api.highcharts.com/highcharts/tooltip.formatter

在这里您可以找到一篇解释如何在 R 中执行此操作的文章: https://www.highcharts.com/blog/tutorials/working-with-highcharts-javascript-syntax-in-r/?fbclid=IwAR0fZ97iISS1_itErg69A6ncxI8R1JUuLVAzj4V_af7FE9oPkMBIPR3F9-I

因为我不明白如何使用 JS 集成为我提供的示例,所以我决定以不同的方式解决这个问题,我只是在我的代码前面添加了一行来转换我正在打印的 df dout 中的值在工具提示中显示为 point.value,在到达 hchart() 函数之前增加 100。我最初发布的示例代码无需更改