Skip to content

Commit fb48879

Browse files
committed
prep for CRAN release
1 parent 2eda0a8 commit fb48879

File tree

5 files changed

+78
-74
lines changed

5 files changed

+78
-74
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ Collate:
6262
'formula2aes.R'
6363
'gf_aux.R'
6464
'gf_dist.R'
65-
'ggiraph.R'
6665
'layer_factory.R'
6766
'gf_function2d.R'
6867
'gf_functions.R'
6968
'gf_plot.R'
7069
'ggridges.R'
7170
'ggstrings.R'
7271
'newplots.R'
72+
'ggiraph.R'
7373
'ggiraph-themes.R'
7474
'ggiraph-documentation-with-examples.R'
7575
'reexports.R'

R/ggiraph.R

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -47,55 +47,6 @@ gf_girafe <- function(ggobj, code, ...) {
4747
}
4848
ggiraph::girafe(code = code, ggobj = ggobj, ...)
4949
}
50-
51-
#' Create an interactive ggformula layer function
52-
#'
53-
#' Primarily intended for package developers, this function factory
54-
#' is used to create layer functions in the ggformula package.
55-
#'
56-
#' @param geom_fun A character string naming an interactive geom (example: "geom_point_interactive")
57-
#'
58-
interactive_layer_factory <- function(geom_fun) {
59-
stopifnot(is.character(geom_fun))
60-
geom_noninteractive <- gsub("_interactive", "", geom_fun, fixed = TRUE)
61-
gf_noninteractive <- gsub("geom_", "gf_", geom_noninteractive, fixed = TRUE)
62-
gfenv <- tryCatch(
63-
environment(get(gf_noninteractive)),
64-
error = function(e) NULL
65-
)
66-
if (is.null(gfenv)) {
67-
return(NULL)
68-
}
69-
70-
aes_form_from_env <- rlang::env_get(gfenv, "aes_form", default = NULL)
71-
extras_from_env <- rlang::env_get(gfenv, "extras", default = alist())
72-
geom_from_env <- rlang::env_get(gfenv, "geom", default = "point")
73-
stat_from_env <- rlang::env_get(gfenv, "stat", default = "identity")
74-
position_from_env <- rlang::env_get(gfenv, "position", default = "identity")
75-
inherit_from_env <- rlang::env_get(gfenv, "inherit.aes", default = TRUE)
76-
aesthetics_from_env <- rlang::env_get(gfenv, "aesthetics", default = aes())
77-
check_aes_from_env <- rlang::env_get(gfenv, "check.aes", default = TRUE)
78-
79-
do.call(
80-
layer_factory,
81-
list(
82-
geom = geom_from_env,
83-
position = position_from_env,
84-
stat = stat_from_env,
85-
interactive = TRUE,
86-
layer_func_interactive = geom_fun,
87-
# pre,
88-
aes_form = aes_form_from_env,
89-
extras = extras_from_env,
90-
# note,
91-
aesthetics = aesthetics_from_env,
92-
inherit.aes = inherit_from_env,
93-
check.aes = check_aes_from_env,
94-
layer_fun = layer_interactive
95-
)
96-
)
97-
}
98-
9950
geoms <- apropos('geom_.*_interactive')
10051

10152
# geoms <- c('geom_contour_filled_interactive')
@@ -214,29 +165,6 @@ gf_labeller_interactive <- function(..., .mapping) {
214165
ggiraph::labeller_interactive(.mapping = .mapping, !!!qdots)
215166
}
216167

217-
###############################################################################
218-
##
219-
## modified version of function in ggiraph, branching based on whether position
220-
## is specified.
221-
222-
layer_interactive <- function(
223-
layer_func, stat = NULL, position = NULL, ...,
224-
interactive_geom = NULL, extra_interactive_params = NULL) {
225-
226-
dots <- list(...)
227-
if (is.null(position)) {
228-
ggiraph_layer_interactive(
229-
layer_func, stat = stat, ...,
230-
interactive_geom = interactive_geom, extra_interactive_params = extra_interactive_params
231-
)
232-
} else {
233-
ggiraph_layer_interactive(
234-
layer_func, stat = stat, position = position, ...,
235-
interactive_geom = interactive_geom, extra_interactive_params = extra_interactive_params
236-
)
237-
}
238-
}
239-
240168

