File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -590,6 +590,10 @@ geom2trace <- list(
590
590
)
591
591
},
592
592
point = function (data , params ){
593
+ # params contains unique values, but we need _all_ values from the data
594
+ for (i in names(params )) {
595
+ if (length(params [[i ]]) > 1 ) params [[i ]] <- data [[i ]]
596
+ }
593
597
L <- list (
594
598
x = data $ x ,
595
599
y = data $ y ,
Original file line number Diff line number Diff line change
1
+ context(" geom_point" )
2
+
3
+ expect_traces <- function (gg , n.traces , name ){
4
+ stopifnot(is.ggplot(gg ))
5
+ stopifnot(is.numeric(n.traces ))
6
+ L <- save_outputs(gg , paste0(" smooth-" , name ))
7
+ all.traces <- L $ data
8
+ no.data <- sapply(all.traces , function (tr ) {
9
+ is.null(tr [[" x" ]]) && is.null(tr [[" y" ]])
10
+ })
11
+ has.data <- all.traces [! no.data ]
12
+ expect_equal(length(has.data ), n.traces )
13
+ list (traces = has.data , layout = L $ layout )
14
+ }
15
+
16
+ test_that(" geom_point size & alpha translate to a single trace" , {
17
+ gg <- ggplot(mtcars , aes(cyl , wt )) +
18
+ geom_point(aes(size = gear , alpha = cyl ))
19
+ info <- save_outputs(gg , " point-size-alpha" )
20
+ expect_equal(length(info $ data ), 1 )
21
+ mkr <- info $ data [[1 ]]$ marker
22
+ expect_equal(length(mkr $ size ), nrow(mtcars ))
23
+ expect_equal(length(mkr $ opacity ), nrow(mtcars ))
24
+ })
You can’t perform that action at this time.
0 commit comments