Last active
November 23, 2016 14:56
-
-
Save auremoser/e9c8e6d9035f492ca5d706a12e642446 to your computer and use it in GitHub Desktop.
D3 Bar Vis 1
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: #00dc97; | |
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 = [3, 7, 21, 31, 35, 10]; | |
var width = window.innerWidth; | |
//TODO scales and domain slides | |
var x = d3.scale.linear() | |
.domain([0, d3.max(data)])//min and max of data that you want to show | |
.range([0, width]);//representation of it. | |
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