// components/visualComponent/geoMap/geoMap.js import * as echarts from '../../../ec-canvas/ec-canvas/echarts'; const app = getApp(); function getGeoJson() { return new Promise((resolve, reject) => { if(app.globalData.geoJson){ resolve(app.globalData.geoJson) } else{ reject({}) } }) } function getOutBreakData() { return new Promise((resolve, reject) => { if(app.globalData.hotData){ resolve(app.globalData.hotData) } else{ reject({}) } }) } async function initChart(canvas, width, height, dpr) { const geoJson = await getGeoJson() const outBreakData = await getOutBreakData() const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr // new }); canvas.setChart(chart); const geoAdcodeMap = [...app.globalData.geoAdcodeMap] echarts.registerMap('guiZhou', geoJson); const targetItem = {...app.globalData.hotData.targetItem}; /** * @type object data热力值 max最大值 */ const hotObj = { max: 0, data: [] } targetItem.children.forEach(item => { const area = geoAdcodeMap.find(mapItem => { return mapItem.adcode.toString() === item.adcode.toString() }) if (area) { const count = item.total.confirm hotObj.data.push({ name: area.name, value: count, adcode: area.adcode.toString }) if (count > hotObj.max) { hotObj.max = count } } }) const option = { title: { text: '热力图', subtext: '累计确诊' }, tooltip: { trigger: 'item', formatter: ((item) => { const name = item.name; const num = (hotData.find((i) => i.name == item.name) || { value: 0 }).value; const renderText = `