Просмотр исходного кода

loads but there will be issues with enter/exit in anim_opts

pkg-fix
Garrick Aden-Buie 7 лет назад
Родитель
Сommit
e775ebccd0
6 измененных файлов: 27 добавлений и 16 удалений
  1. +2
    -3
      DESCRIPTION
  2. +8
    -0
      NAMESPACE
  3. +5
    -3
      R/animate_options.R
  4. +7
    -7
      R/plot_helpers.R
  5. +1
    -1
      R/process_data_helpers.R
  6. +4
    -2
      R/zzzz-package.R

+ 2
- 3
DESCRIPTION Просмотреть файл

Description: Animated explanations of the verbs in the tidyverse Description: Animated explanations of the verbs in the tidyverse
using gganimate and ggplot2. using gganimate and ggplot2.
License: MIT + file LICENSE License: MIT + file LICENSE
Depends:
gganimate (>= 0.9.9.9999),
ggplot2 (>= 3.0.0)
Imports: Imports:
dplyr, dplyr,
gganimate (>= 1.0.0),
ggplot2 (>= 3.0.0),
magrittr, magrittr,
purrr, purrr,
rlang (>= 0.1.2), rlang (>= 0.1.2),

+ 8
- 0
NAMESPACE Просмотреть файл

importFrom(dplyr,select) importFrom(dplyr,select)
importFrom(dplyr,semi_join) importFrom(dplyr,semi_join)
importFrom(dplyr,slice) importFrom(dplyr,slice)
importFrom(gganimate,enter_fade)
importFrom(gganimate,exit_fade)
importFrom(gganimate,transition_states)
importFrom(ggplot2,aes)
importFrom(ggplot2,element_text)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,labs)
importFrom(ggplot2,theme)
importFrom(magrittr,"%>%") importFrom(magrittr,"%>%")
importFrom(tidyr,gather) importFrom(tidyr,gather)
importFrom(tidyr,spread) importFrom(tidyr,spread)

+ 5
- 3
R/animate_options.R Просмотреть файл

rlang::warn("Use `anim_options()` to set `anim_opts`") rlang::warn("Use `anim_options()` to set `anim_opts`")
} }
ao <- fill_anim_opts(ao) ao <- fill_anim_opts(ao)
stopifnot(is.ggproto(ao$enter[[1]]), is.ggproto(ao$exit[[1]]))
stopifnot(ggplot2::is.ggproto(ao$enter[[1]]), ggplot2::is.ggproto(ao$exit[[1]]))
extra_names <- setdiff(names(ao), names(formals(anim_options))) extra_names <- setdiff(names(ao), names(formals(anim_options)))
if (!quiet && length(extra_names)) { if (!quiet && length(extra_names)) {
extra_names <- paste0(sprintf("`%s`", extra_names), collapse = ", ") extra_names <- paste0(sprintf("`%s`", extra_names), collapse = ", ")
family <- match.arg(family, family_options, several.ok = FALSE) family <- match.arg(family, family_options, several.ok = FALSE)
ao_default <- switch( ao_default <- switch(
family, family,
"gather" = anim_options(enter = enter_fade(), exit = exit_fade(),
"gather" = anim_options(enter = gganimate::enter_fade(),
exit = gganimate::exit_fade(),
ease_default = "sine-in-out", ease_default = "sine-in-out",
ease_other = list(y = "cubic-out", x = "cubic-in")), ease_other = list(y = "cubic-out", x = "cubic-in")),
"spread" = anim_options(enter = enter_fade(), exit = exit_fade(),
"spread" = anim_options(enter = gganimate::enter_fade(),
exit = gganimate::exit_fade(),
ease_default = "sine-in-out", ease_default = "sine-in-out",
ease_other = list(y = "cubic-out", x = "cubic-in")), ease_other = list(y = "cubic-out", x = "cubic-in")),
anim_options() anim_options()

+ 7
- 7
R/plot_helpers.R Просмотреть файл



ggplot(d, aes(x = .x * width, y = .y * height, fill = .color, alpha = .alpha, ggplot(d, aes(x = .x * width, y = .y * height, fill = .color, alpha = .alpha,
group = .item_id)) + group = .item_id)) +
geom_tile(width = 0.9 * width, height = 0.9 * height) +
coord_equal() +
geom_text(data = d %>% filter(!is.na(.val)), aes(label = .val, color = .textcolor),
ggplot2::geom_tile(width = 0.9 * width, height = 0.9 * height) +
ggplot2::coord_equal() +
ggplot2::geom_text(data = d %>% filter(!is.na(.val)), aes(label = .val, color = .textcolor),
family = ao$text_family, size = text_size) + family = ao$text_family, size = text_size) +
scale_fill_identity() +
scale_color_identity() +
scale_alpha_identity() +
ggplot2::scale_fill_identity() +
ggplot2::scale_color_identity() +
ggplot2::scale_alpha_identity() +
labs(title = title) + labs(title = title) +
theme_void() +
ggplot2::theme_void() +
theme(plot.title = element_text(family = ao$title_family, hjust = 0.5, size = title_size)) theme(plot.title = element_text(family = ao$title_family, hjust = 0.5, size = title_size))
} }

+ 1
- 1
R/process_data_helpers.R Просмотреть файл

add_duplicate_number <- function(a) { add_duplicate_number <- function(a) {
data_frame(v = a) %>% data_frame(v = a) %>%
group_by(v) %>% group_by(v) %>%
mutate(id = paste(v, 1:n(), sep = "-")) %>%
mutate(id = paste(v, 1:dplyr::n(), sep = "-")) %>%
pull(id) pull(id)
} }



+ 4
- 2
R/zzzz-package.R Просмотреть файл

#' @importFrom dplyr left_join right_join full_join inner_join semi_join anti_join #' @importFrom dplyr left_join right_join full_join inner_join semi_join anti_join
#' @importFrom dplyr mutate select filter arrange bind_rows bind_cols group_by pull slice data_frame row_number #' @importFrom dplyr mutate select filter arrange bind_rows bind_cols group_by pull slice data_frame row_number
#' @importFrom tidyr gather spread #' @importFrom tidyr gather spread
#' @importFrom ggplot2 ggplot aes element_text theme labs
#' @importFrom gganimate enter_fade exit_fade transition_states
#' @keywords internal #' @keywords internal
"_PACKAGE" "_PACKAGE"


state_length = 1, state_length = 1,
ease_default = "sine-in-out", ease_default = "sine-in-out",
ease_other = NULL, ease_other = NULL,
enter = setNames(list(enter_fade()), "enter_fade()"),
exit = setNames(list(exit_fade()), "exit_fade()"),
enter = setNames(list(gganimate::enter_fade), "enter_fade()"),
exit = setNames(list(gganimate::exit_fade), "exit_fade()"),
text_family = "Fira Mono", text_family = "Fira Mono",
title_family = "Fira Mono", title_family = "Fira Mono",
text_size = 5, text_size = 5,

Загрузка…
Отмена
Сохранить