Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created September 14, 2013 22:32
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 enjalot/6566303 to your computer and use it in GitHub Desktop.
Save enjalot/6566303 to your computer and use it in GitHub Desktop.
sparc menu
{"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"}}
//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'})
[{"prices": [9, 16, 45, 85, 290], "strain": "Sativa", "thc": 16, "name": "Green Dragon"},
{"prices": [9, -1, -1, 70, 240], "strain": "Sativa", "thc": 15, "name": "Green Dragon (GH)"},
{"prices": [-1, -1, -1, 40, -1], "strain": "Sativa", "thc": 16, "name": "Green Dragon Shake"},
{"prices": [-1, 14, -1, -1, 260], "strain": "Sativa", "thc": 16, "name": "Sour Pineapple"},
{"prices": [-1, 18, 55, -1, -1], "strain": "Sativa", "thc": 17, "name": "Jack Herer"},
{"prices": [13, 18, 55, -1, -1], "strain": "Sativa", "thc": 18, "name": "Casey Jones"},
{"prices": [-1, -1, -1, 60, -1], "strain": "Sativa", "thc": 14, "name": "Pineapple Thai (OD)"},
{"prices": [9, 16, -1, -1, -1], "strain": "Sativa > Indica", "thc": 25, "name": "OG Kush"},
{"prices": [9, -1, -1, 70, 240], "strain": "Sativa > Indica", "thc": 19, "name": "OG Kush (GH)"},
{"prices": [-1, -1, 45, -1, -1], "strain": "Sativa > Indica", "thc": 9, "name": "Purple Trident CBD"},
{"prices": [13, 18, 55, -1, -1], "strain": "Sativa > Indica", "thc": 19, "name": "Dutch Crunch"},
{"prices": [7, 16, 45, -1, -1], "strain": "Sativa > Indica", "thc": 19, "name": "White Lucy"},
{"prices": [-1, 16, 45, -1, -1], "strain": "Sativa > Indica", "thc": 5, "name": "True Blueberry x OG Kush (OD)"},
{"prices": [-1, 14, 35, 65, 260], "strain": "Sativa > Indica", "thc": 13, "name": "White Russian "},
{"prices": [-1, 14, 35, 65, 260], "strain": "Sativa > Indica", "thc": 14, "name": "Standard Sour Diesel "},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica > Sativa", "thc": 11, "name": "Blueberry (GH)"},
{"prices": [-1, 18, 55, -1, 340], "strain": "Indica > Sativa", "thc": 15, "name": "Blackberry Kush"},
{"prices": [9, 16, 45, 85, 290], "strain": "Indica > Sativa", "thc": 22, "name": "Blue Dream"},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica > Sativa", "thc": 17, "name": "Blue Dream (GH)"},
{"prices": [-1, 18, 55, -1, -1], "strain": "Indica > Sativa", "thc": -1, "name": "Bubba Kush Reserve"},
{"prices": [7, 14, 35, -1, -1], "strain": "Indica > Sativa", "thc": 17, "name": "Grand AK"},
{"prices": [-1, -1, -1, 50, -1], "strain": "Indica > Sativa", "thc": 16, "name": "Cheese Quake (OD)"},
{"prices": [-1, 14, -1, -1, -1], "strain": "Indica > Sativa", "thc": 15, "name": "Monkey B (OD)"},
{"prices": [-1, 16, 45, 85, -1], "strain": "Indica > Sativa", "thc": 18, "name": "Chiesel"},
{"prices": [-1, 16, 45, -1, -1], "strain": "Indica > Sativa", "thc": 11, "name": "CannaT SR01 CBD"},
{"prices": [-1, 14, 35, -1, -1], "strain": "Indica > Sativa", "thc": -1, "name": "Purple Cheese"},
{"prices": [7, 14, 35, 65, 260], "strain": "Indica > Sativa", "thc": 18, "name": "Cheese Quake"},
{"prices": [-1, 16, 45, -1, -1], "strain": "Indica > Sativa", "thc": 21, "name": "Crystal"},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica > Sativa", "thc": 4, "name": "Remus (GH) (CBD)"},
{"prices": [-1, -1, 55, -1, -1], "strain": "Indica", "thc": 16, "name": "Grandaddy Purple"},
{"prices": [-1, 18, 55, -1, -1], "strain": "Indica", "thc": 23, "name": "Skyhash"},
{"prices": [-1, -1, -1, 60, -1], "strain": "Indica", "thc": 9, "name": "Omrita Rx3 CBD (GH)"},
{"prices": [9, 16, 45, 85, 290], "strain": "Indica", "thc": 21, "name": "Romulan"},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica", "thc": 16, "name": "Romulan (GH)"},
{"prices": [-1, 14, 35, 65, 260], "strain": "Indica", "thc": 18, "name": "Pinot Noir (OD)"},
{"prices": [-1, 7, 9, 11, 13], "strain": "General Mixed", "thc": -1, "name": "Assorted Joints"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment