World maps

A world map shows where something happens: countries colored by a value, bubbles at places within them, and a click on a country zooms into it. By default the map uses the Equal Earth projection, so countries keep their true relative size; the Mercator projection of web maps is one parameter away.

Countries and cities

MapSeries colors each country by YValue; XValue is the country as an ISO 3166 code ("SE" or "SWE") or its English name. The color gets stronger with the value's rank among the countries, so a few large values do not wash out the rest; set Max for a linear scale instead. MapBubbleSeries puts a bubble at each item's Latitude and Longitude, its area proportional to YValue. On the world map the places in a country add up to one bubble, so cities close together do not pile up; zoomed into a country, each place has its own (GroupByCountry="false" keeps them apart everywhere).

A click zooms in one level: from the world to the country's continent, from the continent to the country. The path bar above (World › Europe › Sweden) leads back up. Bind TreemapPath to know, or set, the area shown, a continent such as "Europe" or a country code: here it is none, the whole world.

Active sessions. Map with 22 items: Sweden 1,240, Germany 420, Norway 310, Denmark 280, Finland 260, United States of America 210, United Kingdom 190, France 140 and 14 more. Cities with 11 items: Sweden 988, Germany 240, Norway 210, Denmark 190, Finland 170, United States of America 170, United Kingdom 160, France 110 and 3 more. Active sessions81,240SessionsCitiesUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<RioChart TItem="Place" Title="Active sessions" @bind-TreemapPath="region">
    <MapSeries Items="countries" Name="Sessions" XValue="c => c.Name" YValue="c => c.Sessions" />
    <MapBubbleSeries Items="cities" Name="Cities" XValue="c => c.Name" YValue="c => c.Sessions"
                     LatitudeValue="c => c.Latitude" LongitudeValue="c => c.Longitude" />
</RioChart>

@code {
    string? region;
    record Place(string Name, double Sessions, double? Latitude = null, double? Longitude = null);
}

Europe only

Start TreemapPath at a continent to show only that part of the world: here "Europe", which ends at the Urals. Countries outside it fade at the edges, so the map does not look cut off. A click on a country still zooms in, and the path bar leads out to the world and back. The other continents are "Africa", "Asia", "North America", "South America" and "Oceania"; a country code zooms straight into one country.

Active sessions in Europe. Map, Europe with 22 items: Sweden 1,240, Germany 420, Norway 310, Denmark 280, Finland 260, United States of America 210, United Kingdom 190, France 140 and 14 more. Cities with 11 items: Sweden 988, Germany 240, Norway 210, Denmark 190, Finland 170, United States of America 170, United Kingdom 160, France 110 and 3 more. Active sessions in EuropeWorld›Europe81,240SessionsCitiesUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<RioChart TItem="Place" Title="Active sessions in Europe" @bind-TreemapPath="region">
    <MapSeries Items="countries" Name="Sessions" XValue="c => c.Name" YValue="c => c.Sessions" />
    <MapBubbleSeries Items="cities" Name="Cities" XValue="c => c.Name" YValue="c => c.Sessions"
                     LatitudeValue="c => c.Latitude" LongitudeValue="c => c.Longitude" />
</RioChart>

@code {
    string? region = "Europe";   // or "Asia", "North America", a country code such as "SE"
}

Bubbles only

Without a MapSeries, the countries are a gray backdrop for the bubbles. MarkerSize sets the diameter of the largest bubble.

Map with 11 items: Sweden 988, Germany 240, Norway 210, Denmark 190, Finland 170, United States of America 170, United Kingdom 160, France 110 and 3 more. Use Left and Right to move between points. Press Escape to leave.
Code
Razor
<RioChart TItem="Place">
    <MapBubbleSeries Items="cities" Name="Sessions" XValue="c => c.Name" YValue="c => c.Sessions"
                     LatitudeValue="c => c.Latitude" LongitudeValue="c => c.Longitude" MarkerSize="36" />
</RioChart>

Growth and decline

Midpoint splits the colors at a value: countries above it take the series color, countries below it BelowColor (default --rio-negative). Each side is ranked on its own from the midpoint out, so the largest growth and the deepest decline both get the full color. The color scale shows the lowest value, the midpoint and the highest.

Sessions against last year. Map with 19 items: India +62%, Poland +46%, China +38%, France +31%, Germany +24%, South Africa +19%, United States of America +15%, Sweden +12% and 11 more. Sessions against last year-25%0%+62%Use Left and Right to move between points. Press Escape to leave.
Code
Razor
<RioChart TItem="Place" Title="Sessions against last year">
    <MapSeries Items="growth" Name="Change" XValue="c => c.Name" YValue="c => c.Sessions"
               Format="+0'%';-0'%';0'%'" Midpoint="0" />
</RioChart>

Projection

Projection on the chart sets how the round world is drawn flat. MapProjection.EqualEarth, the default, is equal-area: a country's size on the map compares fairly with any other. MapProjection.Mercator is the projection of web maps, the shapes most people know, but areas grow toward the poles (Greenland looks as large as Africa, which is fourteen times larger), so use it when the map should look familiar rather than when sizes matter. It is cut at 85° north and south, like web maps. In a JSON definition: "projection": "mercator".

Map with 22 items: Sweden 1,240, Germany 420, Norway 310, Denmark 280, Finland 260, United States of America 210, United Kingdom 190, France 140 and 14 more. Cities with 11 items: Sweden 988, Germany 240, Norway 210, Denmark 190, Finland 170, United States of America 170, United Kingdom 160, France 110 and 3 more. 81,240SessionsCitiesUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.

Code
Razor
<RioChart TItem="Place" Projection="MapProjection.Mercator">
    <MapSeries Items="countries" Name="Sessions" XValue="c => c.Name" YValue="c => c.Sessions" />
    <MapBubbleSeries Items="cities" Name="Cities" XValue="c => c.Name" YValue="c => c.Sessions"
                     LatitudeValue="c => c.Latitude" LongitudeValue="c => c.Longitude" />
</RioChart>

Data

The country outlines are Natural Earth's 1:110 million Admin 0 countries (public domain), built into RioCharts.Core. Very small countries, such as Singapore and Malta, are not in it at this scale. WorldMap.Find looks a country up by code or name.

An unhandled error has occurred. Reload 🗙