From: karim hamidou Date: Tue, 11 Dec 2012 17:12:26 +0000 (+0100) Subject: changements d'affichage X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=8a77cb3c3caa18f7a9abc4051a15f2ab4432b6b6;p=Projet_IC05.git changements d'affichage --- diff --git a/js/css/main.css b/js/css/main.css index 32b1ad6..3014694 100755 --- a/js/css/main.css +++ b/js/css/main.css @@ -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 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 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 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 index 0000000..0cea725 Binary files /dev/null and b/js/imgs/play_redo.png differ diff --git a/js/index.html b/js/index.html index 591404a..b19af41 100755 --- a/js/index.html +++ b/js/index.html @@ -24,7 +24,10 @@

Les élections, tweetées

-
+
+ + +
diff --git a/js/js/main.js b/js/js/main.js index 4b5bee6..5d759ee 100755 --- a/js/js/main.js +++ b/js/js/main.js @@ -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({