Skip to content

Commit

Permalink
Fix #143
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Jan 19, 2024
1 parent f551f33 commit e8238cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* `shapeGrob()` is now exported for use by other packages (#303)
* Fix a bug in `geom_autohistogram()` that prevented it to be used with
continuous data (#297)
* `facet_zoom()` now throws a better error when used with `coord_flip()` (#143)

# ggforce 0.4.1

Expand Down
8 changes: 4 additions & 4 deletions R/facet_zoom.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ FacetZoom <- ggproto('FacetZoom', Facet,
x_vars <- intersect(x_scales[[1]]$aesthetics, names(layer_data))
SCALE_X <- layout$SCALE_X[match_id]

if (!is.null(params$xlim)) {
if (!is.null(params$xlim) && length(x_scales) > 1) {
x_scales[[2]]$train(x_scales[[2]]$transform(params$xlim))
scale_apply(layer_data, x_vars, 'train', SCALE_X, x_scales[-2])
} else {
Expand All @@ -172,7 +172,7 @@ FacetZoom <- ggproto('FacetZoom', Facet,
y_vars <- intersect(y_scales[[1]]$aesthetics, names(layer_data))
SCALE_Y <- layout$SCALE_Y[match_id]

if (!is.null(params$ylim)) {
if (!is.null(params$ylim) && length(y_scales) > 1) {
y_scales[[2]]$train(y_scales[[2]]$transform(params$ylim))
scale_apply(layer_data, y_vars, 'train', SCALE_Y, y_scales[-2])
} else {
Expand Down Expand Up @@ -358,7 +358,7 @@ FacetZoom <- ggproto('FacetZoom', Facet,
zoom_y <- calc_element('zoom.y', theme)

if (!(is.null(params$x) && is.null(params$xlim)) &&
params$show.area && !inherits(zoom_x, 'element_blank')) {
params$show.area && !inherits(zoom_x, 'element_blank') && length(x_scales) > 1) {
zoom_prop <- rescale(x_scales[[2]]$dimension(expansion(x_scales[[2]])),
from = x_scales[[1]]$dimension(expansion(x_scales[[1]]))
)
Expand All @@ -377,7 +377,7 @@ FacetZoom <- ggproto('FacetZoom', Facet,
x_back <- zeroGrob()
}
if (!(is.null(params$y) && is.null(params$ylim)) &&
params$show.area && !inherits(zoom_y, 'element_blank')) {
params$show.area && !inherits(zoom_y, 'element_blank') && length(y_scales) > 1) {
zoom_prop <- rescale(y_scales[[2]]$dimension(expansion(y_scales[[2]])),
from = y_scales[[1]]$dimension(expansion(y_scales[[1]]))
)
Expand Down

0 comments on commit e8238cf

Please sign in to comment.