Skip to content

Commit 6d19950

Browse files
committed
Add arrow to line params
1 parent 6e3ac81 commit 6d19950

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

R/geom-sf.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,15 @@ GeomSf <- ggproto("GeomSf", Geom,
128128

129129
draw_panel = function(data, panel_params, coord, legend = NULL,
130130
lineend = "butt", linejoin = "round", linemitre = 10,
131-
na.rm = TRUE) {
131+
arrow = NULL, na.rm = TRUE) {
132132
if (!inherits(coord, "CoordSf")) {
133133
abort("geom_sf() must be used with coord_sf()")
134134
}
135135

136136
# Need to refactor this to generate one grob per geometry type
137137
coord <- coord$transform(data, panel_params)
138-
sf_grob(coord, lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm)
138+
sf_grob(coord, lineend = lineend, linejoin = linejoin, linemitre = linemitre,
139+
arrow = arrow, na.rm = na.rm)
139140
},
140141

141142
draw_key = function(data, params, size) {
@@ -160,7 +161,8 @@ default_aesthetics <- function(type) {
160161
}
161162
}
162163

163-
sf_grob <- function(x, lineend = "butt", linejoin = "round", linemitre = 10, na.rm = TRUE) {
164+
sf_grob <- function(x, lineend = "butt", linejoin = "round", linemitre = 10,
165+
arrow = NULL, na.rm = TRUE) {
164166
type <- sf_types[sf::st_geometry_type(x$geometry)]
165167
is_point <- type == "point"
166168
is_line <- type == "line"
@@ -208,7 +210,8 @@ sf_grob <- function(x, lineend = "butt", linejoin = "round", linemitre = 10, na.
208210
lty <- x$linetype %||% defaults$linetype[type_ind]
209211
gp <- gpar(
210212
col = col, fill = fill, fontsize = fontsize, lwd = lwd, lty = lty,
211-
lineend = lineend, linejoin = linejoin, linemitre = linemitre
213+
lineend = lineend, linejoin = linejoin, linemitre = linemitre,
214+
arrow = arrow
212215
)
213216
sf::st_as_grob(x$geometry, pch = pch, gp = gp)
214217
}

0 commit comments

Comments
 (0)