import React, { PureComponent } from 'react'; import { connect } from 'dva'; import { Row, Col, Card } from 'antd'; import numeral from 'numeral'; import { NumberInfo, MiniArea, Pie, WaterWave, Gauge } from '../../components/Charts'; import MapChart from '../../components/MapChart'; import TagCloud from '../../components/TagCloud'; import Countdown from '../../components/Countdown'; import { fixedZero } from '../../utils/utils'; import styles from './Monitor.less'; function getActiveData() { const activeData = []; for (let i = 0; i < 24; i += 1) { activeData.push({ x: `${fixedZero(i)}:00`, y: (i * 50) + (Math.floor(Math.random() * 200)), }); } return activeData; } const MapData = []; for (let i = 0; i < 50; i += 1) { MapData.push({ x: Math.floor(Math.random() * 600), y: Math.floor(Math.random() * 400), value: Math.floor(Math.random() * 1000) + 500, }); } const targetTime = new Date().getTime() + 3900000; @connect(state => ({ monitor: state.monitor, })) export default class Monitor extends PureComponent { state = { activeData: getActiveData(), } componentDidMount() { this.props.dispatch({ type: 'monitor/fetchTags', }); setInterval(() => { this.setState({ activeData: getActiveData(), }); }, 1000); } render() { const { activeData = [] } = this.state; const { monitor } = this.props; const { tags } = monitor; return (
{[...activeData].sort()[activeData.length - 1].y + 200} 亿元
{[...activeData].sort()[Math.floor(activeData.length / 2)].y} 亿元