logo

Ant Design Charts

  • 教程
  • 图表组件
  • 图表示例
  • 选项
  • 所有产品antv logo arrow
  • 2.0.0
  • 统计图表
    • 标题(Title)
    • 坐标轴(Axis)
    • 图例(Legend)
    • 滚动条(Scrollbar)
    • 缩略轴(Slider)
    • 提示信息(Tooltip)
    • 数据标签(Label)
    • 颜色映射(Color)
    • 事件(Event)
    • 交互(Interaction)
      • 概览
      • brushAxisHighlight
      • brushHighlight
      • brushXHighlight
      • brushYHighlight
      • brushFilter
      • brushXFilter
      • brushYFilter
      • chartIndex
      • elementHighlight
      • elementHighlightByColor
      • elementHighlightByX
      • elementSelect
      • elementSelectByColor
      • elementSelectByX
      • fisheye
      • legendFilter
      • legendHighlight
      • poptip
      • scrollbarFilter
      • sliderFilter
    • 状态(State)
    • 样式(Style)
    • 比例尺(Scale)
      • 概览
      • band
      • linear
      • log
      • ordinal
      • point
      • quantile
      • quantize
      • sqrt
      • threshold
      • time
      • pow
    • 动画(Animate)
      • 概览
      • fadeIn
      • fadeOut
      • growInX
      • growInY
      • morphing
      • pathIn
      • scaleInX
      • scaleInY
      • scaleOutX
      • scaleOutY
      • waveIn
      • zoomIn
      • zoomOut
    • 主题(Theme)
      • 概览
      • academy
      • classic
      • classicDark
    • 数据(Data)
      • 概览
      • custom
      • ema
      • fetch
      • filter
      • fold
      • inline
      • join
      • kde
      • log
      • map
      • pick
      • rename
      • slice
      • sort
      • sortBy

inline

上一篇
fold
下一篇
join

Resources

Ant Design
Galacea Effects
Umi-React 应用开发框架
Dumi-组件/文档研发工具
ahooks-React Hooks 库

社区

体验科技专栏
seeconfSEE Conf-蚂蚁体验科技大会

帮助

GitHub
StackOverflow

more products更多产品

Ant DesignAnt Design-企业级 UI 设计语言
yuque语雀-知识创作与分享工具
EggEgg-企业级 Node 开发框架
kitchenKitchen-Sketch 工具集
GalaceanGalacean-互动图形解决方案
xtech蚂蚁体验科技
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

概述

Ant Design Charts 的数据源来源有两种,一种是 inline,即直接传入具体的数据,这种是 Ant Design Charts 默认的数据源类型;另外一种数据源类型是 fetch,即从远程接口获取数据。

使用方式

显式的指定 type 为 inline,完整的写法如下:

{
"data": {
"value": [ { genre: 'Sports', sold: 275 }, { genre: 'Strategy', sold: 115 }, { genre: 'Action', sold: 120 }, { genre: 'Shooter', sold: 350 }, { genre: 'Other', sold: 150 }, ]
}
}

因为 Ant Design Charts 默认的数据类型就是 inline,所以也可以简写为如下:

{
"data": [ { genre: 'Sports', sold: 275 }, { genre: 'Strategy', sold: 115 }, { genre: 'Action', sold: 120 }, { genre: 'Shooter', sold: 350 }, { genre: 'Other', sold: 150 }, ]
}

开始使用

举一个例子如下:

import { Column } from '@ant-design/plots';
import React from 'react';
import { createRoot } from 'react-dom';
const Demo = () => {
const config ={
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'
};
return <Column {...config} />;
};
createRoot(document.getElementById('container')).render(<Demo />);

配置项

属性描述类型默认值
value具体的 object 数组数据object[][]
transform针对数据 inline 数据进行变换DataTransform[]

这个数据源比较简单,相当于传入的数据,直接作为数据源进行 transform 处理加工,然后走渲染逻辑。

⚠️ Ant Design Charts 支持了一些关系图的数据结构,这些数据结构是一个 JavaScript 的 Object 类型,所以使用简写传入的时候,可能会导致 Ant Design Charts 识别出错,所以建议如果图表的数据是 Object 对象,使用完整的写法传入数据。

const graphData = {
nodes: [
/** */
],
edges: [
/** */
],
};
{
"data": {
"value": graphData
}
}