0

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>
Quintakov
  • 95
  • 1
  • 13

1 Answers1

1

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 ).

maxkfranz
  • 11,896
  • 1
  • 27
  • 36
  • So if I wanted to utilize all of my nodes and edges in my JSON file-- how would I go about doing that? I was looking for what the comment on this [other post](https://stackoverflow.com/questions/40317668/loading-and-using-json-for-cytoscape-js) did. – Quintakov Jan 15 '17 at 23:08