| | |
| | | chartStyle: { |
| | | type: Object, |
| | | default: () => ({ |
| | | height: '80%', |
| | | height: '95%', |
| | | width: '100%' |
| | | }) |
| | | }, |
| | |
| | | }, |
| | | renderChart() { |
| | | const option = { |
| | | ...this.options, |
| | | backgroundColor: this.options.backgroundColor || '#fff', |
| | | xAxis: this.xAxis, |
| | | yAxis: this.yAxis, |
| | |
| | | this.chartInstance.dispose() |
| | | this.chartInstance = null |
| | | } |
| | | }, |
| | | |
| | | // 下载图片功能 |
| | | downloadImage(fileName = 'chart') { |
| | | if (!this.chartInstance) return; |
| | | |
| | | const url = this.chartInstance.getDataURL({ |
| | | type: 'png', |
| | | pixelRatio: 2, |
| | | backgroundColor: '#fff' |
| | | }); |
| | | |
| | | const a = document.createElement('a'); |
| | | a.href = url; |
| | | a.download = `${fileName}.png`; |
| | | document.body.appendChild(a); |
| | | a.click(); |
| | | document.body.removeChild(a); |
| | | } |
| | | |
| | | }, |
| | | } |
| | | </script> |