Skip to content

charting with leaflet #11

@smartinsightsfromdata

Description

@smartinsightsfromdata

I tried charting with Leaflet.js in rCharts and with RStudio leaflet library, with no success with either.

Would you be so kind to post an example that works?

Also, have you tried Zeppelin with any htmlwidgets? Do they work?
(the method used below, of saving a file and displaying it as iframe was originally proposed by RamnathV as stop gap for jupyter with R kernel - it doesn't work with all htmlwidgets though).

Leaflet
The following works with the jupyter notebook and R kernel, but it does not work with Zeppelin R:

library(leaflet)
m <- leaflet() %>%
  addTiles() %>%  # Add default OpenStreetMap map tiles
  addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
  # Print the map
tf = 'myfigure.html'
htmlwidgets::saveWidget(m, file = tf, selfcontained = F)
IRdisplay::display_html(paste("<iframe src=' ", tf, " ' ","/>"))

rCharts
I tried to display the classic example below, but the chart is displayed on another tab as index.html (on Safari).

%spark.r
# 
library(rCharts)
map3 <- Leaflet$new()
map3$setView(c(51.505, -0.09), zoom = 13)
map3$marker(c(51.5, -0.09), bindPopup = "<p> Hi. I am a popup </p>")
map3$marker(c(51.495, -0.083), bindPopup = "<p> Hi. I am another popup </p>")
map3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions