Skip to content

Commit

Permalink
Merge options if plugin was already added
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Shevtsov committed Mar 1, 2017
1 parent 3887b2c commit 86ee472
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/dependency.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ dyPlugin <- function(dygraph, name, path, options = list(), version = "1.0") {
if (length(options) == 0) {
options <- JS("{}")
}
# merge options if plugin was already added
if (name %in% names(dygraph$x$plugins)) {
current.options <- dygraph$x$plugins[[name]]
i <- match(names(current.options), names(options))
i <- is.na(i)
if (any(i)) {
options[names(current.options)[which(i)]] = current.options[which(i)]
}
}
dygraph$x$plugins[[name]] <- options

# return dygraph
Expand Down

0 comments on commit 86ee472

Please sign in to comment.