Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Aug 28, 2024
1 parent e7aa29a commit 1f70f58
Show file tree
Hide file tree
Showing 19 changed files with 1,624 additions and 46 deletions.
179 changes: 179 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,16 @@ S3method(tmapSubsetShp,Spatial)
S3method(tmapSubsetShp,sf)
S3method(tmapSubsetShp,sfc)
S3method(tmapSubsetShp,stars)
export(.TMAP)
export(.TMAP_GRID)
export(.TMAP_LEAFLET)
export(chart_save)
export(data_class)
export(data_type)
export(format_aes_results)
export(get_fact_levels_na)
export(get_scale_defaults)
export(lwd_to_mm)
export(make_by_vars)
export(marker_icon)
export(opt_tm_bubbles)
Expand Down Expand Up @@ -241,13 +249,41 @@ export(tm_view)
export(tm_xlab)
export(tm_ylab)
export(tmapAddLayerOptions)
export(tmapChartBinned)
export(tmapChartBinned2d)
export(tmapChartBinned2d_catcat)
export(tmapChartBinned2d_numcat)
export(tmapChartBinned2d_numnum)
export(tmapChartBinned_categorical)
export(tmapChartBinned_numeric)
export(tmapChartNone)
export(tmapChartPass)
export(tmapChartRaw)
export(tmapChartRaw_nna)
export(tmapGetShapeMeta1)
export(tmapGetShapeMeta2)
export(tmapGpar)
export(tmapGridLines)
export(tmapGridPolygons)
export(tmapGridRaster)
export(tmapGridSymbols)
export(tmapGridText)
export(tmapLeafletLines)
export(tmapLeafletPolygons)
export(tmapLeafletRaster)
export(tmapLeafletSymbols)
export(tmapLeafletText)
export(tmapMode)
export(tmapOutput)
export(tmapProxy)
export(tmapScale)
export(tmapScaleAsIs)
export(tmapScaleAuto)
export(tmapScaleBivariate)
export(tmapScaleCategorical)
export(tmapScaleIntervals)
export(tmapScaleRank)
export(tmapSeq)
export(tmapShape)
export(tmapSplitShp)
export(tmapSubsetShp)
Expand All @@ -258,6 +294,147 @@ export(tmapTransLines)
export(tmapTransPolygons)
export(tmapTransRaster)
export(tmapUsrCls)
export(tmapValuesBVV_bgcol)
export(tmapValuesBVV_col)
export(tmapValuesBVV_fill)
export(tmapValuesCVV_angle)
export(tmapValuesCVV_area)
export(tmapValuesCVV_bgcol)
export(tmapValuesCVV_bgcol_alpha)
export(tmapValuesCVV_col)
export(tmapValuesCVV_col_alpha)
export(tmapValuesCVV_fill)
export(tmapValuesCVV_fill_alpha)
export(tmapValuesCVV_fontface)
export(tmapValuesCVV_lty)
export(tmapValuesCVV_lwd)
export(tmapValuesCVV_num)
export(tmapValuesCVV_shape)
export(tmapValuesCVV_size)
export(tmapValuesCVV_skip)
export(tmapValuesCVV_text)
export(tmapValuesCVV_xmod)
export(tmapValuesCVV_ymod)
export(tmapValuesCheck_angle)
export(tmapValuesCheck_area)
export(tmapValuesCheck_bgcol)
export(tmapValuesCheck_bgcol_alpha)
export(tmapValuesCheck_col)
export(tmapValuesCheck_col_alpha)
export(tmapValuesCheck_fill)
export(tmapValuesCheck_fill_alpha)
export(tmapValuesCheck_fontface)
export(tmapValuesCheck_lty)
export(tmapValuesCheck_lwd)
export(tmapValuesCheck_num)
export(tmapValuesCheck_shape)
export(tmapValuesCheck_size)
export(tmapValuesCheck_skip)
export(tmapValuesCheck_text)
export(tmapValuesCheck_xmod)
export(tmapValuesColorize_angle)
export(tmapValuesColorize_area)
export(tmapValuesColorize_bgcol)
export(tmapValuesColorize_bgcol_alpha)
export(tmapValuesColorize_col)
export(tmapValuesColorize_col_alpha)
export(tmapValuesColorize_fill)
export(tmapValuesColorize_fill_alpha)
export(tmapValuesColorize_fontface)
export(tmapValuesColorize_lty)
export(tmapValuesColorize_lwd)
export(tmapValuesColorize_num)
export(tmapValuesColorize_shape)
export(tmapValuesColorize_size)
export(tmapValuesColorize_skip)
export(tmapValuesColorize_text)
export(tmapValuesColorize_xmod)
export(tmapValuesIsDiv_angle)
export(tmapValuesIsDiv_area)
export(tmapValuesIsDiv_bgcol)
export(tmapValuesIsDiv_bgcol_alpha)
export(tmapValuesIsDiv_col)
export(tmapValuesIsDiv_col_alpha)
export(tmapValuesIsDiv_fill)
export(tmapValuesIsDiv_fill_alpha)
export(tmapValuesIsDiv_fontface)
export(tmapValuesIsDiv_lty)
export(tmapValuesIsDiv_lwd)
export(tmapValuesIsDiv_num)
export(tmapValuesIsDiv_shape)
export(tmapValuesIsDiv_size)
export(tmapValuesIsDiv_skip)
export(tmapValuesIsDiv_text)
export(tmapValuesIsDiv_xmod)
export(tmapValuesRange_angle)
export(tmapValuesRange_area)
export(tmapValuesRange_bgcol)
export(tmapValuesRange_bgcol_alpha)
export(tmapValuesRange_col)
export(tmapValuesRange_col_alpha)
export(tmapValuesRange_fill)
export(tmapValuesRange_fill_alpha)
export(tmapValuesRange_fontface)
export(tmapValuesRange_lty)
export(tmapValuesRange_lwd)
export(tmapValuesRange_num)
export(tmapValuesRange_shape)
export(tmapValuesRange_size)
export(tmapValuesRange_skip)
export(tmapValuesRange_text)
export(tmapValuesRange_xmod)
export(tmapValuesScale_angle)
export(tmapValuesScale_area)
export(tmapValuesScale_bgcol)
export(tmapValuesScale_bgcol_alpha)
export(tmapValuesScale_col)
export(tmapValuesScale_col_alpha)
export(tmapValuesScale_fill)
export(tmapValuesScale_fill_alpha)
export(tmapValuesScale_fontface)
export(tmapValuesScale_lty)
export(tmapValuesScale_lwd)
export(tmapValuesScale_num)
export(tmapValuesScale_shape)
export(tmapValuesScale_size)
export(tmapValuesScale_skip)
export(tmapValuesScale_text)
export(tmapValuesScale_xmod)
export(tmapValuesSubmit_angle)
export(tmapValuesSubmit_area)
export(tmapValuesSubmit_bgcol)
export(tmapValuesSubmit_bgcol_alpha)
export(tmapValuesSubmit_col)
export(tmapValuesSubmit_col_alpha)
export(tmapValuesSubmit_fill)
export(tmapValuesSubmit_fill_alpha)
export(tmapValuesSubmit_fontface)
export(tmapValuesSubmit_lty)
export(tmapValuesSubmit_lwd)
export(tmapValuesSubmit_num)
export(tmapValuesSubmit_shape)
export(tmapValuesSubmit_size)
export(tmapValuesSubmit_skip)
export(tmapValuesSubmit_text)
export(tmapValuesSubmit_xmod)
export(tmapValuesSubmit_ymod)
export(tmapValuesVV_angle)
export(tmapValuesVV_area)
export(tmapValuesVV_bgcol)
export(tmapValuesVV_bgcol_alpha)
export(tmapValuesVV_col)
export(tmapValuesVV_col_alpha)
export(tmapValuesVV_fill)
export(tmapValuesVV_fill_alpha)
export(tmapValuesVV_fontface)
export(tmapValuesVV_lty)
export(tmapValuesVV_lwd)
export(tmapValuesVV_num)
export(tmapValuesVV_shape)
export(tmapValuesVV_size)
export(tmapValuesVV_skip)
export(tmapValuesVV_text)
export(tmapValuesVV_xmod)
export(tmap_animation)
export(tmap_arrange)
export(tmap_design_mode)
Expand All @@ -279,6 +456,8 @@ export(tmap_style)
export(tmap_style_catalog)
export(tmap_style_catalogue)
export(tmap_tip)
export(toTitleCase)
export(transform_values)
export(ttm)
export(ttmp)
import(classInt)
Expand Down
11 changes: 11 additions & 0 deletions R/onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@

}

