Created
February 1, 2015 19:13
-
-
Save spidergears/6235f479bb13b848c99e to your computer and use it in GitHub Desktop.
d3.js Demo1
This file contains 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: blue; | |
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_points = [3, 5, 23, 45, 67, 98, 150, 220]; | |
var plot_scale = d3.scale.linear() | |
.domain(d3.extent(data_points)) | |
.range([5, 420]); | |
d3.select(".chart") | |
.selectAll("div") | |
.data(data_points) | |
.enter() | |
.append("div") | |
.style("width", function(data_point) { return plot_scale(data_point) + "px"; }) | |
.text(function(data_point) { return data_point; }); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment