Quintakov
Quintakov

Reputation: 97

Loading JSON file into Cytoscape.js

New to Cytoscape.js. I exported a network file in the .cyjs format from Cytoscape but would like to visualize it in Cytoscape.js now.I've goten stuck in integrating the .cyjs file into my javascript. I've made the following template from the Cytoscape.js tutorial provided online:

<!doctype html>

<html>

<head>
    <meta charset="utf-8"></meta>
    <title>Tutorial 1: Getting Started</title>
    <script src="cytoscape.js"></script>
</head>

<style>
    #cy {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0px;
        left: 0px;
    }
</style>

<body>
    <div id="cy"></div>
    <script>
        var cy = cytoscape({
                    container: document.getElementById('cy'),
                    elements: [
                      //nodes

                      //edges

                    ],
                    style: [
                      {
                        selector: 'node',
                        style: {
                          shape: 'circle',
                          'background-color': 'blue',
                          label: 'data(id)'
                        }
                      }]
                    });
                      cy.layout({
                        name: 'circle'
});
    </script>
</body>

</html>

Upvotes: 0

Views: 1760

Answers (1)

maxkfranz
maxkfranz

Reputation: 12242

Cytoscape desktop erroneously names the exported file with the extension .cyjs. It's just a JSON file, so rename it to .json. Just point Cytoscape.js to the particular parts of the JSON you want to use (when you call cytoscape( myOptions ).

Upvotes: 1

Related Questions