-
-
Save tannerlinsley/df95132bac67b8d196b64fd77ce155c9 to your computer and use it in GitHub Desktop.
Revisions
-
tannerlinsley revised this gist
Apr 4, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -45,7 +45,7 @@ .selectAll("g") .data(data) .enter().append("g") // .attr("transform", function(d) { return "translate(" + x0(d.State) + ",0)"; }) .selectAll("rect") .data(function(d) { return keys.map(function(key) { return {key: key, value: d[key]}; }); }) .enter().append("rect") -
mbostock revised this gist
Dec 24, 2016 . 1 changed file with 23 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,10 +16,18 @@ height = +svg.attr("height") - margin.top - margin.bottom, g = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")"); var x0 = d3.scaleBand() .rangeRound([0, width]) .paddingInner(0.1); var x1 = d3.scaleBand() .padding(0.05); var y = d3.scaleLinear() .rangeRound([height, 0]); var z = d3.scaleOrdinal() .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); d3.csv("data.csv", function(d, i, columns) { for (var i = 1, n = columns.length; i < n; ++i) d[columns[i]] = +d[columns[i]]; @@ -28,9 +36,10 @@ if (error) throw error; var keys = data.columns.slice(1); x0.domain(data.map(function(d) { return d.State; })); x1.domain(keys).rangeRound([0, x0.bandwidth()]); y.domain([0, d3.max(data, function(d) { return d3.max(keys, function(key) { return d[key]; }); })]).nice(); g.append("g") .selectAll("g") @@ -55,12 +64,12 @@ .attr("class", "axis") .call(d3.axisLeft(y).ticks(null, "s")) .append("text") .attr("x", 2) .attr("y", y(y.ticks().pop()) + 0.5) .attr("dy", "0.32em") .attr("fill", "#000") .attr("font-weight", "bold") .attr("text-anchor", "start") .text("Population"); var legend = g.append("g") @@ -73,15 +82,15 @@ .attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; }); legend.append("rect") .attr("x", width - 19) .attr("width", 19) .attr("height", 19) .attr("fill", z); legend.append("text") .attr("x", width - 24) .attr("y", 9.5) .attr("dy", "0.32em") .text(function(d) { return d; }); }); -
mbostock revised this gist
Dec 23, 2016 . 1 changed file with 55 additions and 90 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,123 +1,88 @@ <!DOCTYPE html> <style> .axis .domain { display: none; } </style> <svg width="960" height="500"></svg> <script src="https://d3js.org/d3.v4.min.js"></script> <script> var svg = d3.select("svg"), margin = {top: 20, right: 20, bottom: 30, left: 40}, width = +svg.attr("width") - margin.left - margin.right, height = +svg.attr("height") - margin.top - margin.bottom, g = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")"); var x0 = d3.scaleBand().rangeRound([0, width]).padding(0.1), x1 = d3.scaleBand(), y = d3.scaleLinear().rangeRound([height, 0]), z = d3.scaleOrdinal(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); d3.csv("data.csv", function(d, i, columns) { for (var i = 1, n = columns.length; i < n; ++i) d[columns[i]] = +d[columns[i]]; return d; }, function(error, data) { if (error) throw error; var keys = data.columns.slice(1); x0.domain(data.map(function(d) { return d.State; })); x1.domain(keys).rangeRound([0, x0.bandwidth()]); y.domain([0, d3.max(data, function(d) { return d3.max(keys, function(key) { return d[key]; }); })]); g.append("g") .selectAll("g") .data(data) .enter().append("g") .attr("transform", function(d) { return "translate(" + x0(d.State) + ",0)"; }) .selectAll("rect") .data(function(d) { return keys.map(function(key) { return {key: key, value: d[key]}; }); }) .enter().append("rect") .attr("x", function(d) { return x1(d.key); }) .attr("y", function(d) { return y(d.value); }) .attr("width", x1.bandwidth()) .attr("height", function(d) { return height - y(d.value); }) .attr("fill", function(d) { return z(d.key); }); g.append("g") .attr("class", "axis") .attr("transform", "translate(0," + height + ")") .call(d3.axisBottom(x0)); g.append("g") .attr("class", "axis") .call(d3.axisLeft(y).ticks(null, "s")) .append("text") .attr("fill", "#000") .attr("y", y(y.ticks().pop())) .attr("x", -28) .attr("dy", "-1em") .attr("text-anchor", "start") .attr("font-weight", "bold") .text("Population"); var legend = g.append("g") .attr("font-family", "sans-serif") .attr("font-size", 10) .attr("text-anchor", "end") .selectAll("g") .data(keys.slice().reverse()) .enter().append("g") .attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; }); legend.append("rect") .attr("x", width - 18) .attr("width", 18) .attr("height", 18) .attr("fill", z); legend.append("text") .attr("x", width - 24) .attr("y", 9) .attr("dy", "0.35em") .text(function(d) { return d; }); }); </script> -
mbostock revised this gist
Feb 9, 2016 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ license: gpl-3.0 -
mbostock revised this gist
Dec 18, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -87,7 +87,7 @@ var state = svg.selectAll(".state") .data(data) .enter().append("g") .attr("class", "state") .attr("transform", function(d) { return "translate(" + x0(d.State) + ",0)"; }); state.selectAll("rect") -
mbostock revised this gist
Oct 31, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ </style> <body> <script src="//d3js.org/d3.v3.min.js"></script> <script> var margin = {top: 20, right: 20, bottom: 30, left: 40}, -
mbostock revised this gist
Jun 11, 2015 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ </style> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> <script> var margin = {top: 20, right: 20, bottom: 30, left: 40}, @@ -57,6 +57,8 @@ .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); d3.csv("data.csv", function(error, data) { if (error) throw error; var ageNames = d3.keys(data[0]).filter(function(key) { return key !== "State"; }); data.forEach(function(d) { @@ -118,4 +120,4 @@ }); </script> -
mbostock revised this gist
Oct 14, 2012 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -70,18 +70,18 @@ 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("Population"); var state = svg.selectAll(".state") .data(data) .enter().append("g") -
mbostock revised this gist
Oct 14, 2012 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -70,7 +70,13 @@ svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis) .append("text") .attr("transform", "rotate(-90)") .attr("y", 6) .attr("dy", ".71em") .style("text-anchor", "end") .text("Population"); svg.append("g") .attr("class", "y axis") -
mbostock revised this gist
Oct 14, 2012 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ State,Under 5 Years,5 to 13 Years,14 to 17 Years,18 to 24 Years,25 to 44 Years,45 to 64 Years,65 Years and Over CA,2704659,4499890,2159981,3853788,10604510,8819342,4114496 TX,2027307,3277946,1420518,2454721,7017731,5656528,2472223 NY,1208495,2141490,1058031,1999120,5355235,5120254,2607672 FL,1140516,1938695,925060,1607297,4782119,4746856,3187797 IL,894368,1558919,725973,1311479,3596343,3239173,1575308 PA,737462,1345341,679201,1203944,3157759,3414001,1910571 -
mbostock revised this gist
Oct 14, 2012 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -76,8 +76,23 @@ .attr("class", "y axis") .call(yAxis); var state = svg.selectAll(".state") .data(data) .enter().append("g") .attr("class", "g") .attr("transform", function(d) { return "translate(" + x0(d.State) + ",0)"; }); state.selectAll("rect") .data(function(d) { return d.ages; }) .enter().append("rect") .attr("width", x1.rangeBand()) .attr("x", function(d) { return x1(d.name); }) .attr("y", function(d) { return y(d.value); }) .attr("height", function(d) { return height - y(d.value); }) .style("fill", function(d) { return color(d.name); }); var legend = svg.selectAll(".legend") .data(ageNames.slice().reverse()) .enter().append("g") .attr("class", "legend") .attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; }); @@ -95,21 +110,6 @@ .style("text-anchor", "end") .text(function(d) { return d; }); }); </script> -
mbostock revised this gist
Oct 14, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
mbostock revised this gist
Oct 14, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ .range([height, 0]); var color = d3.scale.ordinal() .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); var xAxis = d3.svg.axis() .scale(x0) -
mbostock revised this gist
Oct 14, 2012 . 1 changed file with 5 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,7 @@ State,Under 5 Years,5 to 13 Years,14 to 17 Years,18 to 24 Years,25 to 44 Years,45 to 64 Years,85 Years and Over CA,2704659,4499890,2159981,3853788,14106543,8819342,612463 TX,2027307,3277946,1420518,2454721,9157082,5656528,332872 NY,1208495,2141490,1058031,1999120,7564953,5120254,397954 FL,1140516,1938695,925060,1607297,7448550,4746856,521366 IL,894368,1558919,725973,1311479,4932730,3239173,238921 PA,737462,1345341,679201,1203944,4758088,3414001,310242 -
mbostock revised this gist
Oct 14, 2012 . 3 changed files with 10 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ This grouped bar chart is constructed from a CSV file storing the populations of different states by age group. The chart employs [conventional margins](http://bl.ocks.org/3019563) and a number of D3 features: * [d3.csv](https://github.com/mbostock/d3/wiki/CSV) - load and parse data * [d3.scale.ordinal](https://github.com/mbostock/d3/wiki/Ordinal-Scales) - *x*-position encoding and color encoding This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,10 @@ State,Under 5 Years,5 to 13 Years,14 to 17 Years,18 to 24 Years,25 to 44 Years,45 to 64 Years,85 Years and Over AL,310504,552339,259034,450818,1788160,1215966,85079 AK,52083,85640,42153,74257,244157,183159,4844 AZ,515910,828669,362642,601943,2544350,1523681,122985 AR,202070,343207,157204,264160,1102950,727124,58675 CA,2704659,4499890,2159981,3853788,14106543,8819342,612463 CO,358280,587154,261701,466194,1908747,1290094,67286 CT,211637,403658,196918,325110,1315851,968967,79111 DE,59319,99496,47414,84464,335753,230528,16118 DC,36352,50439,25225,75569,253061,140043,11144 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ .range([height, 0]); var color = d3.scale.ordinal() .range(["#4682b4", "#536793", "#574d73", "#553355", "#733247", "#8c2f39", "#a52a2a"]); var xAxis = d3.svg.axis() .scale(x0) -
mbostock revised this gist
Oct 14, 2012 . 3 changed files with 14 additions and 64 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ This grouped bar chart is constructed from a CSV file storing the populations of different states by age group. Colors by [Cynthia Brewer](http://colorbrewer2.org/). The chart employs [conventional margins](http://bl.ocks.org/3019563) and a number of D3 features: * [d3.csv](https://github.com/mbostock/d3/wiki/CSV) - load and parse data * [d3.scale.ordinal](https://github.com/mbostock/d3/wiki/Ordinal-Scales) - *x*-position encoding and color encoding @@ -7,5 +7,3 @@ This stacked bar chart is constructed from a CSV file storing the populations of * [d3.max](https://github.com/mbostock/d3/wiki/Arrays#wiki-d3_max) - compute domains * [d3.keys](https://github.com/mbostock/d3/wiki/Arrays#wiki-d3_keys) - compute column names * [d3.svg.axis](https://github.com/mbostock/d3/wiki/SVG-Axes) - display axes This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,52 +1,4 @@ State,Under 5 Years,5 to 13 Years,14 to 17 Years,18 to 24 Years,25 to 44 Years,45 to 64 Years,85 Years and Over CA,2704659,4499890,2159981,3853788,14106543,8819342,612463 NY,1208495,2141490,1058031,1999120,7564953,5120254,397954 TX,2027307,3277946,1420518,2454721,9157082,5656528,332872 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -30,17 +30,19 @@ width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; var x0 = d3.scale.ordinal() .rangeRoundBands([0, width], .1); var x1 = d3.scale.ordinal(); var y = d3.scale.linear() .range([height, 0]); var color = d3.scale.ordinal() .range(["#b2182b", "#ef8a62", "#fddbc7", "#f7f7f7", "#d1e5f0", "#67a9cf", "#2166ac"]); var xAxis = d3.svg.axis() .scale(x0) .orient("bottom"); var yAxis = d3.svg.axis() @@ -58,15 +60,12 @@ var ageNames = d3.keys(data[0]).filter(function(key) { return key !== "State"; }); data.forEach(function(d) { d.ages = ageNames.map(function(name) { return {name: name, value: +d[name]}; }); }); x0.domain(data.map(function(d) { return d.State; })); x1.domain(ageNames).rangeRoundBands([0, x0.rangeBand()]); y.domain([0, d3.max(data, function(d) { return d3.max(d.ages, function(d) { return d.value; }); })]); svg.append("g") .attr("class", "x axis") @@ -100,14 +99,15 @@ .data(data) .enter().append("g") .attr("class", "g") .attr("transform", function(d) { return "translate(" + x0(d.State) + ",0)"; }); state.selectAll("rect") .data(function(d) { return d.ages; }) .enter().append("rect") .attr("width", x1.rangeBand()) .attr("x", function(d) { return x1(d.name); }) .attr("y", function(d) { return y(d.value); }) .attr("height", function(d) { return height - y(d.value); }) .style("fill", function(d) { return color(d.name); }); }); -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -78,7 +78,7 @@ .call(yAxis); var legend = svg.selectAll(".legend") .data(ageNames.reverse()) .enter().append("g") .attr("class", "legend") .attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; }); -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -77,6 +77,25 @@ .attr("class", "y axis") .call(yAxis); var legend = svg.selectAll(".legend") .data(ageNames) .enter().append("g") .attr("class", "legend") .attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; }); legend.append("rect") .attr("x", width - 18) .attr("width", 18) .attr("height", 18) .style("fill", color); legend.append("text") .attr("x", width - 24) .attr("y", 9) .attr("dy", ".35em") .style("text-anchor", "end") .text(function(d) { return d; }); var state = svg.selectAll(".state") .data(data) .enter().append("g") -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ This stacked bar chart is constructed from a CSV file storing the populations of different states by age group. Colors by [Cynthia Brewer](http://colorbrewer2.org/). The chart employs [conventional margins](http://bl.ocks.org/3019563) and a number of D3 features: * [d3.csv](https://github.com/mbostock/d3/wiki/CSV) - load and parse data * [d3.scale.ordinal](https://github.com/mbostock/d3/wiki/Ordinal-Scales) - *x*-position encoding and color encoding -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ This stacked bar chart is constructed from a CSV file storing the populations of different states by age group. The chart employs [conventional margins](http://bl.ocks.org/3019563) and a number of D3 features: * [d3.csv](https://github.com/mbostock/d3/wiki/CSV) - load and parse data * [d3.scale.ordinal](https://github.com/mbostock/d3/wiki/Ordinal-Scales) - *x*-position encoding and color encoding * [d3.scale.linear](https://github.com/mbostock/d3/wiki/Quantitative-Scales) - *y*-position encoding * [d3.format](https://github.com/mbostock/d3/wiki/Formatting#wiki-d3_format) - SI prefix formatting (e.g., “10M” for 10,000,000) * [d3.max](https://github.com/mbostock/d3/wiki/Arrays#wiki-d3_max) - compute domains * [d3.keys](https://github.com/mbostock/d3/wiki/Arrays#wiki-d3_keys) - compute column names * [d3.svg.axis](https://github.com/mbostock/d3/wiki/SVG-Axes) - display axes This example doesn’t use [d3.layout.stack](https://github.com/mbostock/d3/wiki/Stack-Layout) because it’s easy to just stack each state independently via [array.forEach](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach). -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ .range([height, 0]); var color = d3.scale.ordinal() .range(["#b2182b", "#ef8a62", "#fddbc7", "#f7f7f7", "#d1e5f0", "#67a9cf", "#2166ac"]); var xAxis = d3.svg.axis() .scale(x) -
mbostock revised this gist
Oct 13, 2012 . 2 changed files with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ This stacked bar chart is constructed from a CSV file storing the populations of * [d3.csv](https://github.com/mbostock/d3/wiki/CSV) - load and parse data * [d3.scale.ordinal](https://github.com/mbostock/d3/wiki/Ordinal-Scales) - *x*-position encoding * [d3.scale.linear](https://github.com/mbostock/d3/wiki/Quantitative-Scales) - *y*-position encoding * d3.scale.ordinal - color encoding * d3.format - SI prefix formatting (e.g., “10M” for 10,000,000) * [d3.max](https://github.com/mbostock/d3/wiki/Arrays#wiki-d3_max) - compute domains * [d3.svg.axis](https://github.com/mbostock/d3/wiki/SVG-Axes) - display axes This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,8 @@ var y = d3.scale.linear() .range([height, 0]); var color = d3.scale.ordinal() .range(["rgb(215,48,39)","rgb(252,141,89)","rgb(254,224,144)","rgb(255,255,191)","rgb(224,243,248)","rgb(145,191,219)","rgb(69,117,180)"]); var xAxis = d3.svg.axis() .scale(x) -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -58,15 +58,14 @@ data.forEach(function(d) { var y0 = 0; d.ages = ageNames.map(function(name) { return {name: name, y0: y0, y1: y0 += +d[name]}; }); d.total = d.ages[d.ages.length - 1].y1; }); data.sort(function(a, b) { return b.total - a.total; }); x.domain(data.map(function(d) { return d.State; })); y.domain([0, d3.max(data, function(d) { return d.total; })]); svg.append("g") .attr("class", "x axis") -
mbostock revised this gist
Oct 13, 2012 . 2 changed files with 54 additions and 55 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,52 +1,52 @@ State,Under 5 Years,5 to 13 Years,14 to 17 Years,18 to 24 Years,25 to 44 Years,45 to 64 Years,85 Years and Over AL,310504,552339,259034,450818,1788160,1215966,85079 AK,52083,85640,42153,74257,244157,183159,4844 AZ,515910,828669,362642,601943,2544350,1523681,122985 AR,202070,343207,157204,264160,1102950,727124,58675 CA,2704659,4499890,2159981,3853788,14106543,8819342,612463 CO,358280,587154,261701,466194,1908747,1290094,67286 CT,211637,403658,196918,325110,1315851,968967,79111 DE,59319,99496,47414,84464,335753,230528,16118 DC,36352,50439,25225,75569,253061,140043,11144 FL,1140516,1938695,925060,1607297,7448550,4746856,521366 GA,740521,1250460,557860,919876,3705590,2389018,122419 HI,87207,134025,64011,124834,514623,331817,31681 ID,121746,201192,89702,147606,562896,375173,25501 IL,894368,1558919,725973,1311479,4932730,3239173,238921 IN,443089,780199,361393,605863,2419717,1647881,118650 IA,201321,345409,165883,306398,1116360,788485,78699 KS,202529,342134,155822,293114,1032553,713663,62319 KY,284601,493536,229927,381394,1670745,1134283,74759 LA,310716,542341,254916,471275,1630527,1128771,72250 ME,71459,133656,69752,112682,502277,397911,28719 MD,371787,651923,316873,543470,2143906,1513754,91884 MA,383568,701752,341713,665879,2510450,1751508,143097 MI,625526,1179503,585169,974480,3745900,2706100,186744 MN,358471,606802,289371,507289,1959728,1391878,106854 MS,220813,371502,174405,305964,1083566,730133,52235 MO,399450,690476,331543,560463,2253183,1554812,121678 MT,61114,106088,53156,95232,353363,278241,20246 NE,132092,215265,99638,186657,657016,451756,41008 NV,199175,325650,142976,212379,1034700,653357,31930 NH,75297,144235,73826,119114,490607,388250,24480 NJ,557421,1011656,478505,769321,3355280,2335168,175310 NM,148323,241326,112801,203097,741356,501604,35849 NY,1208495,2141490,1058031,1999120,7564953,5120254,397954 NC,652823,1097890,492964,883397,3566601,2380685,148054 ND,41896,67358,33794,82629,231417,166615,17772 OH,743750,1340492,646135,1081734,4361335,3083815,228649 OK,266547,438926,200562,369916,1377898,918688,69824 OR,243483,424167,199925,338162,1471825,1036269,76229 PA,737462,1345341,679201,1203944,4758088,3414001,310242 RI,60934,111408,56198,114502,399424,282321,26001 SC,303024,517803,245400,438147,1712803,1186019,76604 SD,58566,94438,45305,82869,292193,210178,20645 TN,416334,725948,336312,550612,2432897,1646623,106162 TX,2027307,3277946,1420518,2454721,9157082,5656528,332872 UT,268916,413034,167685,329585,985328,538978,32898 VT,32635,62538,33757,61679,229704,188593,12364 VA,522672,887525,413004,768475,3022170,2033550,121693 WA,433119,750274,357782,610378,2520000,1762811,114860 WV,105435,189649,91074,157989,717314,514505,38502 WI,362277,640286,311849,553914,2120449,1522038,117154 WY,38253,60890,29314,53980,193967,147279,8985 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -54,11 +54,10 @@ .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); d3.csv("data.csv", function(error, data) { var ageNames = d3.keys(data[0]).filter(function(key) { return key !== "State"; }); data.forEach(function(d) { var y0 = 0; d.ages = ageNames.map(function(name) { return {name: name, y0: y0, y1: y0 += +d[name]}; }); @@ -67,7 +66,7 @@ data.sort(function(a, b) { return b.Total - a.Total; }); x.domain(data.map(function(d) { return d.State; })); y.domain([0, d3.max(data, function(d) { return d.ages[d.ages.length - 1].y1; })]); svg.append("g") .attr("class", "x axis") -
mbostock revised this gist
Oct 13, 2012 . 2 changed files with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,7 @@ This stacked bar chart is constructed from a CSV file storing the populations of * [d3.csv](https://github.com/mbostock/d3/wiki/CSV) - load and parse data * [d3.scale.ordinal](https://github.com/mbostock/d3/wiki/Ordinal-Scales) - *x*-position encoding * [d3.scale.linear](https://github.com/mbostock/d3/wiki/Quantitative-Scales) - *y*-position encoding * d3.scale.category20 - color encoding * d3.format - SI prefix formatting (e.g., “10M” for 10,000,000) * [d3.max](https://github.com/mbostock/d3/wiki/Arrays#wiki-d3_max) - compute domains * [d3.svg.axis](https://github.com/mbostock/d3/wiki/SVG-Axes) - display axes This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -58,17 +58,16 @@ data.forEach(function(d) { var y0 = 0; d.Total = +d.Total; d.ages = ageNames.map(function(name) { return {name: name, y0: y0, y1: y0 += +d[name]}; }); }); data.sort(function(a, b) { return b.Total - a.Total; }); x.domain(data.map(function(d) { return d.State; })); y.domain([0, d3.max(data, function(d) { return d.Total; })]); svg.append("g") .attr("class", "x axis") -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ <script src="http://d3js.org/d3.v3.min.js"></script> <script> var margin = {top: 20, right: 20, bottom: 30, left: 40}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ <script src="http://d3js.org/d3.v3.min.js"></script> <script> var margin = {top: 20, right: 30, bottom: 30, left: 20}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -44,7 +44,8 @@ var yAxis = d3.svg.axis() .scale(y) .orient("left") .tickFormat(d3.format(".2s")); var svg = d3.select("body").append("svg") .attr("width", width + margin.left + margin.right) -
mbostock revised this gist
Oct 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,7 @@ .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); d3.csv("data.csv", function(error, data) { var ageNames = d3.keys(data[0]).filter(function(key) { return key !== "State" && key !== "Total"; }); data.forEach(function(d) {
NewerOlder