import ReactEcharts from 'echarts-for-react';
import { useMemo } from 'react';
const LineCharts = ({ data }: { data: any[] }) => {
  const option = useMemo(() => {
    const chartData: any = [
      '100',
      '90',
      '80',
      '100',
      '90',
      '80',
      '100',
      '90',
      '80',
      '100',
      '90',
      '80',
      '100',
      '90',
      '80',
      '100',
      '90',
      '80',
    ];
    const showXAis = true;
    return {
      xAxis: {
        type: 'category',
        boundaryGap: false,
        show: showXAis,
        data: showXAis ? data?.map((item) => item.name) : [],
        axisLabel: {
          show: false,
          color: '#CBEDFF',
          interval: 3, // 设置为0以显示所有坐标点
        },
        axisLine: {
          show: false,
        },
      },
      yAxis: {
        type: 'value',
        show: false,
      },
      grid: {
        left: '0', // 左边距
        right: '0', // 右边距
        top: '10%', // 上边距
        bottom: '30%', // 下边距
      },
      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.36)', // 100% 处的颜色
                },
              ],
              global: false, // 缺省为 false
            },
          },
        },
      ],
    };
  }, [data]);

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

export default LineCharts;
