Last active
August 29, 2015 14:20
-
-
Save Qinita/aa6e8629efec6fd84665 to your computer and use it in GitHub Desktop.
Data Visualization Module 3 - Bar 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
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <style> | |
| .chart div { | |
| font: 10px sans-serif; | |
| background-color: steelblue; | |
| text-align: right; | |
| padding: 3px; | |
| margin: 1px; | |
| color: white; | |
| } | |
| </style> | |
| <div class="chart"></div> | |
| <script src="http://d3js.org/d3.v3.min.js"></script> | |
| <script> | |
| var data = [1,4,5,53,6,7,3,6,8,11,14,26,50,105,230,240,270,340]; | |
| var x = d3.scale.linear() | |
| .domain([0, d3.max(data)]) | |
| .range([0, 420]); | |
| d3.select(".chart") | |
| .selectAll("div") | |
| .data(data) | |
| .enter().append("div") | |
| .style("width", function(d) { return x(d) + "px"; }) | |
| .text(function(d) { return d; }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment