|
@@ -223,7 +223,33 @@ export default {
|
|
|
this.$refs.homeSideRefs.getConversationList()
|
|
|
},
|
|
|
// 保存图表
|
|
|
- onSave () {}
|
|
|
+ onSave () {
|
|
|
+ if (!this.chart) {
|
|
|
+ this.$snackbar.error('图表未初始化')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ // 获取图表的Base64数据URL
|
|
|
+ const dataURL = this.chart.getDataURL({
|
|
|
+ type: 'png',
|
|
|
+ pixelRatio: 2, // 提高导出图片清晰度
|
|
|
+ backgroundColor: '#fff' // 设置背景色为白色
|
|
|
+ })
|
|
|
+
|
|
|
+ // 创建一个下载链接
|
|
|
+ const downloadLink = document.createElement('a')
|
|
|
+ downloadLink.href = dataURL
|
|
|
+ downloadLink.download = 'chart-export.png' // 设置下载文件名
|
|
|
+
|
|
|
+ // 模拟点击下载
|
|
|
+ document.body.appendChild(downloadLink)
|
|
|
+ downloadLink.click()
|
|
|
+ document.body.removeChild(downloadLink)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('导出图表失败:', error)
|
|
|
+ this.$snackbar.error('导出失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|