ts-mxgraph-typings
TypeScript icon, indicating that this package has built-in type declarations

4.0.6-rc1 • Public • Published

mxgraph-typings

Typescript Type Definitions / Typings for https://github.com/jgraph/mxgraph

The typings are complete but many optional parameters are currently declared mandatory although optional, many parameters are any typed and much of the JSDoc is not properly formatted/tagged.

Install via

npm install -D ts-mxgraph-typings

Usage (Working in Angular 8.x)

import { mxgraph } from 'mxgraph'; // Typings only - no code!
 
declare var require: any;
 
const mx: typeof mxgraph = require('mxgraph')({
    mxBasePath: 'mxgraph'
});
 
@Component(...)
export class DashboardComponent {
 
    @ViewChild('dashboard') dashboard: ElementRef;
 
    private graph: mxgraph.mxGraph; 
    
    ngAfterViewInit() {
            this.graph = new mx.mxGraph(this.dashboard.nativeElement);
            xml = "<?xml version='1.0' encoding='UTF-8'?><mxGraphModel><root><mxCell id='0'/>...</root></mxGraphModel>";
            
            let doc = mx.mxUtils.parseXml(xml);
            let codec = new mx.mxCodec(doc);
            codec.decode(doc.documentElement, this.graph.getModel());
    }
}

If you are using the Angular CLI you can add the following line to your .angular=cli.json assets array to make the mxGraph assets available

{"glob":"**/*", "input":"node_modules/mxgraph/javascript/src", "output": "./mxgraph"}

Readme

Keywords

Package Sidebar

Install

npm i ts-mxgraph-typings

Weekly Downloads

27

Version

4.0.6-rc1

License

MIT

Unpacked Size

887 kB

Total Files

5

Last publish

Collaborators

  • rabpeter