[ Launch: sparc menu ] 6576221 by gelicia
[ Launch: sparc menu ] 6566540 by enjalot
[ Launch: sparc menu ] 6566369 by enjalot
[ Launch: sparc menu ] 6566303 by enjalot
[ Launch: sparc menu ] 6566151 by enjalot
-
-
Save gelicia/6576221 to your computer and use it in GitHub Desktop.
sparc menu
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
{"description":"sparc menu","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"menu.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/OwFgepP.png","controls":{}} |
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
//https://github.com/enjalot/sparcscraps | |
//using scrapy http://doc.scrapy.org/en/0.18/intro/tutorial.html | |
//to scrape http://sparcsf.org/medicine/flowers | |
var svg = d3.select("svg") | |
var priceTags = ['pre roll', 'gram', 'eighth', 'quarter', 'ounce']; | |
var strains = ['Sativa', 'Sativa > Indica', 'Indica > Sativa', 'Indica', 'General Mixed']; | |
var straincolor = d3.scale.ordinal() | |
.domain(strains) | |
.range([ | |
"#E9AC11", | |
"#DD1676", | |
"#9017D5", | |
"#168A11", | |
"#727272", | |
]) | |
var data = tributary.menu; | |
data.sort(function(a,b) { | |
return a.thc - b.thc; | |
}) | |
var min = 0; | |
var maxThc = d3.max(data, function(d) { return d.thc }); | |
var maxPrice = d3.max(data, function(d) { return d3.max(d.prices) }); | |
var color = d3.scale.category20b() | |
.domain(data.map(function(d) { return d.name})) | |
var yscale = d3.scale.linear() | |
.domain([0, maxThc]) | |
.range([400, 0]) | |
var xscale = d3.scale.linear() | |
.domain([0, maxPrice]) | |
.range([0, 400]); | |
var line = d3.svg.line() | |
.x(function(d,i) { | |
return xscale(i); | |
}) | |
.y(function(d,i) { | |
return yscale(d); | |
}) | |
var flowers = svg.selectAll("g.flower") | |
.data(data) | |
.enter() | |
.append("g").classed("flower", true) | |
.attr({ | |
transform: function(d,i) { | |
var x = 0; | |
var y = 50 + yscale(d.thc) | |
return "translate(" + [x,y] + ")" | |
}, | |
fill: function(d,i) {return straincolor(d.strain) }, | |
//stroke: function(d,i) {return color(d.name) }, | |
title: function(d,i){ | |
var title = d.name; | |
if(d.thc >= 0) title += " thc: " + d.thc + "%" | |
if(d.cbd >= 0) title += " cbd:" + d.cbd + "%" | |
return title | |
} | |
}) | |
flowers.selectAll("circle.price") | |
.data(function(d) { return d.prices }) | |
.enter() | |
.append("circle") | |
.attr({ | |
cx: function(d,j) { return 50 + xscale(d) ; }, | |
r: 5, | |
title: function(d,j) { | |
var title = priceTags[j] | |
if(d >= 0) | |
title += ": $" + d | |
return title | |
} | |
}).style("display", function(d) { | |
if(d >= 0) return | |
return "none" | |
}) | |
$("g").tipsy({gravity: 'nw', offset: 10}) | |
$("circle").tipsy({gravity: 's'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment