import React, { useEffect, useState } from 'react'
import Chart from '@/subpackages/components/Chart'

export default (props) => {
  const { dimensions, source } = props

  const [options, setOptions] = useState()

  useEffect(() => {
    if (dimensions && source) {
      setOptions({
        xAxis: {
          type: 'category',
          axisLabel: {
            rotate: 45, // 旋转 45 度
          }
        },
        yAxis: {
          type: 'value',
        },
        series: [{
          type: 'line',
          smooth: true,
        }],
        color: ['#5470c6'],
        dataset: {
          dimensions,
          source,
        }
      });
    }
  }, [dimensions, source])

  return (
    <Chart options={options} />
  )
}
