%PDF- %PDF-
Direktori : /home/opti/workflow/src/public/app-assets/js/scripts/charts/d3/line/ |
Current File : /home/opti/workflow/src/public/app-assets/js/scripts/charts/d3/line/focus-context.min.js |
/*! * stack-admin-theme (https://pixinvent.com/bootstrap-admin-template/stack) * Copyright 2018 PIXINVENT * Licensed under the Themeforest Standard Licenses */ $(window).on("load",function(){function brushed(){x.domain(brush.empty()?x2.domain():brush.extent()),focus.select(".d3-area").attr("d",area),focus.select("d3-xaxis").call(xAxis)}function type(d){return d.date=parseDate(d.date),d.price=+d.price,d}function resize(){width=ele.node().getBoundingClientRect().width-margin.left-margin.right,container.attr("width",width+margin.left+margin.right),svg.attr("width",width+margin.left+margin.right),x.range([0,width]),x2.range([0,width]),svg.selectAll(".d3-xaxis").call(xAxis),svg.selectAll(".d3-focus-area").attr("d",area),svg.selectAll(".d3-context-area").attr("d",area2)}var ele=d3.select("#focus-context"),margin={top:10,right:10,bottom:100,left:40},margin2={top:430,right:10,bottom:20,left:40},width=ele.node().getBoundingClientRect().width-margin.left-margin.right,height=500-margin.top-margin.bottom;height2=500-margin2.top-margin2.bottom;var parseDate=d3.time.format("%b %Y").parse,x=d3.time.scale().range([0,width]),x2=d3.time.scale().range([0,width]),y=d3.scale.linear().range([height,0]),y2=d3.scale.linear().range([height2,0]),xAxis=d3.svg.axis().scale(x).orient("bottom"),xAxis2=d3.svg.axis().scale(x2).orient("bottom"),yAxis=d3.svg.axis().scale(y).orient("left"),brush=d3.svg.brush().x(x2).on("brush",brushed),area=d3.svg.area().interpolate("monotone").x(function(d){return x(d.date)}).y0(height).y1(function(d){return y(d.price)}),area2=d3.svg.area().interpolate("monotone").x(function(d){return x2(d.date)}).y0(height2).y1(function(d){return y2(d.price)}),container=ele.append("svg"),svg=container.attr("width",width+margin.left+margin.right).attr("height",height+margin.top+margin.bottom);svg.append("defs").append("clipPath").attr("id","clip").append("rect").attr("width",width).attr("height",height);var focus=svg.append("g").attr("class","focus").attr("transform","translate("+margin.left+","+margin.top+")"),context=svg.append("g").attr("class","context").attr("transform","translate("+margin2.left+","+margin2.top+")");d3.csv("../../../app-assets/data/d3/line/focus-context.csv",type,function(error,data){if(error)throw error;x.domain(d3.extent(data.map(function(d){return d.date}))),y.domain([0,d3.max(data.map(function(d){return d.price}))]),x2.domain(x.domain()),y2.domain(y.domain()),focus.append("path").datum(data).attr("class","d3-area d3-focus-area").attr("d",area).style("fill","#5C6BC0"),focus.append("g").attr("class","d3-axis d3-xaxis").attr("transform","translate(0,"+height+")").call(xAxis),focus.append("g").attr("class","d3-axis d3-yaxis").call(yAxis),context.append("path").datum(data).attr("class","d3-area d3-context-area").attr("d",area2).style("fill","#5C6BC0"),context.append("g").attr("class","d3-axis d3-xaxis").attr("transform","translate(0,"+height2+")").call(xAxis2),context.append("g").attr("class","d3-xbrush").call(brush).selectAll("rect").attr("y",-6).attr("height",height2+7).style("fill-opacity",".225")}),$(window).on("resize",resize),$(".menu-toggle").on("click",resize)});