0

I need base64 image chart from 'http://export.highcharts.com/'

    getImg () {
          const self = this;
          axios.post('http://export.highcharts.com/', { options: self.$refs['lineChart'].options, type: 'image/png' }).then(function (response) {
            base64.encode(response.data)
          }).catch(function (e) {
            console.log(e)
          });
    },
Daniel Mesa
  • 586
  • 3
  • 12

2 Answers2

0

Here you can get image and convert it to base64. also similar to this question you can check the following link to get more information.

function getBase64(url) {
      return axios
        .get(url, {
          responseType: 'arraybuffer'
        })
        .then(response => Buffer.from(response.data, 'binary').toString('base64'))
    }
Pooya Panahandeh
  • 578
  • 7
  • 21
0

This works fine

getImg () {
          const self = this;
          axios.post('http://export.highcharts.com/', { options: self.$refs['lineChart'].options, type: 'image/png' }, { responseType: 'arraybuffer' }).then(function (response) {
            let PNGBase64 = 'data:image/png;base64,' + Buffer.from(response.data, 'binary').toString('base64')
          }).catch(function (e) {
            console.log(e)
          });
    },
Daniel Mesa
  • 586
  • 3
  • 12