fixes to passing mutation_before, updates to meta and axes specs

This commit is contained in:
willdebras 2022-03-30 08:03:53 -05:00
Родитель c9ac400688
Коммит 61be8f0cbe
3 изменённых файлов: 22 добавлений и 22 удалений

Просмотреть файл

@ -5,7 +5,7 @@
#' @inheritParams datamation_sanddance
#' @inheritParams prep_specs_data
#' @noRd
prep_specs_count <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, height = 300, width = 300, ...) {
prep_specs_count <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, height = 300, width = 300, mutation_before, ...) {
# Treat count as group_by + summarize(n = n()) steps
# Call prep_specs_group_by and prep_specs_summarize
@ -14,7 +14,7 @@ prep_specs_count <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, heigh
# Group by ----
res[["group_by"]] <- prep_specs_group_by(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width)
res[["group_by"]] <- prep_specs_group_by(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width, mutation_before = FALSE)
# Summarize ----
@ -31,7 +31,7 @@ prep_specs_count <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, heigh
.data <- .data %>%
dplyr::group_by(!!!group_vars)
res[["summarize"]] <- prep_specs_summarize(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width)
res[["summarize"]] <- prep_specs_summarize(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width, mutation_before = FALSE)
# Add meta field for "count" custom animation
res[["summarize"]][[1]][["meta"]][["custom_animation"]] <- "count"

Просмотреть файл

@ -416,15 +416,15 @@ prep_specs_mutate <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, heig
}
# Variables that need to be passed to JS
if (!is.null(mapping$x)) {
# If there is a grouping variable on the x-axis, then each jitter field needs to be split by that X, so we have to tell the JS code that
meta <- append(meta, list(splitField = mapping$x))
# if(length(mutation_variables)>1) {
# # If there is a grouping variable on the x-axis, then each jitter field needs to be split by that X, so we have to tell the JS code that
# meta <- append(meta, list(splitField = mapping$x))
if (!has_facets) {
# If there are facets, they're fake and don't actually have labels, so we need to send those over too!
meta <- append(meta, list(xAxisLabels = levels(data_1[[mapping$x]])))
}
}
# if (!has_facets) {
# # If there are facets, they're fake and don't actually have labels, so we need to send those over too!
# meta <- append(meta, list(xAxisLabels = levels(data_1[[mapping$x]])))
# }
# }
spec <- generate_vega_specs(
.data = data_1,
@ -786,15 +786,15 @@ prep_specs_mutate <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, heig
}
# Variables that need to be passed to JS
if (!is.null(mapping$x)) {
# If there is a grouping variable on the x-axis, then each jitter field needs to be split by that X, so we have to tell the JS code that
meta <- append(meta, list(splitField = mapping$x))
# if(length(mutation_variables)>1) {
# # If there is a grouping variable on the x-axis, then each jitter field needs to be split by that X, so we have to tell the JS code that
# meta <- append(meta, list(splitField = mapping$x))
if (!has_facets) {
# If there are facets, they're fake and don't actually have labels, so we need to send those over too!
meta <- append(meta, list(xAxisLabels = levels(data_2[[mapping$x]])))
}
}
# if (!has_facets) {
# # If there are facets, they're fake and don't actually have labels, so we need to send those over too!
# meta <- append(meta, list(xAxisLabels = levels(data_2[[mapping$x]])))
# }
# }
spec <- generate_vega_specs(
.data = data_2,

Просмотреть файл

@ -5,7 +5,7 @@
#' @inheritParams datamation_sanddance
#' @inheritParams prep_specs_data
#' @noRd
prep_specs_tally <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, height = 300, width = 300, ...) {
prep_specs_tally <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, height = 300, width = 300, mutation_before, ...) {
# Treat tally as summarize(n = n()) with optional group mappings
# Call prep_specs_group_by and prep_specs_summarize
@ -14,7 +14,7 @@ prep_specs_tally <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, heigh
# Group by ----
res[["group_by"]] <- prep_specs_group_by(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width)
res[["group_by"]] <- prep_specs_group_by(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width, mutation_before = FALSE)
# Summarize ----
@ -31,7 +31,7 @@ prep_specs_tally <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, heigh
.data <- .data %>%
dplyr::group_by(!!!group_vars)
res[["summarize"]] <- prep_specs_summarize(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width)
res[["summarize"]] <- prep_specs_summarize(.data, mapping, toJSON = toJSON, pretty = pretty, height = height, width = width, mutation_before = FALSE)
# Add meta field for "tally" custom animation
res[["summarize"]][[1]][["meta"]][["custom_animation"]] <- "tally"