This sample shows many examples of how to use the predefined checkboxes inside GoJS and how they can be customized. These premade Panels exist for common structures needed in many Node templates. To create a checkbox call:
go.GraphObject.build('CheckBox', null, 'choice1')
null
is in place of the optional properties object, 'choice1'
is the name of the Shape that has its GraphObject.visible
property toggled. This represents the value of the checkbox.
For more inforamtion on these predefined panels see Buttons. You can see how they are defined in Buttons.js.
Below is the Diagram.model's Model.modelData. It will update automatically as the model data changes through interactions with the Diagram.
The "Table" Panel, Panel.Table, arranges objects in rows and columns. Each object in a Table Panel is put into the cell indexed by the value of GraphObject.row and GraphObject.column. The panel will look at the rows and columns for all of the objects in the panel to determine how many rows and columns the table should have. More information can be found in the GoJS Intro.
It is sometimes useful to display a variable number of elements in a node by data binding to a JavaScript Array. In GoJS, this is simply achieved by binding (or setting) Panel.itemArray. The Panel will create an element in the panel for each value in the Array. More information can be found in the GoJS Intro.
GoJS defines several Panels for common uses. These include "Button", "TreeExpanderButton", "SubGraphExpanderButton", "PanelExpanderButton", "ContextMenuButton", and "CheckBoxButton". "ContextMenuButton"s are typically used inside of "ContextMenu" Panels; "CheckBoxButton"s are used in the implementation of "CheckBox" Panels.
These predefined panels can be used as if they were Panel-derived classes in calls to GraphObject.make. They are implemented as simple visual trees of GraphObjects in Panels, with pre-set properties and event handlers.
More information can be found in the GoJS Intro.
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 Intro.