当前位置:   article > 正文

【uniApp】ucharts 实现图表下载

【uniApp】ucharts 实现图表下载

由于移动端和PC端功能场景的差异,很多移动端绘制可视化图表是没有下载需求的,导致其在网上提供的解决方法很少,通过对代码的解析发现ucharts内部封装的有saveImage方法,直接调用可以直接保存至手机的相册中,具体方法如下:
在这里插入图片描述

<uni-icons type="download" size="22" color="#04a1f4" @click="downImg()"></uni-icons>
<qiun-data-charts
	ref="myChart"
    type="line"
	:canvas2d="true"
	canvasId='myChart'  
	:opts="myChartOpt"
    :chartData="myChartData"
	:animation="false"
	:ontouch="true"
 />
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
methods: {
	console.log(this.$refs.myChart) // 通过输出图表的this对象可以看到有saveImage方法,如上图所示
	this.$refs.myChart.saveImage()
}

  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/836535
推荐阅读
相关标签
  

闽ICP备14008679号