Skip to content

Commit

Permalink
Merge pull request #158 from pshevtsov/dyPlugin-merge-options
Browse files Browse the repository at this point in the history
Merge options if plugin was already added
  • Loading branch information
jjallaire authored Mar 6, 2017
2 parents 3887b2c + 86ee472 commit 9faedea
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 9faedea

Please sign in to comment.