Skip to content

Instantly share code, notes, and snippets.

@levinalex
Forked from mbostock/.block
Last active December 25, 2015 12:09
Show Gist options
  • Save levinalex/6974245 to your computer and use it in GitHub Desktop.
Save levinalex/6974245 to your computer and use it in GitHub Desktop.

Testing ...

We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 1 column, instead of 2. in line 2.
ts weight
2013-07-17T00:40 72.9
2013-07-17T00:43 72.5
2013-07-17T11:37 71.3
2013-07-17T21:46 70.6
2013-07-18T00:56 71.5
2013-07-18T09:14 70.5
2013-07-18T21:42 71.0
2013-07-19T01:01 71.7
2013-07-19T09:52 70.7
2013-07-19T20:14 70.6
2013-07-20T02:02 70.6
2013-07-20T08:43 70.6
2013-07-20T10:58 70.3
2013-07-21T02:59 72.5
2013-07-21T12:59 71.9
2013-07-21T13:10 71.4
2013-07-22T00:49 71.9
2013-07-22T08:27 71.6
2013-07-22T20:00 70.4
2013-07-22T23:49 71.7
2013-07-23T06:31 71.2
2013-07-23T07:29 71.5
2013-07-23T17:49 69.7
2013-07-23T22:45 70.5
2013-07-23T23:17 70.8
2013-07-24T02:56 70.3
2013-07-24T09:27 69.9
2013-07-24T21:41 69.9
2013-07-25T01:50 71.2
2013-07-25T10:21 70.5
2013-07-25T12:04 70.2
2013-07-25T15:32 71.3
2013-07-26T00:31 71.6
2013-07-29T21:07 72.2
2013-07-30T01:22 71.7
2013-07-30T10:08 70.5
2013-07-30T22:15 70.1
2013-07-31T01:24 71.0
2013-07-31T09:38 70.1
2013-07-31T19:54 69.5
2013-07-31T21:17 70.2
2013-08-01T02:33 70.2
2013-08-01T09:34 69.5
2013-08-02T03:58 69.9
2013-08-02T11:01 69.5
2013-08-02T18:43 69.5
2013-08-03T01:56 70.5
2013-08-04T14:59 70.5
2013-08-04T22:26 70.7
2013-08-05T09:56 70.6
2013-08-05T19:32 70.6
2013-08-06T01:12 71.9
2013-08-06T03:05 70.8
2013-08-06T09:46 70.2
2013-08-06T20:37 70.7
2013-08-07T02:43 70.7
2013-08-07T09:50 69.9
2013-08-07T19:27 69.9
2013-08-08T00:17 70.5
2013-08-08T08:39 70.2
2013-08-08T08:39 69.6
2013-08-08T21:40 69.9
2013-08-09T03:37 70.4
2013-08-09T10:59 69.5
2013-08-09T16:52 69.9
2013-08-10T02:39 70.0
2013-08-10T07:38 69.9
2013-08-13T22:09 71.2
2013-08-14T00:37 71.7
2013-08-14T01:42 71.2
2013-08-14T08:56 70.3
2013-08-15T01:29 71.0
2013-08-15T10:56 69.7
2013-08-15T22:37 69.8
2013-08-16T00:58 70.6
2013-08-16T10:54 70.0
2013-08-17T01:19 72.0
2013-08-17T09:24 70.9
2013-08-18T00:42 72.5
2013-08-18T10:50 71.2
2013-08-19T00:31 72.9
2013-08-19T08:31 71.1
2013-08-20T06:54 71.2
2013-08-20T08:40 70.8
2013-08-20T19:58 70.4
2013-08-21T00:51 70.8
2013-08-21T10:25 70.3
2013-08-22T00:31 70.9
2013-08-22T11:09 70.4
2013-08-23T01:21 70.9
2013-08-23T10:43 70.5
2013-08-23T10:52 70.1
2013-08-23T19:36 70.1
2013-08-24T02:23 71.8
2013-08-24T07:03 70.8
2013-08-26T09:19 71.7
2013-08-27T02:01 71.0
2013-08-27T11:00 70.4
2013-08-28T01:04 71.7
2013-08-28T08:10 70.8
2013-08-28T17:33 70.8
2013-08-29T11:26 70.4
2013-08-30T01:08 71.4
2013-08-30T08:35 70.5
2013-09-03T01:26 70.5
2013-09-03T08:27 70.5
2013-09-03T19:44 69.6
2013-09-04T08:13 69.6
2013-09-04T20:14 69.1
2013-09-05T08:15 69.5
2013-09-05T19:17 69.5
2013-09-06T12:04 69.8
2013-09-06T12:05 69.2
2013-09-09T19:58 70.0
2013-09-10T10:22 70.0
2013-09-10T10:29 69.6
2013-09-11T08:16 70.7
2013-09-11T22:10 70.1
2013-09-12T15:31 69.5
2013-09-13T01:06 70.6
2013-09-13T08:38 70.1
2013-09-17T16:37 70.1
2013-09-17T23:39 71.9
2013-09-18T07:49 70.6
2013-09-18T23:15 71.3
2013-09-19T07:46 70.4
2013-09-20T00:01 71.2
2013-09-20T10:21 70.9
2013-09-20T10:28 70.5
2013-09-21T00:18 71.3
2013-09-21T10:39 70.8
2013-09-22T02:07 71.9
2013-09-22T10:41 71.3
2013-09-23T00:04 71.7
2013-09-23T09:03 70.8
2013-09-23T23:24 71.2
2013-09-25T00:15 70.8
2013-09-26T00:04 71.3
2013-09-26T07:44 70.4
2013-09-26T20:03 69.9
2013-09-27T10:06 70.2
2013-09-29T18:43 72.1
2013-09-30T01:00 71.7
2013-09-30T07:48 70.9
2013-10-01T10:36 70.0
2013-10-02T02:28 71.6
2013-10-02T07:36 70.5
2013-10-03T00:23 70.5
2013-10-03T23:19 71.2
2013-10-04T09:44 70.1
2013-10-05T00:19 70.1
2013-10-05T10:14 69.6
2013-10-06T00:25 71.2
2013-10-06T09:29 70.3
2013-10-07T08:51 70.4
2013-10-07T22:30 70.8
2013-10-08T07:28 70.2
2013-10-09T00:02 71.1
2013-10-10T10:18 70.3
2013-10-11T11:22 69.5
2013-10-13T14:17 71.4
2013-10-14T09:56 70.2
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.x.axis path {
display: none;
}
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.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 parseDate = d3.time.format("%d-%b-%y").parse;
var x = d3.time.scale()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var line = d3.svg.line()
.x(function(d) { return x(d.ts); })
.y(function(d) { return y(d.weight); });
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 + ")");
d3.tsv("data.tsv", function(error, data) {
data.forEach(function(d) {
d.date = parseDate(d.date);
d.close = +d.close;
});
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain(d3.extent(data, function(d) { return d.close; }));
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Price ($)");
svg.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment