Skip to content

Commit 5d9deca

Browse files
committed
made test different from ggplotly
1 parent 7cefa02 commit 5d9deca

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

R/ggplotly.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,8 @@ gg2list <- function(p) {
772772
# we make the size of the plot according to the specified ratio
773773
# note: we set the biggest dimension to 600
774774
if (!is.null(p$coordinates$ratio)) {
775-
x_range <- range(p$data[[as.character(layer.aes$x.name)]], na.rm = TRUE)
776-
y_range <- range(p$data[[as.character(layer.aes$y.name)]], na.rm = TRUE)
775+
x_range <- range(built[[2]]$ranges[[1]]$x.major_source, na.rm = TRUE)
776+
y_range <- range(built[[2]]$ranges[[1]]$y.major_source, na.rm = TRUE)
777777
yx_ratio <- (y_range[2] - y_range[1]) / (x_range[2] - x_range[1])
778778
if (yx_ratio > 1) {
779779
layout$height <- 600

tests/testthat/test-ggplot-coord.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test_that("coord_fixed() is translated to the right height-width ratio", {
3131
x_range <- range(p$data$xval, na.rm = TRUE)
3232
y_range <- range(p$data$yval, na.rm = TRUE)
3333
yx_ratio <- (y_range[2] - y_range[1]) / (x_range[2] - x_range[1])
34-
expect_identical(la$height/la$width, yx_ratio * p$coordinates$ratio)
34+
expect_identical(la$height/la$width, round(yx_ratio) * p$coordinates$ratio)
3535
})
3636

3737
# Equal scaling, with each 1 on the x axis the same length as y on x axis
@@ -46,5 +46,5 @@ test_that("coord_fixed() is translated to the right height-width ratio", {
4646
x_range <- range(p$data$xval, na.rm = TRUE)
4747
y_range <- range(p$data$yval, na.rm = TRUE)
4848
yx_ratio <- (y_range[2] - y_range[1]) / (x_range[2] - x_range[1])
49-
expect_identical(la$height/la$width, yx_ratio * p$coordinates$ratio)
49+
expect_identical(la$height/la$width, round(yx_ratio) * p$coordinates$ratio)
5050
})

0 commit comments

Comments
 (0)