title: Highcharts Export to zip
body: <p>I have a button that exports all my highcharts into a zip.
  At this moment after I press the button, a zip file is created and downloaded but is empty. </p>
  
  <p>I tried to debug this and as far as I can see there is a problem with base_image.onload function. Am I wrong?</p>
  
  <p>//here is an IF for a type of highcharts ex. piecharts</p>
  
  <pre><code>if (typeof pie_charts!='undefined') {
    $.each(pie_charts, function(key, value) {
      if ($('#graph'+key).length&gt;0) {
        var optns = pieChart('#graph'+key, '', value, 1);
        getsvgsrc('#graph'+key, key, optns, function(src) {
          var promise = new Promise(function(resolve, reject){
            zip.file(key+'.png', src, {base64: true});
            resolve();
          })
          promises.push(promise);
        });
      }
    });
  }
  </code></pre>
  
  <p>//here is the function that I think is something wrong about it.</p>
  
  <pre><code>function getsvgsrc(selector, name, optns, callback) {
   if ($(selector).length) {
      var chart = $(selector).highcharts();
      var svg = chart.getSVG(optns);
      var base_image = new Image();
      var canvas = document.createElement('canvas');
      svg = "data:image/svg+xml," + svg;
      base_image.onload = function() {
          canvas.width = base_image.width;
          canvas.height = base_image.height;
          var context = canvas.getContext('2d');
          context.fillStyle = "white";
          context.fillRect(0, 0, canvas.width, canvas.height);
          context.drawImage(base_image, 0, 0);
          var link = canvas.toDataURL('image/png');
          var src = link.substr(link.indexOf(',') + 1);
          callback(src)
      }
      base_image.src = svg;
    }
  }
  </code></pre>
  
  <p>At this moment a zip file is generated but is empty.
  I need to have all the charts from the paga as .png included on this .zip file.</p>