<script setup lang="ts">
import * as echarts from 'echarts'

const props = defineProps<{
  ecahrtsData: object
}>()

const chartRef = ref()
onMounted(() => {
  echarts.init(chartRef.value).setOption({
  color: ['#37A2FF','#80FFA5', '#00DDFF', '#FF0087', '#FFBF00'],
    tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      label: {
        backgroundColor: '#6a7985'
      }
    }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: [
    {
      type: 'category',
      boundaryGap: false,
      data: props.ecahrtsData.xAxis_data
    }
  ],
  yAxis: [
    {
      type: 'value',
        splitLine: {
          show: false 
      },
    }
  ],
  series: [
    {
      name: props.ecahrtsData.series_name,
      type: 'line',
      stack: 'Total',
      smooth: true,
      lineStyle: {
        width: 0
      },
      showSymbol: false,
      areaStyle: {
        opacity: 0.8,
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgb(34,143,255,1)'
          },
          {
            offset: 1,
            color: 'rgba(34,143,255,0.1)'
          }
        ])
      },
      emphasis: {
        focus: 'series'
      },
      data: props.ecahrtsData.series_data
    },
  ]
})
})
</script>

<template>
  <div ref="chartRef" class="w-full h-full " />
</template>
