makeSvg method

SVGElement? makeSvg([
  1. SvgRendererOptions? options
])

Create an SVGElement that contains a SVG rendering of the current Diagram.

By default this method returns a snapshot of the visible diagram, but optional arguments give more options.

See the page on Making SVG for usage examples. See the Minimal SVG Download sample, which also demonstrates downloading an SVG file without involving a web server.

See #makeImageData for an explanation of possible options that are shared by both methods. Additional SVG-specific options for this method:

  • elementFinished: 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(...);
    }
    

Note that the resulting SVG DOM is not interactive -- it is a snapshot of this diagram at this time.

At the current time methods such as Diagram#makeImage, Diagram#makeImageData and Diagram#makeSvg do not work on Overviews.

For the rendering to work, the diagram must have an HTML Div element as the #div. @param {any=} options a JavaScript object detailing optional arguments for SVG creation. @return {SVGElement} @see #makeImage

Implementation

_i6.SVGElement? makeSvg([_i3.SvgRendererOptions? options]) => _i4.callMethod(
      this,
      'makeSvg',
      [options ?? _i5.undefined],
    );