import React, { PureComponent } from 'react'; import { NumberInfo, MiniArea } from '../Charts'; import { fixedZero } from '../../utils/utils'; import styles from './index.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; } export default class ActiveChart extends PureComponent { state = { activeData: getActiveData(), } componentDidMount() { this.timer = setInterval(() => { this.setState({ activeData: getActiveData(), }); }, 1000); } componentWillUnmount() { clearInterval(this.timer); } render() { const { activeData = [] } = this.state; return (
{[...activeData].sort()[activeData.length - 1].y + 200} 亿元
{[...activeData].sort()[Math.floor(activeData.length / 2)].y} 亿元