Gathering detailed insights and metrics for gojs-react
Gathering detailed insights and metrics for gojs-react
Gathering detailed insights and metrics for gojs-react
Gathering detailed insights and metrics for gojs-react
react-gojs
GoJS React integration
eigen-gojs
基于gojs封装的编辑器组件,参考[AntV g6-editor](https://www.yuque.com/antv/g6-editor)设计,目前仅提供react版本
peacetrue-gojs
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
custome-go-react
A set of React components to manage GoJS Diagrams, Palettes, and Overviews
A set of React components to manage GoJS Diagrams, Palettes, and Overviews
npm install gojs-react
Typescript
Module System
Node Version
NPM Version
TypeScript (83.16%)
JavaScript (16.84%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
243 Stars
42 Commits
19 Forks
8 Watchers
3 Branches
3 Contributors
Updated on May 07, 2025
Latest Version
1.1.3
Package Id
gojs-react@1.1.3
Unpacked Size
56.49 kB
Size
8.88 kB
File Count
13
NPM Version
10.2.4
Node Version
20.11.0
Published on
May 07, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
This project provides React components for GoJS Diagrams, Palettes, and Overviews to simplify usage of GoJS within a React application. See the gojs-react-basic project for example usage and the Intro page on using GoJS with React for more information. Some more detail on the implementation of these components can be found here.
gojs-react can be installed via NPM or used via CDN. This package has peer dependencies on GoJS and React, so make sure those are also installed or included on your page.
1npm install --save gojs-react
1<script src="https://cdn.jsdelivr.net/npm/gojs-react/dist/gojsreact.production.min.js"></script>
This package provides three components - ReactDiagram, ReactPalette, and ReactOverview - corresponding to the related GoJS classes. The gojs-react-basic repository provides example usage. Feel free to use these components as examples for setting up your own React components for GoJS. If you'd like to do so, we suggest reading more about the implementation of these components here.
1<ReactDiagram 2 ref={this.diagramRef} 3 divClassName='diagram-component' 4 style={{ backgroundColor: '#eee' }} 5 initDiagram={this.initDiagram} 6 nodeDataArray={this.props.nodeDataArray} 7 linkDataArray={this.props.linkDataArray} 8 modelData={this.props.modelData} 9 onModelChange={this.props.onModelChange} 10 skipsDiagramUpdate={this.props.skipsDiagramUpdate} 11/> 12 13<ReactPalette 14 initPalette={this.initPalette} 15 divClassName='palette-component' 16 style={{ backgroundColor: '#eee' }} 17 nodeDataArray={[{ key: 0, text: 'Alpha' }]} 18/> 19 20<ReactOverview 21 initOverview={this.initOverview} 22 divClassName='overview-component' 23 style={{ backgroundColor: '#eee' }} 24 observedDiagram={this.state.observed} 25/>
Specifies a function that is reponsible for initializing and returning a GoJS Diagram, Palette, or Overview. This is where the model and templates should be instantiated. Node and link data do not need to be set up here, as they will be passed in as separate props.
In the case of an Overview, this is an optional property and when not provided, an Overview with default properties and centered content will be created.
1function initDiagram() {
2 const $ = go.GraphObject.make;
3
4 const diagram = $(go.Diagram,
5 {
6 'undoManager.isEnabled': true, // must be set to allow for model change listening
7 // 'undoManager.maxHistoryLength': 0, // uncomment disable undo/redo functionality
8 model: $(go.GraphLinksModel, {
9 linkKeyProperty: 'key' // this should always be set when using a GraphLinksModel
10 })
11 });
12
13 diagram.nodeTemplate =
14 $(go.Node, 'Auto', // the Shape will go around the TextBlock
15 $(go.Shape, 'RoundedRectangle', { strokeWidth: 0, fill: 'white' },
16 // Shape.fill is bound to Node.data.color
17 new go.Binding('fill', 'color')),
18 $(go.TextBlock,
19 { margin: 8 }, // some room around the text
20 // TextBlock.text is bound to Node.data.key
21 new go.Binding('text', 'key'))
22 );
23
24 return diagram;
25}
Specifies the CSS classname to add to the rendered div. This should usually specify a width/height.
1.diagram-component { 2 width: 400px; 3 height: 400px; 4 border: 1px solid black; 5}
Specifies the style object to add to the rendered div. Uses React.CSSProperties. Using divClassName is preferred.
1style: { backgroundColor: '#333' }
Specifies the array of nodes for the Diagram's model.
Properties should not be removed when setting state, but rather set to undefined if they are no longer needed; GoJS avoids destructive merging.
1nodeDataArray: [ 2 { key: 'Alpha', color: 'lightblue' }, 3 { key: 'Beta', color: 'orange' }, 4 { key: 'Gamma', color: 'lightgreen' }, 5 { key: 'Delta', color: 'pink' } 6]
Specifies the array of links for the Diagram's model, only needed when using a GraphLinksModel, not for Models or TreeModels. If using a GraphLinksModel, make sure to set the GraphLinksModel's linkKeyProperty in the init function.
Properties should not be removed when setting state, but rather set to undefined if they are no longer needed; GoJS avoids destructive merging.
1linkDataArray: [ 2 { key: -1, from: 'Alpha', to: 'Beta' }, 3 { key: -2, from: 'Alpha', to: 'Gamma' }, 4 { key: -3, from: 'Beta', to: 'Beta' }, 5 { key: -4, from: 'Gamma', to: 'Delta' }, 6 { key: -5, from: 'Delta', to: 'Alpha' } 7]
Specifies a modelData object for the Diagram's model, only necessary when using properties that will be shared by the model as a whole. See Model.modelData.
Specifies whether the component should skip updating, often set to true when updating state originating from a GoJS model change. This flag is checked during shouldComponentUpdate. Because GoJS Palettes are read-only by default, this prop is not present on ReactPalette.
Specifies a function to be called when a GoJS transaction has completed. This function will typically be responsible for updating React/Redux state. The first argument will be the result of calling Model.toIncrementalData, summarizing the changes made in the transaction. The second argument will be the Transaction ChangedEvent; use its ChangedEvent.oldValue to get the transaction name.
It is important that state updates made in this function include setting skipsDiagramUpdate to true since the changes are known by GoJS. It will fire even when a GoJS change originated from a state update, as there could be side effects that occur in GoJS. It's a good idea to properly filter out any unnecessary changes before updating state.
Because GoJS Palettes are read-only by default, this prop is not present on ReactPalette. Although there won't be user-driven changes to a Palette's model due to the read-only nature of Palettes, changes to the nodeDataArray, linkDataArray, or modelData props described above allow for a Palette's model to be changed, if necessary.
1function handleModelChange(data) { 2 const insertedNodeKeys = data.insertedNodeKeys; 3 const modifiedNodeData = data.modifiedNodeData; 4 const removedNodeKeys = data.removedNodeKeys; 5 const insertedLinkKeys = data.insertedLinkKeys; 6 const modifiedLinkData = data.modifiedLinkData; 7 const removedLinkKeys = data.removedLinkKeys; 8 9 // ... make state changes 10}
Specifies the go.Diagram which the Overview will observe.
Gets a reference to the GoJS Diagram/Palette/Overview.
1const diagram = this.diagramRef.current.getDiagram(); 2if (diagram instanceof go.Diagram) { 3 // ... 4}
Clears the diagram and allows the next update to be treated as an initial load of the model.
1// clear out the diagram 2this.diagramRef.current.clear(); 3// provide new diagram data, which will be treated as initial data 4this.setState({ 5 nodeDataArray: [ 6 { key: 'Epsilon', color: 'lightblue' }, 7 { key: 'Zeta', color: 'orange' }, 8 { key: 'Eta', color: 'lightgreen' }, 9 { key: 'Theta', color: 'pink' } 10 ], 11 linkDataArray: [ 12 { key: -1, from: 'Epsilon', to: 'Zeta' }, 13 { key: -2, from: 'Epsilon', to: 'Eta' }, 14 { key: -3, from: 'Zeta', to: 'Zeta' }, 15 { key: -4, from: 'Zeta', to: 'Theta' }, 16 { key: -5, from: 'Theta', to: 'Epsilon' } 17 ] 18});
This project is intended to be used alongside GoJS, and is covered by the GoJS software license.
Copyright 1998-2025 by Northwoods Software Corporation.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More