Action that generates SVG diagrams including flowcharts, org charts, and ER diagrams.

This action provides server-side SVG generation for structured diagrams, designed for AI agents and workflows to create publication-quality visualizations from structured data.

Example

// Flowchart example
await runAction({
ActionName: 'Create SVG Diagram',
Params: [
{ Name: 'DiagramType', Value: 'flow' },
{ Name: 'Nodes', Value: JSON.stringify([
{ id: '1', kind: 'start', label: 'Start' },
{ id: '2', kind: 'process', label: 'Process Data' },
{ id: '3', kind: 'end', label: 'End' }
]) },
{ Name: 'Edges', Value: JSON.stringify([
{ from: '1', to: '2', label: 'Begin' },
{ from: '2', to: '3' }
]) },
{ Name: 'Direction', Value: 'TB' },
{ Name: 'Width', Value: '800' },
{ Name: 'Height', Value: '600' }
]
});

// Org chart example
await runAction({
ActionName: 'Create SVG Diagram',
Params: [
{ Name: 'DiagramType', Value: 'org' },
{ Name: 'Nodes', Value: JSON.stringify({
id: '1',
label: 'CEO',
role: 'Chief Executive Officer',
children: [
{ id: '2', label: 'CTO', role: 'Technology' },
{ id: '3', label: 'CFO', role: 'Finance' }
]
}) }
]
});

Hierarchy (view full)

Constructors

Methods

  • Generates an SVG diagram from the provided data and configuration

    Parameters

    • params: RunActionParams<any>

      The action parameters containing:

      • DiagramType: Type of diagram ('flow' | 'org' | 'er')
      • Nodes: JSON array or object of nodes
      • Edges: JSON array of edges (for flow and ER diagrams)
      • Direction: Layout direction ('TB' | 'LR' | 'RL' | 'BT') for flow diagrams
      • Width: Diagram width in pixels (optional, default: 800)
      • Height: Diagram height in pixels (optional, default: 600)
      • Title: Diagram title (optional)
      • Palette: Color palette ('mjDefault' | 'gray' | 'pastel' | 'highContrast')
      • Seed: Random seed for deterministic layouts (optional)

    Returns Promise<SVGActionResult>

    A promise resolving to an SVGActionResult with:

    • Success: true if diagram was generated successfully
    • ResultCode: "SUCCESS" or error code
    • Message: The SVG string or error message
    • svg: The SVG XML string
    • width: Diagram width in pixels
    • height: Diagram height in pixels
  • Executes the action with the provided parameters.

    Parameters

    • params: RunActionParams<any>

      The action execution parameters including context

    Returns Promise<ActionResultSimple>

    Promise resolving to the action result

  • Renders an ER table

    Parameters

    • doc: Document
    • svg: SVGElement
    • table: ERTable & {
          height: number;
          width: number;
          x: number;
          y: number;
      }
    • palette: {
          background: string;
          categorical: string[];
          foreground: string;
      }
      • background: string
      • categorical: string[]
      • foreground: string

    Returns void

  • Renders a single flow node

    Parameters

    • doc: Document
    • svg: SVGElement
    • node: FlowNode & {
          height: number;
          width: number;
          x: number;
          y: number;
      }
    • palette: {
          categorical: string[];
          foreground: string;
      }
      • categorical: string[]
      • foreground: string

    Returns void