rcarcasses / vue-cytoscape

cytoscape.js now inside vue.js
https://rcarcasses.github.io/vue-cytoscape
MIT License
96 stars 34 forks source link

The layout in the config does not take effect when using cy-element #18

Closed herosPan closed 5 years ago

herosPan commented 5 years ago

When using cy-element, if the elements data has no position, how do you need to automatically lay out

rcarcasses commented 5 years ago

See #17, there is a great explanation on the beginning. Basically you will have to mark afterCreated as async:

async after() {
  const cy = await this.$cytoscape.instance;
  cy.layout({
    name: 'breadthfirst',
    circle: false,
    roots: '#existingnode',
    spacingFactor: 1,
    padding: 50,
    fit: true,
  }).run();
}