Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I'm trying to add a chart as a tooltip when clicking on my data point in a map.
For this I'm using the leaflet package to create a map and the data point on a specific location and the chart as a tooltip comes from the highcharter package. I'm basically trying to get the same result as discussed in this link on StackOverflow: https://stackoverflow.com/questions/59173708/r-leaflet-highcharter-tooltip
This is the piece of code that is used in my custom visual based in R, so with RHTML ->
source('./r_files/flatten_HTML.r')
############### Library Declarations ###############
libraryRequireInstall("leaflet");
libraryRequireInstall("sf");
libraryRequireInstall("htmlwidgets");
libraryRequireInstall("dplyr");
libraryRequireInstall("stringr");
libraryRequireInstall("htmltools");
libraryRequireInstall("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)
)
}
Leaflet_Map <- leaflet()
Leaflet_Map <- addProviderTiles(Leaflet_Map, providers$CartoDB)
Leaflet_Map <- addCircleMarkers(Leaflet_Map, 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))
Leaflet_Map <- onRender(Leaflet_Map,
"
function(el,x) {
this.on('popupopen', function() {HTMLWidgets.staticRender();})
}
") %>% add_deps("highchart", 'highcharter') %>% browsable()
############# Create and save widget ###############
internalSaveWidget(Leaflet_Map, 'out.html')
The problem is that the piece of code 'add_deps("highchart", 'highcharter')' gives me the error. If I remove it, I'm almost getting the right result which is an empty box.
But when I use the full code with the adding of 'add_deps("highchart", 'highcharter')', I get this error:
My first thought was to change something in the function internalSaveWidget which resides in the 'flatten_HTML.r' file.
Can somebody help me with this problem please?
Hi @naelske_cronos ,
Please refer to this blog to check whether your highchart option is correct.
For reference: What is highcharter?
Here is a similar post like yours about how to add tooltips in Power BI custom R visual.
For reference: Change R visual to Custom visual with Tooltip
I hope they could help you solve your problem.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @Anonymous
I don't have enough with this information. I thought having more information about the error in the code but no problem. I'll not accept this as an answer to my solution but thanks for your reply.
I used another method to show a tooltip with the R custom visual and this is saving a plot with the ggplot package to a SVG file. This works perfectly!
Kind regards
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
4 | |
3 | |
3 | |
3 | |
2 |