Skip to content

Commit 5d70067

Browse files
committed
Fix #314
1 parent 5e7907d commit 5d70067

17 files changed

+34
-25
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Imports:
4242
vctrs,
4343
systemfonts
4444
LinkingTo: Rcpp, RcppEigen
45-
RoxygenNote: 7.2.1
45+
RoxygenNote: 7.2.3
4646
Suggests:
4747
sessioninfo,
4848
concaveman,

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggforce (development version)
22

3+
* Fixed a bug that would cause reordering of data in some geoms (#314)
4+
35
# ggforce 0.4.1
46

57
* Fixed a sanitizer error in the decent calculations used for the mark geoms

R/aaa.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ combine_aes <- function(aes1, aes2) {
2626
empty_data <- function(x) {
2727
length(x) == 0 || nrow(x) == 0
2828
}
29+
30+
# This function is like base::make.unique, but it
31+
# maintains the ordering of the original names if the values
32+
# are sorted.
33+
make_unique <- function(x, sep = '.') {
34+
if (!anyDuplicated(x)) return(x)
35+
groups <- match(x, unique(x))
36+
suffix <- unsplit(lapply(split(x, groups), seq_along), groups)
37+
max_chars <- nchar(max(suffix))
38+
suffix_format <- paste0('%0', max_chars, 'd')
39+
paste0(x, sep, sprintf(suffix_format, suffix))
40+
}

R/arc_bar.R

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,13 @@ geom_arc_bar <- function(mapping = NULL, data = NULL, stat = 'arc_bar',
184184
)
185185
}
186186

187-
# This function is like base::make.unique, but it
188-
# maintains the ordering of the original names if the values
189-
# are sorted.
190-
make_unique <- function(x, sep = '.') {
191-
if (!anyDuplicated(x)) return(x)
192-
groups <- match(x, unique(x))
193-
suffix <- unsplit(lapply(split(x, groups), seq_along), groups)
194-
max_chars <- nchar(max(suffix))
195-
suffix_format <- paste0('%0', max_chars, 'd')
196-
paste0(x, sep, sprintf(suffix_format, suffix))
197-
}
198-
199187
arcPaths <- function(data, n) {
200188
trans <- radial_trans(c(0, 1), c(0, 2 * pi), pad = 0)
201189
data <- data[data$start != data$end, ]
202190
data$nControl <- ceiling(n / (2 * pi) * abs(data$end - data$start))
203191
data$nControl[data$nControl < 3] <- 3
204192
extraData <- !names(data) %in% c('r0', 'r', 'start', 'end', 'group')
205-
data$group <- make_unique(as.character(data$group))
193+
data$group <- make_unique(data$group)
206194
paths <- lapply(seq_len(nrow(data)), function(i) {
207195
path <- data_frame0(
208196
a = seq(data$start[i], data$end[i], length.out = data$nControl[i]),

R/diagonal.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ StatDiagonal <- ggproto('StatDiagonal', Stat,
106106
compute_panel = function(data, scales, n = 100, strength = 0.5, flipped_aes = FALSE) {
107107
if (empty_data(data)) return(data)
108108
data <- flip_data(data, flipped_aes)
109-
data$group <- make_unique(as.character(data$group))
109+
data$group <- make_unique(data$group)
110110
end <- data
111111
end$x <- end$xend
112112
end$y <- end$yend
@@ -212,7 +212,7 @@ StatDiagonal0 <- ggproto('StatDiagonal0', Stat,
212212
compute_panel = function(data, scales, strength = 0.5, flipped_aes = FALSE) {
213213
if (empty_data(data)) return(data)
214214
data <- flip_data(data, flipped_aes)
215-
data$group <- make_unique(as.character(data$group))
215+
data$group <- make_unique(data$group)
216216
end <- data
217217
end$x <- end$xend
218218
end$y <- end$yend

R/ellipse.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ StatEllip <- ggproto('StatEllip', Stat,
6969
},
7070
compute_panel = function(self, data, scales, n = 360) {
7171
if (empty_data(data)) return(data)
72-
data$group <- make_unique(as.character(data$group))
72+
data$group <- make_unique(data$group)
7373
n_ellipses <- nrow(data)
7474
data <- data[rep(seq_len(n_ellipses), each = n), ]
7575
points <- rep(seq(0, 2 * pi, length.out = n + 1)[seq_len(n)],

R/link.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ NULL
8585
StatLink <- ggproto('StatLink', Stat,
8686
compute_panel = function(data, scales, n = 100) {
8787
extraCols <- !names(data) %in% c('x', 'y', 'xend', 'yend', 'group', 'PANEL')
88-
data$group <- make_unique(as.character(data$group))
88+
data$group <- make_unique(data$group)
8989
data <- lapply(seq_len(nrow(data)), function(i) {
9090
path <- data_frame0(
9191
x = seq(data$x[i], data$xend[i], length.out = n),

R/regon.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ StatRegon <- ggproto('StatRegon', Stat,
6060
if (n %% 2 == 0) p <- p + p[2] / 2
6161
p * 2 * pi
6262
}))
63-
data$group <- make_unique(as.character(data$group))
63+
data$group <- make_unique(data$group)
6464
data <- data[rep(seq_len(nrow(data)), data$sides), ]
6565
x_tmp <- sin(pos) * data$r
6666
y_tmp <- cos(pos) * data$r

R/spiro.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ StatSpiro <- ggproto('StatSpiro', Stat,
6868
if (is.null(data$x0)) data$x0 <- 0
6969
if (is.null(data$y0)) data$y0 <- 0
7070
n_spiro <- nrow(data)
71-
data$group <- make_unique(as.character(data$group))
71+
data$group <- make_unique(data$group)
7272
if (is.null(revolutions)) {
7373
revo <- attr(fractions(data$r / data$R), 'fracs')
7474
revo <- as.numeric(sub('/.*$', '', revo))

man/facet_grid_paginate.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.

man/gather_set_data.Rd

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

man/geom_autohistogram.Rd

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

man/geom_delvor.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_mark_hull.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_sina.Rd

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

man/scale_unit.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.

man/trans_reverser.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)