index.vue 1.4 KB
<script setup lang="ts">
import { onMounted, ref, unref } from 'vue'
import type { ECharts, EChartsOption } from 'echarts'
import { init } from 'echarts'
const firstScreenElRef = ref()

const instance = ref<ECharts>()

const options: EChartsOption = {
  graphic: {
    elements: [
      {
        type: 'text',
        left: 'center',
        top: 'center',
        style: {
          text: 'Apache ECharts',
          fontSize: 80,
          fontWeight: 'bold',
          lineDash: [0, 200],
          lineDashOffset: 0,
          fill: 'transparent',
          stroke: '#000',
          lineWidth: 1,
        },
        keyframeAnimation: {
          duration: 3000,
          loop: true,
          keyframes: [
            {
              percent: 0.7,
              style: {
                fill: 'transparent',
                lineDashOffset: 200,
                lineDash: [200, 0],
              },
            },
            {
              // Stop for a while.
              percent: 0.8,
              style: {
                fill: 'transparent',
              },
            },
            {
              percent: 1,
              style: {
                fill: 'black',
              },
            },
          ],
        },
      },
    ],
  },
}

onMounted(() => {
  instance.value = init(unref(firstScreenElRef), options)
})
</script>

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