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.
Code
<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.
Code
<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.
Code
<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.
Code
<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".
Code
<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.