Git Product home page Git Product logo

maxgraph's Introduction

maxGraph

npm version build status

maxGraph is a TypeScript library which can display and allow interaction with vector diagrams. At a high level, it provides:

  • Nodes, also known as vertices which are typically represented by shapes like rectangles.
  • Edges which can be lines and arrows which normally point between one node and another.

It provides many of the diagramming features which would be expected by a piece of presentation software like Microsoft® PowerPoint™ or LibreOffice® Impress such as being able to resize, move or rotate nodes, but has a stronger focus on automatic layout algorithms and applications of Graph Theory. It is suited towards software which requires finer-grained customization of functionality than off-the-shelf packages.

The maxGraph library uses no third-party software, it requires no plugins and can be integrated in virtually any framework (it's vanilla JS).

maxGraph is the successor of mxGraph which is now end of life. At first, it provides the same features as mxGraph and adds

  • TypeScript support
  • maintained npm package
  • modern modular, tree shakable, version of mxGraph to reduce the whole package size

New features will follow.

Browser support

Chrome, Edge, Firefox, Safari, Chromium based browsers (Brave, Opera, ....) for mobile and desktop.

Project status

maxGraph is under active development and is in alpha. Please try it in your application and submit an issue if you think that something is not working.

You can also test the project by running the Storybook examples or build the npm package locally to get the latest changes.

Install

Install the latest version of maxGraph from the npm registry.

npm

npm install @maxgraph/core

yarn

yarn add @maxgraph/core

pnpm

pnpm add @maxgraph/core

Getting Started

Assuming your page defines an element with the id graph-container, the following will display a rectangle connected to an orange circle.

import {type CellStyle, Graph, InternalEvent} from '@maxgraph/core';

const container = <HTMLElement>document.getElementById('graph-container');
// Disables the built-in context menu
InternalEvent.disableContextMenu(container);

const graph = new Graph(container);
graph.setPanning(true); // Use mouse right button for panning
// Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0).
const parent = graph.getDefaultParent();

// Adds cells to the model in a single step
graph.batchUpdate(() => {
  const vertex01 = graph.insertVertex(parent, null, 'a regular rectangle', 10, 10, 100, 100);
  const vertex02 = graph.insertVertex(parent, null, 'a regular ellipse', 350, 90, 50, 50, <CellStyle>{shape: 'ellipse', fillColor: 'orange'});
  graph.insertEdge(parent, null, 'a regular edge', vertex01, vertex02);
});

You will see something like in the following maxGraph panning demo:

maxGraph panning demo

For more details, have a look at the storybook stories.

TypeScript support

maxGraph is written in TypeScript and provides type definitions so maxGraph can be easily integrated into TypeScript projects.

maxGraph requires TypeScript 3.8 or greater.

Support

For usage question, please open a new discussion on GitHub. You can also use GitHub discussions for other topics like maxGraph development or to get the latest news.

Until we provide a complete documentation, you can check the mxGraph resources

Migrating from mxGraph

maxGraph APIs are not fully compatible with mxGraph APIs. The concepts are the same, so experienced mxGraph users should be able to switch from mxGraph to maxGraph without issues.

For a complete guide, see the dedicated migration page.

History

On 2020-11-09, the development on mxGraph stopped and mxGraph became effectively end of life.

On 2020-11-12, a fork of the mxGraph was created with a call to Contributors.

12 Nov 2020.

If you are interested in becoming a maintainer of mxGraph please comment on issue #1

Initial objectives:

  • The first priority is to maintain a working version of mxGraph and its npm package
  • The ambitious stretch goal is to refactor the codebase to create a modern modular, tree shakable, version of mxGraph to reduce the whole package size.

-- Colin Claverie

The project was then renamed on 2021-06-02 into maxGraph due to licensing issue.

Starting from the mxGraph 4.2.2 release, we

  • moved code to ES9
  • removed Internet Explorer specific code
  • migrated to TypeScript, based on the work initiated in typed-mxgraph
  • migrated the examples to Storybook

Development

Clean former mxGraph tags

Ensure you don't have the former mxGraph tags locally (see #92 fore more details):

git fetch --all --tags --prune

Setting up local development environment

In the project root directory, execute

$ npm install

To watch the core package, execute

$ npm run dev

and select @mxgraph/core.

To run the html(vanilla-js) version of Storybook, execute

$ npm run dev

and select @mxgraph/html.

Since both commands are in watch mode, so it's recommended to open two terminals and run them separately. When a file is saved from the core package, the html storybook will be automatically updated.

Building the npm package for usage in external project

Run

  • from the project root: npm install
  • then, from the packages/core folder: npm pack

The packages/core folder or the generated packages/core/maxgraph-core-***.tgz file are now ready for use in an external project, using npm link or npm install.

Examples of use can be found in the maxgraph-integration-examples repository.

Release

See the dedicated release page.

maxgraph's People

Contributors

mcyph avatar alderg avatar davidjgraph avatar junsikshim avatar tbouffard avatar mayorovad avatar jgadsden avatar mehyaa avatar brendonboshell avatar ilexwg avatar coclav avatar aminosbh avatar andrea11 avatar niccoconnor avatar msamanzhol42 avatar bitdeli-chef avatar cd-yang avatar chomtana avatar davedwards avatar f-wrobel avatar gkaganas-mparticle avatar lgleim avatar marclaporte avatar mosinnik avatar pslocom avatar internetscooter avatar holyhope avatar quoque avatar rojerluo avatar zhangbiggs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.