| | |
| | | }; |
| | | }, |
| | | }, |
| | | // xdata: { |
| | | // type: Array, |
| | | // require: true, |
| | | // }, |
| | | // ydata: { |
| | | // type: Array, |
| | | // require: true, |
| | | // }, |
| | | }, |
| | | data() { |
| | | return { |
| | | // chartData: { |
| | | // datax: [], |
| | | // datay: [], |
| | | // }, |
| | | startValue: 0, |
| | | endValue: 5, |
| | | chartTimer:null, |
| | | chartTimer: null, |
| | | }; |
| | | }, |
| | | watch: { |
| | | "chartData.datay"(val) { |
| | | console.log(val, "设备变更数据"); |
| | | this.ydata = val; |
| | | this.startValue = 0; |
| | | this.endValue = 5; |
| | | this.pieChart("chart", this.chartData); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | // this.pieChart("chart", this.chartData); |
| | | }, |
| | | mounted() {}, |
| | | methods: { |
| | | //在职 |
| | | pieChart(chartName, data) { |
| | | let that = this; |
| | | clearInterval(this.chartTimer); |
| | | let chartDomTwo = this.$refs[chartName]; |
| | | let myChartTwo = echarts.init(chartDomTwo) |
| | | myChartTwo.dispose() |
| | | let chartDom = this.$refs[chartName]; |
| | | if (myChart != null && myChart != "" && myChart != undefined) { |
| | | myChart.dispose(); //销毁 |
| | | } |
| | | myChart = echarts.init(chartDom); |
| | | // if (myChart != null && myChart != "" && myChart != undefined) { |
| | | // console.log("222222222"); |
| | | // myChart.dispose(); //销毁 |
| | | // myChart.resize(); |
| | | // } |
| | | // console.log(myChart, "ssssssss"); |
| | | let option; |
| | | let lineColor = "#35ddc74d"; |
| | | if (this.ydata) { |
| | | if (data) { |
| | | option = { |
| | | color: ["#00FFFF", "#dcb018"], |
| | | tooltip: { |
| | |
| | | } |
| | | }, |
| | | }, |
| | | formatter:function(value){ |
| | | if(value.length>6){ |
| | | return `${value.slice(0,4)}...` |
| | | formatter: function (value) { |
| | | if (value.length > 6) { |
| | | return `${value.slice(0, 4)}...`; |
| | | } |
| | | return value; |
| | | } |
| | | }, |
| | | }, |
| | | data: data.datax ? data.datax : [], |
| | | }, |
| | |
| | | ], |
| | | }; |
| | | |
| | | this.chartTimer=setInterval(function () { |
| | | this.chartTimer = setInterval(function () { |
| | | if (option.dataZoom[0].endValue == data.datay.length) { |
| | | option.dataZoom[0].startValue = that.startValue; |
| | | option.dataZoom[0].endValue = that.endValue; |