-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
183d669
commit bffb56a
Showing
4 changed files
with
1,384 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.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; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function line_chart(svg, width, height, data) | ||
{ | ||
var margin = {top: 20, right: 20, bottom: 30, left: 50}; | ||
width = width - margin.left - margin.right, | ||
height = height - margin.top - margin.bottom; | ||
|
||
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.date); }) | ||
.y(function(d) { return y(d.close); }); | ||
x.domain(d3.extent(data, function(d) { return d.date; })); | ||
y.domain(d3.extent(data, function(d) { return d.close; })); | ||
|
||
svg = svg | ||
.attr("width", width + margin.left + margin.right) | ||
.attr("height", height + margin.top + margin.bottom) | ||
.append("g") | ||
.attr( | ||
"transform", "translate(" + margin.left + "," + margin.top + ")" | ||
); | ||
|
||
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); | ||
|
||
} |
Oops, something went wrong.