import Taro from "@tarojs/taro";
import classnames from "classnames";
import { Block, View, Image, Text, Input } from "@tarojs/components";
import { Popup, Progress, Slider } from "@antmjs/vantui";
import { useEffect, useRef } from "react";
import Echarts, { EChartOption, EchartsHandle } from "taro-react-echarts";
import * as echarts from "echarts";
import "./index.less";

interface Props {
  echartsData: any
}

function Index(echartsData: Props) {
  let { gears, eDate } = echartsData.echartsData;
  const echartsRef = useRef<EchartsHandle>(null);
  const option: EChartOption = {
    grid: {
      // 让图表占满容器
      top: "28rpx",
      left: "30rpx",
      right: "35rpx",
      bottom: "38rpx",
    },
    title: {
      left: 'center',
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      splitLine: {
        show: true,
      },
      data:eDate,
      axisTick: {
        show: false
      },
      axisLine: {
        lineStyle: {
          color: '#ccc'
        }
      },
      axisLabel: {
        fontSize: 9
      }
    },
    yAxis: {
      type: 'value',
      show: false
    },
    series: [
      {
        type: 'line',
        itemStyle: {
          color: 'rgb(168, 222, 244)'
        },
        symbolSize: 0,
        label: {
          show: true,
          distance: 8,
          formatter: function (params) {
            return params.value + '级';
          }
        },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgb(220, 240, 248)'

            },
            {
              offset: 1,
              color: 'rgb(248, 253, 255)'
            }
          ])
        },
        data: gears,
      }
    ]
  };

  return (
    <Block>
      <View className='box'>
        <Echarts
          echarts={echarts}
          option={option}
          ref={echartsRef}
          // isPage={false}
          // style自定义设置echarts宽高
          style={{ width: "100%", height: "260rpx" }}
        />
      </View>
    </Block>
  );
}

export default Index;
