Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read properties of null (reading 'je') #41

Closed
jamesscottbrown opened this issue Jan 19, 2022 · 5 comments
Closed
Labels

Comments

@jamesscottbrown
Copy link

I installed the latest version of this package with npm install, and then tried to use the node REPL to lay out a simple network.

However, this failed with the error Uncaught TypeError: Cannot read properties of null (reading 'je').

$ node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> const cytoscape = require('cytoscape')
undefined
> const elk = require('cytoscape-elk')
undefined
> 
> 
> const nodes = [
...       {"id": "Alice"},
...       {"id": "Bob"},
...       {"id": "Carol"}
...   ];
undefined
> 
> const links = [
...     {"source": "Alice", "target": "Bob"}, // Alice → Bob
...     {"source": "Bob", "target": "Carol"} // Bob → Carol
... ];
undefined
> 
> const elements = [
...     ...nodes.map(n => ({data: n})),
...     ...links.map(n => ({data: n}))
... ];
undefined
> 
> cytoscape.use(elk);
[Function: cytoscape] {
  use: [Function (anonymous)],
  warnings: [Function (anonymous)],
  version: '3.20.0',
  Stylesheet: [Function: Stylesheet],
  stylesheet: [Function: Stylesheet]
}
> 
> let cy = cytoscape({ elements });
undefined
> cy.layout({name: 'elk', animate: false}).run();
<ref *1> Layout {
  options: {
    nodeDimensionsIncludeLabels: false,
    fit: true,
    padding: 20,
    animate: false,
    animateFilter: [Function: animateFilter],
    animationDuration: 500,
    animationEasing: undefined,
    transform: [Function: transform],
    ready: undefined,
    stop: undefined,
    elk: { aspectRatio: 1, algorithm: undefined },
    priority: [Function: priority],
    name: 'elk',
    cy: Core { _private: [Object] },
    eles: Array {
      '0': [Array],
      '1': [Array],
      '2': [Array],
      '3': [Array],
      '4': [Array],
      length: 5,
      _private: [Object]
    }
  },
  _private: {
    cy: Core { _private: [Object] },
    listeners: [],
    emitter: Emitter {
      qualifierCompare: [Function: qualifierCompare],
      eventMatches: [Function: eventMatches],
      addEventFields: [Function: addEventFields],
      callbackContext: [Function: callbackContext],
      beforeEmit: [Function: beforeEmit],
      afterEmit: [Function: afterEmit],
      bubble: [Function: bubble],
      parent: [Function: parent],
      context: [Circular *1],
      listeners: [],
      emitting: 0
    }
  }
}
> Uncaught TypeError: Cannot read properties of null (reading 'je')
    at Jqd (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5706:225)
    at Iqd (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5685:188)
    at h.dispatch (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5984:473)
    at h.saveDispatch (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5984:603)
> 

Showing just the code:

const cytoscape = require('cytoscape')
const elk = require('cytoscape-elk')

const nodes = [
      {"id": "Alice"},
      {"id": "Bob"},
      {"id": "Carol"}
  ];

const links = [
    {"source": "Alice", "target": "Bob"}, // Alice → Bob
    {"source": "Bob", "target": "Carol"} // Bob → Carol
];

const elements = [
    ...nodes.map(n => ({data: n})),
    ...links.map(n => ({data: n}))
];

cytoscape.use(elk);

let cy = cytoscape({ elements });
cy.layout({name: 'elk', animate: false}).run();

I have also tried to use the library with import, but encountered the same error.

I think this is a duplicate of #3, which was marked as stale and closed without resolution.

@maxkfranz
Copy link
Member

@stale
Copy link

stale bot commented Mar 1, 2022

This issue has been automatically marked as stale, because it has not had activity within the past 14 days. It will be closed if no further activity occurs within the next 7 days. If a feature request is important to you, please consider making a pull request. Thank you for your contributions.

@stale stale bot added the stale label Mar 1, 2022
@stale stale bot closed this as completed Mar 8, 2022
@phodal
Copy link

phodal commented Mar 20, 2022

same issue, any ideas to fixed it ? already use web-worker, but still got the Error.

@MaximLukianchuk
Copy link

same error, any news?

@hvgab
Copy link

hvgab commented Jun 29, 2022

"algorithm" should be without "elk."-prefix, the rest should have the prefix.
example:

var elk_options = {
    name: 'elk',
    elk: {
      'algorithm': 'layered',
      'elk.direction': 'RIGHT'
    }
  }

cy.layout(elk_options).run();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants