Skip to content

Commit

Permalink
Merge pull request #556 from JohnCoene/fixCandleSticks
Browse files Browse the repository at this point in the history
Fix candle sticks invertion
  • Loading branch information
munoztd0 authored Jul 28, 2023
2 parents caa97f1 + 2b44658 commit 16a6fa1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion R/add_.R
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ e_candle_ <- function(e, opening, closing, low, high, bind = NULL, name = NULL,
}

for (i in seq_along(e$x$data)) {
data <- .build_data2(e$x$data[[i]], closing, opening, low, high)
data <- .build_data2(e$x$data[[i]], opening, closing, low, high)

if (!is.null(bind)) {
data <- .add_bind2(e, data, bind, i = i)
Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ globalVariables(c("x", "e", ".", "acc", "epoch", "loss", "size", "val_acc", "val
}

.build_data <- function(e, ...) {
data <- e$x$data[[1]] # |>
# dplyr::select(...)
data <- data[, c(...), drop = FALSE]
data <- e$x$data[[1]] |>
dplyr::select(...)
# data <- data[, c(...), drop = FALSE]
data <- unname(data)

apply(data, 1, function(x) {
Expand Down
15 changes: 8 additions & 7 deletions tests/testthat/test-chart_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,14 @@ test_that("e_candle plot has the good data structure and type", {
expect_equal(
plot$x$opts$series[[1]]$data,
list(
list(value = c(200.72, 200.60, 197.82, 203.32)),
list(value = c(198.85, 200.22, 198.07, 200.67)),
list(value = c(199.05, 198.43, 197.90, 200.00)),
list(value = c(203.73, 199.05, 198.10, 203.95)),
list(value = c(204.08, 203.54, 202.00, 204.90)),
list(value = c(208.11, 203.40, 201.50, 208.44)),
list(value = c(211.88, 208.34, 207.60, 213.17)))
list(value = c(200.60, 200.72, 197.82, 203.32)),
list(value = c(200.22, 198.85, 198.07, 200.67)),
list(value = c(198.43, 199.05, 197.90, 200.00)),
list(value = c(199.05, 203.73, 198.10, 203.95)),
list(value = c(203.54, 204.08, 202.00, 204.90)),
list(value = c(203.40, 208.11, 201.50, 208.44)),
list(value = c(208.34, 211.88, 207.60, 213.17))
)
)
expect_equal(
plot$x$opts$series[[1]]$type,
Expand Down

0 comments on commit 16a6fa1

Please sign in to comment.