Skip to content

Commit 02f8da5

Browse files
committed
Merge branch 'ropensci-master7'
2 parents 607e377 + f41218c commit 02f8da5

24 files changed

+281
-126
lines changed

DESCRIPTION

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Imports:
4040
hexbin,
4141
RColorBrewer,
4242
dplyr,
43+
vctrs,
4344
tibble,
4445
lazyeval (>= 0.2.0),
4546
rlang,
@@ -75,7 +76,9 @@ Suggests:
7576
forcats,
7677
thematic
7778
LazyData: true
78-
RoxygenNote: 7.1.0
79+
RoxygenNote: 7.1.1
7980
Encoding: UTF-8
8081
Roxygen: list(markdown = TRUE)
81-
Remotes: rstudio/thematic
82+
Remotes:
83+
rstudio/thematic,
84+
Displayr/htmlwidgets

NAMESPACE

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
S3method(api_create,data.frame)
44
S3method(api_create,ggplot)
55
S3method(api_create,plotly)
6-
S3method(arrange_,plotly)
7-
S3method(distinct_,plotly)
8-
S3method(do_,plotly)
96
S3method(embed_notebook,plotly)
10-
S3method(filter_,plotly)
117
S3method(fortify,SharedData)
128
S3method(geom2trace,GeomBar)
139
S3method(geom2trace,GeomBlank)
@@ -25,12 +21,11 @@ S3method(ggplotly,"NULL")
2521
S3method(ggplotly,ggmatrix)
2622
S3method(ggplotly,ggplot)
2723
S3method(ggplotly,plotly)
28-
S3method(group_by_,plotly)
29-
S3method(groups,plotly)
24+
S3method(highlight_key,default)
25+
S3method(highlight_key,plotly)
3026
S3method(layout,matrix)
3127
S3method(layout,plotly)
3228
S3method(layout,shiny.tag.list)
33-
S3method(mutate_,plotly)
3429
S3method(plotly_build,"NULL")
3530
S3method(plotly_build,gg)
3631
S3method(plotly_build,list)
@@ -40,10 +35,6 @@ S3method(print,api_grid)
4035
S3method(print,api_grid_local)
4136
S3method(print,api_plot)
4237
S3method(print,plotly_data)
43-
S3method(rename_,plotly)
44-
S3method(select_,plotly)
45-
S3method(slice_,plotly)
46-
S3method(summarise_,plotly)
4738
S3method(to_basic,GeomAbline)
4839
S3method(to_basic,GeomAnnotationMap)
4940
S3method(to_basic,GeomArea)
@@ -78,8 +69,6 @@ S3method(to_basic,GeomTile)
7869
S3method(to_basic,GeomViolin)
7970
S3method(to_basic,GeomVline)
8071
S3method(to_basic,default)
81-
S3method(transmute_,plotly)
82-
S3method(ungroup,plotly)
8372
export("%>%")
8473
export(TeX)
8574
export(add_annotations)
@@ -259,6 +248,8 @@ importFrom(lazyeval,is_formula)
259248
importFrom(lazyeval,is_lang)
260249
importFrom(magrittr,"%>%")
261250
importFrom(purrr,transpose)
251+
importFrom(rlang,"!!!")
252+
importFrom(rlang,"!!")
262253
importFrom(rlang,eval_tidy)
263254
importFrom(stats,complete.cases)
264255
importFrom(stats,is.leaf)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This is minor patch release with a few minor bug fixes and updates test expectat
4444

4545
## NEW FEATURES
4646