#' @export
#' @keywords internal
#' @rdname tmap_internal
.TMAP = new.env(FALSE, parent = globalenv())

#' @export
#' @keywords internal
#' @rdname tmap_internal
.TMAP_LEAFLET = new.env(FALSE, parent = globalenv())

#' @export
#' @keywords internal
#' @rdname tmap_internal
.TMAP_GRID = new.env(FALSE, parent = globalenv())
3 changes: 3 additions & 0 deletions R/tm_add_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ tm_add_legend = function(...,
tm_element_list(do.call(tm_element, c(args, list(subclass = c("tm_add_legend", "tm_component")))))
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
toTitleCase = function(x) {
paste0(toupper(substr(x,1,1)), tolower(substr(x,2, nchar(x))))
}
Expand Down
38 changes: 36 additions & 2 deletions R/tmapChart.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartBinned = function(chart, bin_colors, breaks_def, na.show, x1) {
if (is.numeric(x1)) {
tmapChartBinned_numeric(chart, bin_colors, breaks_def, na.show, x1)
Expand All @@ -6,6 +9,9 @@ tmapChartBinned = function(chart, bin_colors, breaks_def, na.show, x1) {
}
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartBinned2d = function(chart, chart1, chart2) {
if (is.numeric(chart1$x1) && is.numeric(chart2$x1)) {
tmapChartBinned2d_numnum(chart, chart1, chart2)
Expand All @@ -20,6 +26,9 @@ tmapChartBinned2d = function(chart, chart1, chart2) {
}
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartBinned2d_numcat = function(chart, chart1, chart2) {
res = bin_num(chart1$x1, chart1$breaks_def, chart1)
chart$tab = as.data.frame(table(bin1 = res$xcat, bin2 = chart2$x1, useNA = "no"), responseName = "freq")
Expand All @@ -29,6 +38,9 @@ tmapChartBinned2d_numcat = function(chart, chart1, chart2) {
chart
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartBinned2d_numnum = function(chart, chart1, chart2) {
res1 = bin_num(chart1$x1, chart1$breaks_def, chart1)
res2 = bin_num(chart2$x1, chart2$breaks_def, chart2)
Expand All @@ -40,6 +52,9 @@ tmapChartBinned2d_numnum = function(chart, chart1, chart2) {
}


#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartBinned2d_catcat = function(chart, chart1, chart2) {
chart$tab = as.data.frame(table(bin1 = chart1$x1, bin2 = chart2$x1, useNA = "no"), responseName = "freq")
chart$pal = NA
Expand All @@ -49,6 +64,9 @@ tmapChartBinned2d_catcat = function(chart, chart1, chart2) {
}


#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartRaw = function(chart, na.show, x1, ...) {
if (!na.show) x1 = na.omit(x1)

Expand All @@ -58,6 +76,9 @@ tmapChartRaw = function(chart, na.show, x1, ...) {
chart
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartRaw_nna = function(chart, na.show, x1, ...) {
x1 = na.omit(x1)

Expand All @@ -67,16 +88,25 @@ tmapChartRaw_nna = function(chart, na.show, x1, ...) {
chart
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartNone = function(chart, na.show, x1, ...) {
chart
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartPass = function(chart, na.show, x1, ...) {
args = c(list(na.show = na.show, x1 = x1), list(...))
chart[names(args)] = args
chart
}

#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartBinned_categorical = function(chart, bin_colors, breaks_def, na.show, x1) {
if (chart$type == "histogram") {
message("histograms are supposed to be used for numerical data, a bar chart will be shown instead (tm_chart_bar)")
Expand All @@ -98,10 +128,11 @@ tmapChartBinned_categorical = function(chart, bin_colors, breaks_def, na.show, x
chart
}


bin_num = function(x1, breaks_def, chart) {
# are breaks (and bin_colors)
predefined = !is.null(breaks_def)

if (is.null(chart$breaks_def)) {
if (!predefined) {
breaks = pretty(x1)
Expand Down Expand Up @@ -129,6 +160,9 @@ bin_num = function(x1, breaks_def, chart) {
}


#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapChartBinned_numeric = function(chart, bin_colors, breaks_def, na.show, x1) {

# are breaks (and bin_colors)
Expand All @@ -137,7 +171,7 @@ tmapChartBinned_numeric = function(chart, bin_colors, breaks_def, na.show, x1) {
res = bin_num(x1, breaks_def, chart)
xcat = res$xcat
ids = res$ids

if (!predefined) {
bin_colors = chart$object.color
}
Expand Down
3 changes: 3 additions & 0 deletions R/tmapGridComp_charts.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ tmapGridLegPlot.tm_chart_bar = function(comp, o, fH, fW) {
## borrowed from https://github.com/CMAP-REPOS/cmapplot
# .lwd <- ggplot2::.pt / ggplot2::.stroke

#' @export
#' @keywords internal
#' @rdname tmap_internal
lwd_to_mm = function(value, unit = "bigpts") {
grid::convertUnit(grid::unit(value, unit), "mm", valueOnly = TRUE)
}
Expand Down
3 changes: 3 additions & 0 deletions R/tmapGridLines.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapGridLines = function(shpTM, dt, gp, bbx, facet_row, facet_col, facet_page, id, pane, group, o, ...) {

rc_text = frc(facet_row, facet_col)
Expand Down
3 changes: 3 additions & 0 deletions R/tmapGridPolygons.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapGridPolygons = function(shpTM, dt, gp, bbx, facet_row, facet_col, facet_page, id, pane, group, o, ...) {

rc_text = frc(facet_row, facet_col)
Expand Down
3 changes: 3 additions & 0 deletions R/tmapGridRaster.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#' @export
#' @keywords internal
#' @rdname tmap_internal
tmapGridRaster <- function(shpTM, dt, gp, bbx, facet_row, facet_col, facet_page, id, pane, group, o, ...) {
args = list(...)
gts = get("gts", .TMAP_GRID)
Expand Down
Loading

0 comments on commit 1f70f58

Please sign in to comment.