pie.md 790 Bytes
Newer Older
nikogu's avatar
nikogu committed
1 2 3 4 5
---
order: 5
title: 饼状图
---

niko's avatar
niko committed
6
```jsx
nikogu's avatar
nikogu committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
import { Pie, yuan } from 'ant-design-pro/lib/Charts';

const salesPieData = [
  {
    x: '家用电器',
    y: 4544,
  },
  {
    x: '食用酒水',
    y: 3321,
  },
  {
    x: '个护健康',
    y: 3113,
  },
  {
    x: '服饰箱包',
    y: 2341,
  },
  {
    x: '母婴产品',
    y: 1231,
  },
  {
    x: '其他',
    y: 1231,
  },
nikogu's avatar
nikogu committed
34
];
nikogu's avatar
nikogu committed
35 36 37 38 39 40

ReactDOM.render(
  <Pie
    hasLegend
    title="销售额"
    subTitle="销售额"
niko's avatar
niko committed
41 42 43 44 45 46 47
    total={() => (
      <span
        dangerouslySetInnerHTML={{
          __html: yuan(salesPieData.reduce((pre, now) => now.y + pre, 0))
        }}
      />
    )}
nikogu's avatar
nikogu committed
48
    data={salesPieData}
niko's avatar
niko committed
49
    valueFormat={val => <span dangerouslySetInnerHTML={{ __html: yuan(val) }} />}
nikogu's avatar
nikogu committed
50
    height={294}
niko's avatar
niko committed
51 52 53 54
  />,
  mountNode,
);
```