import { useMemo } from 'react'
import ReactEcharts from 'echarts-for-react';
const LineCharts = ({ data }: { data: any[] }) => {

  const option = useMemo(() => {
    const chartData: any = [60, 50, 60, 70, 50, 70, 50, 60, 70, 50, 80, 50, 60, 70, 50, 60, 50, 60, 70, 50]
    const showXAis = true
    return {
      xAxis: {
        type: 'category',
        boundaryGap: false,
        show: showXAis,
        data: showXAis ? data?.map(item => item.name) : [],
        axisLabel: {
          color: '#CBEDFF',
          interval: 3 // 设置为0以显示所有坐标点  
        },
        axisLine: {
          show: false,
        },
      },
      yAxis: {
        type: 'value',
        show: false,
      },
      grid: {
        left: '0',  // 左边距
        right: '0', // 右边距
        top: '0',   // 上边距
        bottom: '0' // 下边距
      },
      series: [
        {
          data: chartData,
          symbol: "none",
          type: 'line',
          lineStyle: {
            color: "#57EFE5",
          },

          areaStyle: {
            // 区域填充样式。设置后显示成区域面积图。
            color: {
              type: 'linear',
              x: 0,
              y: 1,
              x2: 0,
              y2: 0.2,
              colorStops: [
                {
                  offset: 0,
                  color: 'rgba(87, 239, 229, 0)', // 0% 处的颜色
                },

                {
                  offset: 1,
                  color: 'rgba(87, 239, 229, 0.4)', // 100% 处的颜色
                },
              ],
              global: false, // 缺省为 false
            },
          },
        },
      ],
    }
  }, [data])

  return (
    <ReactEcharts
      option={option} // option：图表配置项
      style={{ width: '400px', height: '200px' }}
    />
  )
}

export default LineCharts