longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
1
2
3
4
5
6
7
8
9
10
11
12
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<template>
    <div class="e-chart-root">
        <div class="e-chart-container">
            <div class="e-chart" ref="chart"></div>
        </div>
    </div>
</template>
 
<script>
import echarts from 'echarts';
// 引入自定义主题
import "./theme/transparent";
 
export default {
    name: "EChartWrapper",
    chart: "",
    data() {
        return {}
    },
    methods: {
        setOption(option) {
            let chart = this.$options.chart;
            // 清除之前的画布
            chart.clear();
            // 生成新的画布
            chart.setOption(option);
        },
        resize() {
            let chart = this.$options.chart;
            chart.resize();
        }
    },
    mounted() {
        this.$options.chart = echarts.init(this.$refs.chart, 'transparent');
    },
    beforeDestroy() {
        this.$options.chart.clear();
    }
}
</script>
 
<style scoped>
.e-chart-root,
.e-chart-container,
.e-chart {
    height: 100%;
    box-sizing: border-box;
}
 
.e-chart-root.full-screen .e-chart-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: 100% 100%;
    z-index: 9999;
}
 
.e-chart-tools {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 9;
}
 
.e-chart-tools .iconfont {
    margin-left: 8px;
    font-size: 24px;
    cursor: pointer;
    color: #00fefe;
}
 
.e-chart-tools .iconfont:hover {
    color: #04b1b1;
}
 
.e-chart-tools .iconfont:active {
    color: #FF0000;
}
</style>