GoJS API
/ to search
    Preparing search index...

    Interface SvgRendererOptions

    Used for the options argument to Diagram.makeSvg.

    interface SvgRendererOptions {
        background?: BrushLike;
        callback?: ((result: any) => void) | null;
        callbackTimeout?: number;
        document?: Document;
        elementFinished?: ((graphobj: GraphObject, svgelt: SVGElement) => void) | null;
        padding?: MarginLike;
        parts?: Iterable<Part> | Part[];
        position?: Point;
        scale?: number;
        showGrid?: boolean;
        showTemporary?: boolean;
        size?: Size;
        svgFinished?: ((svg: SVGSVGElement) => void) | null;
    }

    Hierarchy (View Summary)

    Index

    Properties

    background?: BrushLike

    A valid CSS color to replace the default (transparent) canvas background. Any padding area is also colored.

    callback?: ((result: any) => void) | null

    The function to call when an image is finished creation. It has one argument, which is of the type specified by the value of the ImageRendererOptions.returnType or SVG DOM. If provided, call the callback when finished instead of returning immediately. This can be useful if you need to wait for image assets to load. This also respects the callbackTimeout. This argument is necessary if the ImageRendererOptions.returnType is "blob", however a callback can be used with any ImageRendererOptions.returnType. See the Minimal Image Blob Download sample for an example usage, which also demonstrates downloading an image file without involving a web server.

    callbackTimeout?: number

    If a callback is specified, the additional amount of time in milliseconds a call will wait before completeing. Right now, it will only wait if image assets in the Diagram are not yet loaded. Default is 300 (milliseconds).

    document?: Document

    An HTML Document, defaulting to window.document (or the root object in other contexts) This may be useful to set if you intend your Image or SVG to be opened in a new window.

    elementFinished?: ((graphobj: GraphObject, svgelt: SVGElement) => void) | null

    A function with two arguments, GraphObject and SVGElement. As the SVG elements are created representing each graph object, this function is called on them, allowing you to modify the SVG as it is being built, to assign stylesheets, IDs, etc. Example:

    elementFinished: (graphObject, SVGElement) => {
    // set something on every SVG element that represents a GoJS TextBlock
    if (graphObject instanceof go.TextBlock) SVGElement.setAttribute(...);
    }
    padding?: MarginLike

    A Margin (or number) to pad the image with. If a size is specified, the padding will not increase the image size, it will only offset the Diagram contents within the image. The default value is a padding of 1.

    parts?: Iterable<Part> | Part[]

    An iterator of GraphObjects, typically Parts, such as one from Diagram.selection or Layer.parts. If GraphObjects are specified their containing Part will be drawn. By default all Parts are drawn except temporary parts (see showTemporary).

    position?: Point

    The position of the diagram, as a Point. By default this is the position of Diagram.documentBounds with the Diagram.padding removed. If a specific parts collection is used, by default this is the top-left diagram position of their collective bounds. If you set a position, you should also set a size.

    scale?: number

    The scale of the diagram. If scale is specified and size is not, the resulting image will be sized to uniformly fit the space needed for the given scale. Can be constrained by the maxSize property. A scale value of NaN will automatically scale to fit within the maxSize, but may be smaller, with a maximum computed scale of 1.

    showGrid?: boolean

    A boolean value, defaulting to the value of showTemporary, that determines whether or not the Grid Layer (containing Diagram.grid) is included in the image regardless of the value of showTemporary. This is useful if you want to include the grid but not adornments, or vice versa.

    showTemporary?: boolean

    A boolean value, defaulting to false, that determines whether or not temporary objects such as adornments are included in the image.

    size?: Size

    The size of the created image, as a Size, limited by the maxSize property. If no scale or position is specified then the diagram will be scaled to fit the given size. If you set a size, you should also set a position. If you are scaling the diagram, you may also want to scale the size.

    svgFinished?: ((svg: SVGSVGElement) => void) | null

    A function that takes the result SVGSVGElement and may modify it.