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/echart35.vue | 57 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/components/echart35.vue b/src/components/echart35.vue index 69f2680..397a6d7 100644 --- a/src/components/echart35.vue +++ b/src/components/echart35.vue @@ -10,68 +10,71 @@ 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: "axis", + trigger: 'axis', axisPointer: { - type: "shadow", + type: 'shadow', }, }, // legend: {}, grid: { - left: "0%", - right: "4%", - bottom: "0%", + left: '0%', + right: '4%', + bottom: '0%', containLabel: true, }, xAxis: { - type: "value", + type: 'value', boundaryGap: [0, 0.01], axisLine: { lineStyle: { - color: "#ccc", + color: '#ccc', }, }, axisLabel: { show: true, textStyle: { - color: "#fff", + color: '#fff', }, }, }, yAxis: { - type: "category", - data: ["涓撶", "鏈", "纭曞+", "鍗氬+鍙婁互涓�", "鍏朵粬"], + type: 'category', + data: ['涓撶', '鏈', '纭曞+', '鍗氬+鍙婁互涓�', '鍏朵粬'], axisLine: { lineStyle: { - color: "#ccc", + color: '#ccc', }, }, axisLabel: { show: true, textStyle: { - color: "#fff", + color: '#fff', }, }, }, series: [ { - name: "浜哄憳鏋勬垚", - type: "bar", + name: '浜哄憳鏋勬垚', + type: 'bar', // barWidth: 20, data: [15, 120, 50, 40, 20], itemStyle: { @@ -80,12 +83,12 @@ barBorderRadius: [0, 10, 10, 0], color: (params) => { var colorList = [ - ["#00FCFF", "#008297"], - ["#0091FF", "#005EA4"], - ["#901698", "#F157EE"], - ["#40FBCB", "#009871"], - ["#FF515A", "#FFDD53"], - ["#6574E2", "#261164"], + ['#00FCFF', '#008297'], + ['#0091FF', '#005EA4'], + ['#901698', '#F157EE'], + ['#40FBCB', '#009871'], + ['#FF515A', '#FFDD53'], + ['#6574E2', '#261164'], ]; var colorItem = colorList[params.dataIndex]; return new this.$echarts.graphic.LinearGradient( @@ -111,10 +114,10 @@ }, ], }; - let myChart = this.$echarts.init(document.getElementById("echart35")); - myChart.setOption(option); - window.addEventListener("resize", function () { - myChart.resize(); + this.myChart = this.$echarts.init(document.getElementById('echart35')); + this.myChart.setOption(option); + window.addEventListener('resize', function () { + this.myChart.resize(); }); }, }, -- Gitblit v1.9.3