diff --git a/DESCRIPTION b/DESCRIPTION index 10b44ced77..e462eebcd4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: plotly Type: Package Title: Interactive, publication-quality graphs online. -Version: 0.5.18 +Version: 0.5.19 Authors@R: c(person("Chris", "Parmer", role = c("aut", "cre"), email = "chris@plot.ly"), person("Scott", "Chamberlain", role = "aut", diff --git a/NEWS b/NEWS index 3e9a48217a..3ec054e9c8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +0.5.19 -- 23 January 2015. + +Support class conversion such as as.Date() within ggplot code. + 0.5.18 -- 22 January 2015. Return proper filepath when filename contains directories. diff --git a/R/plotly-package.r b/R/plotly-package.r index 1a00944894..a39c58d874 100644 --- a/R/plotly-package.r +++ b/R/plotly-package.r @@ -7,7 +7,7 @@ #' \itemize{ #' \item Package: plotly #' \item Type: Package -#' \item Version: 0.5.18 +#' \item Version: 0.5.19 #' \item Date: 2014-03-07 #' \item License: MIT #' } diff --git a/R/plotly.R b/R/plotly.R index db8978d135..7fb269893e 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -82,7 +82,7 @@ For more help, see https://plot.ly/R or contact .") # public attributes/methods that the user has access to pub <- list(username=username, key=key, filename="from api", fileopt=NULL, - version="0.5.18") + version="0.5.19") priv <- list() pub$makecall <- function(args, kwargs, origin) { diff --git a/R/trace_generation.R b/R/trace_generation.R index ca7b8b94ca..5477972f5d 100644 --- a/R/trace_generation.R +++ b/R/trace_generation.R @@ -41,13 +41,24 @@ layer2traces <- function(l, d, misc) { ## For non-numeric data on the axes, we should take the values from ## the original data. - for (axis.name in c("x", "y")){ - if (!misc$is.continuous[[axis.name]]){ + for (axis.name in c("x", "y")) { + if (!misc$is.continuous[[axis.name]]) { aes.names <- paste0(axis.name, c("", "end", "min", "max")) aes.used <- aes.names[aes.names %in% names(g$aes)] for(a in aes.used) { col.name <- g$aes[aes.used] - data.vec <- l$data[[col.name]] + dtemp <- l$data[[col.name]] + if (is.null(dtemp)) { + if (!inherits(g$data[[paste0(a, ".name")]], "NULL")) { + # Handle the case where as.Date() is passed in aes argument. + if (class(g$data[[a]]) != class(g$data[[paste0(a, ".name")]])) { + g$data[[a]] <- g$data[[paste0(a, ".name")]] + data.vec <- g$data[[a]] + } + } + } else { + data.vec <- dtemp + } # For some plot types, we overwrite `data` with `prestats.data`. pdata.vec <- misc$prestats.data[[a]] @@ -274,11 +285,11 @@ toBasic <- list( g } }, - path=function(g){ + path=function(g) { group2NA(g, "path") }, - line=function(g){ - g$data <- g$data[order(g$data$x),] + line=function(g) { + g$data <- g$data[order(g$data$x), ] group2NA(g, "path") }, boxplot=function(g) { @@ -352,14 +363,14 @@ toBasic <- list( #' @export #' @return list of geom info. #' @author Toby Dylan Hocking -group2NA <- function(g, geom){ +group2NA <- function(g, geom) { poly.list <- split(g$data, g$data$group) is.group <- names(g$data) == "group" poly.na.df <- data.frame() - for(i in seq_along(poly.list)){ - no.group <- poly.list[[i]][,!is.group,drop=FALSE] - na.row <- no.group[1,] - na.row[,c("x", "y")] <- NA + for (i in seq_along(poly.list)) { + no.group <- poly.list[[i]][, !is.group, drop=FALSE] + na.row <- no.group[1, ] + na.row[, c("x", "y")] <- NA poly.na.df <- rbind(poly.na.df, no.group, na.row) } g$data <- poly.na.df @@ -370,7 +381,7 @@ group2NA <- function(g, geom){ # Convert basic geoms to traces. geom2trace <- list( - path=function(data, params){ + path=function(data, params) { list(x=data$x, y=data$y, name=params$name,