code: function(filename){
        if (!filename){
          filename = 'chart';
        }
        this.toImg(function(img){
          var a = document.createElement("a");
          // Name of the file being downloaded.
          a.download = filename + ".png";
          a.href = img.getAttribute('src');
          // Support for Firefox which requires inserting in dom.
          a.style.display = 'none';
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
        });
      }
docs: Trigger download of image.