Giter VIP home page Giter VIP logo

cytoscape-dom-node's Introduction

cytoscape-dom-node

This extension lets you set DOM elements as nodes. When enabled providing the DOM element by setting the dom node data will cause the DOM element to be rendered on top of the node, and the node will be set to the size of the DOM element.

For a full working demo, see codepen abWdVOG.

Depenedencies

  • cytoscape ^3.19.0

Extension registration

Either import/require cytoscape-dom-node, and register it as an extension with Cytoscape:

const cytoscape = require('cytoscape');
cytoscape.use(require('cytoscape-dom-node'));

Or it can be included via a <script> tag after cytoscape, and will register itself:

<script type="text/javascript" charset="utf8" src="path/to/cytoscape.js"></script>
<script type="text/javascript" charset="utf8" src="path/to/cytoscape-dom-node.js"></script>

Usage instructions

Create a cytoscape instance and call domNode on it:

let cy = cytoscape({
    'container': document.getElementById('id-of-my-cytoscape-container'),
    'elements': [],
});

cy.domNode();

Now add a node with dom in the data, set to a DOM element:

let div = document.createElement("div");
div.innerHTML = `node ${id}`;

cy.add({
    'data': {
        'id':  id,
        'dom': div,
    },
});

The div you created will be shown as the node now.

See codepen abWdVOG for a working example.

Options

One option is supported, dom_container allows an container element to be specified which will be used for nodes instead of the element it would otherwise create and use. It is the callers responsibility to style the given element appropriately, for example:

cy.domNode({'dom_container': some_element});

cytoscape-dom-node's People

Contributors

mwri avatar engunai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.