[英]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 function 将 {point.value:.3f} 乘以 100
我一直在尝试根据这篇文章来破解一些东西,但我只是不明白 higcharter 或 JS 是如何工作到足以得到它的。 我什至不确定 JS function 是处理它的正确方法吗?
Yes, I think it would be best to use the Highcharts JS API (formatter function) for this: https://api.highcharts.com/highcharts/tooltip.formatter
Here you can find an article explaining how you can do this in 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() function 之前增加 100。 我最初发布的示例代码无需更改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.