mix.md 2.33 KB
Newer Older
nikogu's avatar
nikogu committed
1 2 3 4 5 6 7 8
---
order: 0
title: 图表套件组合展示
---

利用 Ant Design Pro 提供的图表套件,可以灵活组合符合设计规范的图表来满足复杂的业务需求。

````jsx
9
import { ChartCard, Field, MiniArea, MiniBar, MiniProgress } from 'ant-design-pro/lib/Charts';
偏右's avatar
偏右 committed
10
import Trend from 'ant-design-pro/lib/Trend';
偏右's avatar
偏右 committed
11
import NumberInfo from 'ant-design-pro/lib/NumberInfo';
nikogu's avatar
nikogu committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25
import { Row, Col, Icon, Tooltip } from 'antd';
import numeral from 'numeral';
import moment from 'moment';

const visitData = [];
const beginDay = new Date().getTime();
for (let i = 0; i < 20; i += 1) {
  visitData.push({
    x: moment(new Date(beginDay + (1000 * 60 * 60 * 24 * i))).format('YYYY-MM-DD'),
    y: Math.floor(Math.random() * 100) + 10,
  });
}

ReactDOM.render(
nikogu's avatar
nikogu committed
26 27
  <Row>
    <Col span={24}>
nikogu's avatar
nikogu committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
      <ChartCard
        title="搜索用户数量"
        contentHeight={134}
      >
        <NumberInfo
          subTitle={<span>本周访问</span>}
          total={numeral(12321).format('0,0')}
          status="up"
          subTotal={17.1}
        />
        <MiniArea
          line
          height={45}
          data={visitData}
        />
      </ChartCard>
偏右's avatar
偏右 committed
44
    </Col>
nikogu's avatar
nikogu committed
45
    <Col span={24} style={{ marginTop: 24 }}>
nikogu's avatar
nikogu committed
46 47
      <ChartCard
        title="访问量"
nikogu's avatar
nikogu committed
48
        action={<Tooltip title="指标说明"><Icon type="info-circle-o" /></Tooltip>}
nikogu's avatar
nikogu committed
49 50 51 52 53 54 55 56 57
        total={numeral(8846).format('0,0')}
        footer={<Field label="日访问量" value={numeral(1234).format('0,0')} />}
        contentHeight={46}
      >
        <MiniBar
          height={46}
          data={visitData}
        />
      </ChartCard>
偏右's avatar
偏右 committed
58
    </Col>
nikogu's avatar
nikogu committed
59
    <Col span={24} style={{ marginTop: 24 }}>
nikogu's avatar
nikogu committed
60 61
      <ChartCard
        title="线上购物转化率"
nikogu's avatar
nikogu committed
62
        action={<Tooltip title="指标说明"><Icon type="info-circle-o" /></Tooltip>}
nikogu's avatar
nikogu committed
63
        total="78%"
偏右's avatar
偏右 committed
64 65 66 67 68 69 70 71 72 73 74 75
        footer={
          <div>
            <span>
              周同比
              <Trend flag="up" style={{ marginLeft: 8, color: 'rgba(0,0,0,.85)' }}>12%</Trend>
            </span>
            <span style={{ marginLeft: 16 }}>
              日环比
              <Trend flag="down" style={{ marginLeft: 8, color: 'rgba(0,0,0,.85)' }}>11%</Trend>
            </span>
          </div>
        }
nikogu's avatar
nikogu committed
76 77
        contentHeight={46}
      >
nikogu's avatar
nikogu committed
78
        <MiniProgress percent={78} strokeWidth={8} target={80} />
nikogu's avatar
nikogu committed
79
      </ChartCard>
偏右's avatar
偏右 committed
80
    </Col>
nikogu's avatar
nikogu committed
81 82 83
  </Row>
, mountNode);
````