Skip to content

Commit bbd2758

Browse files
committed
have sunburst/pie stroke default to paper_bgcolor
1 parent fea72b6 commit bbd2758

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

R/plotly_build.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ plotly_build.plotly <- function(p, registerFrames = TRUE) {
137137
# verify orientation of boxes/bars
138138
trace <- verify_orientation(trace)
139139
# supply sensible defaults based on trace type
140-
trace <- coerce_attr_defaults(trace)
140+
trace <- coerce_attr_defaults(trace, p$x$layout)
141141

142142

143143

@@ -1025,9 +1025,13 @@ has_fill <- function(trace) {
10251025

10261026
# ensure we've set a sensible trace defaults
10271027
# based on the trace type
1028-
coerce_attr_defaults <- function(trace) {
1029-
if (identical(trace[["type"]], "sunburst")) {
1030-
trace$stroke <- trace[["stroke"]] %||% I("white")
1028+
coerce_attr_defaults <- function(trace, layout) {
1029+
if (trace[["type"]] %in% c("sunburst", "pie")) {
1030+
# As of v1.46.1, paper_bgcolor defaults to '#fff' which
1031+
# col2rgb() can't parse, but expands to '#ffffff'
1032+
# https://stackoverflow.com/a/2899224/1583084
1033+
bgcolor <- p$x$layout$paper_bgcolor %||% "#ffffff"
1034+
trace$stroke <- trace[["stroke"]] %||% default(I(bgcolor))
10311035
}
10321036
trace
10331037
}

0 commit comments

Comments
 (0)