GoJS Change Log
We maintain a GitHub Repository that you can star to follow version updates.
GoJS 4.0
GoJS 4.0 brings a number of new features.
- Performance improvements for large graphs, especially during dragging and object picking.
- ForceDirectedLayout has been re-implemented to be much faster.
- Several improvements for stronger type checking and use with AI tooling. Regardless of tooling, we will continue to make it easier to create and verify code.
- The functionality of the Robot extension has now been merged into the Diagram class.
- We have added a HeatMap extension.
API Improvements for Structured Authoring
-
Added typed constant objects for string-based registries, providing autocomplete and
compile-time checking for values that were previously plain strings. The new constants
are: Figures, Arrowheads, PanelTypes, ToolNames,
Builders, and LayerNames. For example,
go.Figures.RoundedRectangleinstead of"RoundedRectangle", orgo.Arrowheads.Standardinstead of"Standard". Corresponding union types (FigureName, ArrowheadName, PanelTypeName, ToolName, BuilderName, LayerName) are exported for use in TypeScript. However, because the programmer can define new names for each of these kinds of things, those types only represent the built-in subset of possibilities. - Model classes are now generic, accepting NodeDataType and LinkDataType type parameters. These can be optionally specified to get stronger type checking on model data, and in methods such as Model.nodeDataArray, GraphLinksModel.linkDataArray, Model.copyNodeData, and GraphLinksModel.copyLinkData. Model, TreeModel, and GraphLinksModel accept a NodeDataType parameter, while GraphLinksModel accepts both NodeDataType and LinkDataType. These default to ObjectData and are fully backward compatible.
Model typing examples:
Other New Features and Changes for GoJS 4.0
New features of ForceDirectedLayout:
- ForceDirectedLayout now uses a Barnes-Hut approximation algorithm, that uses a quadtree to render large graphs significantly faster. We have observed 7-10x performance boosts on graphs with node counts in the low thousands.
- The ForceDirectedLayout.theta parameter has been added. This parameter controls the accuracy versus speed of the layout. Higher values of theta will produce a faster, but potentially less accurate, layout.
Incompatible changes in ForceDirectedLayout:
- Repulsion between Nodes no longer scales as aggressively with the size of the nodes. If you are using a ForceDirectedLayout with large, or varying, node sizes, you may have to increase the value ForceDirectedLayout.defaultElectricalCharge.
- Some parameters have changed their default values, which should produce strictly better results for most use cases:
- The default value of ForceDirectedLayout.moveLimit has changed from 10 to Infinity, which allows nodes to move arbitrarily far per iteration. For large layouts performed all at once, this will produce better results. If your layout is small or incremental, you may have to set a value for this parameter to prevent nodes from moving too much during incremental changes.
- The default value of ForceDirectedLayout.infinityDistance has changed from 1000 to Infinity, which means Nodes will always interact regardless of how far apart they are. For large layouts performed all at once, this will produce better results. If your layout depends on a limited distance between interacting Nodes, you may have to add an explicit value for this parameter.
Added the HeatMap extension, which assumes each Node or Link could have a temperature used in drawing a heat map in the viewport. There is also a HeatMap.renderImageData method to generate a raster image for any given area.
The functionality of the Robot extension class for simulating mouse and keyboard events has been moved into the Diagram class, with the method names prepended with "emit..."/. This makes it easier to write regression tests and automation scripts, because you no longer need to load the Robot extension code. The Robot extension has been deprecated, although for compatibility it remains in the extensionsJSM and extensions directories. The Robot sample has been rewritten to call the new Diagram methods. The new methods are:
- Diagram.emitMouseDown
- Diagram.emitMouseMove
- Diagram.emitMouseUp
- Diagram.emitMouseWheel
- Diagram.emitKeyDown
- Diagram.emitKeyUp
The maxSize option used by Diagram.makeImageData and Diagram.makeImage has been moved from the DiagramRendererOptions interface to the ImageRendererOptions interface. And due to increased memory available in all devices, the default value has increased from 2000x2000 to 4000x4000.
Other New Features and Changes
- Enhanced the PanningTool to support two-finger panning as well as pinch-zooming and one-finger panning. Added the PanningTool.pan method, taking several arguments to make it easier to override in order to implement custom behaviors. For example, the Pinch Resizing sample now overrides that method to demonstrate resizing and rotating a selected node.
- Added the DragSelectingTool.findInRect method that can be overridden to customize the criteria by which Parts are selected.
- Added the Tool.canStartButton overridable predicate, which defaults to returning true if the Diagram.lastInput has InputEvent.left true -- i.e. whether the left mouse button is held down. You can override this method to change the behavior of many predefined Tools to operate with a mouse button other than the left one.
- Added an optional "result" argument to a number of methods that allocated Points or Rects, so that memory allocation can be reduced by passing one to the method and it can be modified and returned. Those methods are: Diagram.transformDocToView, Diagram.transformViewToDoc, Link.computeOtherPoint, Geometry.computeBoundsWithoutOrigin.
- Some methods now return this instead of returning void, for convenience in chaining calls. Those methods include: Diagram.add, Diagram.remove, Diagram.removeParts, Diagram.addLayer, Diagram.addLayerAfter, Diagram.addLayerBefore, Diagram.removeLayer, Diagram.addChangedListener, Diagram.removeChangedListener, Diagram.addModelChangedListener, Diagram.removeModelChangedListener, Diagram.addDiagramListener, Diagram.removeDiagramListener, Panel.insertAt, Panel.remove, Panel.removeAt, ToolManager.initializeStandardTools.
- Link.computeEndSegmentLength now takes an optional "dir" argument, defaulting to NaN for compatibility.
- Link.computeOtherPoint now takes optional "otherspot", "from", and "result" arguments. When none of those arguments are supplied, the behavior should be compatible.
- RotatingTool.handleAngle now supports angles other than multiples of 90 degrees. RotatingTool.originalLocation is a new property that remembers the original location of the Part with the rotated object.
-
Potentially Incompatible: Library use of
Math.randomhas been replaced withCrypto.getRandomValues(). No random numbers were used for cryptographic purposes, but this should reduce false positives in static analysis tools. Use ofCrypto.getRandomValues()may require Node 19 or higher. -
Potentially Incompatible: The default value of AnimationManager.isInitial is
now
false. This means there is no initial animation by default. This can be set to true to maintain compatibility.
Bug fix changes in 4.0 since 3.1
- ToolManager.GestureMode now works without needing to alter CSS.
- Fixed some uses of GraphObject.shadowVisible incorrectly propagating a no-shadow rule.
- Clicking on a button in GoJS no longer triggers a focus ring as if a keyboard was used.