library(rtemis.draw).:rtemis.draw 0.3.0 π aarch64-apple-darwin23
Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':
Axis
.:rtemis.draw 0.3.0 π aarch64-apple-darwin23
Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':
Axis
The high-level draw_choropleth() builds its data model from a data frame. When you need full control β assembling rows by hand, or setting every styling option explicitly β you drop to the S7 classes, exactly as you would with EChartsOption for charts or SigmaOption for networks. The pattern is the same across all three backends:
MapRow objects into a MapModelMapLibreOptiondraw()These classes are the renderer-agnostic R counterparts of the choropleth model used in rtemis.live.
A MapModel is a list of MapRow objects plus the administrative resolution that selects the geometry, the value label, and the names of any tooltip fields. Each MapRow carries a raw location key, a numeric value, and an optional named list of extras for the tooltip.
model <- MapModel(
rows = list(
MapRow(location = "USA", value = 78.5, extras = list(continent = "N. America")),
MapRow(location = "BRA", value = 75.9, extras = list(continent = "S. America")),
MapRow(location = "FRA", value = 82.5, extras = list(continent = "Europe")),
MapRow(location = "JPN", value = 84.6, extras = list(continent = "Asia")),
MapRow(location = "ZAF", value = 64.9, extras = list(continent = "Africa")),
MapRow(location = "AUS", value = 83.4, extras = list(continent = "Oceania"))
),
resolution = "country",
value_label = "Life expectancy",
tooltip_fields = "continent"
)The classes mirror their rtemis.live TypeScript interfaces:
MapRow β location (required raw key), value (required number), extras (named list of tooltip fields).MapModel β rows, resolution ("country"/"state"/"county"), value_label, tooltip_fields.MapLibreOption render specMapLibreOption is the complete, validated render spec for a choropleth β the MapModel plus every styling field. It is the MapLibre analog of EChartsOption and SigmaOption, and you pass it to the same draw() generic:
draw() dispatches on the option object, so draw(MapLibreOption(...)) selects the MapLibre backend just as draw(EChartsOption(...)) selects ECharts and draw(SigmaOption(...)) selects Sigma.js. Theme handling is identical across backends: theme = NULL (the default) auto-detects light/dark, a Theme object forces one, and theme = NA disables theming.
The styling fields available on MapLibreOption (and as arguments to draw_choropleth() / draw_map()):
classification β "quantile", "equal", or "jenks".color_scheme β sequential ("blues", "viridis", "ylorrd", "greens", "magma") or diverging ("rdbu", "rdylgn", "spectral", "brbg").num_classes β number of color classes (2β12).opacity, show_boundaries, outline_width β fill and outline appearance.show_legend, legend_position, tooltip_position, report_position β overlay visibility and corner anchors.