All Projects → xcomponent → React Gojs

xcomponent / React Gojs

Licence: apache-2.0
GoJS React integration

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to React Gojs

Asciidoctor Kroki
Asciidoctor.js extension to convert diagrams to images using Kroki!
Stars: ✭ 55 (-6.78%)
Mutual labels:  diagram
Hello Bar
👋 Greet your visitors with a hello bar
Stars: ✭ 57 (-3.39%)
Mutual labels:  library
Material About Library
Makes it easy to create beautiful about screens for your apps
Stars: ✭ 1,099 (+1762.71%)
Mutual labels:  library
Silicompressor
A powerful, flexible and easy to use Video and Image compression library for Android.
Stars: ✭ 1,081 (+1732.2%)
Mutual labels:  library
Adrestia
APIs & SDK for interacting with Cardano.
Stars: ✭ 56 (-5.08%)
Mutual labels:  library
Pesdk React Native Demo
React Native example for PhotoEditor SDK
Stars: ✭ 57 (-3.39%)
Mutual labels:  library
Imageviewer.swift
An easy to use Image Viewer that is inspired by Facebook
Stars: ✭ 1,071 (+1715.25%)
Mutual labels:  library
Array view
Wrapper for references to array in C++.
Stars: ✭ 58 (-1.69%)
Mutual labels:  library
Tinf
Tiny inflate library (inflate, gzip, zlib)
Stars: ✭ 57 (-3.39%)
Mutual labels:  library
Cordova Mobile Spec
Apache Cordova mobile-spec
Stars: ✭ 57 (-3.39%)
Mutual labels:  library
Noexception
Java library for handling exceptions in concise, unified, and architecturally clean way.
Stars: ✭ 56 (-5.08%)
Mutual labels:  library
Countrycodepickerproject
Country Code Picker (CCP) is an android library which provides an easy way to search and select country or international phone code. Also supports Android EditText phone mask and international phone validation.
Stars: ✭ 1,085 (+1738.98%)
Mutual labels:  library
Keyboardhidemanager
Codeless manager to hide keyboard by tapping on views for iOS written in Swift
Stars: ✭ 57 (-3.39%)
Mutual labels:  library
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 (-6.78%)
Mutual labels:  diagram
Thrift
Apache Thrift
Stars: ✭ 8,821 (+14850.85%)
Mutual labels:  library
Sanity Typed Queries
A typed, zero-dependency schema generator and query builder for Sanity.
Stars: ✭ 54 (-8.47%)
Mutual labels:  library
Cdcontainers
Library of data containers and data structures for C programming language.
Stars: ✭ 57 (-3.39%)
Mutual labels:  library
Cordova Plugin Device Motion
Apache Cordova Plugin device-motion
Stars: ✭ 58 (-1.69%)
Mutual labels:  library
Lcformvalidation
Javascript based form validation library, third party library / framework agnostic.
Stars: ✭ 58 (-1.69%)
Mutual labels:  library
Macfinder
An iOS Library that helps you find the MAC Address of a specific IP
Stars: ✭ 57 (-3.39%)
Mutual labels:  library

⚠️ react-gojs is no longer under active development. Now, Northwoods provides an official React integration for GoJS: https://github.com/NorthwoodsSoftware/gojs-react. I will not add new features to this lib, only bug fixes. The migration to the official library is pretty easy. I migrated my example here.

NpmVersion npm Build Status Coverage Status TypeScript

react-gojs

react-gojs is a GoJS React integration.

Install

Install it from npm. It has peer dependencies of react and react-dom, which will have to be installed as well.

npm install --save react-gojs

or:

yarn add react-gojs

Usage

Import GojsDiagram in your React component:

import GojsDiagram from 'react-gojs';

To create a GoJS diagram, just use the GojsDiagram React component:

<GojsDiagram
    diagramId="myDiagramDiv"
    model={this.props.model}
    createDiagram={this.createDiagram}
    className="myDiagram"
    onModelChange={this.modelChangedhandler}
    updateDiagramProps={this.updateDiagramProps}
/>

GojsDiagram is a generic React component which is responsible for rendering and updating (when the model changes) the diagram. The render step is based on the model and the go.Diagram object provided as props. It acts as a go.Diagram wrapper.

GojsDiagram props:

  • diagramId: id required by GoJS.
  • model: generic model containing nodes and links.

Model type: DiagramModel<N extends BaseNodeModel, L extends LinkModel>

Example (Typescript / Javascript):

const model = {
    nodeDataArray: [
        { key: 'Alpha', color: 'lightblue' },
        { key: 'Beta', color: 'orange' },
        { key: 'Gamma', color: 'lightgreen' },
        { key: 'Delta', color: 'pink' },
        { key: 'Omega', color: 'grey' }
    ],
    linkDataArray: [
        { from: 'Alpha', to: 'Beta' },
        { from: 'Alpha', to: 'Gamma' },
        { from: 'Beta', to: 'Delta' },
        { from: 'Gamma', to: 'Omega' }
    ]
};
  • createDiagram: method called by the React component to create the customized GoJS diagram object. It enables you to customize the look and feel.

Typescript example:

const createDiagram = (diagramId: string): Diagram => {
    const $ = go.GraphObject.make;

    const myDiagram: Diagram = $(go.Diagram, diagramId, {
        initialContentAlignment: go.Spot.LeftCenter
    });

    myDiagram.nodeTemplate = $(
        go.Node,
        'Auto',
        $(go.Shape, 'RoundedRectangle', { strokeWidth: 0 }, new go.Binding('fill', 'color')),
        $(go.TextBlock, { margin: 8 }, new go.Binding('text', 'key'))
    );

    return myDiagram;
};

Javascript (ES6) example:

const createDiagram = diagramId => {
    const $ = go.GraphObject.make;

    const myDiagram = $(go.Diagram, diagramId, {
        initialContentAlignment: go.Spot.LeftCenter
    });

    myDiagram.nodeTemplate = $(
        go.Node,
        'Auto',
        $(go.Shape, 'RoundedRectangle', { strokeWidth: 0 }, new go.Binding('fill', 'color')),
        $(go.TextBlock, { margin: 8 }, new go.Binding('text', 'key'))
    );

    return myDiagram;
};
  • className: css applied to the div containing our diagram. You should define at least width and height.

Example:

.myDiagram {
    width: 70%;
    height: 400px;
}
  • onModelChange: the onModelChange event occurs when the diagram model has changed (add/remove nodes/links from the UI). This event is very useful to keep your model (provided as prop) in sync with the diagram.

For example, in a Redux environment, the diagram model should be immutable (and stored in the redux store). The onModelChange handler can dispatch actions to update the model.

  • updateDiagramProps (optional parameter): Method allows to update/modify Diagram properties dynamically once the diagram has been rendered. It gives more control to the user, as it is a user-defined. Basic implementation of the method.

Example 1:

const updateDiagramProps = (myDiagram: Diagram): void => {
	myDiagram.layout = go.GraphObject.make(go.LayeredDigraphLayout, { direction: 90 });

	// User can add more properties here.
};

Example 2:

const updateDiagramProps = (myDiagram: Diagram): void => {
	// Empty method.
};

Examples

  • Typescript: You can find a react / redux / react-gojs example + live demo here.

  • Javascript (ES6): You can find a react / react-gojs example + live demo here.

Contributing

Build and Test

yarn install
yarn build
yarn test

Submit a Pull Request

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Fix lint errors: yarn lint
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request

License

Apache License V2

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].