1 <html class="no-js" lang="en">
3 <meta charset="utf-8" />
4 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
5 <meta name="viewport" content="width=device-width">
6 <title>%(titre)s</title>
7 <script src="js/jquery.min.js"></script>
8 <script src="js/sigma.min.js"></script>
9 <script src="js/sigma.parseGexf.js"></script>
12 <div class="container">
14 <h2 class="span12" id="post-title">%(titre)s</h2>
15 <div class="span12 sigma-parent" id="sigma-example-parent">
17 <div class="sigma-expand" id="sigma-example"></div>
21 <script type="text/javascript">
23 // Instanciate sigma.js and customize rendering :
24 //var sigInst = sigma.init(document.getElementById('sigma-example')).drawingProperties({
25 var sigInst = sigma.init($('#sigma-example')[0]).drawingProperties({
26 defaultLabelColor: '#fff',
27 //defaultLabelSize: 10,
28 labelSize: 'proportional',
30 defaultLabelBGColor: '#fff',
31 defaultLabelHoverColor: '#000',
34 defaultEdgeType: 'line'
44 // Parse a GEXF encoded file to fill the graph
45 // (requires "sigma.parseGexf.js" to be included)
46 sigInst.parseGexf('%(gexffile)s');
52 // This function is used to generate the attributes list from the node attributes.
53 // Since the graph comes from GEXF, the attibutes look like:
55 // { attr: 'Lorem', val: '42' },
56 // { attr: 'Ipsum', val: 'dolores' },
58 // { attr: 'Sit', val: 'amet' }
60 function attributesToString(attr) {
63 return '<li>' + o.attr + ' : ' + o.val + '</li>';
68 function showNodeInfo(event) {
69 popUp && popUp.remove();
72 sigInst.iterNodes(function(n){
74 },[event.content[0]]);
77 '<div class="node-info-popup"></div>'
79 // The GEXF parser stores all the attributes in an array named
80 // 'attributes'. And since sigma.js does not recognize the key
81 // 'attributes' (unlike the keys 'label', 'color', 'size' etc),
82 // it stores it in the node 'attr' object :
83 attributesToString( node['attr']['attributes'] )
86 'node-info'+sigInst.getID()
88 'display': 'inline-block',
91 'background': 'rgba(200,120,0,0.6)',
93 'box-shadow': '0 0 4px #666',
94 'position': 'absolute',
95 'left': node.displayX,
96 'top': node.displayY+15
99 $('ul',popUp).css('margin','0 0 0 20px');
101 $('#sigma-example').append(popUp);
104 function hideNodeInfo(event) {
105 popUp && popUp.remove();
109 var greyColor = 'rgba(255,255,255,0.2)';
110 sigInst.bind('overnodes',function(event){
112 sigInst.iterNodes(function(n){
114 },[event.content[0]]);
115 var nodes = [node.id]
116 sigInst.iterNodes(function(n){
117 //if(!neighbors[n.id]){
118 if(n.color != node.color && n.label != 'F1' && n.label != 'F2') {
120 n.attr['true_color'] = n.color;
125 n.color = n.attr['grey'] ? n.attr['true_color'] : n.color;
129 }).bind('outnodes',function(){
131 sigInst.iterEdges(function(e){
132 e.color = e.attr['grey'] ? e.attr['true_color'] : e.color;
134 }).iterNodes(function(n){
135 n.color = n.attr['grey'] ? n.attr['true_color'] : n.color;
141 sigInst.bind('overnodes',showNodeInfo).bind('outnodes',hideNodeInfo).draw();
148 if (document.addEventListener) {
149 document.addEventListener("DOMContentLoaded", init, false);
151 window.onload = init;
154 <style type="text/css">
155 /* sigma.js context : */
159 -moz-border-radius: 4px;
160 -webkit-border-radius: 4px;