@@ -766,7 +766,7 @@ geom2trace.GeomPoint <- function(data, params, p) {
766766 hoveron = hover_on(data )
767767 )
768768 # 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
770770 if (any(idx <- pch %in% 21 : 25 ) || any(idx <- ! is.null(data [[" fill_plotlyDomain" ]]))) {
771771 fill_value <- aes2plotly(data , params , " fill" )
772772 if (length(idx ) == 1 ) {
@@ -866,6 +866,9 @@ geom2trace.GeomPolygon <- function(data, params, p) {
866866
867867# ' @export
868868geom2trace.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 )
869872 compact(list (
870873 x = data [[" x" ]],
871874 y = data [[" y" ]],
@@ -879,16 +882,15 @@ geom2trace.GeomBoxplot <- function(data, params, p) {
879882 aes2plotly(data , params , " fill" ),
880883 aes2plotly(data , params , " alpha" )
881884 ),
882- # marker styling must inherit from GeomPoint$default_aes
883- # https://github.com/hadley/ggplot2/blob/ab42c2ca81458b0cf78e3ba47ed5db21f4d0fc30/NEWS#L73-L77
885+ # markers/points
884886 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 ),
887889 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 )
890892 ),
891- size = mm2pixels(GeomPoint $ default_aes $ size )
893+ size = mm2pixels(point_defaults $ size )
892894 ),
893895 line = list (
894896 color = aes2plotly(data , params , " colour" ),
@@ -1096,21 +1098,26 @@ ribbon_dat <- function(dat) {
10961098aes2plotly <- function (data , params , aes = " size" ) {
10971099 geom <- class(data )[1 ]
10981100
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 ]]
11111118 }
1119+ vals <- vals %|| % NA
11121120
1113- vals <- uniq(data [[aes ]]) %|| % params [[aes ]] %|| % defaults [[aes ]] %|| % NA
11141121 converter <- switch (
11151122 aes ,
11161123 size = mm2pixels ,
0 commit comments