微信小程序echart导出图片

echarts版本5.1.0

用到的echarts组件是uni插件市场的echart组件

html 复制代码
<div style="overflow: hidden;">
			<dCanvas class="uni-ec-canvass" id="uni-ec-canvas" ref="canvas" canvas-id="mychart-gauge" :ec="ec">
			</dCanvas>
		</div>
javascript 复制代码
		initChart(canvas, width, height, canvasDpr) {
				let that = this;
				let ecComonnets = this.selectComponent('#uni-ec-canvas')
				console.log('ecComonnets', ecComonnets);

				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				canvas.setChart(chart)
                setTimeout(function() {
					console.log('asdad', ecComonnets);
					ecComonnets.$vm.canvasToTempFilePath({
						x: 0,
						y: 0,
						width: 290,
						height: 180,
						canvasId: 'myShareCanvas',
						success: function(res) {
							console.log('res.tempFilePath', res.tempFilePath);
							that.$store.commit('set_caseShareEchartPicList', [...that.caseShareEchartPicList, res.tempFilePath])
						},
						fail: function() {
							console.log("echarts生成失败")
						}
					})
				}, 1500)

				return chart
			},

关键代码是

相关推荐
chaosama1 小时前
微信小程序带参分享、链接功能
微信小程序·小程序
胡西风_foxww1 小时前
微信小程序动态组件加载的应用场景与实现方式
微信小程序·应用·加载·动态组件
ALLSectorSorft4 小时前
上门服务小程序会员系统框架设计
小程序·apache
甜甜的资料库6 小时前
基于小程序老人监护管理系统源码数据库文档
微信小程序
说私域11 小时前
基于定制开发开源AI智能名片S2B2C商城小程序的首屏组件优化策略研究
人工智能·小程序·开源·零售
Uyker1 天前
微信小程序动态效果实战指南:从悬浮云朵到丝滑列表加载
前端·微信小程序·小程序
happyCoder1 天前
uniapp 微信小程序实现定时消息订阅提醒(前后端)
微信小程序
Uyker1 天前
从零开始制作小程序简单概述
前端·微信小程序·小程序
打小就很皮...2 天前
HBuilder 发行Android(apk包)全流程指南
前端·javascript·微信小程序
说私域2 天前
定制开发开源AI智能名片驱动下的海报工厂S2B2C商城小程序运营策略——基于社群口碑传播与子市场细分的实证研究
人工智能·小程序·开源·零售