jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
718 stars 147 forks source link

tooltip option to show an image #767

Open peterlittlejohn opened 2 years ago

peterlittlejohn commented 2 years ago

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.

fraupflaume commented 1 year ago

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
               }"))

image

stale[bot] commented 3 months ago

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.