Built with blockbuilder.org
Last active
November 27, 2015 10:46
-
-
Save prashanth-sriram/6cd13f2082b09ab2823c to your computer and use it in GitHub Desktop.
gant chart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tail, start, end | |
| VXVQ1, 10, 30 | |
| VXVQ2, 0, 25 | |
| VXVQ3, 15, 40 | |
| VXVQ4, 5, 35 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <style> | |
| .chart rect { | |
| fill: steelblue; | |
| } | |
| .chart text { | |
| fill: white; | |
| font: 10px sans-serif; | |
| text-anchor: end; | |
| } | |
| </style> | |
| <svg class="chart"></svg> | |
| <script src="//d3js.org/d3.v3.min.js"></script> | |
| <script> | |
| var width = 420; | |
| var x = d3.scale.linear() | |
| .range([0, width]); | |
| var chart = d3.select(".chart") | |
| .attr("width", width); | |
| d3.csv("gant_data.txt", type, function(error, data) { | |
| x.domain([0, d3.max(data, function(d) { return d.end; })]); | |
| var barHeight = 20; | |
| chart.attr("height", barHeight * data.length); | |
| var bar = chart.selectAll("g") | |
| .data(data) | |
| .enter().append("g") | |
| .attr("transform", function(d, i) { return "translate(0," + i * barHeight + ")"; }); | |
| bar.append("rect") | |
| .attr("width", function(d) { return d.end; }) | |
| .attr("height", barHeight - 1); | |
| bar.append("text") | |
| .attr("x", function(d) { return d.end - 3; }) | |
| .attr("y", barHeight / 2) | |
| .attr("dy", ".35em") | |
| .text(function(d) { return d.end; }); | |
| }); | |
| function type(d) { | |
| d.start = +d.start; // coerce to number | |
| d.end = +d.end; // coerce to number | |
| return d; | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment