import React from 'react';
import { LineChart } from '../index';

// 数据格式: [[时间戳, value]]
const getData = () => {
  let base = +new Date(2000, 9, 3);
  let oneDay = 24 * 3600 * 1000;
  let data = [[base, Math.random() * 300]];
  for (let i = 1; i < 20; i++) {
    let now = new Date((base += oneDay));
    data.push([+now, Math.round(Math.random() * 20 + data[i - 1][1])]);
  }
  return data;
};

export default () => {
  const dataSource = [
    {
      name: '用水量',
      unit: 'm³',
      data: getData(),
    },
  ];
  return (
    <div style={{ height: 300 }}>
      <LineChart lineType="area" dataSource={dataSource} />
    </div>
  );
};
