I am working on Angular 4 and I want to integrate mxGraph in my project. I have googled for it but I am not getting the full working example.
I have tried following way, but it also not working for me.
Steps I have followed:
Installed mxgraph:
npm install mxgraph --save
npm package for mxgraph: https://www.npmjs.com/package/mxgraph
Installed mxgraph-typings:
npm install lgleim/mxgraph-typings --save
Github Repo of mxgraph-typings - https://github.com/lgleim/mxgraph-typings
Now I have imported it in my component:
import {mxgraph} from 'mxgraph';
Added the following line in .angular-cli.json assets array to make the mxGraph assets available.
{"glob":"**/*", "input":"node_modules/mxgraph/javascript/src", "output": "./mxgraph"}
If I try to use it like:
const graph: mxgraph.mxGraph = new mxgraph.mxGraph(document.getElementById('graphContainer'));
And when I run
ng serve
Then I get issue/error like:
Module not found: Error: Can't resolve 'mxgraph' in 'path to my file where I have imported and used mxgraph'
Now if I try with setting mxBasePath:
const mx = require('mxgraph')({ mxImageBasePath: 'mxgraph/images', mxBasePath: 'mxgraph' });
And used like this:
const graph: mxgraph.mxGraph = mx.mxGraph(document.getElementById('graphContainer'));
And when I run
ng serve
This time also I am getting same issue/error:
Module not found: Error: Can't resolve 'mxgraph' in 'path to my file where I have imported and used mxgraph'
Is anyone have any idea of what I am missing here? Or Why is it not working?
If someone knows any other/better way of integrating mxGraph with Angular 4, then please let me know.
Thanks in Advance !!
Also, add remote of the official repo
? – Vituperate