From 90a4fc41510358a5f118816ea10a735724158192 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Wed, 23 Oct 2013 20:18:18 +0700 Subject: [PATCH] Set '#chart' as default bindto --- c3.js | 10 ++-- c3.min.js | 124 ++++++++++++++++++++++---------------------- htdocs/js/c3.min.js | 124 ++++++++++++++++++++++---------------------- 3 files changed, 129 insertions(+), 129 deletions(-) diff --git a/c3.js b/c3.js index e36f432..d22b2d2 100644 --- a/c3.js +++ b/c3.js @@ -28,7 +28,7 @@ } // bindto - id to bind the chart - checkConfig('bindto', 'bindto is required in config'); + var __bindto = getConfig(['size','width'], '#chart'); var __size_width = getConfig(['size','width'], null), __size_height = getConfig(['size','height'], 280); @@ -133,7 +133,7 @@ /*-- Set Variables --*/ - var clipId = config.bindto.replace('#','') + '-clip', + var clipId = __bindto.replace('#','') + '-clip', clipPath = "url(#" + clipId + ")"; var isTimeSeries = (__axis_x_type === 'timeseries'), @@ -303,7 +303,7 @@ var color = generateColor(__data_colors, __color_pattern); // Define svgs - var svg = d3.select(config.bindto).append("svg") + var svg = d3.select(__bindto).append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom); @@ -348,7 +348,7 @@ } // Define tooltip - var tooltip = d3.select(config.bindto) + var tooltip = d3.select(__bindto) .style("position", "relative") .append("div") .style("position", "absolute") @@ -360,7 +360,7 @@ function getParentWidth () { // TODO: if rotated, use height - return +d3.select(config.bindto).style("width").replace('px',''); + return +d3.select(__bindto).style("width").replace('px',''); } //-- Scale --// diff --git a/c3.min.js b/c3.min.js index d47981b..241c74d 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,62 +1,62 @@ -(function(rb){function sb(){function k(c,Xa){c.attr("transform",function(c){return"translate("+(Xa(c)+T)+",0)"})}function u(c,k){c.attr("transform",function(c){return"translate(0,"+k(c)+")"})}function Ha(c){var k=c[0];c=c[c.length-1];return kr[d].indexOf(c.id)))for(e=0;e=t;t+=diffx2)q+=c(a[f-1],a[f],t,m);return q}function Ub(){return"translate("+(g?0:s)+","+(g?10:0)+")"}function hb(a){var b=l.data.targets=N(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));Q.domain(E(b,"y2"));C.domain(m.domain());Ka.domain(x.domain());La.domain(Q.domain());D.ticks(10>a.length? -a.length:10);ka.ticks(yc).outerTickSize(0).tickFormat(zc);Ma.ticks(Ac).outerTickSize(0).tickFormat(Bc);Eb=m.domain();R.x(C);ma&&Ba.x(m);h.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(g?ka:D);h.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?D:ka).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Cc);xb&&h.append("g").attr("class", -"y2 axis").attr("transform",Ub).call(Ma);if(ma)h.append("rect").attr("class","zoom-rect").attr("width",s).attr("height",v).style("opacity",0).call(Ba).on("dblclick.zoom",null);d=h.append("g").attr("clip-path",Sa).attr("class","grid");Vb&&d.append("g").attr("class","xgrids");ib&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(ib).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+ -a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-p).attr("dy",-6).text(function(a){return a.text}));Dc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?s:-10).attr("y1",g?-10:p).attr("y2",g?-10:v);Wb&&d.append("g").attr("class","ygrids");jb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(jb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]}); -h.append("g").attr("clip-path",Sa).attr("class","regions");h.append("g").attr("clip-path",Sa).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return Y&&da?"pointer":null}).on("mouseover",function(a,b){if(!Ta){var d=l.data.targets.map(function(a){return Ia(a.values[b])}),c,e;if(0",d,c,f;for(d=0;d"+f+""+c+"";return b+""}),Fc=c(["tooltip","init","show"],!1),pa=c(["tooltip","init","x"],0),ac=c(["tooltip","init","position"],{top:"0px",left:"50px"}), -pb=y.bindto.replace("#","")+"-clip",Sa="url(#"+pb+")",H="timeseries"===dc,ga="categorized"===dc,mb=null,Ta=!1,lb=!1,ba=oa?40:0,Oc=function(a){return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"), -function(a){return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),function(a){return a.getMilliseconds()}]]),ca=d3.time.format(Lc).parse,ub,zb,wb,yb,Ab,s,v,ja,Cb,Db,ab,bb,m,x,Q,C,Ka,La,D=ga?sb():d3.svg.axis(),ka=d3.svg.axis(),Ma=d3.svg.axis(),la=ga?sb():d3.svg.axis();P();T();H&&D.tickFormat(Oc);ga?(D.categories(Va).tickCentered(ec),la.categories(Va).tickCentered(ec)):(D.tickOffset=function(){return 0}, -la.tickOffset=function(){return 0});ga&&function(){var a=m,b=C,c=Object.keys(m),e,f;m=function(b){return a(b)+D.tickOffset()};C=function(a){return b(a)+la.tickOffset()};for(f=0;fa?0:a},S=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Mc,Nc),Wa=d3.select(y.bindto).append("svg").attr("width",s+G+B).attr("height",v+p+U),qb=Wa.append("defs");qb.append("clipPath").attr("id",pb).append("rect").attr("y",p).attr("width",s).attr("height",v-p);qb.append("clipPath").attr("id", -"xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",s+2).attr("height",40);qb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+1).attr("y",p-1).attr("width",G).attr("height",v-p+2);var h=Wa.append("g").attr("transform","translate("+G+","+p+")"),K=null;na&&(K=Wa.append("g").attr("transform","translate("+J+","+qa+")"));var Fa=null;oa&&(Fa=Wa.append("g").attr("transform","translate("+Ha+","+tb+")"));var ea=d3.select(y.bindto).style("position","relative").append("div").style("position", -"absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),R=d3.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1})}),Ba=d3.behavior.zoom().on("zoom",ma?Jc:null),Qa=null,cb=null,Eb;l.focus=function(a){l.defocus();d3.selectAll(Ga(a)).filter(function(a){return Ya(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Ga(a)).filter(function(a){return Ya(a.id)}).classed("focused",!1).transition().duration(100).style("opacity", -0.3)};l.revert=function(a){d3.selectAll(Ga(a)).filter(function(a){return Ya(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Ga(a)).transition().style("opacity",1)};l.hide=function(a){d3.selectAll(Ga(a)).transition().style("opacity",0)};l.load=function(a){u(a.done)&&(a.done=function(){});if("cacheIds"in a&&ha(a.cacheIds))Da(ia(a.cacheIds),a.done);else if("data"in a)Da(N(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Da(N(c),a.done)}); -else if("rows"in a)Da(N(ra(a.rows)),a.done);else if("columns"in a)Da(N(sa(a.columns)),a.done);else throw Error("url or rows or columns is required.");};l.unload=function(a){l.data.targets=l.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();oa&&(d3.selectAll(".legend-item-"+a).remove(),Ua(l.data.targets));0b.classes.indexOf(a)})});return L};l.data.get=function(a){a=l.data.getAsTarget(a);return k(a)?a.values.map(function(a){return a.value}):void 0};l.data.getAsTarget=function(a){var b=Na(function(b){return b.id==a});return 0r[d].indexOf(c.id)))for(e=0;e=t;t+=diffx2)q+=c(a[f-1],a[f],t,m);return q}function Vb(){return"translate("+(g?0:s)+","+(g?10:0)+")"}function ib(a){var b=l.data.targets=M(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(D(b,"y"));P.domain(D(b,"y2"));B.domain(m.domain());La.domain(x.domain());Ma.domain(P.domain());C.ticks(10>a.length? +a.length:10);ka.ticks(zc).outerTickSize(0).tickFormat(Ac);Na.ticks(Bc).outerTickSize(0).tickFormat(Cc);Fb=m.domain();Q.x(B);ma&&Ba.x(m);h.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(g?ka:C);h.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?C:ka).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Dc);yb&&h.append("g").attr("class", +"y2 axis").attr("transform",Vb).call(Na);if(ma)h.append("rect").attr("class","zoom-rect").attr("width",s).attr("height",v).style("opacity",0).call(Ba).on("dblclick.zoom",null);d=h.append("g").attr("clip-path",Ta).attr("class","grid");Wb&&d.append("g").attr("class","xgrids");jb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(jb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+ +a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-p).attr("dy",-6).text(function(a){return a.text}));Ec&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?s:-10).attr("y1",g?-10:p).attr("y2",g?-10:v);Xb&&d.append("g").attr("class","ygrids");kb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(kb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]}); +h.append("g").attr("clip-path",Ta).attr("class","regions");h.append("g").attr("clip-path",Ta).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return Y&&da?"pointer":null}).on("mouseover",function(a,b){if(!Ua){var d=l.data.targets.map(function(a){return Ia(a.values[b])}),c,e;if(0",d,c,f;for(d=0;d"+f+""+c+"";return b+""}),Gc=c(["tooltip","init","show"],!1),pa=c(["tooltip","init","x"],0),bc=c(["tooltip","init","position"],{top:"0px",left:"50px"}), +qb=Ka.replace("#","")+"-clip",Ta="url(#"+qb+")",G="timeseries"===ec,ga="categorized"===ec,nb=null,Ua=!1,mb=!1,ba=oa?40:0,Pc=function(a){return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){return a.getHours()}], +[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),function(a){return a.getMilliseconds()}]]),ca=d3.time.format(Mc).parse,vb,Ab,xb,zb,Bb,s,v,ja,Db,Eb,bb,cb,m,x,P,B,La,Ma,C=ga?tb():d3.svg.axis(),ka=d3.svg.axis(),Na=d3.svg.axis(),la=ga?tb():d3.svg.axis();O();T();G&&C.tickFormat(Pc);ga?(C.categories(Wa).tickCentered(fc),la.categories(Wa).tickCentered(fc)):(C.tickOffset=function(){return 0},la.tickOffset=function(){return 0}); +ga&&function(){var a=m,b=B,c=Object.keys(m),e,f;m=function(b){return a(b)+C.tickOffset()};B=function(a){return b(a)+la.tickOffset()};for(f=0;fa?0:a},R=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Nc,Oc),Xa=d3.select(Ka).append("svg").attr("width",s+F+A).attr("height",v+p+U),rb=Xa.append("defs");rb.append("clipPath").attr("id",qb).append("rect").attr("y",p).attr("width",s).attr("height",v-p);rb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x", +-1).attr("y",-1).attr("width",s+2).attr("height",40);rb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-F+1).attr("y",p-1).attr("width",F).attr("height",v-p+2);var h=Xa.append("g").attr("transform","translate("+F+","+p+")"),J=null;na&&(J=Xa.append("g").attr("transform","translate("+I+","+qa+")"));var Fa=null;oa&&(Fa=Xa.append("g").attr("transform","translate("+Ha+","+ub+")"));var ea=d3.select(Ka).style("position","relative").append("div").style("position","absolute").style("width", +"30%").style("z-index","10").style("visibility","hidden"),Q=d3.svg.brush().on("brush",function(){H({withTransition:!1,withY:!1,withSubchart:!1})}),Ba=d3.behavior.zoom().on("zoom",ma?Kc:null),Ra=null,db=null,Fb;l.focus=function(a){l.defocus();d3.selectAll(Ga(a)).filter(function(a){return Za(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Ga(a)).filter(function(a){return Za(a.id)}).classed("focused",!1).transition().duration(100).style("opacity", +0.3)};l.revert=function(a){d3.selectAll(Ga(a)).filter(function(a){return Za(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Ga(a)).transition().style("opacity",1)};l.hide=function(a){d3.selectAll(Ga(a)).transition().style("opacity",0)};l.load=function(a){u(a.done)&&(a.done=function(){});if("cacheIds"in a&&ha(a.cacheIds))Da(ia(a.cacheIds),a.done);else if("data"in a)Da(M(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Da(M(c),a.done)}); +else if("rows"in a)Da(M(ra(a.rows)),a.done);else if("columns"in a)Da(M(sa(a.columns)),a.done);else throw Error("url or rows or columns is required.");};l.unload=function(a){l.data.targets=l.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();oa&&(d3.selectAll(".legend-item-"+a).remove(),Va(l.data.targets));0b.classes.indexOf(a)})});return K};l.data.get=function(a){a=l.data.getAsTarget(a);return k(a)?a.values.map(function(a){return a.value}):void 0};l.data.getAsTarget=function(a){var b=Oa(function(b){return b.id==a});return 0r[d].indexOf(c.id)))for(g=0;g=t;t+=diffx2)q+=c(a[f-1],a[f],t,m);return q}function Sb(){return"translate("+(e?0:s)+","+(e?10:0)+")"}function gb(a){var b=l.data.targets=N(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));Q.domain(E(b,"y2"));C.domain(m.domain());Ja.domain(x.domain());Ka.domain(Q.domain());D.ticks(10>a.length? -a.length:10);ka.ticks(wc).outerTickSize(0).tickFormat(xc);La.ticks(yc).outerTickSize(0).tickFormat(zc);Cb=m.domain();R.x(C);Aa.x(m);h.append("g").attr("class","x axis").attr("clip-path",e?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(e?ka:D);h.append("g").attr("class","y axis").attr("clip-path",e?"url(#yaxis-clip)":"").call(e?D:ka).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Ac);vb&&h.append("g").attr("class", -"y2 axis").attr("transform",Sb).call(La);h.append("rect").attr("class","zoom-rect").attr("width",s).attr("height",v).style("opacity",0).call(Aa);d=h.append("g").attr("clip-path",Ra).attr("class","grid");Tb&&d.append("g").attr("class","xgrids");hb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(hb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor", -"end").attr("transform",e?"":"rotate(-90)").attr("dx",e?0:-p).attr("dy",-6).text(function(a){return a.text}));Bc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",e?0:-10).attr("x2",e?s:-10).attr("y1",e?-10:p).attr("y2",e?-10:v);Ub&&d.append("g").attr("class","ygrids");ib&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(ib).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path", -Ra).attr("class","regions");h.append("g").attr("clip-path",Ra).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return Y&&da?"pointer":null}).on("mouseover",function(a,b){if(!Sa){var d=l.data.targets.map(function(a){return Ha(a.values[b])}),c,g;if(0",d,c,f;for(d=0;d"+f+""+c+"";return b+""}),Dc=c(["tooltip","init","show"],!1),oa=c(["tooltip","init","x"],0),Zb=c(["tooltip","init","position"],{top:"0px",left:"50px"}),nb=y.bindto.replace("#","")+"-clip",Ra="url(#"+nb+")",H="timeseries"===bc,ga="categorized"===bc,kb=null,Sa=!1,ba=na?40:0,Lc=function(a){return function(b){for(var d=a.length-1,c=a[d];!c[1](b);)c= -a[--d];return c[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),function(a){return a.getMilliseconds()}]]), -ca=d3.time.format(Ic).parse,sb,xb,ub,wb,yb,s,v,ja,Ab,Bb,$a,ab,m,x,Q,C,Ja,Ka,D=ga?qb():d3.svg.axis(),ka=d3.svg.axis(),La=d3.svg.axis(),la=ga?qb():d3.svg.axis();P();T();H&&D.tickFormat(Lc);ga?(D.categories(Ua).tickCentered(cc),la.categories(Ua).tickCentered(cc)):(D.tickOffset=function(){return 0},la.tickOffset=function(){return 0});ga&&function(){var a=m,b=C,c=Object.keys(m),g,f;m=function(b){return a(b)+D.tickOffset()};C=function(a){return b(a)+la.tickOffset()};for(f=0;fa?0:a},S=function(a,b){var c=[],g=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in -a)return a[b];0<=c.indexOf(b)||c.push(b);return g[c.indexOf(b)%g.length]}}(Jc,Kc),Va=d3.select(y.bindto).append("svg").attr("width",s+G+B).attr("height",v+p+U),ob=Va.append("defs");ob.append("clipPath").attr("id",nb).append("rect").attr("y",p).attr("width",s).attr("height",v-p);ob.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",s+2).attr("height",40);ob.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+1).attr("y",p-1).attr("width", -G).attr("height",v-p+2);var h=Va.append("g").attr("transform","translate("+G+","+p+")"),K=null;ma&&(K=Va.append("g").attr("transform","translate("+J+","+pa+")"));var Ea=null;na&&(Ea=Va.append("g").attr("transform","translate("+Ga+","+rb+")"));var ea=d3.select(y.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),R=d3.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1})}), -Aa=d3.behavior.zoom().on("zoom",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!1})}),Pa=null,bb=null,Cb;l.focus=function(a){l.defocus();d3.selectAll(Fa(a)).filter(function(a){return Xa(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Fa(a)).filter(function(a){return Xa(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};l.revert=function(a){d3.selectAll(Fa(a)).filter(function(a){return Xa(a.id)}).classed("focused", -!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Fa(a)).transition().style("opacity",1)};l.hide=function(a){d3.selectAll(Fa(a)).transition().style("opacity",0)};l.load=function(a){u(a.done)&&(a.done=function(){});if("cacheIds"in a&&ha(a.cacheIds))Ca(ia(a.cacheIds),a.done);else if("data"in a)Ca(N(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Ca(N(c),a.done)});else if("rows"in a)Ca(N(qa(a.rows)),a.done);else if("columns"in a)Ca(N(ra(a.columns)),a.done); -else throw Error("url or rows or columns is required.");};l.unload=function(a){l.data.targets=l.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();na&&(d3.selectAll(".legend-item-"+a).remove(),Ta(l.data.targets));0b.classes.indexOf(a)})});return L};l.data.get=function(a){a=l.data.getAsTarget(a);return k(a)?a.values.map(function(a){return a.value}):void 0};l.data.getAsTarget=function(a){var b=Ma(function(b){return b.id==a});return 0r[d].indexOf(c.id)))for(e=0;e=t;t+=diffx2)q+=c(a[f-1],a[f],t,m);return q}function Vb(){return"translate("+(g?0:s)+","+(g?10:0)+")"}function ib(a){var b=l.data.targets=M(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(D(b,"y"));P.domain(D(b,"y2"));B.domain(m.domain());La.domain(x.domain());Ma.domain(P.domain());C.ticks(10>a.length? +a.length:10);ka.ticks(zc).outerTickSize(0).tickFormat(Ac);Na.ticks(Bc).outerTickSize(0).tickFormat(Cc);Fb=m.domain();Q.x(B);ma&&Ba.x(m);h.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(g?ka:C);h.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?C:ka).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Dc);yb&&h.append("g").attr("class", +"y2 axis").attr("transform",Vb).call(Na);if(ma)h.append("rect").attr("class","zoom-rect").attr("width",s).attr("height",v).style("opacity",0).call(Ba).on("dblclick.zoom",null);d=h.append("g").attr("clip-path",Ta).attr("class","grid");Wb&&d.append("g").attr("class","xgrids");jb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(jb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+ +a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-p).attr("dy",-6).text(function(a){return a.text}));Ec&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?s:-10).attr("y1",g?-10:p).attr("y2",g?-10:v);Xb&&d.append("g").attr("class","ygrids");kb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(kb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]}); +h.append("g").attr("clip-path",Ta).attr("class","regions");h.append("g").attr("clip-path",Ta).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return Y&&da?"pointer":null}).on("mouseover",function(a,b){if(!Ua){var d=l.data.targets.map(function(a){return Ia(a.values[b])}),c,e;if(0",d,c,f;for(d=0;d"+f+""+c+"";return b+""}),Gc=c(["tooltip","init","show"],!1),pa=c(["tooltip","init","x"],0),bc=c(["tooltip","init","position"],{top:"0px",left:"50px"}), +qb=Ka.replace("#","")+"-clip",Ta="url(#"+qb+")",G="timeseries"===ec,ga="categorized"===ec,nb=null,Ua=!1,mb=!1,ba=oa?40:0,Pc=function(a){return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){return a.getHours()}], +[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),function(a){return a.getMilliseconds()}]]),ca=d3.time.format(Mc).parse,vb,Ab,xb,zb,Bb,s,v,ja,Db,Eb,bb,cb,m,x,P,B,La,Ma,C=ga?tb():d3.svg.axis(),ka=d3.svg.axis(),Na=d3.svg.axis(),la=ga?tb():d3.svg.axis();O();T();G&&C.tickFormat(Pc);ga?(C.categories(Wa).tickCentered(fc),la.categories(Wa).tickCentered(fc)):(C.tickOffset=function(){return 0},la.tickOffset=function(){return 0}); +ga&&function(){var a=m,b=B,c=Object.keys(m),e,f;m=function(b){return a(b)+C.tickOffset()};B=function(a){return b(a)+la.tickOffset()};for(f=0;fa?0:a},R=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Nc,Oc),Xa=d3.select(Ka).append("svg").attr("width",s+F+A).attr("height",v+p+U),rb=Xa.append("defs");rb.append("clipPath").attr("id",qb).append("rect").attr("y",p).attr("width",s).attr("height",v-p);rb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x", +-1).attr("y",-1).attr("width",s+2).attr("height",40);rb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-F+1).attr("y",p-1).attr("width",F).attr("height",v-p+2);var h=Xa.append("g").attr("transform","translate("+F+","+p+")"),J=null;na&&(J=Xa.append("g").attr("transform","translate("+I+","+qa+")"));var Fa=null;oa&&(Fa=Xa.append("g").attr("transform","translate("+Ha+","+ub+")"));var ea=d3.select(Ka).style("position","relative").append("div").style("position","absolute").style("width", +"30%").style("z-index","10").style("visibility","hidden"),Q=d3.svg.brush().on("brush",function(){H({withTransition:!1,withY:!1,withSubchart:!1})}),Ba=d3.behavior.zoom().on("zoom",ma?Kc:null),Ra=null,db=null,Fb;l.focus=function(a){l.defocus();d3.selectAll(Ga(a)).filter(function(a){return Za(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Ga(a)).filter(function(a){return Za(a.id)}).classed("focused",!1).transition().duration(100).style("opacity", +0.3)};l.revert=function(a){d3.selectAll(Ga(a)).filter(function(a){return Za(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Ga(a)).transition().style("opacity",1)};l.hide=function(a){d3.selectAll(Ga(a)).transition().style("opacity",0)};l.load=function(a){u(a.done)&&(a.done=function(){});if("cacheIds"in a&&ha(a.cacheIds))Da(ia(a.cacheIds),a.done);else if("data"in a)Da(M(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Da(M(c),a.done)}); +else if("rows"in a)Da(M(ra(a.rows)),a.done);else if("columns"in a)Da(M(sa(a.columns)),a.done);else throw Error("url or rows or columns is required.");};l.unload=function(a){l.data.targets=l.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();oa&&(d3.selectAll(".legend-item-"+a).remove(),Va(l.data.targets));0b.classes.indexOf(a)})});return K};l.data.get=function(a){a=l.data.getAsTarget(a);return k(a)?a.values.map(function(a){return a.value}):void 0};l.data.getAsTarget=function(a){var b=Oa(function(b){return b.id==a});return 0