]> khamidou — GitHub mirrors - Projet_IC05.git/commitdiff
changements d'affichage
authorkarim hamidou <khamidou@gmail.com>
Tue, 11 Dec 2012 17:12:26 +0000 (18:12 +0100)
committerkarim hamidou <khamidou@gmail.com>
Tue, 11 Dec 2012 17:12:26 +0000 (18:12 +0100)
js/css/main.css
js/imgs/pause_24.png [new file with mode: 0644]
js/imgs/pause_redo.png [new file with mode: 0644]
js/imgs/play_24.png [new file with mode: 0644]
js/imgs/play_redo.png [new file with mode: 0644]
js/index.html
js/js/main.js

index 32b1ad679259ae29b223daa0c63bd138dcd03366..3014694f52021cc471e94e9b0b8d5a297e91e69e 100755 (executable)
@@ -15,16 +15,25 @@ h2.title {
 }
 
 #graphWrapper {
+    position: relative;
     float: left;
     width: 760px;
     margin: 0 auto;
-    background-color: #303030;
+    background-color: rgba(48, 48, 48, 0.45); /* <=> #303030 */
+    //background-image: url('../imgs/background.png');
+    background-image: -webkit-gradient(0deg, #fff, #000);
 }
 
 #graphWrapper #scale {
 
 }
 
+.ppButton {
+    position: absolute;
+    bottom: 1px;
+    right: 0px;
+}
+
 #legend {
     float: left;
     width: 192px;
diff --git a/js/imgs/pause_24.png b/js/imgs/pause_24.png
new file mode 100644 (file)
index 0000000..34dffa4
Binary files /dev/null and b/js/imgs/pause_24.png differ
diff --git a/js/imgs/pause_redo.png b/js/imgs/pause_redo.png
new file mode 100644 (file)
index 0000000..4ad58f7
Binary files /dev/null and b/js/imgs/pause_redo.png differ
diff --git a/js/imgs/play_24.png b/js/imgs/play_24.png
new file mode 100644 (file)
index 0000000..511b9e5
Binary files /dev/null and b/js/imgs/play_24.png differ
diff --git a/js/imgs/play_redo.png b/js/imgs/play_redo.png
new file mode 100644 (file)
index 0000000..0cea725
Binary files /dev/null and b/js/imgs/play_redo.png differ
index 591404aa958fe82982db8caa59da9eddd39e3a85..b19af4192e8a0809431d88f088c24b7403cc8d66 100755 (executable)
         <h2 class="title">Les élections, tweetées</h2>
 
         <div id="graphWrapper">
-            <div id="graphCanvas"></div>
+            <div id="graphCanvas">
+            
+                 <img class="ppButton" src="imgs/play_24.png"></img>
+            </div>
             <div id="scale"></div>
         </div>
         <div id="legend">
index 4b5bee68d05fbfe1ee8532c3e7ea356954368b69..5d759ee4cd34226086d2644a85b214024be5431e 100755 (executable)
@@ -1,20 +1,27 @@
 $(document).ready(function() {
-    d3.json("miserables.json", setup);
+    $(".ppButton").click(handlePlayPause);
+    $.ajax("full.json", {success :setup});
+    /*
     window.setTimeout(step1, 2000);
     window.setTimeout(step2, 5000);
     window.setTimeout(step3, 5000);
+    */
 });
 
 function plotterMouseoverHandler(n, v, l, x, y) {
 }
 
-function setup() {
+var jsonData = {};
+
+function setup(json) {
+    jsonData = json;
+
     var w = 760,
         h = 500;
 
     force = d3.layout.force()
-        .gravity(.05)
-        .distance(100)
+        .gravity(.01)
+        .distance(400)
         .charge(-30)
         .size([w, h]);
 
@@ -35,6 +42,8 @@ function setup() {
           .attr("x2", function(d) { return d.target.x; })
           .attr("y2", function(d) { return d.target.y; });
     });
+    //step2();
+    stepN();
 }
 
 function restart() {
@@ -111,6 +120,70 @@ function step3() {
    restart();
 }
 
+var displayed_nodes = [];
+var count = 0;
+var NUMELEMENTS = 2;
+function stepN() {
+    displayed = jsonData.edges.splice(count, count + NUMELEMENTS); 
+    validEdges = [];
+    validNodes = [];
+
+    for(var i = 0; i < displayed.length; i++) {
+        if("destination" in displayed[i] && "source" in displayed[i]) {
+            validEdges.push(displayed[i]);
+            var dest = displayed[i]["destination"];
+            var src = displayed[i]["source"];
+
+            // cherche le noeud destination correspondant
+            for(var j = 0; j < jsonData["nodes"].length; j++) {
+                if(jsonData["nodes"][j]["nodeName"] == dest) {
+                    validNodes.push(jsonData["nodes"][j]);
+                    break;
+                }
+            }
+            // fait figurer les noeuds sources 
+            for(var j = 0; j < jsonData["nodes"].length; j++) {
+                if(jsonData["nodes"][j]["nodeName"] == src) {
+                    validNodes.push(jsonData["nodes"][j]);
+                    break;
+                }
+            }
+ 
+        }
+    }
+
+    nodes = [];
+    links = [];
+    // ajoute les noeuds
+    for(var j = 0; j < validNodes.length; j++) {
+        nodes.push({id: validNodes[j]["nodeName"], weight: validNodes[j]["nodeScore"]});
+        console.log(nodes[j]);
+    }
+
+    // ajoute les liens
+    for(var j = 0; j < validEdges.length; j++) {
+        links.push({source: validEdges[j]["source"], target: validEdges[j]["destination"]});
+        console.log(links[j]);
+    }
+
+    restart();
+    count += NUMELEMENTS;
+}
+
+var mode = "PAUSED";
+
+function handlePlayPause() {
+    if(mode == "PAUSED") {
+        mode = "PLAYING";
+        $(".ppButton").attr("src", "imgs/pause_24.png"); 
+    } else {
+        mode = "PAUSED";
+        $(".ppButton").attr("src", "imgs/play_24.png"); 
+    }
+
+    stepN();
+}
+
 function setupPlotter() {
 /*
        harry({