Personal tools

User:Hisa/cytoscape test: Difference between revisions

From FANTOM5_SSTAR

Jump to: navigation, search
No edit summary
No edit summary
Line 6: Line 6:
             #cytoscapeweb { width: 100%; height: 100%; }
             #cytoscapeweb { width: 100%; height: 100%; }
         </style>
         </style>


         <div id="cytoscapeweb" style="width:100%;height:600px" resize:both;>
         <div id="cytoscapeweb" style="width:100%;height:600px" resize:both;>
Line 28: Line 26:
                 var div_id = "cytoscapeweb";
                 var div_id = "cytoscapeweb";
                  
                  
                 // you could also use other formats (e.g. GraphML) or grab the network data via AJAX
                                var xml = '\
 
                 <graphml>\
                 var sif = 'node1 typeA node2 node3 node4 node5\nnode2 typeB node6';
                  <key id="label" for="all" attr.name="label" attr.type="string"/>\
                  <key id="weight" for="node" attr.name="weight" attr.type="double"/>\
                  <graph edgedefault="directed">\
                    <node id="1">\
                        <data key="label">A</data>\
                        <data key="weight">2.0</data>\
                    </node>\
                    <node id="2">\
                        <data key="label">B</data>\
                        <data key="weight">1.5</data>\
                    </node>\
                    <node id="3">\
                        <data key="label">C</data>\
                        <data key="weight">1.0</data>\
                    </node>\
                    <edge source="1" target="2">\
                        <data key="label">A to B</data>\
                    </edge>\
                    <edge source="1" target="3">\
                        <data key="label">A to C</data>\
                    </edge>\
                  </graph>\
                 </graphml>\
                ';
                  
                  
                 // initialization options
                 // initialization options
Line 40: Line 61:
                 };
                 };
                  
                  
                // init and draw
                 var vis = new org.cytoscapeweb.Visualization("cytoscapeweb", options);
                 var vis = new org.cytoscapeweb.Visualization(div_id, options);
 
                 vis.draw({ network: sif });
// draw
                                var draw_options = {
                    // your data goes here
                    network: xml,
                   
                    // show edge labels too
                    edgeLabelsVisible: true,
                   
                    // let's try another layout
                    layout: "Tree",
                   
                    // hide pan zoom
                    panZoomControlVisible: false
                };
 
                 vis.draw(draw_options);
             };
             };
         </script>
         </script>

Revision as of 16:31, 27 June 2012

Cytoscape Web will replace the contents of this div with your graph.