block by aaizemberg b683ef1f1f153bc2b260

ds

Full Screen

index.html

<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
  <meta charset="utf-8">
  <title>Data Science books</title>

<style>
  body {
    font: 10px sans-serif;
  }
  
  .axis path,.axis line {
    fill: none;
    stroke: #ccc;
  }
  
/* 
  clip-path by //bennettfeely.com/clippy/ 
*/ 
  image.out {
    -webkit-clip-path: circle(25% at 50% 50%);
    clip-path: circle(25% at 50% 50%);
  }
  image.over {
    -webkit-clip-path: circle(100% at 50% 50%);
    clip-path: circle(100% at 50% 50%);
  }
</style>

</head>
<body>

<script>
  var margin = {top: 20, right: 20, bottom: 30, left: 40},
    width = 400 - margin.left - margin.right,
    height = 400 - margin.top - margin.bottom;

  var x = d3.scale.linear().range([0, width]);
  var y = d3.scale.linear().range([height, 0]);

  var svg = d3.select("body").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

d3.tsv("https://gist.githubusercontent.com/aaizemberg/b683ef1f1f153bc2b260/raw/03e98b8c8d718f5a5a4acef48964258f09a01f49/ds.tsv", function(error, data) {
  if (error) throw error;

  data.forEach(function(d) {
    d.x = +d.year;
    d.y = +d.pages;
  });

  x.domain([2012.5,2015.5]);
  y.domain([0,500]);

  svg.append("g")
      .attr("class", "x axis")
      .attr("transform", "translate(0," + height + ")")
      .call(d3.svg.axis().ticks(3).scale(x).orient("bottom"));

  svg.append("g")
      .attr("class", "y axis")
      .call(d3.svg.axis()
            .ticks(5)
            .scale(y)
            .orient("left"));

  svg.selectAll(".point")
      .data(data)
    .enter()
      .append("image")
      .attr("class","out")
      .attr("x", function(d) { return x(d.x)-(75/2); })
      .attr("width","75px")
      .attr("y", function(d) { return y(d.y)-(100/2); })
      .attr("height","100px")
      .attr("xlink:href", function(d) { return d.img;} )
      .on("mouseover", function() { d3.select(this).attr("class", "over");  })
      .on("mouseout" , function() { d3.select(this).attr("class", "out"); })
      .append("title")
        .html(function(d) {return d.title + "<br>" + d.subtitle;} );
  });
  
  svg.append("text")
     .attr("text-anchor", "middle")  
     .attr("transform", "translate(-20,13)" )  
     .text("pages");
     
  svg.append("text")
     .attr("text-anchor", "middle")  
     .attr("transform", "translate("+ (width-10) +","+(height+16)+")")  
     .text("year");
     
</script>  
  
</body>
</html>

ds.tsv

title	subtitle	year	pages	img
Doing Data Science	Straight Talk from the Frontline	2013	406	http://it-ebooks.info/images/ebooks/3/doing_data_science.jpg
Agile Data Science	Building Data Analytics Applications with Hadoop	2013	178	http://it-ebooks.info/images/ebooks/3/agile_data_science.jpg
Practical Data Science Cookbook	89 hands-on recipes to help you complete real-world data science projects in R and Python	2014	396	http://it-ebooks.info/images/ebooks/14/practical_data_science_cookbook.jpg
Data Science at the Command Line	Facing the Future with Time-Tested Tools	2014	212	http://it-ebooks.info/images/ebooks/3/data_science_at_the_command_line.jpg
R for Data Science	Learn and explore the fundamentals of data science with R	2014	364	http://it-ebooks.info/images/ebooks/14/r_for_data_science.jpg
Data Science from Scratch	First Principles with Python	2015	330	http://it-ebooks.info/images/ebooks/3/data_science_from_scratch.jpg
Learning to Love Data Science	Explorations of Emerging Technologies and Platforms for Predictive Analytics, Machine Learning, Digital Manufacturing and Supply Chain Optimization	2015	162	http://it-ebooks.info/images/ebooks/3/learning_to_love_data_science.jpg
Data Science For Dummies	 	2015	408	http://it-ebooks.info/images/ebooks/9/data_science_for_dummies.jpg