$(window).on("load",(function(){var t=d3.select("#focus-context"),a={top:10,right:10,bottom:100,left:40},e=430,n=20,r=40,i=t.node().getBoundingClientRect().width-a.left-a.right,d=500-a.top-a.bottom;height2=500-e-n;var l=d3.time.format("%b %Y").parse,s=d3.time.scale().range([0,i]),o=d3.time.scale().range([0,i]),c=d3.scale.linear().range([d,0]),p=d3.scale.linear().range([height2,0]),g=d3.svg.axis().scale(s).orient("bottom"),h=d3.svg.axis().scale(o).orient("bottom"),f=d3.svg.axis().scale(c).orient("left"),u=d3.svg.brush().x(o).on("brush",(function(){s.domain(u.empty()?o.domain():u.extent()),y.select(".d3-area").attr("d",m),y.select("d3-xaxis").call(g)})),m=d3.svg.area().interpolate("monotone").x((function(t){return s(t.date)})).y0(d).y1((function(t){return c(t.price)})),x=d3.svg.area().interpolate("monotone").x((function(t){return o(t.date)})).y0(height2).y1((function(t){return p(t.price)})),v=t.append("svg"),w=v.attr("width",i+a.left+a.right).attr("height",d+a.top+a.bottom);w.append("defs").append("clipPath").attr("id","clip").append("rect").attr("width",i).attr("height",d);var y=w.append("g").attr("class","focus").attr("transform","translate("+a.left+","+a.top+")"),b=w.append("g").attr("class","context").attr("transform","translate("+r+","+e+")");function C(){i=t.node().getBoundingClientRect().width-a.left-a.right,v.attr("width",i+a.left+a.right),w.attr("width",i+a.left+a.right),s.range([0,i]),o.range([0,i]),w.selectAll(".d3-xaxis").call(g),w.selectAll(".d3-focus-area").attr("d",m),w.selectAll(".d3-context-area").attr("d",x)}d3.csv("../../../app-assets/data/d3/line/focus-context.csv",(function(t){return t.date=l(t.date),t.price=+t.price,t}),(function(t,a){if(t)throw t;s.domain(d3.extent(a.map((function(t){return t.date})))),c.domain([0,d3.max(a.map((function(t){return t.price})))]),o.domain(s.domain()),p.domain(c.domain()),y.append("path").datum(a).attr("class","d3-area d3-focus-area").attr("d",m).style("fill","#5C6BC0"),y.append("g").attr("class","d3-axis d3-xaxis").attr("transform","translate(0,"+d+")").call(g),y.append("g").attr("class","d3-axis d3-yaxis").call(f),b.append("path").datum(a).attr("class","d3-area d3-context-area").attr("d",x).style("fill","#5C6BC0"),b.append("g").attr("class","d3-axis d3-xaxis").attr("transform","translate(0,"+height2+")").call(h),b.append("g").attr("class","d3-xbrush").call(u).selectAll("rect").attr("y",-6).attr("height",height2+7).style("fill-opacity",".225")})),$(window).on("resize",C),$(".menu-toggle").on("click",C)}));