block by aaizemberg 90e39c5dd5630517b6c016cfbd2123b8

el ejemplo que hicimos hoy durante la clase

Full Screen

index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title></title>
  <script src="https://d3js.org/d3.v4.min.js"></script>
  <style>
    rect {
      fill: steelblue;
    }
  </style>
  </head>
<body>

  <h1>los seguidores de:</h1>

<script>
  var datos = [
   {"candidato":"cristina","seguidores":4867517},
   {"candidato":"macri","seguidores":3937615},
   {"candidato":"randazo","seguidores":465163}
];

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

svg.selectAll("text")
  .data(datos)
  .enter()
  .append("text")
    .attr("x",10)
    .attr("y", function(d,i) {return 50*i+50; } )
    .text( function(d,i) { return d.candidato; }  );

var escala = d3.scaleLinear().domain([0,4867517]).range([0,300]);

svg.selectAll("rect")
  .data(datos)
  .enter()
  .append("rect")
    .attr("rx",10)
    .attr("ry",10)
    .attr("x",100)
    .attr("y", function(d,i) {return 50*i+40; } )
    .attr("width", function(d,i) {return escala(d.seguidores)} )
    .attr("height", 20)
      .append("title")
      .text( function(d,i) {return d.seguidores} );

</script>  
  
</body>
</html>