Blame view

src/views/dashboard/analysis/components/VisitAnalysis.vue 2.18 KB
Vben authored
1
2
3
<template>
  <div ref="chartRef" :style="{ height, width }"></div>
</template>
sanmu authored
4
5
<script lang="ts" setup>
sanmu authored
6
  import { ref, Ref, watchEffect } from 'vue';
Vben authored
7
  import { useECharts } from '/@/hooks/web/useECharts';
sanmu authored
8
9
10
  import { basicProps } from './props';
  import { max } from 'lodash-es';
  import { useDataStoreWithOut } from '/@/store/modules/data';
Vben authored
11
12
13
14
15
16
  defineProps({
    ...basicProps,
  });
  const chartRef = ref<HTMLDivElement | null>(null);
  const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
sanmu authored
17
18
19
20
  const dataStore = useDataStoreWithOut();
  watchEffect(() => {
    const data = dataStore?.getChartData || {};
    const maxY = data?.y ? max(data?.y) : 0;
21
22
23
24
25
26
27
    setOptions({
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          lineStyle: {
            width: 1,
            color: '#019680',
Vben authored
28
          },
29
30
31
32
33
        },
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
sanmu authored
34
        data: data?.x,
35
36
37
38
39
40
        splitLine: {
          show: true,
          lineStyle: {
            width: 1,
            type: 'solid',
            color: 'rgba(226,226,226,0.5)',
Vben authored
41
          },
42
43
44
45
46
47
48
49
        },
        axisTick: {
          show: false,
        },
      },
      yAxis: [
        {
          type: 'value',
sanmu authored
50
          max: maxY + 20,
51
52
53
54
55
56
57
58
          splitNumber: 4,
          axisTick: {
            show: false,
          },
          splitArea: {
            show: true,
            areaStyle: {
              color: ['rgba(255,255,255,0.2)', 'rgba(226,226,226,0.2)'],
Vben authored
59
            },
60
61
62
63
64
65
66
          },
        },
      ],
      grid: { left: '1%', right: '1%', top: '2  %', bottom: 0, containLabel: true },
      series: [
        {
          smooth: true,
sanmu authored
67
          data: data?.y,
68
69
70
71
72
73
          type: 'line',
          areaStyle: {},
          itemStyle: {
            color: '#5ab1ef',
          },
        },
sanmu authored
74
75
76
77
78
79
80
81
82
83
84
85
        // {
        //   smooth: true,
        //   data: [
        //     33, 66, 88, 333, 3333, 5000, 18000, 3000, 1200, 13000, 22000, 11000, 2221, 1201, 390,
        //     198, 60, 30, 22, 11,
        //   ],
        //   type: 'line',
        //   areaStyle: {},
        //   itemStyle: {
        //     color: '#019680',
        //   },
        // },
86
87
      ],
    });
Vben authored
88
89
  });
</script>