World Map

World map web component: countries shaded by a value (choropleth), with keyboard reading, selection and a screen-reader table.

  • 17.1 KB gzipped
  • @lit-material/world-map 1.8.0
  • Renders on the server

Example

Install

npm install @lit-material/world-map @lit-material/tokens
import "@lit-material/world-map";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-world-map>

A world map shaded by a value per country (a choropleth), e.g. visitors by country.

Properties

PropertyAttributeTypeDefaultDescription
datadataCountryValues{}Values by country code (case-insensitive). Non-finite and negative values are left out.
labellabelstring""The map's accessible name, e.g. "Visitors by country". Unset, "World map", translated.
unitunitstring""A unit appended to values, e.g. "visitors".
selectableselectablebooleanfalseCountries can be selected with a click, Enter or Space; fires change.
selectedselectedstring""The selected country's code, or "".
formatproperty only(n: number) => string | undefinednoneFormats values. Default: the element's language, compact above 10,000.

Events

EventDescription
changeWith selectable, a country was selected or the selection cleared. detail: { code, value }.

CSS parts

PartDescription
mapThe SVG.
tooltipThe hover/focus readout.
legendThe colour scale under the map.
elsewhereThe list of countries too small to draw.

CSS custom properties

PropertyDescription
--lit-material-world-map-fillColour of the highest value (default: the first chart series colour).
--lit-material-world-map-emptyColour of countries with no value.
--lit-material-world-map-borderColour of the borders between countries.

Source on GitHub npm