Placeholder README.md
-
-
Save enactdev/7674e9ea4e3c8157e017 to your computer and use it in GitHub Desktop.
Knight Data Viz
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> | |
<html lang="en"> | |
<meta charset="utf-8"> | |
<body> | |
<svg class="chart"></svg> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<script> | |
var margin = {top: 20, right: 30, bottom: 30, left: 40}, | |
width = 960 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
var x = d3.scale.ordinal() | |
.rangeRoundBands([0, width], .1); | |
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 chart = d3.select(".chart") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
d3.csv("web_trackers.csv", type, function(data) { | |
console.log(data); | |
x.domain(data.map(function(d) { return d.name; })); | |
y.domain([0, d3.max(data, function(d) { return d.value; })]); | |
/****************** | |
chart.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis); | |
chart.append("g") | |
.attr("class", "y axis") | |
.call(yAxis); | |
chart.selectAll(".bar") | |
.data(data) | |
.enter().append("rect") | |
.attr("class", "bar") | |
.attr("x", function(d) { return x(d.name); }) | |
.attr("y", function(d) { return y(d.value); }) | |
.attr("height", function(d) { return height - y(d.value); }) | |
.attr("width", x.rangeBand()); | |
******************/ | |
}); | |
function type(d) { | |
d.value = +d.value; // coerce to number | |
return d; | |
} | |
</script> | |
</body> | |
</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
alexa_rank | website | num_trackers | |
---|---|---|---|
19 | cnn.com | 26 | |
22 | espn.go.com | 14 | |
29 | nytimes.com | 44 | |
31 | huffingtonpost.com | 59 | |
37 | buzzfeed.com | 25 | |
44 | foxnews.com | 40 | |
50 | washingtonpost.com | 41 | |
66 | dailymail.co.uk | 76 | |
67 | cnet.com | 37 | |
68 | usatoday.com | 27 | |
72 | ijreview.com | 95 | |
73 | forbes.com | 45 | |
81 | businessinsider.com | 68 | |
89 | vice.com | 28 | |
92 | bleacherreport.com | 70 | |
97 | bbc.com | 37 | |
100 | nbcnews.com | 80 | |
103 | wsj.com | 28 | |
111 | theguardian.com | 36 | |
117 | people.com | 56 | |
123 | patch.com | 78 | |
124 | drudgereport.com | 112 | |
133 | gizmodo.com | 26 | |
137 | npr.org | 19 | |
140 | time.com | 40 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment