context("Performance charts")
load_data <- function() {
h <- new.env()
load("testdata/history.RData",envir=h)
return(get("history",envir=h))
}
test_that("charts 2 accepts defaults",{
h <- load_data()
XLE <- get("XLE",envir=h)
colnames(XLE) <- gsub("XLE.","",colnames(XLE))
g <- gg_candles(XLE)
expect_equal(length(g),10)
expect_equal(ncol(g$data),9)
expect_equal(length(g$layers),3)
expect_equal(length(g$mapping),1)
expect_equal(length(g$theme),57)
})
test_that("charts 2 accepts title", {
h <- load_data()
XLE <- get("XLE",envir=h)
test_title <- "XLE Adjusted"
colnames(XLE) <- gsub("XLE.","",colnames(XLE))
g <- gg_charts_summary_2(XLE,ptitle=test_title)
expect_equal(length(g),9)
expect_equal(ncol(g$data),4)
expect_equal(length(g$layers),2)
expect_equal(length(g$mapping),4)
expect_equal(length(g$theme),1)
expect_equal(g$labels$title,test_title)
})
test_that("charts 2 accepts drawdown", {
h <- load_data()
XLE <- get("XLE",envir=h)
dd_color <- "yellow"
colnames(XLE) <- gsub("XLE.","",colnames(XLE))
g <- gg_charts_summary_2(XLE,drawdown_minima=dd_color)
expect_equal(length(g),9)
expect_equal(ncol(g$data),4)
expect_equal(length(g$layers),3)
expect_equal(length(g$mapping),4)
expect_equal(length(g$theme),1)
expect_equal(g$labels$yintercept,"mindd")
})
test_that("charts 3 accepts defaults",{
h <- load_data()
XLE <- get("XLE",envir=h)
colnames(XLE) <- gsub("XLE.","",colnames(XLE))
g <- gg_charts_summary_3(XLE)
expect_equal(length(g),9)
expect_equal(ncol(g$data),4)
expect_equal(length(g$layers),4)
expect_equal(length(g$mapping),4)
expect_equal(length(g$theme),1)
})
test_that("charts 3 accepts title", {
h <- load_data()
XLE <- get("XLE",envir=h)
test_title <- "XLE Adjusted"
colnames(XLE) <- gsub("XLE.","",colnames(XLE))
g <- gg_charts_summary_3(XLE,ptitle=test_title)
expect_equal(length(g),9)
expect_equal(ncol(g$data),4)
expect_equal(length(g$layers),4)
expect_equal(length(g$mapping),4)
expect_equal(length(g$theme),1)
expect_equal(g$labels$title,test_title)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.