Skip to content

Bubble

Dots of different sizes appear above the geographic area of ​​the bubble chart, and the area of ​​the circle is proportional to its value in the data set.

案例

accomplish

Let’s introduce how to draw a common bubble chart.

import { Scene, PointLayer } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';

const scene = new Scene({
  id: 'map',
  map: new GaodeMap({
    style: 'light',
    center: [140.067171, 36.26186],
    zoom: 5.32,
    maxZoom: 10,
  }),
});
scene.on('loaded', () => {
  fetch('https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json')
    .then((res) => res.json())
    .then((data) => {
      const pointLayer = new PointLayer({})
        .source(data)
        .shape('circle')
        .size('mag', [1, 25])
        .color('mag', (mag) => {
          return mag > 4.5 ? '#5B8FF9' : '#5CCEA1';
        })
        .style({
          opacity: 0.3,
          strokeWidth: 1,
        });
      scene.addLayer(pointLayer);
    });
});

source

Bubble charts accept plain point data.

shape

bubble chartshapeGenerallycircle,can also besquare、triangleand other shapes.

size

bubble chartsizeGenerally used to represent a certain field in the data, so constants are not used but data mapping is used.

layer.size('area', [1, 100]); // Use interval mapping
layer.size('area', (area) => {
  // Use callback function to implement mapping
  return area * 10;
});

color

bubble chartcolorIt is generally used to represent a certain field in the data, so constants are not used but data mapping is used.

layer.color('area', ['#f00', '#ff0']); // Use interval mapping
layer.color('area', (area) => {
  // Use callback function to implement mapping
  if (area > 100) {
    return '#f00';
  } else {
    return '#ff0';
  }
});
© Copyright 2026 Ant Group Co., Ltd..备案号:京ICP备15032932号-38
Site search
Documentation and examplesType to start searching

Search documentation, APIs, and examples

↑↓Select↵OpenEscClose