技能 设计创意 Lucidchart 图表自动化生成

Lucidchart 图表自动化生成

v20260423
lucidchart-hello-world
本技能提供了一个关于如何通过编程方式调用 Lucidchart API的指南。它演示了如何创建新的文档,使用标准导入格式添加结构化的形状和连接线,并最终导出完整的图表(如 PNG 格式)。非常适用于自动化绘制架构图、系统流程图或商业流程图。
获取技能
205 次下载
概览

Lucidchart Hello World

Overview

Minimal working examples demonstrating core Lucidchart API functionality.

Instructions

Step 1: Create a Document

const doc = await client.documents.create({
  title: 'API Architecture Diagram',
  product: 'lucidchart'  // or 'lucidspark'
});
console.log(`Document: ${doc.documentId}`);
console.log(`Edit URL: ${doc.editUrl}`);

Step 2: Add Shapes via Standard Import

// Lucid Standard Import uses .lucid file format
const importData = {
  pages: [{
    id: 'page1',
    title: 'Main',
    shapes: [
      { id: 's1', type: 'rectangle', boundingBox: { x: 100, y: 100, w: 200, h: 80 },
        text: 'API Gateway', style: { fill: '#4A90D9' } },
      { id: 's2', type: 'rectangle', boundingBox: { x: 100, y: 300, w: 200, h: 80 },
        text: 'Database', style: { fill: '#7B68EE' } }
    ],
    lines: [
      { id: 'l1', endpoint1: { shapeId: 's1' }, endpoint2: { shapeId: 's2' },
        stroke: { color: '#333', width: 2 } }
    ]
  }]
};
await client.documents.import(doc.documentId, importData);

Step 3: Export Document

const png = await client.documents.export(doc.documentId, {
  format: 'png', pageIndex: 0, scale: 2
});
fs.writeFileSync('diagram.png', png);

Error Handling

Error Cause Solution
Auth error Invalid credentials Check LUCID_API_KEY
Not found Invalid endpoint Verify API URL
Rate limit Too many requests Implement backoff

Resources

Next Steps

See lucidchart-local-dev-loop.

信息
Category 设计创意
Name lucidchart-hello-world
版本 v20260423
大小 1.98KB
更新时间 2026-04-26
语言