javascript - How to get cytoscape.js to work -


i'm having problems getting simple cytoscape.js example work @ all. here code in pastebin link

i'm new javascript in general, may basic mistake. console.log statements put through function calls indicate cy function getting called , executed, , browser console doesn't seem t throw errors, cannot graph show. there i'm missing in definition?

i tried make minimalistic possible. code verbatim copied of cytoscape.js examples. cy.cytoscape relevant function. calling code @ bottom

$('#cy').cytoscape({   .......  <body>   <div id="cy"></div> </body> 

edit: jsfiddle link

i have made changes in code.now working fine. please @ link below

css

    body {        font: 14px helvetica neue, helvetica, arial, sans-serif;     }      #cy {       height: 100%;       width: 100%;       position: absolute;       left: 0;       top: 0;     } 

javascript

 $(function() { // on dom ready          $('#cy').cytoscape({              style: cytoscape.stylesheet()                 .selector('node')                 .css({                 'content': 'data(name)',                     'text-valign': 'center',                     'color': 'white',                     'text-outline-width': 2,                     'text-outline-color': '#888'             })                 .selector('edge')                 .css({                 'target-arrow-shape': 'triangle'             })                 .selector(':selected')                 .css({                 'background-color': 'black',                     'line-color': 'black',                     'target-arrow-color': 'black',                     'source-arrow-color': 'black'             })                 .selector('.faded')                 .css({                 'opacity': 0.25,                     'text-opacity': 0             }),              elements: {                 nodes: [{                     data: {                         id: 'j',                         name: 'jerry'                     }                 }, {                     data: {                         id: 'e',                         name: 'elaine'                     }                 }, {                     data: {                         id: 'k',                         name: 'kramer'                     }                 }, {                     data: {                         id: 'g',                         name: 'george'                     }                 }],                 edges: [{                     data: {                         source: 'j',                         target: 'e'                     }                 }, {                     data: {                         source: 'j',                         target: 'k'                     }                 }, {                     data: {                         source: 'j',                         target: 'g'                     }                 }, {                     data: {                         source: 'e',                         target: 'j'                     }                 }, {                     data: {                         source: 'e',                         target: 'k'                     }                 }, {                     data: {                         source: 'k',                         target: 'j'                     }                 }, {                     data: {                         source: 'k',                         target: 'e'                     }                 }, {                     data: {                         source: 'k',                         target: 'g'                     }                 }, {                     data: {                         source: 'g',                         target: 'j'                     }                 }]             },              ready: function() {                 window.cy = this;                  // giddy up...                  cy.elements().unselectify();                  cy.on('tap', 'node', function(e) {                     var node = e.cytarget;                     var neighborhood = node.neighborhood().add(node);                      cy.elements().addclass('faded');                     neighborhood.removeclass('faded');                 });                  cy.on('tap', function(e) {                     if (e.cytarget === cy) {                         cy.elements().removeclass('faded');                     }                 });             }          });      }); // on dom ready 

html

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script> <body>   <div id="cy"></div> </body> 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -