logo

Ant Design Charts

  • Manual
  • Components
  • Examples
  • Options
  • Productsantv logo arrow
  • 2.6.5
  • Common Configuration Statistical Charts
    • Title
    • Axis
    • Legend
    • Scrollbar
    • Slider
    • Tooltip
    • Label
    • Color
    • event
    • Interaction
      • Overview
      • brushAxisHighlight
      • brushHighlight
      • brushXHighlight
      • brushYHighlight
      • brushFilter
      • brushXFilter
      • brushYFilter
      • chartIndex
      • elementHighlight
      • elementHighlightByColor
      • elementHighlightByX
      • elementSelect
      • elementSelectByColor
      • elementSelectByX
      • fisheye
      • legendFilter
      • legendHighlight
      • poptip
      • scrollbarFilter
      • sliderFilter
    • State
    • Style
    • Scale
      • overview
      • band
      • linear
      • log
      • ordinal
      • point
      • pow
      • quantile
      • quantize
      • sqrt
      • threshold
      • time
    • Animate
      • overview
      • fadeIn
      • fadeOut
      • growInX
      • growInY
      • morphing
      • pathIn
      • scaleInX
      • scaleInY
      • scaleOutX
      • scaleOutY
      • waveIn
      • zoomIn
      • zoomOut
    • Theme
      • overview
      • Academy
      • classic
      • classicDark
    • Data
      • overview
      • custom
      • ema
      • fetch
      • filter
      • fold
      • inline
      • join
      • kde
      • log
      • map
      • pick
      • rename
      • slice
      • sort
      • sortBy

Label

Previous
Tooltip
Next
Color

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2026 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Overview

In Ant Design Charts, Data Labels are one of the means to add annotations to charts, providing content annotation for the current group of data. They include elements such as data points, connector lines, and text values, which are selected based on different chart types. Through concise text descriptions, they reduce misunderstandings, make charts easier to interpret, and emphasize key data or trends, guiding attention to important information.

Elements

Includes connector lines and text value elements, which are selected based on different chart types.

Among them, pie charts, donut charts, rose charts, etc., can use connector line elements to connect label text elements and mark graphics.

Usage/Configuration

Adding to Mark

Multiple labels can be added to a mark:

({
labels: [
{
text: 'genre', // Specify the bound field
style: { dy: -15 }, // Specify style
},
{
text: 'sold', // Specify the bound field
style: { fill: '#fff', dy: 5 }, // Specify style
},
],
});

Mark Labels

Each mark can have multiple labels. Here's a simple example:

import { Column } from '@ant-design/plots';
import React from 'react';
import { createRoot } from 'react-dom/client';
const Demo = () => {
const config = {
height: 300,
data: [
{ genre: 'Sports', sold: 275 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
],
xField: 'genre',
yField: 'sold',
labels: [
{ text: 'genre', style: { dy: -15 } },
{ text: 'sold', style: { fill: '#fff', dy: 5 } },
],
};
return <Column {...config} />;
};
createRoot(document.getElementById('container')).render(<Demo />);

Configuration Options

PropertyDescriptionTypeDefault ValueRequired
dxLabel text horizontal offset, can also be configured through style.dxnumber0
dyLabel text vertical offset, can also be configured through style.dynumber0
offsetLabel offset distance, can also be configured through style.offsetnumber-
textLabel data channel, similar to mark's x channel, corresponds to text element, can use callback to customize string textstring | Function-
innerHTMLSimilar to text configuration, when both are configured, text becomes ineffective, can use callback to customize string text or HTMLElement complex htmlstring | Function-
formatterLabel text formattingstring | Function<string>-
renderSame configuration type as innerHTMLstring | Function-
selectorLabel selector, can retain or hide labelsselector{type: 'cartesian' }
transformLabel transformation, used to optimize label display, solving label overlap and color visibility issuestransform-
positionLabel position relative to graphics, not label directionposition-
styleLabel style configurationstyle-
backgroundWhether to show background colorbooleanSee background
connectorWhether to show connector lines, used in non-Cartesian coordinate systems like pie and donut chartsbooleanSee connector

text & innerHTML

label text element content configuration

import { Column } from '@ant-design/plots';
import React from 'react';
import { createRoot } from 'react-dom/client';
const Demo = () => {
const config = {
height: 340,
insetTop: 20,
data: [
{ genre: 'Sports', sold: 275 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
],
xField: 'genre',
yField: 'sold',
labels: [
{ text: 'sold', style: { dy: -30 } }, // text maps to field sold
{ text: ({ genre }) => genre, style: { dy: -20 } }, // text custom return string type
{
// innerHTML maps to field genre
// Note: background color might be black sometimes, need to configure fill background color
// color is text color, HTMLElement itself can also configure styles
innerHTML: 'genre',
dx: 20,
dy: 10,
style: { fill: '#fff', color: '#333', fontSize: 10 },
},
{
// innerHTML custom return HTMLElement type data
innerHTML: ({ genre, sold }) =>
`<div style="padding:0 4px;border-radius: 10px;background: #f5f5f5;border: 2px solid #5ea9e6;font-size: 11px;">${genre}:${sold}</div>`,
dx: 10,
dy: 50,
style: { fill: 'rgba(0,0,0,0)', color: '#333' },
},
],
};
return <Column {...config} />;
};
createRoot(document.getElementById('container')).render(<Demo />);

You can also try configuring HTMLElement with render, the parameters differ from innerHTML, but the return is consistent.

type RenderFunc = (text: string, datum: object, index: number, {channel: Record<string, Channel>}) => String | HTMLElement;

More options about label, see the document of label.