-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/facet-refresh' into develop
- Loading branch information
Showing
94 changed files
with
2,736 additions
and
1,745 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,71 @@ | ||
Coord <- proto(TopLevel, expr={ | ||
limits <- list() | ||
class <- function(.) "coord" | ||
|
||
muncher <- function(.) FALSE | ||
|
||
# Rescaling at coord level should not be clipped: this is what | ||
# makes zooming work | ||
rescale_var <- function(., data, range, clip = FALSE) { | ||
rescale(data, 0:1, range) | ||
} | ||
|
||
munch <- function(., data, details, segment_length = 0.01) { | ||
if (!.$muncher()) return(.$transform(data, details)) | ||
|
||
# Calculate distances using coord distance metric | ||
dist <- .$distance(data$x, data$y, details) | ||
dist[data$group[-1] != data$group[-nrow(data)]] <- NA | ||
|
||
# Munch and then transform result | ||
munched <- munch_data(data, dist, segment_length) | ||
.$transform(munched, details) | ||
} | ||
|
||
distance <- function(., x, y, details) { | ||
max_dist <- dist_euclidean(details$x.range, details$y.range) | ||
dist_euclidean(x, y) / max_dist | ||
} | ||
|
||
compute_aspect <- function(., ranges) { | ||
NULL | ||
} | ||
|
||
labels <- function(., scales) { | ||
scales | ||
} | ||
|
||
pprint <- function(., newline=TRUE) { | ||
args <- formals(get("new", .)) | ||
args <- args[!names(args) %in% c(".", "...")] | ||
|
||
cat("coord_", .$objname, ": ", clist(args), sep="") | ||
|
||
if (newline) cat("\n") | ||
} | ||
|
||
guide_foreground <- function(., scales, theme) { | ||
theme_render(theme, "panel.border") | ||
} | ||
# Html defaults | ||
|
||
html_returns <- function(.) { | ||
ps( | ||
"<h2>Returns</h2>\n", | ||
"<p>This function returns a coordinate system object.</p>" | ||
) | ||
} | ||
|
||
parameters <- function(.) { | ||
params <- formals(get("new", .)) | ||
params[setdiff(names(params), c("."))] | ||
} | ||
|
||
}) | ||
#' New coordinate system. | ||
#' | ||
#' Internal use only. | ||
#' | ||
#' @param ... object fields | ||
#' @keywords internal | ||
#' @export | ||
coord <- function(..., subclass = c()) { | ||
structure(list(...), class = c(subclass, "coord")) | ||
} | ||
|
||
#' Is this object a coordinate system? | ||
#' | ||
#' @export is.coord | ||
#' @keywords internal | ||
is.coord <- function(x) inherits(x, "coord") | ||
|
||
distance <- function(., x, y, details) { | ||
max_dist <- dist_euclidean(details$x.range, details$y.range) | ||
dist_euclidean(x, y) / max_dist | ||
} | ||
|
||
coord_aspect <- function(coord, ranges) | ||
UseMethod("coord_aspect") | ||
coord_aspect.default <- function(coord, ranges) NULL | ||
|
||
coord_labels <- function(coord, scales) UseMethod("coord_labels") | ||
coord_labels.default <- function(coord, scales) scales | ||
|
||
coord_render_fg <- function(coord, scales, theme) | ||
UseMethod("coord_render_fg") | ||
coord_render_fg.default <- function(coord, scales, theme) | ||
theme_render(theme, "panel.border") | ||
|
||
coord_render_bg <- function(coord, scales, theme) | ||
UseMethod("coord_render_bg") | ||
#' @S3method coord_render_bg default | ||
coord_render_bg.default <- function(coord, details, theme) { | ||
x.major <- unit(details$x.major, "native") | ||
x.minor <- unit(details$x.minor, "native") | ||
y.major <- unit(details$y.major, "native") | ||
y.minor <- unit(details$y.minor, "native") | ||
|
||
guide_grid(theme, x.minor, x.major, y.minor, y.major) | ||
} | ||
|
||
coord_render_axis_h <- function(coord, scales, theme) | ||
UseMethod("coord_render_axis_h") | ||
#' @S3method coord_render_axis_h default | ||
coord_render_axis_h.default <- function(coord, details, theme) { | ||
guide_axis(details$x.major, details$x.labels, "bottom", theme) | ||
} | ||
|
||
coord_render_axis_v <- function(coord, scales, theme) | ||
UseMethod("coord_render_axis_v") | ||
#' @S3method coord_render_axis_v default | ||
coord_render_axis_v.default <- function(coord, details, theme) { | ||
guide_axis(details$y.major, details$y.labels, "left", theme) | ||
} | ||
|
||
coord_train <- function(coord, scales) | ||
UseMethod("coord_train") | ||
|
||
coord_transform <- function(coord, data, range) | ||
UseMethod("coord_transform") | ||
|
||
coord_distance <- function(coord, x, y, details) | ||
UseMethod("coord_distance") | ||
|
||
is.linear <- function(coord) UseMethod("is.linear") | ||
is.linear.default <- function(coord) FALSE |
Oops, something went wrong.