The main diagram-js entry point that bootstraps the diagram with the given configuration.

To register extensions with the diagram, pass them as Array to the constructor.

Example: Creating a plug-in that logs whenever a shape is added to the canvas.

// plug-in implementation
function MyLoggingPlugin(eventBus) {
eventBus.on('shape.added', function(event) {
console.log('shape ', event.shape, ' was added to the diagram');
});
}

// export as module
export default {
__init__: [ 'myLoggingPlugin' ],
myLoggingPlugin: [ 'type', MyLoggingPlugin ]
};

Use the plug-in in a Diagram instance:

import MyLoggingModule from 'path-to-my-logging-plugin';

var diagram = new Diagram({
modules: [
MyLoggingModule
]
});

diagram.invoke([ 'canvas', function(canvas) {
// add shape to drawing canvas
canvas.addShape({ x: 10, y: 10 });
});

// 'shape ... was added to the diagram' logged to console

Constructors

Properties

Methods

Constructors

Properties

get: {
    <T>(name): T;
    <T_1>(name, strict): T_1;
    <T_2>(name, strict): T_2;
}

Resolves a diagram service.

Type declaration

    • <T>(name): T
    • Resolves a diagram service.

      Type Parameters

      • T

      Parameters

      • name: string

        The name of the service to get.

      Returns T

    • <T_1>(name, strict): T_1
    • Resolves a diagram service.

      Type Parameters

      • T_1

      Parameters

      • name: string

        The name of the service to get.

      • strict: true

        If false, resolve missing services to null.

      Returns T_1

    • <T_2>(name, strict): T_2
    • Resolves a diagram service.

      Type Parameters

      • T_2

      Parameters

      • name: string

        The name of the service to get.

      • strict: boolean

        If false, resolve missing services to null.

      Returns T_2

Param: name

The name of the service to get.

Param: strict

If false, resolve missing services to null.

Returns

invoke: {
    <T_3>(func, context?, locals?): T_3;
    <T_4>(func, context?, locals?): T_4;
}

Executes a function with its dependencies injected.

Type declaration

    • <T_3>(func, context?, locals?): T_3
    • Executes a function with its dependencies injected.

      Type Parameters

      • T_3

      Parameters

      • func: FactoryFunction<T_3>

        function to be invoked

      • Optional context: unknown

        context of the invocation

      • Optional locals: LocalsMap

        locals provided

      Returns T_3

    • <T_4>(func, context?, locals?): T_4
    • Executes a function with its dependencies injected.

      Type Parameters

      • T_4

      Parameters

      • func: ArrayFunc<T_4>

        function to be invoked

      • Optional context: unknown

        context of the invocation

      • Optional locals: LocalsMap

        locals provided

      Returns T_4

Param: func

function to be invoked

Param: context

context of the invocation

Param: locals

locals provided

Returns

Methods

  • Clear the diagram, removing all contents.

    Returns void

Generated using TypeDoc