I want to include a highcharter plot in my leaflet popup. With help from this post Iam able to include a sparkline plot. However, due
Hello @Pierre and @MalditoBarbudo, I have tried to adapt your exemple in a shinyApp and I was not able to run it corretly
Can I have some help please?
library(shiny)
library(tidyverse)
library(htmlwidgets)
library(htmltools)
library(leaflet)
library(highcharter)
as.character.htmlwidget <- function(x, ...) {
htmltools::HTML(
htmltools:::as.character.shiny.tag.list(
htmlwidgets:::as.tags.htmlwidget(
x
),
...
)
)
}
add_deps <- function(dtbl, name, pkg = name) {
tagList(
dtbl,
htmlwidgets::getDependency(name, pkg)
)
}
ui = fluidPage(
leafletOutput("map")
)
#server.r
server = function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
addCircleMarkers(lat = 45.4, lng = 14.9,
popup = list(paste(as.character(
hchart(data.frame(x = 1:10, y = 1:10), type = "line", hcaes(x = x, y = y)) %>% hc_size(width = 300, height = 200)
))),
popupOptions = popupOptions(minWidth = 300, maxHeight = 200)) %>%
onRender(
"
function(el,x) {
this.on('popupopen', function() {HTMLWidgets.staticRender();})
}
") %>%
add_deps("highchart", 'highcharter') %>%
browsable()
})
}
shinyApp(ui = ui, server = server)