Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created September 15, 2013 22:09
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 zeffii/6574751 to your computer and use it in GitHub Desktop.
Save zeffii/6574751 to your computer and use it in GitHub Desktop.
sparc menu cf
{"description":"sparc menu cf","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},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"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/MhEoNEG.png"}
#https://github.com/enjalot/sparcscraps
#using scrapy http://doc.scrapy.org/en/0.18/intro/tutorial.html
#to scrape http://sparcsf.org/medicine/flowers
svg = d3.select("svg")
data = tributary.menu
#console.log(data)
group1 = svg.append('g')
.classed('group1', true)
.attr
transform: 'translate(' + [172, 40] + ')'
fake_min = (d) ->
raw_min = d3.min(d.prices)
min_val = if raw_min > -1 then raw_min else d3.max(d.prices)
style_ball =
fill: '#C5C5C5',
stroke: '#686868'
'stroke-width': 1
cbd_style =
fill: '#FF2525'
stroke: '#F3F3F3'
'stroke-width': 2.64
line_height = 20
type_y_offset = 3.52
rip_color = '#7CCAE2'
price_radius = 7
tgroups = group1.selectAll('g').data(data).enter()
strain = tgroups.append('g')
.classed('strain', true)
.style style_ball
# prices
strain.append('path')
.attr
d: (d, i) ->
p1 = {x: min_val = fake_min(d), y:i*line_height}
p2 = {x: d3.max(d.prices), y:i*line_height}
'M' + [p1.x, p1.y, p2.x, p2.y]
.style
stroke: '#FAC1C1'
'stroke-width': 8
# price to thc
strain.append('path')
.attr
d: (d, i) ->
tval = d.thc
if tval >= 0
tval = d.thc* 10
y = i*line_height
p1 = {x: tval, y:y}
p2 = {x: d3.max(d.prices), y:y}
'M' + [p1.x, p1.y, p2.x, p2.y]
.style
stroke:rip_color
'stroke-width': 8
# max price
strain.append('circle')
.attr
r: price_radius
transform: (d, i) ->
'translate(' + [d3.max(d.prices), i*line_height] + ')'
strain.append('circle')
.attr
r: price_radius
transform: (d, i) ->
min_val = fake_min(d)
'translate(' + [min_val, i*line_height] + ')'
strain.append('text')
.text((d)-> d.name)
.style
'font-size': 10
'text-anchor': 'end'
stroke: 'none'
fill: '#123'
.attr
transform: (d, i) ->
pos = [-13, i*line_height + type_y_offset]
'translate(' + pos + ')'
strain.append('circle')
.attr
r: (d) ->
tval = d.thc
if tval >= 0 then 7 else 0
transform: (d, i) ->
tval = d.thc
if tval >= 0
tval = d.thc* 10
'translate(' + [tval, i*line_height] + ')'
.style
fill: rip_color
stroke: 'none'
# thc to cbd
strain.append('circle')
.attr
r: (d) ->
if d.cbd > 0 then 7 else 0
transform: (d, i) ->
'translate(' + [d.cbd*10, i*line_height] + ')'
.style cbd_style
# EOF #
[{"prices": [9, 16, 45, 85, 290], "strain": "Sativa", "thc": 16, "name": "Green Dragon", "cbd": -1},
{"prices": [9, -1, -1, 70, 240], "strain": "Sativa", "thc": 15, "name": "Green Dragon (GH)", "cbd": 1},
{"prices": [-1, -1, -1, 40, -1], "strain": "Sativa", "thc": 16, "name": "Green Dragon Shake", "cbd": -1},
{"prices": [-1, 14, -1, -1, 260], "strain": "Sativa", "thc": 16, "name": "Sour Pineapple", "cbd": -1},
{"prices": [-1, 18, 55, -1, -1], "strain": "Sativa", "thc": 17, "name": "Jack Herer", "cbd": -1},
{"prices": [13, 18, 55, -1, -1], "strain": "Sativa", "thc": 18, "name": "Casey Jones", "cbd": -1},
{"prices": [-1, -1, -1, 60, -1], "strain": "Sativa", "thc": 14, "name": "Pineapple Thai (OD)", "cbd": -1},
{"prices": [9, 16, -1, -1, -1], "strain": "Sativa > Indica", "thc": 25, "name": "OG Kush", "cbd": -1},
{"prices": [9, -1, -1, 70, 240], "strain": "Sativa > Indica", "thc": 19, "name": "OG Kush (GH)", "cbd": 1},
{"prices": [-1, -1, 45, -1, -1], "strain": "Sativa > Indica", "thc": 9, "name": "Purple Trident CBD", "cbd": 7},
{"prices": [13, 18, 55, -1, -1], "strain": "Sativa > Indica", "thc": 19, "name": "Dutch Crunch", "cbd": -1},
{"prices": [7, 16, 45, -1, -1], "strain": "Sativa > Indica", "thc": 19, "name": "White Lucy", "cbd": -1},
{"prices": [-1, 16, 45, -1, -1], "strain": "Sativa > Indica", "thc": 5, "name": "True Blueberry x OG Kush (OD)", "cbd": 12},
{"prices": [-1, 14, 35, 65, 260], "strain": "Sativa > Indica", "thc": 13, "name": "White Russian ", "cbd": -1},
{"prices": [-1, 14, 35, 65, 260], "strain": "Sativa > Indica", "thc": 14, "name": "Standard Sour Diesel ", "cbd": 1},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica > Sativa", "thc": 11, "name": "Blueberry (GH)", "cbd": -1},
{"prices": [-1, 18, 55, -1, 340], "strain": "Indica > Sativa", "thc": 15, "name": "Blackberry Kush", "cbd": 17},
{"prices": [9, 16, 45, 85, 290], "strain": "Indica > Sativa", "thc": 22, "name": "Blue Dream", "cbd": -1},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica > Sativa", "thc": 17, "name": "Blue Dream (GH)", "cbd": 1},
{"prices": [-1, 18, 55, -1, -1], "strain": "Indica > Sativa", "thc": -1, "name": "Bubba Kush Reserve", "cbd": -1},
{"prices": [7, 14, 35, -1, -1], "strain": "Indica > Sativa", "thc": 17, "name": "Grand AK", "cbd": -1},
{"prices": [-1, -1, -1, 50, -1], "strain": "Indica > Sativa", "thc": 16, "name": "Cheese Quake (OD)", "cbd": -1},
{"prices": [-1, 16, 45, 85, -1], "strain": "Indica > Sativa", "thc": 18, "name": "Chiesel", "cbd": -1},
{"prices": [-1, 16, 45, -1, -1], "strain": "Indica > Sativa", "thc": 11, "name": "CannaT SR01 CBD", "cbd": 8},
{"prices": [-1, 14, 35, -1, -1], "strain": "Indica > Sativa", "thc": -1, "name": "Purple Cheese", "cbd": -1},
{"prices": [7, 14, 35, 65, 260], "strain": "Indica > Sativa", "thc": 18, "name": "Cheese Quake", "cbd": -1},
{"prices": [-1, 16, 45, -1, -1], "strain": "Indica > Sativa", "thc": 21, "name": "Crystal", "cbd": -1},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica > Sativa", "thc": 4, "name": "Remus (GH) (CBD)", "cbd": 12},
{"prices": [-1, -1, 55, -1, -1], "strain": "Indica", "thc": 16, "name": "Grandaddy Purple", "cbd": -1},
{"prices": [-1, 18, 55, -1, -1], "strain": "Indica", "thc": 23, "name": "Skyhash", "cbd": -1},
{"prices": [-1, -1, -1, 60, -1], "strain": "Indica", "thc": 9, "name": "Omrita Rx3 CBD (GH)", "cbd": 9},
{"prices": [9, 16, 45, 85, 290], "strain": "Indica", "thc": 21, "name": "Romulan", "cbd": -1},
{"prices": [-1, -1, -1, 70, 240], "strain": "Indica", "thc": 16, "name": "Romulan (GH)", "cbd": 1},
{"prices": [-1, 14, 35, 65, 260], "strain": "Indica", "thc": 18, "name": "Pinot Noir (OD)", "cbd": -1},
{"prices": [-1, 7, 9, 11, 13], "strain": "General Mixed", "thc": -1, "name": "Assorted Joints", "cbd": -1}]
.cm-s-elegant.CodeMirror { background: #1e2426; color: #696969; }
.cm-s-elegant div.CodeMirror-selected {background: #064968 !important;} /* 33322B*/
.cm-s-elegant span.cm-variable { color:#22EFFF; }
.cm-s-elegant span.cm-variable-2 { color: #FFCCB4; }
.cm-s-elegant span.cm-variable-3 { color: white; }
.cm-s-elegant span.cm-string { color: Chartreuse; }
.cm-s-elegant span.cm-string-2 {color: Chartreuse;}
.cm-s-elegant span.cm-def {color: #FFCCB4; opacity: 1.0}
.cm-s-elegant span.cm-bracket { color: #EBEFE7; }
.cm-s-elegant pre { color:#FFF; }
.cm-s-elegant span.cm-qualifier { color:#C0C0C0; }
.cm-s-elegant span.cm-comment { color: #AFB4B4;}
.cm-s-elegant span.cm-property {color: #FDA676;}
.cm-s-elegant span.cm-number { color: #FF92EE;}
.cm-s-elegant span.cm-keyword { color: #FFFF18; }
.cm-s-elegant .CodeMirror-cursor { border-left: 1px solid white !important; }
.cm-s-elegant .CodeMirror-gutters {background: #505050;}
.cm-s-elegant .CodeMirror-linenumber {color: #D3D3D3;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment