Last active
October 27, 2016 23:20
-
-
Save sarubenfeld/2168431991b86dbc0465805d9d166b6d to your computer and use it in GitHub Desktop.
2016: AAPL Stock Market Close
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
date | close | |
---|---|---|
2016-01-04 | 103.58618 | |
2016-01-05 | 100.99038 | |
2016-01-06 | 99.01403 | |
2016-01-07 | 94.835186 | |
2016-01-08 | 95.336649 | |
2016-01-11 | 96.880363 | |
2016-01-12 | 98.286422 | |
2016-01-13 | 95.75945 | |
2016-01-14 | 97.853786 | |
2016-01-15 | 95.503801 | |
2016-01-19 | 95.041677 | |
2016-01-20 | 95.169497 | |
2016-01-21 | 94.687703 | |
2016-01-22 | 99.721977 | |
2016-01-25 | 97.775131 | |
2016-01-26 | 98.315919 | |
2016-01-27 | 91.855917 | |
2016-01-28 | 92.514698 | |
2016-01-29 | 95.710285 | |
2016-02-01 | 94.815524 | |
2016-02-02 | 92.898175 | |
2016-02-03 | 94.736862 | |
2016-02-04 | 95.498081 | |
2016-02-05 | 92.947509 | |
2016-02-08 | 93.926221 | |
2016-02-09 | 93.906445 | |
2016-02-10 | 93.194657 | |
2016-02-11 | 92.631159 | |
2016-02-12 | 92.917852 | |
2016-02-16 | 95.537625 | |
2016-02-17 | 97.000746 | |
2016-02-18 | 95.161963 | |
2016-02-19 | 94.944471 | |
2016-02-22 | 95.774885 | |
2016-02-23 | 93.609872 | |
2016-02-24 | 95.003784 | |
2016-02-25 | 95.656259 | |
2016-02-26 | 95.80455 | |
2016-02-29 | 95.587058 | |
2016-03-01 | 99.383251 | |
2016-03-02 | 99.600743 | |
2016-03-03 | 100.342188 | |
2016-03-04 | 101.834965 | |
2016-03-07 | 100.70797 | |
2016-03-08 | 99.877548 | |
2016-03-09 | 99.966525 | |
2016-03-10 | 100.01595 | |
2016-03-11 | 101.09352 | |
2016-03-14 | 101.350549 | |
2016-03-15 | 103.387056 | |
2016-03-16 | 104.7612 | |
2016-03-17 | 104.593141 | |
2016-03-18 | 104.711767 | |
2016-03-21 | 104.701886 | |
2016-03-22 | 105.502644 | |
2016-03-23 | 104.91937 | |
2016-03-24 | 104.464619 | |
2016-03-28 | 103.990098 | |
2016-03-29 | 106.451693 | |
2016-03-30 | 108.310245 | |
2016-03-31 | 107.746747 | |
2016-04-01 | 108.73534 | |
2016-04-04 | 109.852455 | |
2016-04-05 | 108.557393 | |
2016-04-06 | 109.694276 | |
2016-04-07 | 107.301883 | |
2016-04-08 | 107.420517 | |
2016-04-11 | 107.776404 | |
2016-04-12 | 109.180211 | |
2016-04-13 | 110.761959 | |
2016-04-14 | 110.821272 | |
2016-04-15 | 108.596938 | |
2016-04-18 | 106.253977 | |
2016-04-19 | 105.690479 | |
2016-04-20 | 105.907963 | |
2016-04-21 | 104.7612 | |
2016-04-22 | 104.474507 | |
2016-04-25 | 103.881352 | |
2016-04-26 | 103.159676 | |
2016-04-27 | 96.704165 | |
2016-04-28 | 93.748274 | |
2016-04-29 | 92.670704 | |
2016-05-02 | 92.571846 | |
2016-05-03 | 94.09428 | |
2016-05-04 | 93.115575 | |
2016-05-05 | 92.737619 | |
2016-05-06 | 92.220424 | |
2016-05-09 | 92.290046 | |
2016-05-10 | 92.916649 | |
2016-05-11 | 92.011556 | |
2016-05-12 | 89.853242 | |
2016-05-13 | 90.032273 | |
2016-05-16 | 93.37417 | |
2016-05-17 | 92.986272 | |
2016-05-18 | 94.050506 | |
2016-05-19 | 93.692445 | |
2016-05-20 | 94.706954 | |
2016-05-23 | 95.910433 | |
2016-05-24 | 97.372514 | |
2016-05-25 | 99.083248 | |
2016-05-26 | 99.868992 | |
2016-05-27 | 99.809311 | |
2016-05-31 | 99.321953 | |
2016-06-01 | 97.929494 | |
2016-06-02 | 97.193484 | |
2016-06-03 | 97.392403 | |
2016-06-06 | 98.098577 | |
2016-06-07 | 98.496423 | |
2016-06-08 | 98.406912 | |
2016-06-09 | 99.113085 | |
2016-06-10 | 98.297504 | |
2016-06-13 | 96.815526 | |
2016-06-14 | 96.934883 | |
2016-06-15 | 96.616607 | |
2016-06-16 | 97.024402 | |
2016-06-17 | 94.816362 | |
2016-06-20 | 94.587598 | |
2016-06-21 | 95.393239 | |
2016-06-22 | 95.035178 | |
2016-06-23 | 95.58221 | |
2016-06-24 | 92.89676 | |
2016-06-27 | 91.544087 | |
2016-06-28 | 93.085731 | |
2016-06-29 | 93.891372 | |
2016-06-30 | 95.084904 | |
2016-07-01 | 95.373342 | |
2016-07-05 | 94.47819 | |
2016-07-06 | 95.015281 | |
2016-07-07 | 95.423076 | |
2016-07-08 | 96.159086 | |
2016-07-11 | 96.457473 | |
2016-07-12 | 96.895097 | |
2016-07-13 | 96.348065 | |
2016-07-14 | 98.257718 | |
2016-07-15 | 98.24777 | |
2016-07-18 | 99.292116 | |
2016-07-19 | 99.331901 | |
2016-07-20 | 99.421412 | |
2016-07-21 | 98.894269 | |
2016-07-22 | 98.128421 | |
2016-07-25 | 96.815526 | |
2016-07-26 | 96.149138 | |
2016-07-27 | 102.3953 | |
2016-07-28 | 103.77781 | |
2016-07-29 | 103.648513 | |
2016-08-01 | 105.478603 | |
2016-08-02 | 103.917063 | |
2016-08-03 | 105.220002 | |
2016-08-04 | 105.870003 | |
2016-08-05 | 107.480003 | |
2016-08-08 | 108.370003 | |
2016-08-09 | 108.809998 | |
2016-08-10 | 108.0 | |
2016-08-11 | 107.93 | |
2016-08-12 | 108.18 | |
2016-08-15 | 109.480003 | |
2016-08-16 | 109.379997 | |
2016-08-17 | 109.220001 | |
2016-08-18 | 109.080002 | |
2016-08-19 | 109.360001 | |
2016-08-22 | 108.510002 | |
2016-08-23 | 108.849998 | |
2016-08-24 | 108.029999 | |
2016-08-25 | 107.57 | |
2016-08-26 | 106.940002 | |
2016-08-29 | 106.82 | |
2016-08-30 | 106.0 | |
2016-08-31 | 106.099998 | |
2016-09-01 | 106.730003 | |
2016-09-02 | 107.730003 | |
2016-09-06 | 107.699997 | |
2016-09-07 | 108.360001 | |
2016-09-08 | 105.519997 | |
2016-09-09 | 103.129997 | |
2016-09-12 | 105.440002 | |
2016-09-13 | 107.949997 | |
2016-09-14 | 111.769997 | |
2016-09-15 | 115.57 | |
2016-09-16 | 114.919998 | |
2016-09-19 | 113.580002 | |
2016-09-20 | 113.57 | |
2016-09-21 | 113.550003 | |
2016-09-22 | 114.620003 | |
2016-09-23 | 112.709999 | |
2016-09-26 | 112.879997 | |
2016-09-27 | 113.089996 | |
2016-09-28 | 113.949997 | |
2016-09-29 | 112.18 | |
2016-09-30 | 113.050003 | |
2016-10-03 | 112.519997 | |
2016-10-04 | 113.0 | |
2016-10-05 | 113.050003 | |
2016-10-06 | 113.889999 | |
2016-10-07 | 114.059998 | |
2016-10-10 | 116.050003 | |
2016-10-11 | 116.300003 | |
2016-10-12 | 117.339996 | |
2016-10-13 | 116.980003 | |
2016-10-14 | 117.629997 | |
2016-10-17 | 117.550003 | |
2016-10-18 | 117.470001 | |
2016-10-19 | 117.120003 | |
2016-10-20 | 117.059998 | |
2016-10-21 | 116.599998 | |
2016-10-24 | 117.650002 | |
2016-10-25 | 118.25 |
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> | |
body { | |
font-family: Futura; | |
font-size: 10px; | |
} | |
div { | |
display: inline-block; | |
} | |
h2 { | |
font-family: futura; | |
font-size: 10px; | |
} | |
.axis { | |
stroke-dasharray: 2, 2; | |
stroke-linecap: "round"; | |
shape-rendering: crispEdges; | |
} | |
.area { | |
fill: url(#area-gradient); | |
stroke-width: 0px; | |
} | |
.axis line { | |
stroke: #ccc; | |
stroke-dasharray: 1px 1px; | |
} | |
text { | |
font-family: Futura; | |
} | |
</style> | |
<body> | |
<div class="g-chart-container"> | |
<h1> 2016: AAPL Stock Market Close </h1> | |
</div> | |
</body> | |
<script | |
src="https://d3js.org/d3.v4.min.js"></script> | |
<script> | |
var margin = {top: 20, right: 20, bottom: 30, left: 50}, | |
width = 960 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", | |
"translate(" + margin.left + "," + margin.top + ")"); | |
var parseTime = d3.timeParse("%Y-%m-%d"); | |
var x = d3.scaleTime().range([0, width]); | |
var y = d3.scaleLinear().range([height, 0]); | |
var area = d3.area() | |
.x(function(d) { return x(d.date); }) | |
.y0(height) | |
.y1(function(d) { return y(d.close); }); | |
d3.csv("aapl.csv", function(error, data) { | |
if (error) throw error; | |
data.forEach(function(d) { | |
d.date = parseTime(d.date); | |
d.close = +d.close; | |
}); | |
x.domain(d3.extent(data, function(d) { return d.date; })); | |
y.domain([0, d3.max(data, function(d) { return d.close; })]); | |
var colours = ["#00ffb3","#00fff3","#00cbff","#008cff","#004cff","#000cff"]; | |
svg.append("linearGradient") | |
.attr("id", "area-gradient") | |
.attr("gradientUnits", "userSpaceOnUse") | |
.attr("spreadMethod", "pad") | |
.style("mix-blend-mode","color-dodge") | |
.attr("x1", 0).attr("y1", y(0)) | |
.attr("x2", 0).attr("y2", y(110)) | |
.selectAll("stop") | |
.data(colours) | |
.enter().append("stop") | |
.attr("offset", function(d,i) { return i/(colours.length-1); }) | |
.attr("stop-color", function(d) { return d; }); | |
svg.append("path") | |
.data([data]) | |
.attr("class", "area") | |
.attr("d", area); | |
svg.append("g") | |
.attr("transform", "translate(0," + height + ")") | |
.call(d3.axisBottom(x)); | |
svg.append("g") | |
.call(d3.axisLeft(y)); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment