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

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: [
        ['date', '数量'],
        ['语文', 1080],
        ['数学', 2060],
        ['英语', 2800],
        ['物理', 2600],
        ['化学', 3100],
        ['生物', 3000],
        ['政治', 3000],
        ['历史', 3000],
        ['地理', 3000],
        ['其他', 3000],
      ],
    },
    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>
