Router Shifting Link Labels to Reduce Overlaps
The Diagram.routers List has both the Link Label Router and Avoids Links Router, this way Links and labels won't overlap allowing the Diagram be more readable.
The Avoids Links Router live updates while Nodes are being dragged, after the Node is released the Link Label Router will adjust the labels to prevent overlapping when possible.
See AvoidsLinksRouter.ts for the TypeScript source.
See the Ports learn page for an explanation of GoJS ports.
GoJS Features in this sample
Custom Link Routing
Each Link performs a very fast default computation of its desired path, its "route", based only on the properties of the Link and the properties of the port objects that it is connected with. GoJS provides a way to customize link routing by allowing consideration of other Nodes and Links, with the Router class.
Routers work by defining a method, Router.routeLinks, which takes a collection of recently recomputed link routes, plus a collection context that is either a Group or the Diagram. This method is called by the Diagram during the update phase after layouts are performed.
More information can be found in the GoJS learn pages.
GoJS Extensions
GoJS can be extended in a variety of ways. The most common way to change the standard behavior is to set properties on the GraphObject, Diagram, CommandHandler, Tool, or Layout. But when the desired property does not exist, you might need to override methods of CommandHandler, Tool, Layout, Link, or Node. Methods that you can override are documented in the API reference. Various features of GoJS can be overriden, either by replacing a method on an instance (a feature of JavaScript) or by defining a subclass. You should not modify the prototypes of any of the GoJS classes.
In addition to our samples, GoJS provides an
extensions gallery, showcasing the creation of custom tools and layouts. Those classes and samples are
written in TypeScript, available at ../extensionsJSM/, as
ECMAScript/JavaScript modules -- these use the
../release/go-module.js library. We recommend that you copy the files that
you need into your project, so that you can adjust how they refer to the GoJS library
that you choose and so that you can include them into your own building and packaging
procedures.
More information can be found in the GoJS learn pages.