Created
June 5, 2020 03:36
-
-
Save pedroviniv/2f1c8dcf7cc5310c17a11234f9d6bfd5 to your computer and use it in GitHub Desktop.
apache echarts get canvas image in base64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const img = new Image(); | |
// get the chart instance data as url | |
img.src = myChart.getDataURL({ | |
type: 'png', // can be jpeg or png | |
pixelRatio: 5, // image's ratio. default is 1 | |
backgroundColor: '#fff', // hex color defining the background of the chart | |
}); | |
// just for sampling | |
// opening new tab | |
const imgTab = window.open(''); | |
// rendering the base64 image retrieved | |
imgTab.document.write(`<img src='${img.src}'/>`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment