Created
February 14, 2017 01:00
-
-
Save rednebmas/9c1afb001a3c60f8292e1cf57ff08580 to your computer and use it in GitHub Desktop.
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
| <!-- http://alignedleft.com/tutorials/d3/making-a-bar-chart --> | |
| <div class="container"> | |
| <style type="text/css"> | |
| div.bar { | |
| display: inline-block; | |
| width: 20px; | |
| height: 75px; /* Gets overriden by D3-assigned height below */ | |
| margin-right: 2px; | |
| background-color: teal; | |
| } | |
| </style> | |
| <div class="chart"></div> | |
| <script type="text/javascript"> | |
| var dataset = [ 5, 10, 13, 19, 21, 25, 22, 18, 15, 13, | |
| 11, 12, 15, 20, 18, 17, 16, 18, 23, 25 ]; | |
| d3.select(".chart").selectAll("div") | |
| .data(dataset.sort(function(a,b) { | |
| return b - a; | |
| })) | |
| .enter() | |
| .append("div") | |
| .attr("class", "bar") | |
| .style("height", function(d) { | |
| var barHeight = d * 5; | |
| return barHeight + "px"; | |
| }); | |
| </script> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment