Skip to content

Instantly share code, notes, and snippets.

@DeBraid
Created February 5, 2014 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeBraid/8829900 to your computer and use it in GitHub Desktop.
Save DeBraid/8829900 to your computer and use it in GitHub Desktop.
Crowdfunding Stats: vertical
{"description":"Crowdfunding Stats: vertical","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/M3GfyRM.png"}
[
{
"Category ":"All",
"Success":55797,
"Under $1000":6033,
"$1000-$9999":35439,
"$10000-19999":7461,
"$20000-99999":5755,
"100K - $999999":1053,
"Over $1 Million":56
},
{
"Category ":"Music",
"Success":14744,
"Under $1000":1434,
"$1000-$9999":10935,
"$10000-19999":1709,
"$20000-99999":634,
"100K - $999999":31,
"Over $1 Million":1
},
{
"Category ":"Film & Video",
"Success":12796,
"Under $1000":1216,
"$1000-$9999":7748,
"$10000-19999":2008,
"$20000-99999":1668,
"100K - $999999":153,
"Over $1 Million":3
},
{
"Category ":"Art",
"Success":5491,
"Under $1000":1035,
"$1000-$9999":3782,
"$10000-19999":457,
"$20000-99999":203,
"100K - $999999":14,
"Over $1 Million":0
},
{
"Category ":"Publishing",
"Success":4985,
"Under $1000":763,
"$1000-$9999":3258,
"$10000-19999":588,
"$20000-99999":351,
"100K - $999999":25,
"Over $1 Million":0
},
{
"Category ":"Theater",
"Success":3502,
"Under $1000":465,
"$1000-$9999":2634,
"$10000-19999":258,
"$20000-99999":137,
"100K - $999999":8,
"Over $1 Million":0
},
{
"Category ":"Games",
"Success":2822,
"Under $1000":150,
"$1000-$9999":1091,
"$10000-19999":541,
"$20000-99999":763,
"100K - $999999":248,
"Over $1 Million":29
},
{
"Category ":"Design",
"Success":2433,
"Under $1000":146,
"$1000-$9999":852,
"$10000-19999":458,
"$20000-99999":719,
"100K - $999999":249,
"Over $1 Million":9
},
{
"Category ":"Food",
"Success":2042,
"Under $1000":93,
"$1000-$9999":1002,
"$10000-19999":528,
"$20000-99999":397,
"100K - $999999":22,
"Over $1 Million":0
},
{
"Category ":"Comics",
"Success":1703,
"Under $1000":216,
"$1000-$9999":1024,
"$10000-19999":246,
"$20000-99999":187,
"100K - $999999":29,
"Over $1 Million":1
},
{
"Category ":"Fashion",
"Success":1464,
"Under $1000":149,
"$1000-$9999":816,
"$10000-19999":229,
"$20000-99999":234,
"100K - $999999":35,
"Over $1 Million":1
},
{
"Category ":"Photography",
"Success":1426,
"Under $1000":219,
"$1000-$9999":936,
"$10000-19999":182,
"$20000-99999":87,
"100K - $999999":1,
"Over $1 Million":1
},
{
"Category ":"Technology",
"Success":1212,
"Under $1000":52,
"$1000-$9999":385,
"$10000-19999":173,
"$20000-99999":353,
"100K - $999999":238,
"Over $1 Million":11
},
{
"Category ":"Dance",
"Success":1177,
"Under $1000":95,
"$1000-$9999":976,
"$10000-19999":84,
"$20000-99999":22,
"100K - $999999":0,
"Over $1 Million":0
}
]
// Example http://bl.ocks.org/mbostock/3887051
var data = tributary.data;
// constants
var width = 800;
var height = 900;
var numGroups = data.length; // total unique categories
var numSeries = 6; // break outs based on $ value
var c = [ "#E41A1C", "#377EB8", "#4DAF4A", "#f7fcb9", "#addd8e", "#31a354" ];
// total $ raised d.Success
var yRange = d3.extent(data, function(d, i){ return data[i].Success; });
// range of values from
var x0 = d3.scale.ordinal()
.domain(d3.range(numGroups))
.rangeBands([width, 0.3]);
var x1 = d3.scale.ordinal()
.domain(d3.range(numSeries))
.rangeBands([0, x0.rangeBand()]);
var y = d3.scale.linear()
.domain([yRange])
.range([0, height])
//canvas
var canvas = d3.select("svg")
.attr({"width": width,
"height": height
});
var series = canvas.selectAll("g.series")
.data(data)
.enter().append("svg:g")
.attr({
"class": "series",
"fill": function(d,i) { return c[i]; },
"transform": function (d,i) { return "translate(" + x1(i) + ")"; }
});
var groups = series.selectAll("rect")
.data(data)
.enter().append("svg:rect")
.attr({
"x": 0,
"y": function(d, i) { return height - y(d[i].Success); },
"width": x1.rangeBand(),
"height": y,
"transform": function(d,i) { return "translate(" + x0(i) + ")"; }
})
/*
var rects = canvas.selectAll("rect")
.data(data).enter().append("svg:rect").attr()
// text on y axis d.Category
var labels = canvas.selectAll("text")
.data(data)
.enter().append("text").text(function (d,i) { return d[i].Category; })
.attr({
"x": 100,
"dy": "1.5em"
});
console.log("bazzz");
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment