@@ -17,12 +17,26 @@ test_that("plot_ly() handles a simple scatterplot", {
17
17
expect_identical(l $ layout $ yaxis $ title , " Petal.Length" )
18
18
})
19
19
20
- test_that(" Using group argument creates multiple traces" , {
21
- skip(" FIXME disabled since group doesn't create new traces now" )
22
- p <- plot_ly(data = iris , x = Sepal.Length , y = Petal.Length , group = Species )
23
- l <- expect_traces(p , 3 , " scatterplot-group" )
20
+ test_that(" Using group argument doesn't transform the data in markers mode" , {
21
+ p <- plot_ly(data = iris , x = Sepal.Length , y = Petal.Length , group = Species , mode = " markers" )
22
+ l <- expect_traces(p , 1 , " scatterplot-group-markers" )
24
23
expect_identical(l $ layout $ xaxis $ title , " Sepal.Length" )
25
24
expect_identical(l $ layout $ yaxis $ title , " Petal.Length" )
25
+ expect_identical(l $ data [[1 ]]$ group , iris $ Species )
26
+ })
27
+
28
+ test_that(" Using group argument for scatter plot in lines mode introduces breaks (NA values separating different groups)" , {
29
+ p <- plot_ly(data = iris , x = Sepal.Length , y = Petal.Length , group = Species , mode = " lines" )
30
+ l <- expect_traces(p , 1 , " scatterplot-group" )
31
+ expect_identical(l $ layout $ xaxis $ title , " Sepal.Length" )
32
+ expect_identical(l $ layout $ yaxis $ title , " Petal.Length" )
33
+ n_groups <- length(unique(iris $ Species ))
34
+ n_pts <- length(l $ data [[1 ]]$ x )
35
+ expect_identical(n_pts , nrow(iris )+ n_groups - 1L )
36
+ expect_identical(sum(is.na(l $ data [[1 ]]$ x )), n_groups - 1L )
37
+ expect_true(all(is.na(l $ data [[1 ]]$ group [- 1 ]) |
38
+ is.na(l $ data [[1 ]]$ group [- n_pts ]) |
39
+ (l $ data [[1 ]]$ group [- 1 ] == l $ data [[1 ]]$ group [- n_pts ])))
26
40
})
27
41
28
42
test_that(" Mapping a variable to symbol works" , {
0 commit comments