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

关键代码是

相关推荐
Jiaberrr17 分钟前
前端实战:使用JS和Canvas实现运算图形验证码(uniapp、微信小程序同样可用)
前端·javascript·vue.js·微信小程序·uni-app
h177113472051 小时前
单身狗的逆袭之路之开发相亲交友系统
微信小程序·小程序·交友·系统开发·回归算法
工业互联网专业2 小时前
毕业设计选题:基于springboot+vue+uniapp的驾校报名小程序
vue.js·spring boot·小程序·uni-app·毕业设计·源码·课程设计
李宥小哥3 小时前
微信小程序05-常用API下
微信小程序·小程序
李宥小哥4 小时前
微信小程序06-综合项目点餐系统
微信小程序·小程序·notepad++
说私域7 小时前
构建有温度的用户关系:开源 AI 智能名片、链动 2+1 模式与 S2B2C 商城小程序的作用
人工智能·小程序
说私域7 小时前
社交电商中“信任”基础与“链动 2+1 模式 O2O 商城小程序”的价值探索
小程序
I592O9297837 小时前
大健康裂变分销小程序开发
小程序
前端-文龙刚8 小时前
小程序给对象赋值(双向绑定)方法之一
服务器·小程序·apache
fakaifa10 小时前
八戒农场小程序V2最新源码
小程序·uni-app·php·生活·开源软件