// Generated by CoffeeScript 1.10.0 (function() { var BAR_HEIGHT, color, documents, documents_data, height, sections, svg, vis, width; documents_data = [ { sections: [ { id: 0, length: 3 }, { id: 1, length: 2 }, { id: 2, length: 2 }, { id: 3, length: 1 }, { id: 4, length: 4 }, { id: 5, length: 3 }, { id: 6, length: 4 }, { id: 7, length: 2 }, { id: 8, length: 3 }, { id: 9, length: 3 }, { id: 10, length: 2 }, { id: 11, length: 1 }, { id: 12, length: 2 }, { id: 13, length: 2 }, { id: 14, length: 1 }, { id: 15, length: 3 }, { id: 16, length: 3 }, { id: 17, length: 4 }, { id: 18, length: 3 }, { id: 19, length: 1 } ] }, { sections: [ { id: 0, length: 3 }, { id: 1, length: 2 }, { id: 2, length: 2 }, { id: -1, length: 2 }, { id: 3, length: 1 }, { id: 4, length: 4 }, { id: 5, length: 3 }, { id: 6, length: 4 }, { id: 7, length: 2 }, { id: 8, length: 3 }, { id: 9, length: 3 }, { id: 10, length: 2 }, { id: 11, length: 1 }, { id: 12, length: 2 }, { id: 13, length: 2 }, { id: 14, length: 1 }, { id: 15, length: 3 }, { id: 16, length: 2 }, { id: 17, length: 4 }, { id: 18, length: 3 }, { id: 19, length: 1 } ] }, { sections: [ { id: 0, length: 3 }, { id: 1, length: 2 }, { id: 2, length: 2 }, { id: -1, length: 2 }, { id: 3, length: 1 }, { id: 4, length: 4 }, { id: 15, length: 3 }, { id: 16, length: 2 }, { id: 17, length: 4 }, { id: 18, length: 3 }, { id: 19, length: 1 }, { id: 5, length: 3 }, { id: 6, length: 3 }, { id: 7, length: 2 }, { id: 8, length: 3 }, { id: 9, length: 3 }, { id: 10, length: 2 }, { id: 11, length: 1 }, { id: 12, length: 2 }, { id: 13, length: 2 }, { id: 14, length: 2 } ] }, { sections: [ { id: 0, length: 3 }, { id: 1, length: 1 }, { id: 2, length: 1 }, { id: -1, length: 2 }, { id: 3, length: 2 }, { id: 4, length: 4 }, { id: 15, length: 3 }, { id: 16, length: 2 }, { id: 17, length: 3 }, { id: 18, length: 3 }, { id: 19, length: 1 }, { id: 5, length: 3 }, { id: 11, length: 1 }, { id: 12, length: 2 }, { id: 13, length: 1 }, { id: 6, length: 3 }, { id: 7, length: 2 }, { id: 8, length: 3 }, { id: 9, length: 2 }, { id: 10, length: 2 }, { id: 14, length: 2 } ] }, { sections: [ { id: 0, length: 3 }, { id: 1, length: 2 }, { id: 2, length: 2 }, { id: -1, length: 2 }, { id: 3, length: 1 }, { id: 4, length: 4 }, { id: 15, length: 3 }, { id: 16, length: 2 }, { id: 17, length: 4 }, { id: 18, length: 3 }, { id: 19, length: 1 }, { id: -1, length: 2 }, { id: 5, length: 3 }, { id: 11, length: 1 }, { id: 12, length: 2 }, { id: 13, length: 4 }, { id: 6, length: 3 }, { id: 7, length: 2 }, { id: 8, length: 3 }, { id: -1, length: 1 }, { id: 9, length: 3 }, { id: -1, length: 1 }, { id: 10, length: 2 }, { id: 14, length: 2 } ] }, { sections: [ { id: -1, length: 1 }, { id: 0, length: 3 }, { id: 1, length: 2 }, { id: 2, length: 2 }, { id: -1, length: 2 }, { id: -1, length: 1 }, { id: 11, length: 1 }, { id: 12, length: 2 }, { id: 13, length: 4 }, { id: 6, length: 3 }, { id: 7, length: 2 }, { id: 8, length: 3 }, { id: -1, length: 1 }, { id: 9, length: 3 }, { id: -1, length: 1 }, { id: 3, length: 1 }, { id: 4, length: 4 }, { id: 15, length: 3 }, { id: 16, length: 2 }, { id: 17, length: 4 }, { id: -1, length: 2 }, { id: 18, length: 3 }, { id: 19, length: 1 }, { id: -1, length: 2 }, { id: 5, length: 3 }, { id: 10, length: 2 }, { id: 14, length: 2 } ] } ]; documents_data.forEach(function(doc) { var offset; offset = 0; return doc.sections.forEach(function(sec) { sec.offset = offset; return offset += sec.length; }); }); BAR_HEIGHT = 30; color = d3.scale.linear().domain([0, 20]).range([d3.hcl(-20, 50, 10), d3.hcl(100, 60, 93)]).interpolate(d3.interpolateHcl); svg = d3.select('svg'); width = svg.node().getBoundingClientRect().width; height = svg.node().getBoundingClientRect().height; vis = svg.append('g').attr({ transform: "translate(60, 120)" }); documents = vis.selectAll('.document').data(documents_data); documents.enter().append('g').attr({ "class": 'document', transform: function(d, i) { return "translate(0, " + (i * BAR_HEIGHT * 1.3) + ")"; } }); sections = documents.selectAll('.section').data(function(d) { return d.sections; }); sections.enter().append('rect').attr({ "class": 'section', height: BAR_HEIGHT }); sections.attr({ x: function(d) { return d.offset * 10; }, width: function(d) { return d.length * 10; }, fill: function(d) { if (d.id !== -1) { return color(d.id); } else { return 'gray'; } } }); }).call(this);