All Projects → NorthwoodsSoftware → Gojs React

NorthwoodsSoftware / Gojs React

Licence: other
A set of React components to manage GoJS Diagrams, Palettes, and Overviews

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Gojs React

Deep Viz
A React component library, providing concise and beautiful diversity charts with Canvas, SVG, E-map, WebGL, Dom, based on data visualization experience and commercial data display practice.
Stars: ✭ 55 (-57.69%)
Mutual labels:  diagram, react-components
Rxjs Diagrams
React Components for visualising RxJS observables and operators
Stars: ✭ 126 (-3.08%)
Mutual labels:  react-components
Tikzcd Editor
A simple visual editor for creating commutative diagrams.
Stars: ✭ 1,627 (+1151.54%)
Mutual labels:  diagram
Structurizr Php
🗺 https://structurizr.com library for PHP - generate architecture diagrams from code
Stars: ✭ 118 (-9.23%)
Mutual labels:  diagram
React Workshop
⚒ 🚧 This is a workshop for learning how to build React Applications
Stars: ✭ 114 (-12.31%)
Mutual labels:  react-components
React Structured Data
React Structured Data provides an easy way to add structured data to your React apps
Stars: ✭ 120 (-7.69%)
Mutual labels:  react-components
React Native Firebase Chat
React Native chat application using firebase.
Stars: ✭ 113 (-13.08%)
Mutual labels:  react-components
React Splitters
React splitter component, written in TypeScript.
Stars: ✭ 127 (-2.31%)
Mutual labels:  react-components
Orama
Plug and play React charts
Stars: ✭ 125 (-3.85%)
Mutual labels:  react-components
React Lazy
Universal lazy loader components using IntersectionObserver for React
Stars: ✭ 118 (-9.23%)
Mutual labels:  react-components
Gatsby Docs Kit
📃Easy to Maintain Markdown/React Documentation Static Websites
Stars: ✭ 117 (-10%)
Mutual labels:  react-components
Component Docs
📝 Simple documentation for your React components
Stars: ✭ 116 (-10.77%)
Mutual labels:  react-components
React Rainbow
🌈 React Rainbow Components. Build your web application in a snap.
Stars: ✭ 1,662 (+1178.46%)
Mutual labels:  react-components
Advanced React Patterns
This is the latest advanced react patterns workshop
Stars: ✭ 1,899 (+1360.77%)
Mutual labels:  react-components
Quiver
A modern commutative diagram editor for the web.
Stars: ✭ 1,799 (+1283.85%)
Mutual labels:  diagram
Rough Charts
📈 A responsive, composable react charting library with a hand-drawn style.
Stars: ✭ 1,485 (+1042.31%)
Mutual labels:  react-components
Nomnoml
The sassy UML diagram renderer
Stars: ✭ 1,685 (+1196.15%)
Mutual labels:  diagram
Gakki
🌼🌸 A React Native App for Mastodon. 一个由React Native编写的长毛象客户端App🦋
Stars: ✭ 120 (-7.69%)
Mutual labels:  react-components
Devextreme Reactive
Business React components for Bootstrap and Material-UI
Stars: ✭ 1,800 (+1284.62%)
Mutual labels:  react-components
React
Modern and minimalist React UI library.
Stars: ✭ 2,546 (+1858.46%)
Mutual labels:  react-components

gojs-react

By Northwoods Software for GoJS 2.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.

Installation

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.

NPM

npm install --save gojs-react

CDN

<script src="https://unpkg.com/gojs-react/dist/gojsreact.production.min.js"></script>

Usage

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.

<ReactDiagram
  ref={this.diagramRef}
  divClassName='diagram-component'
  initDiagram={this.initDiagram}
  nodeDataArray={this.props.nodeDataArray}
  linkDataArray={this.props.linkDataArray}
  modelData={this.props.modelData}
  onModelChange={this.props.onModelChange}
  skipsDiagramUpdate={this.props.skipsDiagramUpdate}
/>

<ReactPalette
  initPalette={this.initPalette}
  divClassName='palette-component'
  nodeDataArray={[{ key: 0, text: 'Alpha' }]}
/>

<ReactOverview
  initOverview={this.initOverview}
  divClassName='overview-component'
  observedDiagram={this.state.observed}
/>

Component Props

initDiagram/initPalette/initOverview

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.

function initDiagram() {
  const $ = go.GraphObject.make;

  const diagram = $(go.Diagram,
    {
      'undoManager.isEnabled': true,  // must be set to allow for model change listening
      // 'undoManager.maxHistoryLength': 0,  // uncomment disable undo/redo functionality
      model: $(go.GraphLinksModel, {
        linkKeyProperty: 'key'  // this should always be set when using a GraphLinksModel
      })
    });

  diagram.nodeTemplate =
    $(go.Node, 'Auto',  // the Shape will go around the TextBlock
      $(go.Shape, 'RoundedRectangle', { strokeWidth: 0, fill: 'white' },
        // Shape.fill is bound to Node.data.color
        new go.Binding('fill', 'color')),
      $(go.TextBlock,
        { margin: 8 },  // some room around the text
        // TextBlock.text is bound to Node.data.key
        new go.Binding('text', 'key'))
    );

  return diagram;
}

divClassName

Specifies the CSS classname to add to the rendered div. This should usually specify a width/height.

.diagram-component {
  width: 400px;
  height: 400px;
  border: 1px solid black;
}

nodeDataArray (ReactDiagram and ReactPalette only)

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.

nodeDataArray: [
  { key: 'Alpha', color: 'lightblue' },
  { key: 'Beta', color: 'orange' },
  { key: 'Gamma', color: 'lightgreen' },
  { key: 'Delta', color: 'pink' }
]

Optional - linkDataArray (ReactDiagram and ReactPalette only)

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.

linkDataArray: [
  { key: -1, from: 'Alpha', to: 'Beta' },
  { key: -2, from: 'Alpha', to: 'Gamma' },
  { key: -3, from: 'Beta', to: 'Beta' },
  { key: -4, from: 'Gamma', to: 'Delta' },
  { key: -5, from: 'Delta', to: 'Alpha' }
]

Optional - modelData (ReactDiagram and ReactPalette only)

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.

skipsDiagramUpdate (ReactDiagram only)

Specifies whether the component should skip updating, often set to true when updating state from a GoJS model change. This flag is checked during shouldComponentUpdate.

Optional - onModelChange (ReactDiagram only)

Specifies a function to be called when a GoJS transaction has completed. This function will typically be responsible for updating React/Redux state.

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.

function handleModelChange(data) {
  const insertedNodeKeys = data.insertedNodeKeys;
  const modifiedNodeData = data.modifiedNodeData;
  const removedNodeKeys = data.removedNodeKeys;
  const insertedLinkKeys = data.insertedLinkKeys;
  const modifiedLinkData = data.modifiedLinkData;
  const removedLinkKeys = data.removedLinkKeys;

  // ... make state changes
}

observedDiagram (ReactOverview only)

Specifies the go.Diagram which the Overview will observe.

License

This project is intended to be used alongside GoJS, and is covered by the GoJS software license.

Copyright 1998-2021 by Northwoods Software Corporation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].