微信小程序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
			},

关键代码是

相关推荐
甜甜的资料库2 小时前
基于微信小程序的睡眠宝系统源码数据库文档
数据库·微信小程序·小程序
华子w9089258592 小时前
SpringBoot+uniapp 的 Champion 俱乐部微信小程序设计与实现,论文初版实现
spring boot·微信小程序·uni-app
恰薯条的屑海鸥3 小时前
关于我对各开发语言的看法与接下来的文章内容
开发语言·学习·微信小程序·网站开发·全栈开发
勿念4363 小时前
基于鸿蒙(HarmonyOS5)的打车小程序
华为·小程序·harmonyos
Stanford_11065 小时前
关于大数据的基础知识(二)——国内大数据产业链分布结构
大数据·开发语言·物联网·微信小程序·微信公众平台·twitter·微信开放平台
邹荣乐7 小时前
uni-app开发微信小程序的报错[渲染层错误]排查及解决
前端·微信小程序·uni-app
weixin_1772972206910 小时前
盲盒一番赏小程序:引领盲盒新潮流
小程序
chaosama1 天前
微信小程序带参分享、链接功能
微信小程序·小程序
胡西风_foxww1 天前
微信小程序动态组件加载的应用场景与实现方式
微信小程序·应用·加载·动态组件
ALLSectorSorft1 天前
上门服务小程序会员系统框架设计
小程序·apache