Skip to content

Commit

Permalink
Merge pull request #413 from USEPA/410-whole-numbers-for-characterist…
Browse files Browse the repository at this point in the history
…ic-and-measurement-legends-in-tada_overviewmap

410 whole numbers for characteristic and measurement legends in tada overviewmap
  • Loading branch information
cristinamullin committed Mar 6, 2024
2 parents 3257fd5 + b0fb5b8 commit a6d34b8
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions R/Figures.R
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,11 @@ TADA_OverviewMap <- function(.data) {
dplyr::group_by(MonitoringLocationIdentifier, MonitoringLocationName, TADA.LatitudeMeasure, TADA.LongitudeMeasure) %>%
dplyr::summarise("Sample_Count" = length(unique(ResultIdentifier)), "Visit_Count" = length(unique(ActivityStartDate)), "Parameter_Count" = length(unique(TADA.CharacteristicName)), "Organization_Count" = length(unique(OrganizationIdentifier)))

pt_sizes <- round(unique(stats::quantile(sumdat$Sample_Count, probs = c(0.1, 0.25, 0.5, 0.75)), 0))
param_counts <- sort(unique(sumdat$Parameter_Count))
param_length <- length(param_counts)
param_diff <- diff(param_counts)

pt_sizes <- round(stats::quantile(sumdat$Sample_Count, probs = c(0.1, 0.25, 0.5, 0.75)), 0)
pt_labels <- c(
paste0("<=", pt_sizes[1]),
paste0(">", pt_sizes[1]),
Expand All @@ -418,10 +422,23 @@ TADA_OverviewMap <- function(.data) {

site_legend <- subset(site_size, site_size$Point_size %in% unique(sumdat$radius))

pal <- leaflet::colorBin(
palette = "Blues",
domain = sumdat$Parameter_Count
)


# set color palette
if (length(unique(param_diff)) == 1 & param_length < 10) {
pal <- leaflet::colorFactor(
palette = "Blues",
levels = param_counts
)
} else {
# set breaks to occur only at integers
pretty.breaks <- unique(round(pretty(sumdat$Parameter_Count)))

pal <- leaflet::colorBin(
palette = "Blues",
bins = pretty.breaks
)
}

# Tribal layers will load by default in the overview map, restricted by the bounding box of the current dataset
# They can be toggled on and off using a button (all layers work together and can't be turned on/off individually).
Expand Down

0 comments on commit a6d34b8

Please sign in to comment.