[ Launch: sparc menu ] 6566303 by enjalot
[ Launch: sparc menu ] 6566151 by enjalot
-
-
Save enjalot/6566303 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/MHzzeuG.png","controls":{"price":"pre roll"}} |
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 data = tributary.menu; | |
data.sort(function(a,b) { | |
return a.thc - b.thc; | |
}) | |
var priceIndex = 0; | |
priceIndex = priceTags.indexOf(tributary.control({name:"price", options: priceTags})) | |
console.log(priceIndex); | |
var min = 0; | |
var maxThc = d3.max(data, function(d) { return d.thc }); | |
var max8th = d3.max(data, function(d) { return d.prices[priceIndex] }); | |
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, max8th]) | |
.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) | |
flowers.append("circle") | |
.attr({ | |
cx: function(d,i) { return 50 + xscale(d.prices[priceIndex]) ; }, | |
cy: function(d,i) { return 50 + yscale(d.thc) }, | |
r: 5, | |
title: function(d,i){ return d.name }, | |
fill: function(d,i) {return color(d.name) } | |
}) | |
$("circle").tipsy({gravity: 's'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment