diff --git a/.gitignore b/.gitignore index b9f826b92a..e2325cfa68 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ R/.Rhistory Rapp.history /Karthik_local.R *~ -.Rhistory \ No newline at end of file +.Rhistory +.RData +Makefile diff --git a/DESCRIPTION b/DESCRIPTION index 03c0637d45..c9f8b7d93f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: plotly Type: Package Title: Interactive, publication-quality graphs online. -Version: 0.5.4 +Version: 0.5.5 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 7614179183..b3fb602f87 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +0.5.5 -- 24 October 2014. + +Support category histograms (with factors). + 0.5.4 -- 22 October 2014. Support conversion of geom_vline(). diff --git a/R/trace_generation.R b/R/trace_generation.R index 93670b44d8..7c7064b369 100644 --- a/R/trace_generation.R +++ b/R/trace_generation.R @@ -21,7 +21,6 @@ layer2traces <- function(l, d, misc) { barmode <- "group" if (g$geom == "bar" || g$geom == "histogram") { if (l$stat$objname == "bin") { - bargap <- 0 if (g$geom != "histogram") { warning("You may want to use geom_histogram.") } @@ -67,13 +66,15 @@ layer2traces <- function(l, d, misc) { "%Y-%m-%d %H:%M:%S") } else if (inherits(data.vec, "factor")) { ## Re-order data so that Plotly gets it right from ggplot2. - g$data <- g$data[order(g$data[[a]]),] + g$data <- g$data[order(g$data[[a]]), ] data.vec <- data.vec[match(g$data[[a]], as.numeric(data.vec))] - g$prestats.data <- g$prestats.data[order(g$prestats.data[[a]]),] + g$prestats.data <- g$prestats.data[order(g$prestats.data[[a]]), ] pdata.vec <- pdata.vec[match(g$prestats.data[[a]], as.numeric(pdata.vec))] if (length(pdata.vec) == length(data.vec)) pdata.vec <- data.vec + if (!is.factor(pdata.vec)) + pdata.vec <- g$prestats.data[[paste0(a, ".name")]] } g$data[[a]] <- data.vec g$prestats.data[[a]] <- pdata.vec diff --git a/tests/testthat/test-ggplot-histogram.R b/tests/testthat/test-ggplot-histogram.R index 0460d5c6e9..42b236bcb9 100644 --- a/tests/testthat/test-ggplot-histogram.R +++ b/tests/testthat/test-ggplot-histogram.R @@ -8,6 +8,9 @@ test_that("default position is translated to barmode=stack", { L <- gg2list(hist) expect_equal(length(L), 2) expect_identical(L$kwargs$layout$barmode, "stack") + expect_identical(L$kwargs$layout$xaxis$type, "category") + expect_identical(L[[1]]$type, "histogram") + expect_true(L[[1]]$x[1] %in% c("CDN", "MEX", "USA")) save_outputs(hist, "histogram-barmodestack") })