<template>
  <div ref="chartTop" style="height: 300px;width: 50%"/>
</template>
<script setup lang="ts">
import * as echarts from "echarts"
const chartTop = ref(null)
function initChart(data){
  const myChart = echarts.init(chartTop.value)
  const option = {
    tooltip: {
      trigger: 'axis'
    },
    grid: {
      left: '1%',
      right: '1%',
      bottom: '1%',
      top: '5%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data:data.time,
      axisLine: {
        show: true,
        lineStyle: {
          color: "#849ac4",
          width: 0,
        }
      },
      axisTick: {
        show: false,
      },
    },
    yAxis: {
      type: 'value',
      axisLine: {
        show: true,
        lineStyle: {
          color: "#849ac4",
          width: 0,
        }
      },
      splitLine: {
        lineStyle: {
          color: "#849ac480",
          type: 'dashed',
        }
      },
    },
    series: [
      {
        data: data.data,
        type: 'line',
      }
    ]
  };
  myChart.setOption(option)
}

defineExpose({initChart})
</script>
