mapview (version 1.2.0)

popupGraph: Create HTML strings for popup graphs

Description

Create HTML strings for popup graphs used as input for mapview or leaflet.

Usage

popupGraph(graphs, type = c("png", "svg", "html"), ...)

Arguments

graphs
A list of figures associated with x.
type
Output filetype, one of "png" (default), "svg" or "html".
...
Further arguments passed on to png or svg.

Value

A list of HTML strings required to create popup graphs.

Details

Type svg uses native svg encoding via readLines. height and width are set via ... and passed on to svg Type png embeds via ". height and width are set via ... and passed on to png Type html embeds via "

See Also

popupTable and popupImage.

Examples

Run this code
## Not run: 
# ### example: svg -----
# 
# library(sp)
# 
# data(meuse)
# coordinates(meuse) <- ~ x + y
# proj4string(meuse) <- CRS("+init=epsg:28992")
# 
# ## create plots with points colored according to feature id
# library(lattice)
# p <- xyplot(copper ~ cadmium, data = meuse@data, col = "grey")
# p <- mget(rep("p", length(meuse)))
# 
# clr <- rep("grey", length(meuse))
# p <- lapply(1:length(p), function(i) {
#   clr[i] <- "red"
#   update(p[[i]], col = clr)
# })
# 
# mapview(meuse, popup = popupGraph(p, type = "svg", width = 3, height = 2.5))
# 
# ### example: png -----
# pt <- data.frame(x = 174.764474, y = -36.877245)
# 
# coordinates(pt) <- ~ x + y
# proj4string(pt) <- "+init=epsg:4326"
# 
# p2 <- levelplot(t(volcano), col.regions = terrain.colors(100))
# 
# mapview(pt, popup = popupGraph(p2, width = 300, height = 400))
# 
# ### example: html -----
# library(scatterD3)
# p <- lapply(1:length(meuse), function(i) {
#   clr <-rep(0, length(meuse))
#   clr[[i]] <- 1
#   scatterD3(x = meuse$cadmium,
#             y = meuse$copper,
#             col_var = clr,
#             legend_width = 0)
# })
# 
# mapview(meuse, popup = popupGraph(p, type = "html", width = 400, height = 300))
# 
# mapview(pt, popup = popupGraph(mapview(pt)@map, type = "html"))
# ## End(Not run)

Run the code above in your browser using DataLab