From 9c803f20cc05395bac2d3386accfe230210c07dc Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期一, 19 十二月 2022 20:58:31 +0800 Subject: [PATCH] 1 --- src/components/echart44.vue | 47 +++++++++++++++++++++++++---------------------- 1 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/components/echart44.vue b/src/components/echart44.vue index 5b85155..b513684 100644 --- a/src/components/echart44.vue +++ b/src/components/echart44.vue @@ -10,46 +10,49 @@ components: {}, data() { //杩欓噷瀛樻斁鏁版嵁 - return {}; + return { myChart }; }, mounted() { this.lineChart(); + this.$bus.$on('resizeEchart', (res) => { + this.myChart.resize(); + }); }, //鏂规硶闆嗗悎 methods: { lineChart() { let option = { title: { - text: "鍚勯」鐩�讳綋杩涘害", + text: '鍚勯」鐩�讳綋杩涘害', textStyle: { - color: "#fff", + color: '#fff', }, }, tooltip: { - trigger: "item", + trigger: 'item', }, // legend: {}, grid: { - left: "3%", - right: "4%", - bottom: "3%", + left: '3%', + right: '4%', + bottom: '3%', containLabel: true, }, series: [ { - name: "鍚勯」鐩�讳綋杩涘害", - type: "pie", - radius: ["40%", "70%"], - roseType: "radius", - color: ["#03effb", "#00bec4", "#3a82ab"], + name: '鍚勯」鐩�讳綋杩涘害', + type: 'pie', + radius: ['40%', '70%'], + roseType: 'radius', + color: ['#03effb', '#00bec4', '#3a82ab'], avoidLabelOverlap: false, itemStyle: { - fontColor: "fff", - borderColor: "#fff", + fontColor: 'fff', + borderColor: '#fff', }, label: { show: false, - position: "center", + position: 'center', }, emphasis: { // label: { @@ -61,17 +64,17 @@ show: false, }, data: [ - { value: 4, name: "宸插畬鎴�" }, - { value: 7, name: "杩涜涓�" }, - { value: 8, name: "鏈紑濮�" }, + { value: 4, name: '宸插畬鎴�' }, + { value: 7, name: '杩涜涓�' }, + { value: 8, name: '鏈紑濮�' }, ], }, ], }; - let myChart = this.$echarts.init(document.getElementById("echart44")); - myChart.setOption(option); - window.addEventListener("resize", function () { - myChart.resize(); + this.myChart = this.$echarts.init(document.getElementById('echart44')); + this.myChart.setOption(option); + window.addEventListener('resize', function () { + this.myChart.resize(); }); }, }, -- Gitblit v1.9.3