Skip to main content

Bubble map

info

Charts are available with Avalonia Pro.

Bubble maps use circles of different sizes to represent data values over geographic regions, using ShapeMap as a basis to display a ShapeLayer with a superimposed BubbleLayer. They show locality and value magnitude in the same view.

Bubble map overlaying circles of varying sizes on geographic regions to represent city activity levels.

When to use

  • Event distribution: Mapping the location and scale of occurrences (e.g., earthquakes, sales events).
  • Urban statistics: Comparing populations or activity levels across specific cities.
  • Global indicators: Visualizing country-level data where the size of the bubble represents the value.

Code example

XAML

<charts:ShapeMap Name="BubbleSample" Title="Major Cities by Population" Height="400" ShowLegend="True" LegendPosition="Bottom">
<charts:ShapeMap.Layers>
<charts:ShapeLayer GeoJson="{Binding WorldGeoJson}"
GeoJsonIdPath="ISO_A2"
LowBrush="#E3F2FD"
HighBrush="#E3F2FD"
StrokeThickness="0.3" />
<charts:BubbleLayer LatitudePath="Lat"
LongitudePath="Lon"
SizePath="Population"
LabelPath="City"
MinBubbleSize="6"
MaxBubbleSize="45"
Fill="#B4F44336"
ShowLabels="True"
ItemsSource="{Binding CityBubbles}">
<charts:BubbleLayer.TooltipTemplate>
<DataTemplate>
<StackPanel Spacing="4">
<TextBlock Text="{Binding City}" FontWeight="Bold"/>
<TextBlock Text="{Binding Population, StringFormat='Pop: {0:N1}M'}"/>
</StackPanel>
</DataTemplate>
</charts:BubbleLayer.TooltipTemplate>
</charts:BubbleLayer>
</charts:ShapeMap.Layers>
</charts:ShapeMap>

Data model (C#)

Ensure the GeoJSON file is included in your project and available at the specified relative path at runtime.

using System.IO;

public record CityData(string City, double Lat, double Lon, double Population);

public string WorldGeoJson { get; } =
File.ReadAllText("Resources/ne_110m_world.geojson");

public CityData[] CityBubbles { get; } = new CityData[]
{
new("Tokyo", 35.7, 139.7, 37.4),
new("Delhi", 28.6, 77.2, 32.9),
new("Shanghai", 31.2, 121.5, 29.2),
new("São Paulo", -23.5, -46.6, 22.4),
new("Mexico City", 19.4, -99.1, 21.9),
new("Cairo", 30.0, 31.2, 21.3),
new("Mumbai", 19.1, 72.9, 21.0),
new("Beijing", 39.9, 116.4, 20.9),
new("New York", 40.7, -74.0, 18.8),
new("London", 51.5, -0.1, 9.5),
new("Paris", 48.9, 2.3, 11.1),
new("Sydney", -33.9, 151.2, 5.4)
};

Common properties: ShapeLayer

PropertyDescriptionDefault
GeoJsonGeoJSON data.null
SourceURI for the source of the GeoJSON data.null
GeoJsonIdPathUnique ID of the GeoJSON data.null
ItemsSourceData collection containing map regions.null
RegionPathProperty linking data to GeoJSON coordinates.null
ValuePathProperty linking data to region values.null
MinValueMinimum value for color normalization.0.0
MaxValueMaximum value for color normalization.100.0
LowBrushColor representing the lowest data value.#E3F2FD
HighBrushColor representing the highest data value.#1565C0
StrokeColor of region outlines.null
StrokeThicknessThickness of region outlines.0.5
ShowLabelsWhether to display labels on regions.false
LabelPathPath of the label text.null
LabelForegroundBrush used for region labels.null
SelectionModeSelection mode for selecting regions. Use None, Single, SingleDeselect, or Multiple.None
SelectionBrushColor of selected regions.#FFC107
SelectionStrokeColor of the outline of selected regions.null
SelectionStrokeThicknessThickness of the outline of selected regions.2.0
SelectedItemThe currently selected region.null
HoverBrushBrush used when a region is hovered.White at 30% opacity

Common properties: BubbleLayer

PropertyDescriptionDefault
ItemsSourceData source for bubbles.null
LatitudePathProperty path for latitude coordinates.null
LongitudePathProperty path for longitude coordinates.null
SizePathSize of bubbles.null
PointBrushPathOptional property path that supplies a brush or color per bubble.null
ShowLabelsWhether to display labels over bubbles.true
LabelPathContent of labels.null
MinBubbleSizeMinimum bubble radius.8.0
MaxBubbleSizeMaximum bubble radius.40.0
FillColor of bubbles.null
StrokeColor of bubble outlines.null