This text is displayed if your browser does not support the Canvas HTML element.

This sample demonstrates the PolygonDrawingTool, a custom tool added to the Diagram's mouseDownTools. It is defined in its own file, as PolygonDrawingTool.js.

These extensions serve as examples of features that can be added to GoJS by writing new classes. With the PolygonDrawingTool, a new mode is supported that allows the user to draw custom shapes.

Click a "Draw" button and then click in the diagram to place a new point in a polygon or polyline shape. Right-click or Enter to finish. Press Escape to cancel, or Z to remove the last point. Click the "Select Mode" button to switch back to the normal selection behavior, so that you can select, resize, and rotate the shapes.

View this sample page's source in-page

View this sample page's source on GitHub