@@ -10,7 +10,7 @@ expect_traces <- function(gg, n.traces, name) {
1010 })
1111 has.data <- all.traces [! no.data ]
1212 expect_equal(length(has.data ), n.traces )
13- list (traces = has.data , layout = L $ layout )
13+ list (data = has.data , layout = L $ layout )
1414}
1515
1616df <- data.frame (
@@ -23,7 +23,7 @@ gg <- ggplot(df, aes(xmin = x, xmax = x + 1, ymin = y, ymax = y + 2)) +
2323
2424test_that(' geom_rect becomes 1 trace with mode="lines" fill="tozerox"' , {
2525 info <- expect_traces(gg , 1 , " black" )
26- tr <- info $ traces [[1 ]]
26+ tr <- info $ data [[1 ]]
2727 expect_identical(tr $ fill , " tozerox" )
2828 expect_identical(tr $ type , " scatter" )
2929 expect_identical(tr $ mode , " lines" )
@@ -42,7 +42,7 @@ gg4 <- ggplot(df4, aes(xmin = x, xmax = x + 0.5, ymin = 0, ymax = 1)) +
4242
4343test_that(' trace contains NA back to 1st rect' , {
4444 info <- expect_traces(gg4 , 1 , " black4" )
45- tr <- info $ traces [[1 ]]
45+ tr <- info $ data [[1 ]]
4646 expect_identical(tr $ fill , " tozerox" )
4747 expect_identical(tr $ type , " scatter" )
4848 expect_identical(tr $ mode , " lines" )
@@ -70,7 +70,7 @@ rect.color <- ggplot(df4, aes(xmin = x, xmax = x + 0.5, ymin = 0, ymax = 1)) +
7070test_that(' rect color' , {
7171 info <- expect_traces(rect.color , 2 , " color" )
7272 traces.by.name <- list ()
73- for (tr in info $ traces ){
73+ for (tr in info $ data ){
7474 expect_true(tr $ fillcolor == toRGB(" grey" ))
7575 expect_true(tr $ fill == " tozerox" )
7676 expect_equal(tr $ y ,
@@ -97,7 +97,7 @@ rect.fill <- ggplot(df4, aes(xmin = x, xmax = x + 0.5, ymin = 0, ymax = 1)) +
9797test_that(' rect color' , {
9898 info <- expect_traces(rect.fill , 2 , " fill" )
9999 traces.by.name <- list ()
100- for (tr in info $ traces ){
100+ for (tr in info $ data ){
101101 expect_true(tr $ line $ color == " transparent" )
102102 expect_true(tr $ fill == " tozerox" )
103103 expect_equal(tr $ y ,
@@ -125,7 +125,7 @@ rect.fill.color <-
125125test_that(' rect aes(fill) with constant color' , {
126126 info <- expect_traces(rect.fill.color , 2 , " fill-color" )
127127 traces.by.name <- list ()
128- for (tr in info $ traces ){
128+ for (tr in info $ data ){
129129 expect_true(tr $ line $ color == toRGB(" black" ))
130130 expect_true(tr $ fill == " tozerox" )
131131 expect_equal(tr $ y ,
@@ -145,3 +145,14 @@ test_that('rect aes(fill) with constant color', {
145145 expect_false(traces.by.name [[1 ]]$ fillcolor ==
146146 traces.by.name [[2 ]]$ fillcolor )
147147})
148+
149+
150+ p <- ggplot(data = data.frame (x1 = 1 , x2 = 2 , y1 = 1 , y2 = 2 )) +
151+ geom_rect(aes(xmin = x1 , xmax = x2 , ymin = y1 , ymax = y2 ),
152+ fill = " #00000011" , color = " black" )
153+
154+ test_that(' Specifying alpha in hex color code works' , {
155+ info <- expect_traces(p , 1 , " fill-hex-alpha" )
156+ expect_match(info $ data [[1 ]]$ fillcolor , " rgba\\ (0,0,0,0\\ .0[6]+" )
157+ })
158+
0 commit comments