Skip to content

Commit

Permalink
arguments, na_colour and deprecating function palette
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Nov 14, 2018
1 parent 9124894 commit 3d71ae5
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 23 deletions.
5 changes: 1 addition & 4 deletions DESCRIPTION
Expand Up @@ -26,14 +26,11 @@ Imports:
jsonify (>= 0.1.1),
magrittr,
Rcpp,
scales,
shiny,
spatialwidget,
viridisLite
spatialwidget
RoxygenNote: 6.1.0
Suggests:
covr,
geojsonsf,
knitr,
rmarkdown,
sf,
Expand Down
5 changes: 4 additions & 1 deletion R/legend.R
Expand Up @@ -2,7 +2,10 @@
#'
#' Clears the legend for a given layer_id
#'
#' @inheritParams add_arc
#' @param map_id the id of the map you want to clear the legend from.
#' @param layer_id single value specifying an id for the layer. Use this value to
#' distinguish between shape layers of the same type. Layers with the same id are likely
#' to conflict and not plot correctly
#'
#' @export
clear_legend <- function( map_id, layer_id ) {
Expand Down
6 changes: 4 additions & 2 deletions R/map_data.R
Expand Up @@ -208,9 +208,11 @@ resolve_data.default <- function( data ) stop("This type of data is not supporte


resolve_palette <- function( l, palette ) {
#if ( is.matrix( palette ) ) {
if ( is.function( palette ) ) {
warning("Function palettes have been deprecated, reverting to the viridis palette. See the palette arguemnt in the help file for valid arguments")
} else {
l[['palette']] <- palette
#}
}
return( l )
}

Expand Down
5 changes: 4 additions & 1 deletion R/map_layer_arc.R
Expand Up @@ -79,7 +79,9 @@ mapdeckArcDependency <- function() {
#' , tooltip = "info"
#' , auto_highlight = TRUE
#' , legend = T
#' , legend_options = list(stroke_from = list( title = "Origin airport" ), css = "max-height: 100px;")
#' , legend_options = list(
#' stroke_from = list( title = "Origin airport" ),
#' css = "max-height: 100px;")
#' )
#'
#' ## Using a 2-sfc-column sf object
Expand Down Expand Up @@ -152,6 +154,7 @@ add_arc <- function(
l[["stroke_width"]] <- force(stroke_width)
l[["tooltip"]] <- force(tooltip)
l[["id"]] <- force(id)
l[["na_colour"]] <- force(na_colour)

l <- resolve_palette( l, palette )
l <- resolve_legend( l, legend )
Expand Down
3 changes: 2 additions & 1 deletion R/map_layer_hexagon.R
Expand Up @@ -30,7 +30,8 @@ mapdeckHexagonDependency <- function() {
#' key <- 'abc'
#'
#' df <- read.csv(paste0(
#' 'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv'
#' 'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/'
#' , '3d-heatmap/heatmap-data.csv'
#' ))
#'
#' df <- df[!is.na(df$lng), ]
Expand Down
2 changes: 2 additions & 0 deletions R/map_layer_line.R
Expand Up @@ -87,6 +87,7 @@ add_line <- function(
auto_highlight = FALSE,
highlight_colour = "#AAFFFFFF",
palette = "viridis",
na_colour = "#808080FF",
legend = FALSE,
legend_options = NULL
) {
Expand All @@ -106,6 +107,7 @@ add_line <- function(
l[["stroke_opacity"]] <- force( stroke_opacity )
l[["tooltip"]] <- force( tooltip )
l[["id"]] <- force( id )
l[["na_colour"]] <- force(na_colour)

l <- resolve_palette( l, palette )
l <- resolve_legend( l, legend )
Expand Down
1 change: 1 addition & 0 deletions R/map_layer_path.R
Expand Up @@ -82,6 +82,7 @@ add_path <- function(
l[["stroke_opacity"]] <- force( stroke_opacity )
l[["tooltip"]] <- force(tooltip)
l[["id"]] <- force(id)
l[["na_colour"]] <- force(na_colour)

# l[["legend"]] <- force( legend )
# l[["legend_options"]] <- force( legend_options )
Expand Down
1 change: 1 addition & 0 deletions R/map_layer_pointcloud.R
Expand Up @@ -96,6 +96,7 @@ add_pointcloud <- function(
l[["fill_opacity"]] <- force( fill_opacity )
l[["tooltip"]] <- force(tooltip)
l[["id"]] <- force(id)
l[["na_colour"]] <- force(na_colour)

l <- resolve_palette( l, palette )
l <- resolve_legend( l, legend )
Expand Down
5 changes: 1 addition & 4 deletions R/map_layer_polygon.R
Expand Up @@ -18,9 +18,6 @@ mapdeckPolygonDependency <- function() {
#' @inheritParams add_arc
#'
#' @param polyline column of \code{data} containing the polylines
#' @param geometry string specifying the `sfc` column of an SF object. If NULL and
#' \code{data} is an `sf` object the \code{geometry} will be automatically assinged
#' from \code{ sf::st_geometry( data ) }
#' @param fill_colour column of \code{data} or hex colour for the fill colour
#' @param fill_opacity value between 1 and 255. Either a string specifying the
#' column of \code{data} containing the fill opacity of each shape, or a value
Expand Down Expand Up @@ -81,7 +78,6 @@ add_polygon <- function(
map,
data = get_map_data(map),
polyline = NULL,
#geometry = NULL,
stroke_colour = NULL,
stroke_width = NULL,
fill_colour = NULL,
Expand Down Expand Up @@ -116,6 +112,7 @@ add_polygon <- function(
l[["elevation"]] <- force( elevation )
l[["tooltip"]] <- force(tooltip)
l[["id"]] <- force(id)
l[["na_colour"]] <- force(na_colour)

l <- resolve_palette( l, palette )
l <- resolve_legend( l, legend )
Expand Down
1 change: 1 addition & 0 deletions R/map_layer_scatterplot.R
Expand Up @@ -110,6 +110,7 @@ add_scatterplot <- function(
l[["fill_opacity"]] <- force(fill_opacity)
l[["tooltip"]] <- force(tooltip)
l[["id"]] <- force(id)
l[["na_colour"]] <- force(na_colour)

l <- resolve_palette( l, palette )
l <- resolve_legend( l, legend )
Expand Down
2 changes: 2 additions & 0 deletions R/map_layer_text.R
Expand Up @@ -68,6 +68,7 @@ add_text <- function(
auto_highlight = FALSE,
highlight_colour = "#AAFFFFFF",
palette = "viridis",
na_colour = "#808080FF",
legend = FALSE,
legend_options = NULL
) {
Expand All @@ -91,6 +92,7 @@ add_text <- function(
l[["alignment_baseline"]] <- force( alignment_baseline )
l[["tooltip"]] <- force(tooltip)
l[["id"]] <- force(id)
l[["na_colour"]] <- force(na_colour)

l <- resolve_palette( l, palette )
l <- resolve_legend( l, legend )
Expand Down
4 changes: 3 additions & 1 deletion man/add_arc.Rd

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

3 changes: 2 additions & 1 deletion man/add_hexagon.Rd

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

2 changes: 1 addition & 1 deletion man/add_line.Rd

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

4 changes: 0 additions & 4 deletions man/add_polygon.Rd

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

5 changes: 4 additions & 1 deletion man/add_text.Rd

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

2 changes: 2 additions & 0 deletions man/clear_legend.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-map_layer_parameters.R
Expand Up @@ -18,8 +18,8 @@ test_that("check numeric works", {

test_that("check palette works", {
expect_error(mapdeck:::checkPalette('a'))
expect_silent(mapdeck:::checkPalette(viridisLite::plasma))
expect_error(mapdeck:::checkPalette(list(viridisLite::plasma)))
# expect_silent(mapdeck:::checkPalette(viridisLite::plasma))
# expect_error(mapdeck:::checkPalette(list(viridisLite::plasma)))
})


Expand Down

0 comments on commit 3d71ae5

Please sign in to comment.