Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add ggalluvial support #2061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 2, 2021
Prev Previous commit
Next Next commit
Improve tests and type safety
  • Loading branch information
cpsievert committed Nov 1, 2021
commit 391ba4c62e11f6d8e04c76eb3138baa289fe9f43
28 changes: 15 additions & 13 deletions 28 R/layers2traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -613,33 +613,35 @@ to_basic.GeomQuantile <- function(data, prestats_data, layout, params, p, ...){
dat
}

# ggalluvial::GeomStratum
#' @export
to_basic.GeomStratum <- function (data, ...) {
to_basic.GeomStratum <- function(data, ...) {
to_basic.GeomRect(data, ...)
}

# ggalluvial::GeomAlluvium
#' @export
to_basic.GeomAlluvium <- function (data, ...) {
prefix_class(transform_alluvium(data), "GeomPolygon")
}

# transform the alluvium data into the corresponding polygons
transform_alluvium <- function(data) {
to_basic.GeomAlluvium <- function(data, ...) {
data <- data[order(data$x), ]

if(unique(data$colour) == 0) data$colour <- NULL
cols <- unique(data$colour)
if (length(cols) == 1 && cols[1] == 0) {
data$colour <- NULL
}

unused_aes <- !names(data) %in% c("x", "y", "ymin", "ymax")

unused_aes <- ! names(data) %in% c("x", "y", "ymin", "ymax")

row_number <- nrow(data)

data_rev <- data[rev(seq_len(row_number)), ]

structure(rbind(
d <- structure(rbind(
cbind(x = data$x, y = data$ymin, data[unused_aes]),
cbind(x = data$x[row_number], y = data$ymin[row_number], data[row_number, unused_aes]),
cbind(x = data_rev$x, y = data_rev$ymax, data_rev[unused_aes])
), class = class(data))

prefix_class(d, "GeomPolygon")
}

#' @export
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.