Browse Source

tests

master
boB Rudis 5 years ago
parent
commit
d06dcc5024
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 4
      R/a-geom-rect.R
  2. 8
      R/geom-chicklet.R
  3. 2
      R/utils-infix-helpers.R
  4. 2
      tests/testthat/test-ggchicklet.R

4
R/a-geom-rect.R

@ -1,4 +1,4 @@
geom_rrect <- function(mapping = NULL, data = NULL,
geom_rrect <- function(mapping = NULL, data = NULL, # nocov start
stat = "identity", position = "identity",
radius = grid::unit(6, "pt"),
...,
@ -63,4 +63,4 @@ GeomRrect <- ggplot2::ggproto(
draw_key = ggplot2::draw_key_polygon
)
) # nocov end

8
R/geom-chicklet.R

@ -68,7 +68,7 @@ geom_chicklet <- function(mapping = NULL, data = NULL,
)
}
draw_key_rrect <- function(data, params, size) {
draw_key_rrect <- function(data, params, size) { # nocov start
grid::roundrectGrob(
r = params$radius,
default.units = "native",
@ -80,13 +80,13 @@ draw_key_rrect <- function(data, params, size) {
lty = data$linetype %||% 1
)
)
}
} # nocov end
#' ggchicklet-ggplot2-ggproto
#' @format NULL
#' @usage NULL
#' @export
GeomChicklet <- ggproto(
GeomChicklet <- ggproto( # nocov start
"GeomChicklet", GeomRrect,
required_aes = c("x", "y"),
@ -112,4 +112,4 @@ GeomChicklet <- ggproto(
draw_key = draw_key_rrect
)
) # nocov end

2
R/utils-infix-helpers.R

@ -1,4 +1,2 @@
`%l0%` <- function(x, y) if (length(x) == 0) y else x
`%||%` <- function(x, y) if (is.null(x)) y else x
`%@%` <- function(x, name) attr(x, name, exact = TRUE)
`%nin%` <- function(x, table) match(x, table, nomatch = 0) == 0

2
tests/testthat/test-ggchicklet.R

@ -13,6 +13,8 @@ test_that("chicklet geoms are created properly", {
ggplot(debates2019) +
geom_chicklet(aes(speaker, elapsed, group = timestamp, fill = topic)) -> gg
print(gg)
ggplot_build(gg) -> gb
ggplot_gtable(gb) -> gt

Loading…
Cancel
Save