Skip to content

Commit a51a24a

Browse files
author
Jordan S Read
committed
start on #456
1 parent 5f3161d commit a51a24a

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

R/axis.R

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,39 @@ axis.gsplot <- function(object, ..., n.minor=0, tcl.minor=0.15, reverse=NULL, ap
6868

6969
fun.name <- "axis"
7070

71-
user_args <- filter_arguments(fun.name = fun.name, ...,
72-
custom.config = object[["global"]][["config"]][["config.file"]])$call.args
71+
args <- filter_arguments(fun.name = fun.name, ...,
72+
custom.config = object[["global"]][["config"]][["config.file"]])
7373

74-
sides <- user_args[[fun.name]]$side
75-
user_args[[fun.name]]$side <- NULL
76-
user_args[[fun.name]]$n.minor <- n.minor
77-
user_args[[fun.name]]$tcl.minor <- tcl.minor
74+
if (length(args$extracted.args) > 0){
75+
warning('axs.gsplot is not configured to support embedded function calls', call. = FALSE)
76+
}
77+
78+
user.args <- args$call.args
79+
sides <- user.args[[fun.name]]$side
80+
81+
if (is.null(sides)){
82+
return(object)
83+
}
84+
85+
user.args[[fun.name]]$side <- NULL
86+
user.args[[fun.name]]$n.minor <- n.minor
87+
user.args[[fun.name]]$tcl.minor <- tcl.minor
88+
89+
user.args[[fun.name]] <- append(args$call.args[[fun.name]], args$option.args)
7890

7991
for(side in sides){
8092
# append the side and give it defaults if it doesn't exist
81-
if(append){
82-
83-
} else {
93+
if(!append){
8494
object <- modify_side(object, args = list(), side=side)
8595
}
8696

8797
object[[as.side_name(side)]][['usr.axes']] <- TRUE
88-
object[[as.side_name(side)]][['axis']] <- append_replace(object[[as.side_name(side)]][['axis']], user_args[[fun.name]])
98+
object[[as.side_name(side)]][['axis']] <- append_replace(object[[as.side_name(side)]][['axis']], user.args[[fun.name]])
8999
if (!is.null(reverse)){
90100
object[[as.side_name(side)]][['reverse']] <- reverse
91101
}
92102
}
103+
93104
class(object) <- 'gsplot'
94105
return(object)
95106

tests/testthat/tests-axis.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ test_that("axis tracks append FALSE by default",{
8383
# expect_equal(sum(names(gs$side.1) == 'axis'), 2)
8484
})
8585

86+
context("axis style arguments handled appropriately")
87+
88+
test_that("par args sent to axis() end up in axis args",{
89+
gs <- points(gsplot(), 1, 0) %>% axis(side=1, tcl = -0.25)
90+
expect_equal(gs$side.1$axis[["tcl"]], -0.25)
91+
})
92+
93+
94+
test_that("minor ticks get default direction and size from major ticks",{
95+
# tcl
96+
# tcl.minor
97+
})
98+
8699
context("axis user flipped on")
87100

88101
test_that("axis user FALSE by default",{
@@ -97,13 +110,14 @@ test_that("axis user flipped to TRUE when specified",{
97110
})
98111

99112

113+
100114
test_that("format",{
101115

102116
gs <- gsplot() %>%
103117
points(seq.Date(as.Date("2010-01-01"), as.Date("2010-12-31"), by="month"),
104118
1:12) %>%
105119
axis(side = 1, format="%Y-%m")
106-
120+
107121
expect_true(class(gs$side.1$lim) == "Date")
108122

109123
gs <- gsplot() %>%

0 commit comments

Comments
 (0)