Class DiagramViewer

DiagramViewer is the main diagram viewing web component of the MJS Diagram library.

You add an instance of DiagramViewer to your page to display dynamic and interactive diagrams created either with DiagramEditor or in code.

You can add it in your HTML markup as a custom element with something like this:

<mjs-diagram-viewer id="mjsDiaViewer"></mjs-diagram-viewer>

Or you can add it in code.

One important thing to set when the component loads is the StencilSet you want to use.

Here we add a Flowchart stencil set:

let viewer = document.getElementById('mjsDiaViewer');
viewer.stencilSet = flowchartStencilSet;

You display previously saved or created state by passing it to the show method.

viewer.show(myState);

See

Check out MJS Diagram docs and demos for more details.

Hierarchy

  • HTMLElement
    • DiagramViewer

Constructors

  • Creates a new instance of the Diagram Viewer.

    Returns DiagramViewer

Properties

settings: DiagramSettings = ...

Diagram settings.

zoomSteps: number[] = ...

Zoom level steps the interactive zoom controls go through.

Accessors

  • get autoScaling(): AutoScaleDirection
  • Configures auto-scaling behavior.

    • none - no auto-scaling
    • down (default) - auto-scales the diagram down when it doesn't fit into the control
    • up - auto-scales the diagram to the largest size fitting into the control but not smaller than 100%
    • both - keeps diagram at maximum size that fits into the control

    Since

    1.1.0

    Returns AutoScaleDirection

  • set autoScaling(value): void
  • Parameters

    Returns void

  • get loadAnimationEnabled(): boolean
  • Returns whether diagram stencils should fade in after loading

    Since

    1.2.0

    Returns boolean

  • set loadAnimationEnabled(value): void
  • Sets whether diagram stencils should fade in after loading

    Since

    1.2.0

    Parameters

    • value: boolean

    Returns void

  • get toolbarVisible(): boolean
  • Returns whether toolbar is visible (enabled)

    Since

    1.2.0

    Returns boolean

  • set toolbarVisible(value): void
  • Sets whether toolbar is visible (enabled)

    Since

    1.2.0

    Parameters

    • value: boolean

    Returns void

  • get zoomLevel(): number
  • Gets the current zoom level of the control (1 is 100%).

    Returns number

  • set zoomLevel(value): void
  • Set the zoom level of the contrl (1 is 100%).

    Parameters

    • value: number

    Returns void

Methods

  • Type Parameters

    Parameters

    • type: T
    • listener: ((this, ev) => void)
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Type Parameters

    • K extends keyof HTMLElementEventMap

    Parameters

    • type: K
    • listener: ((this, ev) => void)
        • (this, ev): void
        • Parameters

          • this: HTMLElement
          • ev: HTMLElementEventMap[K]

          Returns void

    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Scales the diagram inside the viewer according to the autoScaling setting.

    Since

    1.1.0

    Returns void

  • Returns a new internal object identifier.

    Returns number

  • Type Parameters

    Parameters

    • type: T
    • listener: ((this, ev) => void)
    • Optional options: boolean | EventListenerOptions

    Returns void

  • Type Parameters

    • K extends keyof HTMLElementEventMap

    Parameters

    • type: K
    • listener: ((this, ev) => void)
        • (this, ev): void
        • Parameters

          • this: HTMLElement
          • ev: HTMLElementEventMap[K]

          Returns void

    • Optional options: boolean | EventListenerOptions

    Returns void

  • Displays a previously saved diagram.

    Remarks

    Make sure to set the correct corresponding stencilSet before calling show().

    Parameters

    Returns void

  • Zooms in or out to the supplied zoom level (1 = 100%).

    Parameters

    • factor: number

      zoom level.

    Returns void

Generated using TypeDoc