var defOptions = {
  name: '图表图片',
  suffix: '.png',
  pixelRatio: 2,
  backgroundColor: '#fff'
};
function useDownLoad(getFn) {
  var downloadImg = function downloadImg(options) {
    var def = Object.assign({}, defOptions, options);
    var chartIns = typeof getFn == 'function' ? getFn() : getFn;
    var imgUrl = chartIns === null || chartIns === void 0 ? void 0 : chartIns.getDataURL({
      pixelRatio: def.pixelRatio,
      backgroundColor: def.backgroundColor
    });
    var tempA = document.createElement('a');
    tempA.download = def.name + def.suffix;
    tempA.href = imgUrl;
    document.body.appendChild(tempA);
    tempA.click();
    tempA.remove();
  };
  return {
    downloadImg: downloadImg
  };
}

export { useDownLoad };
