block by michalskop 6318965

Czech parl.network '10-'13

Full Screen

index.html

<!DOCTYPE html>
<meta charset="utf-8">
<title>Network of Sponsors of bills.</title>
<style>

.node {
  stroke: #fff;
  stroke-width: 1.5px;
}

.link {
  stroke: #999;
  stroke-opacity: .6;
}

</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>

var width = 600,
    height = 400;

//var color = d3.scale.category20();

var color = Array(
'#000000',
'#FF9933',
'#FF0000',
'#000099',
'#0099FF',
'#CC00CC',
'#888888'
);

var force = d3.layout.force()
    .charge(-50)
    /*.linkDistance(10)*/
    .size([width, height]);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

d3.json("data5.json", function(error, graph) {
  force
      .nodes(graph.nodes)
      .links(graph.links)
      .linkDistance(function (d) {return 15*(Math.log(36+2)-Math.log(d.value))})	//36 is max in data
      .start();

 var link = svg.selectAll(".link")
      .data(graph.links)
    .enter().append("line")
      .attr("class", "link")
      .style("stroke-width", function(d) { return 0.5*Math.sqrt(Math.max(0,d.value-2)) })
      .style("display", function(d) { if(d.value<2) return "none"; else return "inline";});

  var node = svg.selectAll(".node")
      .data(graph.nodes)
    .enter().append("circle")
      .attr("class", "node")
      .attr("r", 5)
      .style("fill", function(d) {return color[d.group]}) //{ return color(d.group); })
      .call(force.drag);

  node.append("title")
      .text(function(d) { return d.name; });

  force.on("tick", function() {
    link.attr("x1", function(d) { return d.source.x; })
        .attr("y1", function(d) { return d.source.y; })
        .attr("x2", function(d) { return d.target.x; })
        .attr("y2", function(d) { return d.target.y; });

    node.attr("cx", function(d) { return d.x; })
        .attr("cy", function(d) { return d.y; });
  });
});

</script>
<div id="chart"></div>
<div id="description" style="color:#bbbbbb">
Network of Sponsors of bills. Czech parliament (lower chamber) 2010-2013. Prepared with Kamil Gregor.<br/>
Notes: The links with weight 1 were omitted (more than 7000) and left only with weight 2 and more (more than 6000). MPs with no links are omitted. Links with weight 2 are not shown for clarity reasons.
</div>
</body>

a-network

Czech parliament connections 2010-2013. Network of Sponsors of bills.