From 307b17ef15c73a071912a262834f2a5f68e1fa87 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 11 九月 2025 15:20:35 +0800 Subject: [PATCH] 完成走航季度报告自动生成 --- src/utils/chart/chart-map.js | 92 +-------------------------------------------- 1 files changed, 3 insertions(+), 89 deletions(-) diff --git a/src/utils/chart/chart-map.js b/src/utils/chart/chart-map.js index fb72feb..0918317 100644 --- a/src/utils/chart/chart-map.js +++ b/src/utils/chart/chart-map.js @@ -115,16 +115,6 @@ chart.setOption(option); - // 灏嗗儚绱犲潗鏍囪浆鎹负缁忕含搴� - // const convert = (x, y) => { - // return chart.convertFromPixel( - // { - // geoIndex: 0 - // }, - // [x, y] - // ); - // }; - // 灏嗙粡绾害杞崲涓哄儚绱犲潗鏍� const convert = (lng, lat) => { return chart.convertToPixel( @@ -162,88 +152,12 @@ pixelRatio: 2, backgroundColor: '#fff' }); + // 閿�姣佸疄渚嬪苟绉婚櫎涓存椂DOM + chart.dispose(); + document.body.removeChild(div); resolve(url); }, 1000); }); - // return captureMapByBounds({ - // chart: chart, - // bounds: bounds - // }).catch((err) => { - // console.error('鎴浘澶辫触:', err); - // }); } - -/** - * 鏍规嵁缁忕含搴﹁寖鍥存埅鍙栧湴鍥惧尯鍩� - * @param {Object} params - 鎴彇鍙傛暟 - * @param {Array} params.bounds - 缁忕含搴﹁寖鍥� [minLng, minLat, maxLng, maxLat] - * @param {Object} params.chart - ECharts瀹炰緥 - * @returns {Promise<string>} 鎴彇鍖哄煙鐨刡ase64鍥剧墖 - */ -// function captureMapByBounds(params) { -// const { bounds, chart } = params; -// const [minLng, minLat, maxLng, maxLat] = bounds; - -// // 鑾峰彇鍦板浘鍧愭爣绯� -// // const geo = chart.getModel().getComponent('geo'); -// // if (!geo) return Promise.reject('鏈壘鍒板湴鍥剧粍浠�'); - -// // 灏嗙粡绾害杞崲涓哄儚绱犲潗鏍� -// const convert = (lng, lat) => { -// return chart.convertToPixel( -// { -// geoIndex: 0 -// }, -// [lng, lat] -// ); -// }; - -// // 璁$畻鍥涗釜瑙掔殑鍍忕礌鍧愭爣 -// const topLeft = convert(minLng, maxLat); -// const bottomRight = convert(maxLng, minLat); - -// // 鍒涘缓涓存椂Canvas -// const canvas = document.createElement('canvas'); -// const ctx = canvas.getContext('2d'); - -// // 鑾峰彇鍘熷鍥捐〃Canvas -// const originalCanvas = chart.getDom().querySelector('canvas'); - -// // 璁剧疆Canvas灏哄涓烘埅鍙栧尯鍩熷ぇ灏� -// topLeft[0] -= 10; -// topLeft[1] -= 10; -// bottomRight[0] += 10; -// bottomRight[1] += 10; -// topLeft[0] = Math.max(topLeft[0], 0); -// topLeft[1] = Math.max(topLeft[1], 0); -// bottomRight[0] = Math.min(bottomRight[0], originalCanvas.width); -// bottomRight[1] = Math.min(bottomRight[1], originalCanvas.height); -// const width = bottomRight[0] - topLeft[0]; -// const height = bottomRight[1] - topLeft[1]; -// canvas.width = width; -// canvas.height = height; - -// // 瑁佸壀鎸囧畾鍖哄煙 -// ctx.drawImage( -// originalCanvas, -// topLeft[0], -// topLeft[1], // 婧愬浘鍍忚鍓捣鐐� -// width, -// height, // 婧愬浘鍍忚鍓昂瀵� -// 0, -// 0, // 鐩爣鍥惧儚缁樺埗璧风偣 -// width, -// height // 鐩爣鍥惧儚缁樺埗灏哄 -// ); - -// // 杞崲涓篵ase64鍥剧墖 -// return new Promise((resolve) => { -// // 寤惰繜鎵ц纭繚缁樺埗瀹屾垚 -// setTimeout(() => { -// const base64 = canvas.toDataURL('image/png', 1.0); -// resolve(base64); -// }, 100); -// }); -// } export default { generateGridMap }; -- Gitblit v1.9.3