甘特图导出插件
功能介绍
ExportGanttPlugin是为了支持让甘特图全量的导出并且可以适应甘特图的大小而写的插件
该插件会在Gantt的constructor的时候开始生效
当需要导出图片的时候,你可以去执行exportGanttPlugin.exportToImage来导出图片
但是由于目前的实现原理是建立一个足够容下整个gantt组件的容器,然后把这个我们的gantt组件放进去然后使用toDataURL进行导出,所以这个会有大小限制导致导出失败的情况
插件配置
当你调用exportGanttPlugin.exportToImage是,里面还需要接受以下参数来更改导出图片的参数
fileName: '甘特图导出测试',
type: formatSelect.value as 'png' | 'jpeg',
// 分辨率倍数
scale: Number(scaleSelect.value),
backgroundColor: bgColorInput.value,
// 导出的图片的质量
quality: 1
download: false // 是否下载图片
插件示例
初始化插件对象,添加到Gantt配置中的plugins中
const exportGanttPlugin = new ExportGanttPlugin();
const option = {
records,
columns,
padding: 30,
plugins: [exportGanttPlugin]
};