/**
 * 
 *     @dfsj/echarts： 专业的水文曲线组件或构造函数以及通用的echart二次封装图表
 *     版本: v3.7.0
 *     作者：yangbo <1747837358@qq.com>
 *     日期：2025-05-27 15:53:33
 *     
 *     
 */

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 };
