[ Launch: sparc menu cf2 ] 6637269 by zeffii
[ Launch: sparc menu cf2 ] 6636757 by zeffii
[ Launch: sparc menu cf ] 6624241 by zeffii
[ Launch: sparc menu cf ] 6574751 by zeffii
[ Launch: sparc menu ] 6572134 by zeffii
[ Launch: sparc menu ] 6566151 by enjalot
-
-
Save zeffii/6637269 to your computer and use it in GitHub Desktop.
sparc menu cf2
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 cf2","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/D3lxEQ7.png"} |
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 | |
# with hover states | |
### todo | |
done | |
### | |
svg = d3.select("svg") | |
svg.append("rect").attr({width:"100%", height:"100%", fill: '#E2E2E2'}) | |
markers = ["pre-roll", "g", "1/8", "1/4", "oz"] | |
data = tributary.menu | |
num_items = data.length | |
# | |
# user functions and constants | |
# | |
pop_prices = (d) -> | |
rval = "" | |
for i in [0..d.prices.length] | |
price = d.prices[i] | |
if (price > 0) | |
rval += (markers[i] + ": $" + price + "<br/>") | |
rval | |
fake_min = (d) -> | |
above_zero = (i for i in d.prices when i > 0) | |
raw_min = d3.min(above_zero) | |
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 | |
# | |
# svg composition | |
# | |
group1 = svg.append('g') | |
.classed('group1', true) | |
.attr | |
transform: 'translate(' + [172, 77] + ')' | |
tgroups = group1.selectAll('g').data(data).enter() | |
strain = tgroups.append('g') | |
.classed('strain', true) | |
.style style_ball | |
# prices | |
strain | |
.attr title: (d) -> d.strain | |
strain.append('path') | |
.attr | |
d: (d, i) -> | |
p1 = {x: 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] + ')' | |
title: (d) -> pop_prices(d) | |
# min price | |
strain.append('circle') | |
.attr | |
r: price_radius | |
transform: (d, i) -> | |
min_val = fake_min(d) | |
'translate(' + [min_val, i*line_height] + ')' | |
title: (d) -> pop_prices(d) | |
# strain name | |
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 + ')' | |
# thc % | |
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] + ')' | |
title: (d) -> | |
tval = d.thc | |
if tval < 0 then 'thc unknown' else 'thc: ' + tval + '%' | |
.style | |
fill: rip_color | |
stroke: 'none' | |
# 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] + ')' | |
title: (d) -> | |
tval = d.cbd | |
if tval < 0 then 'cbd unknown' else 'cbd: ' + tval + '%' | |
.style cbd_style | |
$("g").tipsy({gravity: 'nw', offset: 10, delayIn: 200, fade: true}) | |
$("circle").tipsy({gravity: 'sw', html: true, delayIn: 200, fade: true}) | |
# | |
# axis details | |
# | |
# percent | |
td = ( d.thc*10 for d in data) | |
max_thc = d3.max(td) | |
x = d3.scale.linear().range([0, max_thc]) | |
x.domain(d3.extent(data, (d) -> return d.thc )) | |
xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("bottom") | |
group1.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(" + [0, num_items*line_height]+ ")") | |
.call(xAxis) | |
# prices | |
tp = ( d3.max(d.prices) for d in data) | |
max_price = d3.max(tp) | |
xp = d3.scale.linear().range([0, max_price]) | |
xp.domain(d3.extent(data, (d) -> return d3.max(d.prices) )) | |
xpAxis = d3.svg.axis() | |
.scale(xp) | |
.orient("top") | |
group1.append("g") | |
.attr("class", "xp axis") | |
.attr("transform", "translate(" + [0, -line_height]+ ")") | |
.call(xpAxis) | |
# legend | |
p1 = group1.append('g') | |
.attr("class", "xp axis") | |
.attr("transform", "translate(" + [137, -2.5* line_height]+ ")") | |
p1.append('text') | |
.text('Prices in $') | |
p1.append('circle') | |
.attr | |
r: price_radius | |
cx: -15 | |
cy: -3 | |
.style style_ball | |
# ingredients | |
bsize = 7 | |
p1 = group1.append('g') | |
.attr("class", "x axis") | |
.attr("transform", "translate(" + [80, (num_items+2) * line_height]+ ")") | |
p1.append('text') | |
.text('CBD %') | |
p1.append('circle') | |
.attr | |
r: price_radius | |
cx: -15 | |
cy: -3 | |
.style cbd_style | |
p1.append('text') | |
.text('THC %') | |
.attr transform: 'translate(' + [86,0] + ')' | |
p1.append('circle') | |
.attr | |
r: price_radius | |
cx: 71 | |
cy: -3 | |
.style | |
fill: rip_color | |
stroke: 'none' | |
# EOF # | |
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
.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;} | |
.axis { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
.x.axis path { | |
display: none; | |
} | |
.line { | |
fill: none; | |
stroke: steelblue; | |
stroke-width: 1.5px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment