跳到主要内容

png()

描述

将图表导出为 PNG 文件

备注

为了避免导出过程中出现问题,必须将 Diagram 图形的所有图像设置为 base64 格式或使用绝对 URL 路径。

用法

png(config?: object): Promise<void>;

返回值

数据导出操作的 Promise 对象

参数

  • config - (可选)导出设置对象。您可以为导出为 PNG 指定以下设置:
    • url?: string - (可选)执行导出并返回导出文件的服务的 URL。该设置为可选项,仅当您需要指定本地导出服务的路径时才需要使用。默认值为 https://export.dhtmlx.com/diagram/png/6.1.0
    • name?: string - (可选)导出文件的名称
    • header?: string - (可选)导出文件中页眉的 HTML 模板
    • footer?: string - (可选)导出文件中页脚的 HTML 模板

示例

const diagram = new dhx.Diagram("diagram_container", {
// 配置选项
});
diagram.data.parse(data);

// 默认导出
diagram.export.png()
.then(() => console.log("success"))
.catch(() => console.log("failure"))
.finally(() => console.log("finished"));

// 使用配置设置导出
diagram.export.png({
name: "result_png"
})
.then(() => console.log("success"))
.catch(() => console.log("failure"))
.finally(() => console.log("finished"));

相关文章: 导出 Diagram

相关示例: