| | |
| | | <template> |
| | | <div class="echarts-wrapper"> |
| | | <div class="echarts-wrapper" @dblclick="dblclick"> |
| | | <div class="echarts-content" ref="chart" id="cityChart"> |
| | | |
| | | </div> |
| | |
| | | let chartData = []; //chart数据 |
| | | let abnormalArr = []; //异常数组 |
| | | let tempData = []; //站点数组 |
| | | let chart, chartLng, chartLat, timers; |
| | | let chart, chartLng, chartLat; |
| | | |
| | | export default { |
| | | components: { InfoPanel }, |
| | |
| | | chartData: "", |
| | | data() { |
| | | return { |
| | | timer: null, |
| | | parentsStyle: {}, |
| | | isAllScreen: false, |
| | | timers: null, |
| | | mapName: 'zhongguo', |
| | | mapInfoX: null, |
| | | mapInfoY: null, |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | findParents(node, select) { |
| | | var parent = node.parentNode; |
| | | if (parent === null || parent.className.indexOf(select) != -1) { |
| | | return parent; |
| | | } else { |
| | | return this.findParents(parent, select); |
| | | } |
| | | }, |
| | | dblclick(e) { |
| | | this.isAllScreen = !this.isAllScreen |
| | | let parents = this.findParents(e.currentTarget, 'vdr') |
| | | if (this.isAllScreen) { |
| | | this.parentsStyle = JSON.parse(JSON.stringify(parents.style)); |
| | | parents.style.transform = 'none'; |
| | | parents.style.width = '100%'; |
| | | parents.style.height = '100%'; |
| | | parents.style.position = 'fixed'; |
| | | parents.style.left = 0; |
| | | parents.style.right = 0; |
| | | parents.style.bottom = 0; |
| | | parents.style.top = 0; |
| | | parents.style.zIndex = 99999; |
| | | } else { |
| | | parents.style.transform = this.parentsStyle.transform; |
| | | parents.style.width = this.parentsStyle.width; |
| | | parents.style.height = this.parentsStyle.height; |
| | | parents.style.position = this.parentsStyle.position; |
| | | parents.style.left = 'initial'; |
| | | parents.style.right = 'initial'; |
| | | parents.style.bottom = 'initial'; |
| | | parents.style.top = 'initial'; |
| | | parents.style.zIndex = 'auto'; |
| | | } |
| | | this.$options.chart.resize(); |
| | | }, |
| | | setOption(opt) { |
| | | this.$options.chart.setOption(opt); |
| | | }, |
| | | setData(sendData) { |
| | | this.$options.chartData = sendData; |
| | | if (sendData) { |
| | | this.$options.chartData = sendData; |
| | | this.organizeData(sendData) |
| | | } else { |
| | | // 初始化页面 |
| | | this.getAllMapOutlineAction(); |
| | | } |
| | | }, |
| | | organizeData(data) { |
| | | let geoJson = require(`../../../public/mapJson/${this.mapName}.json`); |
| | | echarts.registerMap('map', geoJson); |
| | | // 整体配置项 |
| | |
| | | } |
| | | } |
| | | }, |
| | | series: this.getSeries(sendData) |
| | | series: this.getSeries(data) |
| | | }; |
| | | // 设置配置项 |
| | | this.setOption(option); |
| | |
| | | return point; |
| | | }, |
| | | startSearchMapHomeState() { |
| | | this.timer = setInterval(() => { |
| | | this.timers = setInterval(() => { |
| | | this.searchChartHomeState() |
| | | }, 4000) |
| | | |
| | | }, 60 * 1000) |
| | | }, |
| | | initPage() { |
| | | // 初始化地图 |
| | |
| | | chart = echarts.init(document.getElementById('cityChart')); |
| | | |
| | | chart.on("georoam", (params) => { |
| | | clearInterval(this.timer) |
| | | clearInterval(this.timers) |
| | | if (!this.isShowInfoPanel) { |
| | | return; |
| | | } |
| | | this.isShowInfoPanel = false; |
| | | clearTimeout(timers); |
| | | timers = setTimeout(() => { |
| | | this.timers = setTimeout(() => { |
| | | this.isShowInfoPanel = true; |
| | | let poit = this.convertMain(chartLng, chartLat); |
| | | this.mapInfoX = poit[0] - 120; |
| | |
| | | } |
| | | chart.setOption(option); //设置option |
| | | |
| | | this.startSearchMapHomeState(); |
| | | // this.startSearchMapHomeState(); |
| | | }, 300); |
| | | }); |
| | | chart.off("click"); //防止chart点击触发多次 |
| | |
| | | item.value.push(item.latitude); |
| | | tempData.push(item) |
| | | }) |
| | | this.searchChartHomeState() |
| | | this.startSearchMapHomeState(); |
| | | } else { |
| | | this.initChart([], []); |
| | |
| | | type: 'scatter', |
| | | coordinateSystem: 'geo', |
| | | symbol: function (value, params) { |
| | | let asd = value |
| | | return 'image://' + params.data.img |
| | | }, |
| | | symbolSize: [26, 26], |
| | |
| | | type: 'scatter', |
| | | coordinateSystem: 'geo', |
| | | symbol: function (value, params) { |
| | | let asd = value |
| | | return 'image://' + params.data.img |
| | | }, |
| | | symbolSize: [26, 26], |
| | |
| | | "*" |
| | | ); |
| | | }, |
| | | outClear() { |
| | | window.removeEventListener('resize', this.resize); |
| | | clearInterval(this.timers) |
| | | this.timers = null |
| | | } |
| | | }, |
| | | mounted() { |
| | | // 初始化页面 |
| | | this.getAllMapOutlineAction(); |
| | | // 基于准备好的dom,初始化echarts实例 |
| | | this.$options.chart = echarts.init(this.$refs.chart); |
| | | // 监听chartMap的面板 |
| | |
| | | return; |
| | | } |
| | | this.isShowInfoPanel = false; |
| | | timers = setTimeout(() => { |
| | | setTimeout(() => { |
| | | this.isShowInfoPanel = true; |
| | | let poit = this.convertMain(chartLng, chartLat); |
| | | this.mapInfoX = poit[0] - 120; |
| | |
| | | }, |
| | | destroyed() { |
| | | window.removeEventListener('resize', this.resize); |
| | | clearInterval(this.timer) |
| | | clearInterval(this.timers) |
| | | }, |
| | | } |
| | | </script> |