TopLeftLoading.vue 1.55 KB
Newer Older
hucy's avatar
hucy committed
1
<script lang="ts" setup>
hucy's avatar
hucy committed
2 3 4 5 6 7 8
import { ref, onMounted } from 'vue';

import * as echarts from 'echarts';

type EChartsOption = echarts.EChartsOption;

const titleChartRef = ref<HTMLElement | null>(null);
hucy's avatar
hucy committed
9 10

onMounted(() => {
hucy's avatar
hucy committed
11
  initDom();
hucy's avatar
hucy committed
12
});
hucy's avatar
hucy committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

function initDom() {
  var myChart = echarts.init(titleChartRef.value as HTMLElement);
  let option: EChartsOption = {
    graphic: {
      elements: [
        {
          type: 'group',
          left: 'center',
          top: 'center',
          children: new Array(10).fill(0).map((val, i) => ({
            type: 'rect',
            x: i * 14,
            shape: {
              x: 0,
              y: -20,
              width: 5,
              height: 30,
            },
            style: {
              fill: '#FED049',
            },
            keyframeAnimation: {
              duration: 1000,
              delay: i * 200,
              loop: true,
              keyframes: [
                {
                  percent: 0.5,
                  scaleY: 0.3,
                  easing: 'cubicIn',
                },
                {
                  percent: 1,
                  scaleY: 1,
                  easing: 'cubicOut',
                },
              ],
            },
          })),
        },
      ],
    },
  };
  myChart.setOption(option);
}
hucy's avatar
hucy committed
59 60 61
</script>
<template>
  <div class="top-left-box row items-center justify-center overflow-hidden">
hucy's avatar
hucy committed
62
    <div style="width: 100%; height: 100%" ref="titleChartRef"></div>
hucy's avatar
hucy committed
63 64 65 66 67 68 69 70
  </div>
</template>
<style lang="scss" scoped>
.top-left-box {
  height: 50px;
  padding: $padding-sm;
}
</style>