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

const props = defineProps<{
  echartsData: Array
}>()

const chartRef = ref()
onMounted(() => {
  echarts.init(chartRef.value).setOption({
    tooltip: {
      trigger: 'item',
    },
    legend: {
      top: '1%',
      right: '5%',
      textStyle: {
        color: '#ccc',
      },
    },
    grid: {
      top: '8%',
      bottom: '80px',
    },
    color: ['#7D7CFC', '#0293FD'],
    dataset: {
      source: props.echartsData.dataset_source,
    },
    xAxis: {
      type: 'category',
      axisLine: {
        show: true,

        lineStyle: {
          type: 'dashed',
          color: '#ccc',
        },
      },
    },
    yAxis: {
      axisLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: '#ccc',
        },
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: '#ccc',
        },
      },
    },
    // Declare several bar series, each will be mapped
    // to a column of dataset.source by default.
    series: [{ type: 'bar', barWidth: 50 }],

  })
})

</script>

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