I've made a treemap in high charter and I want to print the value multiplied by 100 and add a percentage symbol on the end. I currently have this code that produces the image below
hchart(dout, type = "treemap")%>%
hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
value: {point.value:.3f}%<br>")
I'm thinking I need a JS function to multiply {point.value:.3f} by 100
I've been trying to hack together something based on this post but I just don't understand how higcharter or JS work enough to get it. I'm not even sure a JS function is the right way to handle it?
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
Because I don't understand how to integrate the examples provided for me using JS I decided to attack this problem differently and I just added a line earlier in my code to convert the value in the df dout that I am printing out as point.value in the tooltip, by 100 before it gets to the hchart() function. No change is necessary to the example code I posted initially
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.