Skip to content

Commit

Permalink
BUGFIX: parameter 'initialTime' was not working correctly in some sit…
Browse files Browse the repository at this point in the history
…uations
  • Loading branch information
FrancoisGuillem committed Jul 7, 2017
1 parent fd1c17d commit d80ce0a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions R/add_minicharts.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ updateMinicharts <- function(map, layerId, chartdata = NULL, time = NULL, maxVal
legend = TRUE, legendPosition = NULL,
timeFormat = NULL, initialTime = NULL, onChange = NULL) {

type <- match.arg(type, c("auto", "bar", "pie", "polar-area", "polar-radius"))
if (!is.null(type)) {
type <- match.arg(type, c("auto", "bar", "pie", "polar-area", "polar-radius"))
}
if (is.null(time)) time <- 1
if (!is.null(chartdata) & !is.null(popup) & is.null(popup$labels)) popup$labels <- colnames(chartdata)

Expand Down Expand Up @@ -218,7 +220,6 @@ updateMinicharts <- function(map, layerId, chartdata = NULL, time = NULL, maxVal
# Update time slider only if data is updated
if(is.null(chartdata)) {
args$timeLabels <- NULL
args$initialTime <- NULL
}

# Update legend if required
Expand Down
1 change: 1 addition & 0 deletions R/prepare_js_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
}
}
timeLabels <- as.character(timeLabels)
if (!is.null(initialTime)) initialTime <- as.character(initialTime)

list(
options = options,
Expand Down
6 changes: 3 additions & 3 deletions inst/leaflet.minicharts.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions javascript/timeslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
},

setTimeLabels: function(timeLabels) {
if (timeLabels === null) return;
var self = this;

if (typeof timeLabels == "undefined") {
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-prepare_js_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,11 @@ describe(".prepareJSArgs", {
expect_equal(jsArgs$timeLabels, I(expectedLabels))
expect_equal(jsArgs$initialTime, expectedLabels[1])
})

it ("returns timeLabels and initialTimes in character format", {
jsArgs <- .prepareJSArgs(myOptions, mydata,
initialTime = min(myOptions$options$time))
expect_equal(mode(jsArgs$timeLabels), "character")
expect_is(jsArgs$initialTime, "character")
})
})

0 comments on commit d80ce0a

Please sign in to comment.