@@ -30,6 +30,7 @@ test_that("polygons filled with the same color become one trace", {
30
30
12 , 13 , 13 , 12 , 12 , NA ,
31
31
10 , 10 )
32
32
expect_equal(tr $ x , expected.x )
33
+ expect_equal(tr $ fill , " tozerox" )
33
34
expected.y <-
34
35
c(0 , 0 , 1 , 1 , 0 , NA ,
35
36
0 , 0 , 1 , 1 , 0 , NA ,
@@ -49,6 +50,7 @@ test_that("polygons with different color become separate traces", {
49
50
traces.by.name <- list ()
50
51
for (tr in info $ traces ){
51
52
expect_equal(tr $ fillcolor , toRGB(" grey" ))
53
+ expect_equal(tr $ fill , " tozerox" )
52
54
traces.by.name [[tr $ name ]] <- tr
53
55
}
54
56
expect_equal(traces.by.name $ left $ x , c(10 , 11 , 11 , 10 , 10 ))
@@ -85,6 +87,7 @@ test_that("geom_polygon(aes(fill), color) -> line$color", {
85
87
traces.by.name <- list ()
86
88
for (tr in info $ traces ){
87
89
expect_equal(tr $ line $ color , toRGB(" black" ))
90
+ expect_equal(tr $ fill , " tozerox" )
88
91
traces.by.name [[tr $ name ]] <- tr
89
92
}
90
93
expect_equal(traces.by.name $ left $ x , c(10 , 11 , 11 , 10 , 10 ))
@@ -104,6 +107,7 @@ test_that("geom_polygon(aes(linetype), fill, color)", {
104
107
for (tr in info $ traces ){
105
108
expect_equal(tr $ fillcolor , toRGB(" red" ))
106
109
expect_equal(tr $ line $ color , toRGB(" blue" ))
110
+ expect_equal(tr $ fill , " tozerox" )
107
111
traces.by.name [[tr $ name ]] <- tr
108
112
}
109
113
expect_equal(traces.by.name $ left $ x , c(10 , 11 , 11 , 10 , 10 ))
@@ -123,6 +127,7 @@ test_that("geom_polygon(aes(size), fill, colour)", {
123
127
for (tr in info $ traces ){
124
128
expect_equal(tr $ fillcolor , toRGB(" orange" ))
125
129
expect_equal(tr $ line $ color , toRGB(" black" ))
130
+ expect_equal(tr $ fill , " tozerox" )
126
131
traces.by.name [[tr $ name ]] <- tr
127
132
}
128
133
expect_equal(traces.by.name $ left $ x , c(10 , 11 , 11 , 10 , 10 ))
@@ -145,3 +150,60 @@ test_that("borders become one trace with NA", {
145
150
146
151
save_outputs(gg , " polygons-canada-borders" )
147
152
})
153
+
154
+ x <- c(0 , - 1 , 2 , - 2 , 1 )
155
+ y <- c(2 , 0 , 1 , 1 , 0 )
156
+ stars <-
157
+ rbind(data.frame (x , y , group = " left" ),
158
+ data.frame (x = x + 10 , y , group = " right" ))
159
+ star.group <- ggplot(stars )+
160
+ geom_polygon(aes(x , y , group = group ))
161
+
162
+ test_that(" geom_polygon(aes(group)) -> 1 trace" , {
163
+ info <- expect_traces(star.group , 1 , " star-group" )
164
+ tr <- info $ traces [[1 ]]
165
+ expect_equal(tr $ fill , " tozerox" )
166
+ expect_equal(tr $ x ,
167
+ c(0 , - 1 , 2 , - 2 , 1 , 0 , NA ,
168
+ 10 , 9 , 12 , 8 , 11 , 10 , NA ,
169
+ 0 , 0 ))
170
+ expect_equal(tr $ y ,
171
+ c(2 , 0 , 1 , 1 , 0 , 2 , NA ,
172
+ 2 , 0 , 1 , 1 , 0 , 2 , NA ,
173
+ 2 , 2 ))
174
+ })
175
+
176
+ star.group.color <- ggplot(stars )+
177
+ geom_polygon(aes(x , y , group = group ), color = " red" )
178
+
179
+ test_that(" geom_polygon(aes(group), color) -> 1 trace" , {
180
+ info <- expect_traces(star.group.color , 1 , " star-group-color" )
181
+ tr <- info $ traces [[1 ]]
182
+ expect_equal(tr $ fill , " tozerox" )
183
+ expect_equal(tr $ line $ color , toRGB(" red" ))
184
+ expect_equal(tr $ x ,
185
+ c(0 , - 1 , 2 , - 2 , 1 , 0 , NA ,
186
+ 10 , 9 , 12 , 8 , 11 , 10 , NA ,
187
+ 0 , 0 ))
188
+ expect_equal(tr $ y ,
189
+ c(2 , 0 , 1 , 1 , 0 , 2 , NA ,
190
+ 2 , 0 , 1 , 1 , 0 , 2 , NA ,
191
+ 2 , 2 ))
192
+ })
193
+
194
+ star.fill.color <- ggplot(stars )+
195
+ geom_polygon(aes(x , y , group = group , fill = group ), color = " black" )
196
+
197
+ test_that(" geom_polygon(aes(group, fill), color) -> 2 trace" , {
198
+ info <- expect_traces(star.fill.color , 2 , " star-fill-color" )
199
+ tr <- info $ traces [[1 ]]
200
+ traces.by.name <- list ()
201
+ for (tr in info $ traces ){
202
+ expect_equal(tr $ line $ color , toRGB(" black" ))
203
+ expect_equal(tr $ fill , " tozerox" )
204
+ expect_equal(tr $ y , c(2 , 0 , 1 , 1 , 0 , 2 ))
205
+ traces.by.name [[tr $ name ]] <- tr
206
+ }
207
+ expect_equal(traces.by.name $ left $ x , c(0 , - 1 , 2 , - 2 , 1 , 0 ))
208
+ expect_equal(traces.by.name $ right $ x , c(10 , 9 , 12 , 8 , 11 , 10 ))
209
+ })
0 commit comments