iVis-at-Bilkent / cytoscape.js-fcose

fCoSE: a fast Compound Spring Embedder
MIT License
141 stars 25 forks source link

numeric is undefined #4

Closed TianrenWang closed 5 years ago

TianrenWang commented 5 years ago

I am getting the following error:

ERROR ReferenceError: numeric is not defined
    at Object.eval [as clone] (eval at <anonymous> (numeric-1.2.6.js:746), <anonymous>:5:9)
    at Object.svd (numeric-1.2.6.js:4147)
    at sample (cytoscape-fcose.js:888)
    at spectralLayout (cytoscape-fcose.js:1140)
    at a.run (cytoscape-fcose.js:199)
    at cytoscape.min.js:23
    at cytoscape.min.js:23
    at cytoscape.min.js:23
    at new qa (cytoscape.min.js:23)
    at zs (cytoscape.min.js:23)

I forked this https://github.com/asiftasleem/angular-2-cytoscape repo. I modified the script that calls the fcose layout (called ng-cyto.component.ts) like this:

import {Component, OnChanges, Renderer, ElementRef, Input, Output, EventEmitter} from '@angular/core';
import fcose from 'cytoscape-fcose';

declare var cytoscape: any;
.....
export class NgCytoComponent implements OnChanges {

    ......

    ngOnInit() {
        cytoscape.use( fcose );
    }

    public ngOnChanges(): any {
        this.render();
        console.log(this.el.nativeElement);
    }

    public render() {
        let cy_container = this.renderer.selectRootElement("#cy");
        let localselect = this.select;
        let cy = cytoscape({
            container : cy_container,
            layout: this.layout,   // <----------- { name: 'fcose' }
            minZoom: this.zoom.min,
            maxZoom: this.zoom.max,
            style: this.style,
            elements: this.elements,
        });

        ....
    }

}

Any help would be appreciated.

hasanbalci commented 5 years ago

@TianrenWang Since I am not so familiar with Angular.js, I didn't test the extension there. But I know someone who encountered with the same error and he fixed it by adding the path of numeric in node modules ("node_modules/numeric/numeric-1.2.6.min.js") to the scripts field in the angular.json file (projects -> app_name -> architect -> build -> options -> scripts). I don't know whether this is a proper solution, but it can solve your problem for now.

TianrenWang commented 5 years ago

Thank you very much. That did indeed solve the problem.

hasanbalci commented 4 years ago

Important: Beginning from v1.2.2, numeric.js dependency is removed from fCoSE. Before v1.2.2, angular.js was requiring a path to be added into angular.json file as mentioned above. From now on, there is no need to this path and users who added this path before must remove it when they update fCoSE to a version >=1.2.2.

Thanks!