Skip to content

Commit

Permalink
fix popupOptions + add example + update version
Browse files Browse the repository at this point in the history
  • Loading branch information
bthieurmel committed Apr 7, 2021
1 parent b1697d8 commit 023cc04
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 18 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: leaflet.minicharts
Type: Package
Title: Mini Charts for Interactive Maps
Version: 0.6.1
Version: 0.6.2
Authors@R: c(
person(given = "Veronique",
family = "Bachelier",
Expand All @@ -21,7 +21,7 @@ Imports: leaflet (>= 1.1.0),
htmltools
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.0.1
RoxygenNote: 7.1.1
Suggests: knitr,
rmarkdown,
dplyr,
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Changes in version 0.6.2 (2021-04-07)

NEW FEATURES:
* add popupOptions

Changes in version 0.6.1 (2019-12-16)

BUGFIXES:
Expand Down
10 changes: 10 additions & 0 deletions R/add_flows.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
#' time = bal$month
#' )
#'
#' # popupOptions
#' data("eco2mixBalance")
#' bal <- eco2mixBalance
#' leaflet() %>% addTiles() %>%
#' addFlows(
#' bal$lng0, bal$lat0, bal$lng1, bal$lat1,
#' flow = bal$balance,
#' time = bal$month,
#' popupOptions = list(closeOnClick = FALSE, autoClose = FALSE)
#' )
#'
#' @export
addFlows <- function(map, lng0, lat0, lng1, lat1, color = "blue", flow = 1,
Expand Down
13 changes: 10 additions & 3 deletions R/add_minicharts.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
#' @param onChange (For power users who know javascript) A character string
#' containing javascript code that is executed each time a chart is updated.
#' See the details section to understand why and how to use this parameter.
#' @param popupOptions Change popupOptions (ex : autoClose, maxHeight, closeButton ...)
#' see leaflet::popupOptions for more informations.
#' @param popupOptions Change default popupOptions (ex : autoClose, maxHeight, closeButton ...)
#' See \code{\link[leaflet]{popupOptions}} for more informations.
#'
#' @details
#' Since version 0.5, the parameter \code{onChange} can be used to execute
Expand Down Expand Up @@ -124,6 +124,13 @@
#' mymap %>% updateMinicharts("c1", maxValues = 6)
#' mymap %>% updateMinicharts("c1", type="pie")
#'
#' # popupOptions
#' mymap <- leaflet() %>% addTiles() %>%
#' addMinicharts(0, 0, chartdata = 1:3, layerId = "c1", popupOptions = list(closeButton = FALSE))
#'
#' mymap
#' mymap %>% updateMinicharts("c1", maxValues = 6, popupOptions = list(closeButton = TRUE))
#'
#' @export
#'
addMinicharts <- function(map, lng, lat, chartdata = 1, time = NULL, maxValues = NULL, type = "auto",
Expand Down Expand Up @@ -201,7 +208,7 @@ updateMinicharts <- function(map, layerId, chartdata = NULL, time = NULL, maxVal
transitionTime = NULL, popup = NULL,
legend = TRUE, legendPosition = NULL,
timeFormat = NULL, initialTime = NULL, onChange = NULL,
popupOptions= NULL) {
popupOptions = NULL) {

if (!is.null(type)) {
type <- match.arg(type, c("auto", "bar", "pie", "polar-area", "polar-radius"))
Expand Down
2 changes: 1 addition & 1 deletion inst/leaflet.minicharts.min.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions javascript/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@
if (l.popupArgs.noPopup) return;

if (l.opts[timeId].popupHTML) {
if(l.isPopupOpen() === false){
if(l.isPopupOpen() === false){
l.bindPopup(l.opts[timeId].popupHTML, l.popupOptions);
} else {
l.setPopupContent(l.opts[timeId].popupHTML);
}
/* l.bindPopup(l.opts[timeId].popupHTML, l.popupOptions); */
/* l.bindPopup(l.opts[timeId].popupHTML); */
return;
}

Expand Down Expand Up @@ -164,12 +164,12 @@
}

popup = '<div class="popup">'+ title + content + '</div>';
/* l.bindPopup(popup.popupHTML, l.popupOptions); */
if(l.isPopupOpen() === false){
l.bindPopup(l.opts[timeId].popupHTML, l.popupOptions);
} else {
l.setPopupContent(l.opts[timeId].popupHTML);
}
/* l.bindPopup(popup); */
if(l.isPopupOpen() === false){
l.bindPopup(popup, l.popupOptions);
} else {
l.setPopupContent(popup);
}
return popup;
}

Expand Down
14 changes: 12 additions & 2 deletions man/addFlows.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions man/addMinicharts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 023cc04

Please sign in to comment.