@@ -766,7 +766,7 @@ geom2trace.GeomPoint <- function(data, params, p) {
766
766
hoveron = hover_on(data )
767
767
)
768
768
# fill is only relevant for pch %in% 21:25
769
- pch <- uniq(data $ shape ) %|| % params $ shape %|| % GeomPoint $ default_aes $ shape
769
+ pch <- uniq(data $ shape ) %|| % params $ shape %|| % GeomPoint $ use_defaults( NULL ) $ shape
770
770
if (any(idx <- pch %in% 21 : 25 ) || any(idx <- ! is.null(data [[" fill_plotlyDomain" ]]))) {
771
771
fill_value <- aes2plotly(data , params , " fill" )
772
772
if (length(idx ) == 1 ) {
@@ -866,6 +866,9 @@ geom2trace.GeomPolygon <- function(data, params, p) {
866
866
867
867
# ' @export
868
868
geom2trace.GeomBoxplot <- function (data , params , p ) {
869
+ # marker styling must inherit from GeomPoint$default_aes
870
+ # https://github.com/hadley/ggplot2/blob/ab42c2ca81458b0cf78e3ba47ed5db21f4d0fc30/NEWS#L73-L7
871
+ point_defaults <- GeomPoint $ use_defaults(NULL )
869
872
compact(list (
870
873
x = data [[" x" ]],
871
874
y = data [[" y" ]],
@@ -879,16 +882,15 @@ geom2trace.GeomBoxplot <- function(data, params, p) {
879
882
aes2plotly(data , params , " fill" ),
880
883
aes2plotly(data , params , " alpha" )
881
884
),
882
- # marker styling must inherit from GeomPoint$default_aes
883
- # https://github.com/hadley/ggplot2/blob/ab42c2ca81458b0cf78e3ba47ed5db21f4d0fc30/NEWS#L73-L77
885
+ # markers/points
884
886
marker = list (
885
- opacity = GeomPoint $ default_aes $ alpha ,
886
- outliercolor = toRGB(GeomPoint $ default_aes $ colour ),
887
+ opacity = point_defaults $ alpha ,
888
+ outliercolor = toRGB(point_defaults $ colour ),
887
889
line = list (
888
- width = mm2pixels(GeomPoint $ default_aes $ stroke ),
889
- color = toRGB(GeomPoint $ default_aes $ colour )
890
+ width = mm2pixels(point_defaults $ stroke ),
891
+ color = toRGB(point_defaults $ colour )
890
892
),
891
- size = mm2pixels(GeomPoint $ default_aes $ size )
893
+ size = mm2pixels(point_defaults $ size )
892
894
),
893
895
line = list (
894
896
color = aes2plotly(data , params , " colour" ),
@@ -1096,21 +1098,26 @@ ribbon_dat <- function(dat) {
1096
1098
aes2plotly <- function (data , params , aes = " size" ) {
1097
1099
geom <- class(data )[1 ]
1098
1100
1099
- # Hack to support this geom_sf hack
1100
- # https://github.com/tidyverse/ggplot2/blob/505e4bfb/R/sf.R#L179-L187
1101
- defaults <- if (inherits(data , " GeomSf" )) {
1102
- type <- if (any(grepl(" [P-p]oint" , class(data )))) " point" else if (any(grepl(" [L-l]ine" , class(data )))) " line" else " "
1103
- ggfun(" default_aesthetics" )(type )
1104
- } else {
1105
- geom_obj <- ggfun(geom )
1106
- # If the first class of `data` is a data.frame,
1107
- # ggfun() returns a function because ggplot2 now
1108
- # defines data.frame in it's namespace
1109
- # https://github.com/ropensci/plotly/pull/1481
1110
- if (" default_aes" %in% names(geom_obj )) geom_obj $ default_aes else NULL
1101
+ vals <- uniq(data [[aes ]]) %|| % params [[aes ]]
1102
+
1103
+ if (is.null(vals )) {
1104
+ # Hack to support this geom_sf hack
1105
+ # https://github.com/tidyverse/ggplot2/blob/505e4bfb/R/sf.R#L179-L187
1106
+ defaults <- if (inherits(data , " GeomSf" ) && exists(" default_aesthetics" , envir = asNamespace(" ggplot2" ))) {
1107
+ type <- if (any(grepl(" [P-p]oint" , class(data )))) " point" else if (any(grepl(" [L-l]ine" , class(data )))) " line" else " "
1108
+ ggfun(" default_aesthetics" )(type )
1109
+ } else {
1110
+ geom_obj <- ggfun(geom )
1111
+ # If the first class of `data` is a data.frame,
1112
+ # ggfun() returns a function because ggplot2 now
1113
+ # defines data.frame in it's namespace
1114
+ # https://github.com/ropensci/plotly/pull/1481
1115
+ if (" default_aes" %in% names(geom_obj )) geom_obj $ use_defaults(NULL ) else NULL
1116
+ }
1117
+ vals <- defaults [[aes ]]
1111
1118
}
1119
+ vals <- vals %|| % NA
1112
1120
1113
- vals <- uniq(data [[aes ]]) %|| % params [[aes ]] %|| % defaults [[aes ]] %|| % NA
1114
1121
converter <- switch (
1115
1122
aes ,
1116
1123
size = mm2pixels ,
0 commit comments