Skip to content

Commit 692b838

Browse files
committed
implement GeomMap
1 parent 265b9a6 commit 692b838

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ S3method(to_basic,GeomHline)
2525
S3method(to_basic,GeomJitter)
2626
S3method(to_basic,GeomLine)
2727
S3method(to_basic,GeomLinerange)
28+
S3method(to_basic,GeomMap)
2829
S3method(to_basic,GeomPointrange)
2930
S3method(to_basic,GeomRaster)
3031
S3method(to_basic,GeomRect)

R/layers2traces.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@ to_basic.GeomRect <- function(data, prestats_data, layout, params, ...) {
201201
prefix_class(data, "GeomPolygon")
202202
}
203203

204+
#' @export
205+
to_basic.GeomMap <- function(data, prestats_data, layout, params, ...) {
206+
common <- intersect(data$map_id, params$map$id)
207+
data <- data[data$map_id %in% common, , drop = FALSE]
208+
map <- params$map[params$map$id %in% common, , drop = FALSE]
209+
# TODO: do we need coord_munch() as in GeomMap$draw_panel()
210+
data$id <- data$map_id
211+
data$map_id <- NULL
212+
data$group <- NULL
213+
data <- merge(data, map, by = "id", sort = FALSE)
214+
data$group <- interaction(data[names(data) %in% c("PANEL", "group", "id")])
215+
prefix_class(data, c("GeomPolygon", "GeomMap"))
216+
}
217+
204218
#' @export
205219
to_basic.GeomRaster <- function(data, prestats_data, layout, params, ...) {
206220
data <- prefix_class(data, "GeomTile")

0 commit comments

Comments
 (0)