Skip to content

Commit 2521414

Browse files
committed
air format that
1 parent f0f4fe2 commit 2521414

11 files changed

+70
-28
lines changed

R/facet_interactive.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ label_data_to_wrap <- function(layout, gtab_layout, facets) {
214214

215215
## ordering
216216
# create a fake key in gtab_layout
217-
gtab_layout$layout_key <- gsub("(.*?)([0-9]+-[0-9]+)", "\\2", gtab_layout$name)
217+
gtab_layout$layout_key <- gsub(
218+
"(.*?)([0-9]+-[0-9]+)",
219+
"\\2",
220+
gtab_layout$name
221+
)
218222
# create a fake key in layout
219223
layout$layout_key <- paste(layout$COL, layout$ROW, sep = "-")
220224
layout$layout_key <- factor(

R/fonts.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ extract_family_names_regex <- function(lines) {
154154

155155
# Pattern for @font-face
156156
fontface_pattern <- "@font-face\\s*\\{[^}]+\\}"
157-
fontface_blocks <- regmatches(css_text, gregexpr(fontface_pattern, css_text, perl = TRUE))[[1]]
157+
fontface_blocks <- regmatches(
158+
css_text,
159+
gregexpr(fontface_pattern, css_text, perl = TRUE)
160+
)[[1]]
158161

159162
if (length(fontface_blocks) == 0) {
160163
return(character())
@@ -210,7 +213,9 @@ list_families_from_dependencies <- function(dependencies) {
210213

211214
fonts_checking_registered <- function(family_list) {
212215
datafonts <- sys_fonts()
213-
missing_family_list <- family_list[!tolower(family_list) %in% tolower(datafonts$family)]
216+
missing_family_list <- family_list[
217+
!tolower(family_list) %in% tolower(datafonts$family)
218+
]
214219

215220
if (length(missing_family_list) > 0) {
216221
cli::cli_abort(c(
@@ -239,4 +244,3 @@ fonts_checking_dependencies <- function(dependencies, family_list) {
239244
)
240245
}
241246
}
242-

R/geom_quasirandom_interactive.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ geom_quasirandom_interactive <- function(...) {
2525
interactive_geom = GeomInteractivePoint
2626
)
2727
}
28-

R/geom_ribbon_interactive.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,21 @@ GeomInteractiveRibbon <- ggproto(
4242
polygon_child_index <- which(grepl("polygon", names(grtree$children)))[1]
4343
if (length(polygon_child_index) == 1L && is.finite(polygon_child_index)) {
4444
grtree$children[[polygon_child_index]] <-
45-
add_interactive_attrs(grtree$children[[polygon_child_index]], aes, ipar = .ipar)
45+
add_interactive_attrs(
46+
grtree$children[[polygon_child_index]],
47+
aes,
48+
ipar = .ipar
49+
)
4650
}
4751

4852
polyline_child_index <- which(grepl("polyline", names(grtree$children)))[1]
4953
if (length(polyline_child_index) == 1L && is.finite(polyline_child_index)) {
5054
grtree$children[[polyline_child_index]] <-
51-
add_interactive_attrs(grtree$children[[polyline_child_index]], aes, ipar = .ipar)
55+
add_interactive_attrs(
56+
grtree$children[[polyline_child_index]],
57+
aes,
58+
ipar = .ipar
59+
)
5260
grtree$children[[polyline_child_index]]$.interactive_hooks <- c("fill_na")
5361
}
5462

R/girafe.R

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,20 @@ girafe <- function(
179179
fonts_checking_registered(family_list = family_list)
180180
} else if (check_fonts_registered && is.null(ggobj)) {
181181
cli::cli_warn(
182-
c("!" = "Dependencies checking can not be performed if `ggobj` is missing.")
182+
c(
183+
"!" = "Dependencies checking can not be performed if `ggobj` is missing."
184+
)
183185
)
184186
}
185187
if (check_fonts_dependencies && !is.null(ggobj)) {
186-
fonts_checking_dependencies(dependencies = dependencies, family_list = family_list)
188+
fonts_checking_dependencies(
189+
dependencies = dependencies,
190+
family_list = family_list
191+
)
187192
} else if (check_fonts_dependencies && is.null(ggobj)) {
188-
cli::cli_warn("!" = "Dependencies checking can not be performed if `ggobj` is missing.")
193+
cli::cli_warn(
194+
"!" = "Dependencies checking can not be performed if `ggobj` is missing."
195+
)
189196
}
190197

191198
# create widget -----
@@ -305,5 +312,8 @@ run_girafe_example <- function(name = "crimes") {
305312

306313

307314
UUIDgenerate <- function() {
308-
paste(format(as.hexmode(sample(256, 8, replace = TRUE) - 1), width = 2), collapse = "")
315+
paste(
316+
format(as.hexmode(sample(256, 8, replace = TRUE) - 1), width = 2),
317+
collapse = ""
318+
)
309319
}

R/ipar.R

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,22 @@ interactive_attr_toxml <- function(x, ids = character(0), rows = NULL) {
399399
}
400400
attrName <- switch(a, tooltip = "title", data_id = data_attr, a)
401401

402-
if (isTRUE("fill_na" %in% x$.interactive_hooks) && anyNA(attrValue) && !is.na(attrValue[1])) {
403-
attrValue <- Reduce(f = function(a, b) {
404-
newb <- if (is.na(b)) {
405-
rev(a)[1]
406-
} else b
407-
c(a, newb)
408-
}, x = attrValue)
402+
if (
403+
isTRUE("fill_na" %in% x$.interactive_hooks) &&
404+
anyNA(attrValue) &&
405+
!is.na(attrValue[1])
406+
) {
407+
attrValue <- Reduce(
408+
f = function(a, b) {
409+
newb <- if (is.na(b)) {
410+
rev(a)[1]
411+
} else {
412+
b
413+
}
414+
c(a, newb)
415+
},
416+
x = attrValue
417+
)
409418
}
410419

411420
set_attr(

R/utils_data.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ panel_path_reshape <- function(data) {
1515
data <- filter(data, !.data$has_na)
1616
data <- mutate(
1717
data,
18-
has_na = NULL, segment_change = NULL
18+
has_na = NULL,
19+
segment_change = NULL
1920
)
2021
as.data.frame(data)
2122
}
22-

examples/geom_label_interactive.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ library(gdtools)
55
register_liberationsans()
66

77
p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
8-
geom_label_interactive(aes(
9-
tooltip = paste(rownames(mtcars), mpg, sep = "\n")
10-
), family = "Liberation Sans") +
8+
geom_label_interactive(
9+
aes(
10+
tooltip = paste(rownames(mtcars), mpg, sep = "\n")
11+
),
12+
family = "Liberation Sans"
13+
) +
1114
theme_minimal(base_family = "Liberation Sans", base_size = 11)
1215
x <- girafe(
1316
ggobj = p,

examples/geom_quasirandom_interactive.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ if (
4949
dodge_width <- .8
5050
position <- position_dodge(width = dodge_width)
5151

52-
gg_qr <- ggplot(dat, aes(x = am, y = disp, fill = gear, group = interaction(am, gear))) +
52+
gg_qr <- ggplot(
53+
dat,
54+
aes(x = am, y = disp, fill = gear, group = interaction(am, gear))
55+
) +
5356
geom_quasirandom_interactive(
5457
aes(tooltip = disp, data_id = name),
5558
shape = 21,

examples/girafe.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ dataset$carname <- row.names(mtcars)
1010
gg_point <- ggplot(
1111
data = dataset,
1212
mapping = aes(
13-
x = wt, y = qsec, color = disp,
14-
tooltip = carname, data_id = carname
13+
x = wt,
14+
y = qsec,
15+
color = disp,
16+
tooltip = carname,
17+
data_id = carname
1518
)
1619
) +
17-
geom_point_interactive(hover_nearest = TRUE, size = 11/.pt) +
20+
geom_point_interactive(hover_nearest = TRUE, size = 11 / .pt) +
1821
theme_minimal(base_family = "Liberation Sans", base_size = 11)
1922

2023
x <- girafe(

0 commit comments

Comments
 (0)