highcharter icon indicating copy to clipboard operation
highcharter copied to clipboard

tooltip option to show an image

Open peterlittlejohn opened this issue 2 years ago • 2 comments

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.

peterlittlejohn avatar Jun 14 '22 15:06 peterlittlejohn

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

fraupflaume avatar Nov 25 '22 04:11 fraupflaume

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.

stale[bot] avatar Mar 17 '24 09:03 stale[bot]