Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finished lesson 6 section 3. started section 4
- Loading branch information
Showing
4 changed files
with
76 additions
and
88 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,67 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="http://d3js.org/d3.v2.js"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
d3.json("tag_counts_last_30_days.json", function(allTags) { | ||
var topTags = allTags.slice(1, 3); | ||
var midTags = allTags.slice(100, 3); | ||
var tags = topTags.concat(midTags); | ||
|
||
var width = 600, | ||
height = 300, | ||
padding = 20; | ||
|
||
var colorScale = d3.scale.category10(); // do this after the first item | ||
|
||
var vis = d3.select("body") | ||
.append('svg') | ||
.attr('width', width) | ||
.attr('height', height); | ||
|
||
d3.json("tags/" + tags[0][1], function(tagData) { | ||
|
||
var timeExtent = d3.extent(tagData.d.map(function)) | ||
var xScale = d3.time.scale().domain(chartSettings.xExtent).range([chartSettings.padding, chartSettings.width - chartSettings.padding]); | ||
// add visual rules for timeline | ||
vis.append("g") | ||
.attr("class", "rule").selectAll("line") | ||
.data(chartSettings.xScale.ticks(10)) | ||
.enter() | ||
.append("line") | ||
.attr("x1", chartSettings.xScale) | ||
.attr("x2", chartSettings.xScale) | ||
.attr("y1", chartSettings.padding) | ||
.attr("y2", chartSettings.height - chartSettings.padding); | ||
|
||
// place axis tick labels | ||
var xAxis = d3.svg.axis() | ||
.scale(chartSettings.xScale) | ||
.orient("bottom") | ||
.ticks(8); | ||
|
||
var timeAxis = vis.append("g") | ||
.attr("class", "x axis") | ||
.attr("transform", "translate(0," + (chartSettings.height - chartSettings.padding) + ")") | ||
.call(xAxis); | ||
|
||
var yAxis = d3.svg.axis() | ||
.scale(chartSettings.yScale) | ||
.orient("left") | ||
.ticks(5) | ||
|
||
vis.append("g") | ||
.attr("class", "y axis") | ||
.attr("transform", "translate(" + (chartSettings.padding) + ",0)") | ||
.call(yAxis); | ||
}) | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
<!DOCTYPE html> | ||
<html> |
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