$(window).on("load",(function(){var t=d3.select("#difference-chart"),a={top:20,right:20,bottom:30,left:50},e=t.node().getBoundingClientRect().width-a.left-a.right,n=500-a.top-a.bottom,r=d3.time.format("%Y%m%d").parse,i=d3.time.scale().range([0,e]),d=d3.scale.linear().range([n,0]),o=d3.svg.axis().scale(i).orient("bottom"),l=d3.svg.axis().scale(d).orient("left"),s=d3.svg.area().interpolate("basis").x((function(t){return i(t.date)})).y((function(t){return d(t["New York"])})),c=d3.svg.area().interpolate("basis").x((function(t){return i(t.date)})).y1((function(t){return d(t["New York"])})),p=t.append("svg"),f=p.attr("width",e+a.left+a.right).attr("height",n+a.top+a.bottom).append("g").attr("transform","translate("+a.left+","+a.top+")");function h(){e=t.node().getBoundingClientRect().width-a.left-a.right,p.attr("width",e+a.left+a.right),f.attr("width",e+a.left+a.right),i.range([0,e]),f.selectAll(".d3-xaxis").call(o),f.selectAll(".d3-area").attr("d",c)}d3.tsv("../../../app-assets/data/d3/line/difference.tsv",(function(t,a){if(t)throw t;a.forEach((function(t){t.date=r(t.date),t["New York"]=+t["New York"],t["San Francisco"]=+t["San Francisco"]})),i.domain(d3.extent(a,(function(t){return t.date}))),d.domain([d3.min(a,(function(t){return Math.min(t["New York"],t["San Francisco"])})),d3.max(a,(function(t){return Math.max(t["New York"],t["San Francisco"])}))]),f.datum(a),f.append("clipPath").attr("id","clip-below").append("path").attr("d",c.y0(n)),f.append("clipPath").attr("id","clip-above").append("path").attr("d",c.y0(0)),f.append("path").attr("class","d3-area above").attr("clip-path","url(#clip-above)").attr("d",c.y0((function(t){return d(t["San Francisco"])}))).style("fill","#00BCD4"),f.append("path").attr("class","d3-area below").attr("clip-path","url(#clip-below)").attr("d",c).style("fill","#E91E63"),f.append("path").attr("class","d3-line").attr("d",s),f.append("g").attr("class","d3-axis d3-xaxis").attr("transform","translate(0,"+n+")").call(o),f.append("g").attr("class","d3-axis d3-yaxis").call(l).append("text").attr("transform","rotate(-90)").attr("y",6).attr("dy",".71em").style("text-anchor","end").style("fill","#666").style("font-size",12).text("Temperature (ºF)")})),$(window).on("resize",h),$(".menu-toggle").on("click",h)}));