1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
labels <- c("Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura")
parents <- c("", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve")
test_that("treemap renders", {
plot_ly(
type = "treemap",
labels = labels,
parents = parents
) %>%
expect_doppelganger("basic")
})
test_that("treemap advanced", {
plot_ly(
labels = labels,
parents = parents,
textinfo = "label+value+percent parent+percent entry",
outsidetextfont = list(size = 20, color = "#377eb8"),
marker = list(line = list(width = 2)),
pathbar = list(visible = FALSE)
) %>%
add_trace(
type = "treemap",
values = c(10, 14, 12, 10, 2, 6, 6, 1, 4),
domain = list(x = c(0, 0.48))
) %>%
add_trace(
type = "treemap",
branchvalues = "total",
domain = list(x = c(0.52, 1)),
values = c(65, 14, 12, 10, 2, 6, 6, 1, 4)
) %>%
layout(
annotations = list(
list(
showarrow = FALSE,
text = "branchvalues = <b>remainder</b>",
x = 0.25,
xanchor = "center",
y = 1.1,
yanchor = "bottom"
),
list(
showarrow = FALSE,
text = "branchvalues = <b>total</b>",
x = 0.75,
xanchor = "center",
y = 1.1,
yanchor = "bottom"
)
)
) %>%
expect_doppelganger("advanced")
})
|