chart-card.md 2.43 KB
Newer Older
nikogu's avatar
nikogu committed
1 2 3 4 5 6 7
---
order: 1
title: 图表卡片
---

用于展示图表的卡片容器,可以方便的配合其它图表套件展示丰富信息。

niko's avatar
niko committed
8
```jsx
偏右's avatar
偏右 committed
9 10
import { ChartCard, yuan, Field } from 'ant-design-pro/lib/Charts';
import Trend from 'ant-design-pro/lib/Trend';
11
import { Row, Col, Icon, Tooltip } from 'antd';
nikogu's avatar
nikogu committed
12 13 14
import numeral from 'numeral';

ReactDOM.render(
15 16 17 18
  <Row>
    <Col span={24}>
      <ChartCard
        title="销售额"
niko's avatar
niko committed
19 20 21 22 23 24 25 26 27 28 29
        action={
          <Tooltip title="指标说明">
            <Icon type="info-circle-o" />
          </Tooltip>
        }
        total={() => (
          <span dangerouslySetInnerHTML={{ __html: yuan(126560) }} />
        )}
        footer={
          <Field label="日均销售额" value={numeral(12423).format("0,0")} />
        }
30 31 32 33
        contentHeight={46}
      >
        <span>
          周同比
niko's avatar
niko committed
34 35 36
          <Trend flag="up" style={{ marginLeft: 8, color: "rgba(0,0,0,.85)" }}>
            12%
          </Trend>
37 38 39
        </span>
        <span style={{ marginLeft: 16 }}>
          日环比
niko's avatar
niko committed
40 41 42 43 44 45
          <Trend
            flag="down"
            style={{ marginLeft: 8, color: "rgba(0,0,0,.85)" }}
          >
            11%
          </Trend>
46 47 48 49 50 51
        </span>
      </ChartCard>
    </Col>
    <Col span={24} style={{ marginTop: 24 }}>
      <ChartCard
        title="移动指标"
nikogu's avatar
nikogu committed
52 53 54 55 56 57 58
        avatar={
          <img
            style={{ width: 56, height: 56 }}
            src="https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png"
            alt="indicator"
          />
        }
niko's avatar
niko committed
59 60 61 62 63 64 65 66 67 68 69
        action={
          <Tooltip title="指标说明">
            <Icon type="info-circle-o" />
          </Tooltip>
        }
        total={() => (
          <span dangerouslySetInnerHTML={{ __html: yuan(126560) }} />
        )}
        footer={
          <Field label="日均销售额" value={numeral(12423).format("0,0")} />
        }
70 71 72 73 74
      />
    </Col>
    <Col span={24} style={{ marginTop: 24 }}>
      <ChartCard
        title="移动指标"
niko's avatar
niko committed
75
        avatar={
nikogu's avatar
nikogu committed
76 77 78 79 80
          <img
            alt="indicator"
            style={{ width: 56, height: 56 }}
            src="https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png"
          />
niko's avatar
niko committed
81 82 83 84 85 86 87 88
        }
        action={
          <Tooltip title="指标说明">
            <Icon type="info-circle-o" />
          </Tooltip>
        }
        total={() => (
          <span dangerouslySetInnerHTML={{ __html: yuan(126560) }} />
nikogu's avatar
nikogu committed
89
        )}
90 91
      />
    </Col>
niko's avatar
niko committed
92 93 94 95
  </Row>,
  mountNode,
);
```