Learning to create a reusable chart function for a scatter plot, following Mike Bostock's "Towards Reusable Charts." Also includes a random data generator.
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
var width = 660, | |
height = 600; | |
var color = d3.scale.linear() | |
.domain([0, width/4, width/4 * 2, width/4 * 3, width]) | |
.range(["#fb000f", "#6e00fb", "#00fbec", "#8dfb00", "#fb3c00"]) | |
.interpolate(d3.interpolateHsl); | |
var svg = d3.select("#colorz").append("svg") | |
.attr("width", width) |
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
Occurance | a | b | c | d | d | f | g | h | i | j | |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 166292 | 30212 | 123040 | 27224 | 5992 | 276200 | 80 | 4408 | 246852 | 34932 | |
2 | 87256 | 22004 | 33608 | 16004 | 3316 | 125656 | 252 | 5120 | 147444 | 15652 | |
3 | 48932 | 20280 | 40816 | 11872 | 1948 | 72856 | 188 | 4588 | 99108 | 9016 |
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> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script> | |
<style type="text/css"> | |
html, body, #map { | |
width: 100%; |