highcharter
highcharter copied to clipboard
tooltip option to show an image
Hello,
Thank you so much for your R wrapper to use the stunning Highcharts Library. Would it be possible to have a tooltip to show an image (.png)? I know that you have a few posts about tooltips, but this did not seem to be a direct extension of those.
Yes, you can. Here's an example.
library(highcharter)
data(economics, package = 'ggplot2')
economics <- economics[1, ]
highchart() %>%
hc_xAxis(categories = economics$date, type = "datetime") %>%
hc_add_series(name = "Unemployed", data = economics$unemploy) %>%
hc_tooltip(useHTML = T,
formatter = JS("function() {
var img = '<img src = \"https://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Transparent_Background_Dromedary_Camel.png/97px-Transparent_Background_Dromedary_Camel.png?20220413201058\" height=\"80\" width=\"99\"/>';
return img
}"))
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.