47-
* `ggplotly()` now works well with the [**thematic** package](https://rstudio.github.io/thematic). That is, it can now correctly translate **ggplot2** styling that derives from **thematic** (#1801).
47+
* `ggplotly()` now works well with the [**thematic** package](https://rstudio.github.io/thematic). That is, it can now correctly translate **ggplot2** styling that derives from **thematic**. Note that, in order to use **thematic**'s auto theming in Shiny with `ggplotly()`, you need **shiny** v1.5.0 (or higher) and **htmlwidgets** v1.5.1.9001 (or higher). Relatedly, if these versions are available, one may now also call `getCurrentOutputInfo()` inside `renderPlotly()` to get CSS styles of the output container (#1801 and #1802).
4848

4949
## IMPROVEMENTS
5050

R/add.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ add_sf <- function(p, ..., x = ~x, y = ~y, data = NULL, inherit = TRUE) {
334334
y = y,
335335
`_bbox` = bbox,
336336
set = set,
337-
data = if ("group" %in% names(d[[i]])) group_by_(d[[i]], "group", add = TRUE) else d[[i]],
337+
data = if ("group" %in% names(d[[i]])) group_by_add(d[[i]], !!rlang::sym("group")) else d[[i]],
338338
inherit = inherit
339339
)
340340
args <- modify_list(args, attrs)

R/ggplotly.R

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ gg2list <- function(p, width = NULL, height = NULL,
517517
)
518518
}
519519
# anchor X axis to the lowest plot in its column
520-
layout$layout <- dplyr::group_by_(layout$layout, "xaxis")
520+
layout$layout <- dplyr::group_by(layout$layout, !!rlang::sym("xaxis"))
521521
layout$layout <- dplyr::mutate(layout$layout, xanchor = max(as.integer(yaxis)))
522522
}
523523
layout$layout <- as.data.frame(layout$layout)
@@ -1112,7 +1112,7 @@ gg2list <- function(p, width = NULL, height = NULL,
11121112
# translate group aesthetics to data attributes
11131113
return_dat <- Map(function(x, y) {
11141114
if (is.null(y[["group"]])) return(x)
1115-
dplyr::group_by_(x, y[["group"]])
1115+
dplyr::group_by(x, !!rlang::as_quosure(y[["group"]]))
11161116
}, return_dat, mappingFormulas)
11171117

11181118
# don't need to add group as an attribute anymore
@@ -1258,12 +1258,31 @@ bbox <- function(txt = "foo", angle = 0, size = 12) {
12581258
text2font <- function(x = ggplot2::element_text(), type = "height") {
12591259
list(
12601260
color = toRGB(x$colour),
1261-
family = x$family,
1261+
family = font_family(x$family),
12621262
# TODO: what about the size of vertical text?
12631263
size = unitConvert(grid::unit(x$size %||% 0, "points"), "pixels", type)
12641264
)
12651265
}
12661266

1267+
# Replace a default font family, "", with thematic's font option (if set)
1268+
font_family <- function(family = "") {
1269+
if (!identical(family, "")) {
1270+
return(family)
1271+
}
1272+
if (!isNamespaceLoaded("thematic")) {
1273+
return("")
1274+
}
1275+
font <- thematic::thematic_get_option("font")
1276+
if (!length(font)) {
1277+
return("")
1278+
}
1279+
# font$families is a vector of families, but font.family wants to be a
1280+
# string (like CSS font-family), so make sure the names are unquoted,
1281+
# then quote them
1282+
families <- sub("'$", "", sub("^'", "", font$families))
1283+
sprintf("'%s'", paste(families, collapse = "', '"))
1284+
}
1285+
12671286
# wrap text in bold/italics according to the text "face"
12681287
faced <- function(txt, face = "plain") {
12691288
if (is.null(face)) face <- "plain"

R/imports.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' @importFrom purrr transpose
1515
#' @importFrom tools file_ext file_path_sans_ext
1616
#' @importFrom data.table as.data.table setorderv
17-
#' @importFrom rlang eval_tidy
17+
#' @importFrom rlang eval_tidy !! !!!
1818
NULL
1919

2020

R/onLoad.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.onLoad <- function(...) {
2+
# These generics are defined in R/plotly_data.R
3+
dplyr_generics <- c(
4+
"groups", "ungroup", "group_by", "summarise", "mutate", "do", "arrange",
5+
"select", "filter", "distinct", "slice", "rename", "transmute"
6+
)
7+
dplyr_generics <- paste0("dplyr::", dplyr_generics)
8+
for (generic in dplyr_generics) {
9+
vctrs::s3_register(generic, "plotly")
10+
if (generic %in% c("dplyr::groups", "dplyr::ungroup")) {
11+
next
12+
}
13+
vctrs::s3_register(paste0(generic, "_"), "plotly")
14+
}
15+
}

R/plotly_build.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ train_data <- function(data, trace) {
561561
idx2 <- seq.int(2, NROW(dat), by = 2)
562562
dat[idx2, "x"] <- data[["xend"]]
563563
dat[idx2, "y"] <- data[["yend"]]
564-
data <- dplyr::group_by_(dat, ".plotlyGroupIndex", add = TRUE)
564+
data <- group_by_add(dat, !!rlang::sym(".plotlyGroupIndex"))
565565
}
566566

567567
# TODO: a lot more geoms!!!

0 commit comments

Comments
 (0)