241169
##########################################################################
242170
## Functions copied from ggiraph because they are not (yet) exported there.

R/layer_factory.R

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,80 @@ layer_factory <-
368368
res
369369
}
370370

371+
###############################################################################
372+
##
373+
## modified version of function in ggiraph, branching based on whether position
374+
## is specified.
375+
376+
layer_interactive <- function(
377+
layer_func, stat = NULL, position = NULL, ...,
378+
interactive_geom = NULL, extra_interactive_params = NULL) {
379+
380+
dots <- list(...)
381+
if (is.null(position)) {
382+
ggiraph_layer_interactive(
383+
layer_func, stat = stat, ...,
384+
interactive_geom = interactive_geom, extra_interactive_params = extra_interactive_params
385+
)
386+
} else {
387+
ggiraph_layer_interactive(
388+
layer_func, stat = stat, position = position, ...,
389+
interactive_geom = interactive_geom, extra_interactive_params = extra_interactive_params
390+
)
391+
}
392+
}
393+
394+
395+
###############################################################################
396+
397+
#' Create an interactive ggformula layer function
398+
#'
399+
#' Primarily intended for package developers, this function factory
400+
#' is used to create layer functions in the ggformula package.
401+
#'
402+
#' @param geom_fun A character string naming an interactive geom (example: "geom_point_interactive")
403+
#'
404+
interactive_layer_factory <- function(geom_fun) {
405+
stopifnot(is.character(geom_fun))
406+
geom_noninteractive <- gsub("_interactive", "", geom_fun, fixed = TRUE)
407+
gf_noninteractive <- gsub("geom_", "gf_", geom_noninteractive, fixed = TRUE)
408+
gfenv <- tryCatch(
409+
environment(get(gf_noninteractive)),
410+
error = function(e) NULL
411+
)
412+
if (is.null(gfenv)) {
413+
return(NULL)
414+
}
415+
416+
aes_form_from_env <- rlang::env_get(gfenv, "aes_form", default = NULL)
417+
extras_from_env <- rlang::env_get(gfenv, "extras", default = alist())
418+
geom_from_env <- rlang::env_get(gfenv, "geom", default = "point")
419+
stat_from_env <- rlang::env_get(gfenv, "stat", default = "identity")
420+
position_from_env <- rlang::env_get(gfenv, "position", default = "identity")
421+
inherit_from_env <- rlang::env_get(gfenv, "inherit.aes", default = TRUE)
422+
aesthetics_from_env <- rlang::env_get(gfenv, "aesthetics", default = aes())
423+
check_aes_from_env <- rlang::env_get(gfenv, "check.aes", default = TRUE)
424+
425+
do.call(
426+
layer_factory,
427+
list(
428+
geom = geom_from_env,
429+
position = position_from_env,
430+
stat = stat_from_env,
431+
interactive = TRUE,
432+
layer_func_interactive = geom_fun,
433+
# pre,
434+
aes_form = aes_form_from_env,
435+
extras = extras_from_env,
436+
# note,
437+
aesthetics = aesthetics_from_env,
438+
inherit.aes = inherit_from_env,
439+
check.aes = check_aes_from_env,
440+
layer_fun = layer_interactive
441+
)
442+
)
443+
}
444+
371445

372446
#########################################################################
373447
#

cran-comments.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This release
55
* addresses issues caused by the update of {ggplot2}
66
* adds interactive features based on {ggiraph}, which has also been updated subsequent to {ggplot2}.
77

8+
I'll check on mosaic and fastR2 once this package is resolved.
9+
810
## Test environments
911

1012
* local

man/interactive_layer_factory.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)