diff --git a/c3.js b/c3.js index e757a99..f2c92c1 100644 --- a/c3.js +++ b/c3.js @@ -847,6 +847,10 @@ var orgXDomain; + function translateForY2 () { + return "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 10 : 0) + ")"; + } + function init (data) { var targets = c3.data.targets = convertDataToTargets(data); var rectX, rectW; @@ -895,7 +899,7 @@ if (__axis_y2_show) { main.append("g") .attr("class", "y2 axis") - .attr("transform", "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 10 : 0) + ")") + .attr("transform", translateForY2) .call(yAxis2); } @@ -1429,6 +1433,8 @@ d3.select('svg').attr('width', width + margin.left + margin.right); d3.select('#'+clipId).select('rect').attr('width', width); d3.select('#xaxis-clip').select('rect').attr('width', width + 2); + // Update Axis translate + d3.select('g.y2.axis').attr("transform", translateForY2) // Update legend if (__legend_show) updateLegend(c3.data.targets, {withTransition:false}); // Draw with new sizes & scales diff --git a/c3.min.js b/c3.min.js index 925047c..f4bcf87 100644 --- a/c3.min.js +++ b/c3.min.js @@ -4,59 +4,59 @@ B(0))/2;E=c?0:S;switch(p){case "bottom":A=k;qa.attr("y2",C);sa.attr("y",Math.max ".32em").style("text-anchor","end"),M.text(function(c){return n.lengthr[d].indexOf(c.id)))for(g=0;gr[d].indexOf(c.id)))for(g=0;g=s;s+=diffx2)q+=c(a[f-1],a[f],s,m);return q}function eb(a){var b=l.data.targets=M(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));Q.domain(E(b,"y2"));y.domain(m.domain());Ha.domain(x.domain());Ia.domain(Q.domain());D.ticks(10>a.length? -a.length:10);ja.ticks(wc).outerTickSize(0).tickFormat(xc);Ja.ticks(yc).outerTickSize(0).tickFormat(zc);Bb=m.domain();Sb.x(m);h.append("g").attr("class","x axis").attr("clip-path",e?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(e?ja:D);h.append("g").attr("class","y axis").attr("clip-path",e?"url(#yaxis-clip)":"").call(e?D:ja).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Ac);ub&&h.append("g").attr("class","y2 axis").attr("transform", -"translate("+(e?0:t)+","+(e?10:0)+")").call(Ja);d=h.append("g").attr("clip-path",Pa).attr("class","grid");Tb&&d.append("g").attr("class","xgrids");fb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(fb).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?t:-10).attr("y1",e?-10:p).attr("y2",e?-10:v);Ub&&d.append("g").attr("class","ygrids");gb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(gb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Pa).attr("class","regions");h.append("g").attr("clip-path",Pa).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 X&&ca?"pointer":null}).on("mouseover",function(a,b){if(!Qa){var d=l.data.targets.map(function(a){return Fa(a.values[b])}),c,g;if(0=s;s+=diffx2)q+=c(a[f-1],a[f],s,m);return q}function Sb(){return"translate("+(e?0:t)+","+(e?10:0)+")"}function eb(a){var b=l.data.targets=M(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));Q.domain(E(b,"y2"));y.domain(m.domain()); +Ha.domain(x.domain());Ia.domain(Q.domain());D.ticks(10>a.length?a.length:10);ja.ticks(xc).outerTickSize(0).tickFormat(yc);Ja.ticks(zc).outerTickSize(0).tickFormat(Ac);Bb=m.domain();Tb.x(m);h.append("g").attr("class","x axis").attr("clip-path",e?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(e?ja:D);h.append("g").attr("class","y axis").attr("clip-path",e?"url(#yaxis-clip)":"").call(e?D:ja).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor", +"end").text(Bc);ub&&h.append("g").attr("class","y2 axis").attr("transform",Sb).call(Ja);d=h.append("g").attr("clip-path",Pa).attr("class","grid");Ub&&d.append("g").attr("class","xgrids");fb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(fb).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}));Cc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",e?0:-10).attr("x2",e?t:-10).attr("y1",e?-10:p).attr("y2",e?-10:v);Vb&&d.append("g").attr("class","ygrids");gb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(gb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Pa).attr("class","regions");h.append("g").attr("clip-path", +Pa).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 X&&ca?"pointer":null}).on("mouseover",function(a,b){if(!Qa){var d=l.data.targets.map(function(a){return Fa(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"}),mb=z.bindto.replace("#","")+"-clip",Pa="url(#"+mb+")",H="timeseries"===bc,fa="categorized"===bc,ib=null,Qa=!1,aa=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()}]]),ba=d3.time.format(Ic).parse,rb,wb,tb,vb,xb,t,v,ia,zb,Ab,Ya,Za,m,x,Q,y,Ha,Ia,D=fa?pb():d3.svg.axis(),ja=d3.svg.axis(),Ja=d3.svg.axis(),ka=fa?pb():d3.svg.axis();P();S(); -H&&D.tickFormat(Lc);fa?(D.categories(Sa).tickCentered(cc),ka.categories(Sa).tickCentered(cc)):(D.tickOffset=function(){return 0},ka.tickOffset=function(){return 0});fa&&function(){var a=m,b=y,c=Object.keys(m),g,f;m=function(b){return a(b)+D.tickOffset()};y=function(a){return b(a)+ka.tickOffset()};for(f=0;fa?0:a},R=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),Ta=d3.select(z.bindto).append("svg").attr("width",t+G+C).attr("height",v+p+T),nb=Ta.append("defs"); +if(!("data"in z))throw Error("data is required in config");var Ma=c(["data","x"],"x"),Jc=c(["data","x_format"],"%Y-%m-%d"),mc=c(["data","id_converter"],function(a){return a}),xa=c(["data","names"],{}),r=c(["data","groups"],[]),Cb=c(["data","axes"],{}),W=c(["data","types"],{}),bc=c(["data","regions"],{}),Kc=c(["data","colors"],{}),X=c(["data","selection","enabled"],!1),ca=c(["data","selection","grouped"],!1),ea=c(["data","selection","isselectable"],function(a){return!0}),la=c(["subchart","show"],!1), +sb=la?c(["subchart","size","height"],60):0,kb=c(["subchart","default"],null),Lc=c(["color","pattern"],null),na=c(["legend","show"],!0),Ba=c(["legend","item","width"],80),Ic=c(["legend","item","onclick"],function(){}),cc=c(["axis","x","type"],"indexed"),Sa=c(["axis","x","categories"],[]),dc=c(["axis","x","tick","centered"],!1),ic=c(["axis","y","max"],null),gc=c(["axis","y","min"],null),kc=c(["axis","y","center"],null),Bc=c(["axis","y","text"],null);c(["axis","y","rescale"],!0);var Xa=c(["axis","y", +"inner"],!1),yc=c(["axis","y","format"],function(a){return a}),va=c(["axis","y","padding"],null),xc=c(["axis","y","ticks"],10),ub=c(["axis","y2","show"],!1),hc=c(["axis","y2","max"],null),fc=c(["axis","y2","min"],null),jc=c(["axis","y2","center"],null);c(["axis","y2","text"],null);c(["axis","y2","rescale"],!0);var Wa=c(["axis","y2","inner"],!1),Ac=c(["axis","y2","format"],function(a){return a}),wa=c(["axis","y2","padding"],null),zc=c(["axis","y2","ticks"],10),e=c(["axis","rotated"],!1),Ub=c(["grid", +"x","show"],!1),Fc=c(["grid","x","type"],"tick"),fb=c(["grid","x","lines"],null),Vb=c(["grid","y","show"],!1);c(["grid","y","type"],"tick");var gb=c(["grid","y","lines"],null),hb=c(["point","show"],!0)?c(["point","r"],2.5):0,Cc=c(["point","focus","line","enabled"],!0),Wb=c(["point","focus","expand","enabled"],!0),Xb=c(["point","focus","expand","r"],Wb?4:hb),za=c(["point","focus","select","r"],8),Dc=c(["point","onclick"],function(){}),tc=c(["point","onselected"],function(){}),uc=c(["point","onunselected"], +function(){}),K=c(["regions"],[]),Yb=c(["tooltip","contents"],function(a){var b="",d,c,f;for(d=0;d";return b+"
"+(H?a[0].x.getFullYear()+"."+(a[0].x.getMonth()+1)+"."+a[0].x.getDate():fa?a[0].x
"+f+""+c+"
"}), +Ec=c(["tooltip","init","show"],!1),oa=c(["tooltip","init","x"],0),$b=c(["tooltip","init","position"],{top:"0px",left:"50px"}),mb=z.bindto.replace("#","")+"-clip",Pa="url(#"+mb+")",H="timeseries"===cc,fa="categorized"===cc,ib=null,Qa=!1,aa=na?40:0,Mc=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()}]]),ba=d3.time.format(Jc).parse,rb,wb,tb,vb,xb,t,v,ia,zb,Ab,Ya,Za,m,x,Q,y,Ha,Ia,D=fa?pb():d3.svg.axis(),ja=d3.svg.axis(),Ja=d3.svg.axis(),ka=fa?pb():d3.svg.axis();P();S(); +H&&D.tickFormat(Mc);fa?(D.categories(Sa).tickCentered(dc),ka.categories(Sa).tickCentered(dc)):(D.tickOffset=function(){return 0},ka.tickOffset=function(){return 0});fa&&function(){var a=m,b=y,c=Object.keys(m),g,f;m=function(b){return a(b)+D.tickOffset()};y=function(a){return b(a)+ka.tickOffset()};for(f=0;fa?0:a},R=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]}}(Kc,Lc),Ta=d3.select(z.bindto).append("svg").attr("width",t+G+C).attr("height",v+p+T),nb=Ta.append("defs"); nb.append("clipPath").attr("id",mb).append("rect").attr("y",p).attr("width",t).attr("height",v-p);nb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",t+2).attr("height",40);nb.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=Ta.append("g").attr("transform","translate("+G+","+p+")"),O=null;la&&(O=Ta.append("g").attr("transform","translate("+J+","+pa+")"));var Ca=null;na&& -(Ca=Ta.append("g").attr("transform","translate("+Ea+","+qb+")"));var da=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ma=d3.svg.brush().x(y).on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1})}),Sb=d3.behavior.zoom().on("zoom",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!1})}),Na=null,$a=null,Bb;l.focus=function(a){l.defocus();d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused", +(Ca=Ta.append("g").attr("transform","translate("+Ea+","+qb+")"));var da=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ma=d3.svg.brush().x(y).on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1})}),Tb=d3.behavior.zoom().on("zoom",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!1})}),Na=null,$a=null,Bb;l.focus=function(a){l.defocus();d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused", !0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};l.revert=function(a){d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Da(a)).transition().style("opacity",1)};l.hide=function(a){d3.selectAll(Da(a)).transition().style("opacity",0)};l.load=function(a){u(a.done)&& (a.done=function(){});if("cacheIds"in a&&ga(a.cacheIds))Aa(ha(a.cacheIds),a.done);else if("data"in a)Aa(M(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Aa(M(c),a.done)});else if("rows"in a)Aa(M(qa(a.rows)),a.done);else if("columns"in a)Aa(M(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(),Ra(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= -Ka(function(b){return b.id==a});return 0r[d].indexOf(c.id)))for(g=0;gr[d].indexOf(c.id)))for(g=0;g=s;s+=diffx2)q+=c(a[f-1],a[f],s,m);return q}function eb(a){var b=l.data.targets=M(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));Q.domain(E(b,"y2"));y.domain(m.domain());Ha.domain(x.domain());Ia.domain(Q.domain());D.ticks(10>a.length? -a.length:10);ja.ticks(wc).outerTickSize(0).tickFormat(xc);Ja.ticks(yc).outerTickSize(0).tickFormat(zc);Bb=m.domain();Sb.x(m);h.append("g").attr("class","x axis").attr("clip-path",e?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(e?ja:D);h.append("g").attr("class","y axis").attr("clip-path",e?"url(#yaxis-clip)":"").call(e?D:ja).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(Ac);ub&&h.append("g").attr("class","y2 axis").attr("transform", -"translate("+(e?0:t)+","+(e?10:0)+")").call(Ja);d=h.append("g").attr("clip-path",Pa).attr("class","grid");Tb&&d.append("g").attr("class","xgrids");fb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(fb).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?t:-10).attr("y1",e?-10:p).attr("y2",e?-10:v);Ub&&d.append("g").attr("class","ygrids");gb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(gb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Pa).attr("class","regions");h.append("g").attr("clip-path",Pa).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 X&&ca?"pointer":null}).on("mouseover",function(a,b){if(!Qa){var d=l.data.targets.map(function(a){return Fa(a.values[b])}),c,g;if(0=s;s+=diffx2)q+=c(a[f-1],a[f],s,m);return q}function Sb(){return"translate("+(e?0:t)+","+(e?10:0)+")"}function eb(a){var b=l.data.targets=M(a),d,c;m.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));Q.domain(E(b,"y2"));y.domain(m.domain()); +Ha.domain(x.domain());Ia.domain(Q.domain());D.ticks(10>a.length?a.length:10);ja.ticks(xc).outerTickSize(0).tickFormat(yc);Ja.ticks(zc).outerTickSize(0).tickFormat(Ac);Bb=m.domain();Tb.x(m);h.append("g").attr("class","x axis").attr("clip-path",e?"":"url(#xaxis-clip)").attr("transform","translate(0,"+v+")").call(e?ja:D);h.append("g").attr("class","y axis").attr("clip-path",e?"url(#yaxis-clip)":"").call(e?D:ja).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor", +"end").text(Bc);ub&&h.append("g").attr("class","y2 axis").attr("transform",Sb).call(Ja);d=h.append("g").attr("clip-path",Pa).attr("class","grid");Ub&&d.append("g").attr("class","xgrids");fb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(fb).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}));Cc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",e?0:-10).attr("x2",e?t:-10).attr("y1",e?-10:p).attr("y2",e?-10:v);Vb&&d.append("g").attr("class","ygrids");gb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(gb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Pa).attr("class","regions");h.append("g").attr("clip-path", +Pa).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 X&&ca?"pointer":null}).on("mouseover",function(a,b){if(!Qa){var d=l.data.targets.map(function(a){return Fa(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"}),mb=z.bindto.replace("#","")+"-clip",Pa="url(#"+mb+")",H="timeseries"===bc,fa="categorized"===bc,ib=null,Qa=!1,aa=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()}]]),ba=d3.time.format(Ic).parse,rb,wb,tb,vb,xb,t,v,ia,zb,Ab,Ya,Za,m,x,Q,y,Ha,Ia,D=fa?pb():d3.svg.axis(),ja=d3.svg.axis(),Ja=d3.svg.axis(),ka=fa?pb():d3.svg.axis();P();S(); -H&&D.tickFormat(Lc);fa?(D.categories(Sa).tickCentered(cc),ka.categories(Sa).tickCentered(cc)):(D.tickOffset=function(){return 0},ka.tickOffset=function(){return 0});fa&&function(){var a=m,b=y,c=Object.keys(m),g,f;m=function(b){return a(b)+D.tickOffset()};y=function(a){return b(a)+ka.tickOffset()};for(f=0;fa?0:a},R=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),Ta=d3.select(z.bindto).append("svg").attr("width",t+G+C).attr("height",v+p+T),nb=Ta.append("defs"); +if(!("data"in z))throw Error("data is required in config");var Ma=c(["data","x"],"x"),Jc=c(["data","x_format"],"%Y-%m-%d"),mc=c(["data","id_converter"],function(a){return a}),xa=c(["data","names"],{}),r=c(["data","groups"],[]),Cb=c(["data","axes"],{}),W=c(["data","types"],{}),bc=c(["data","regions"],{}),Kc=c(["data","colors"],{}),X=c(["data","selection","enabled"],!1),ca=c(["data","selection","grouped"],!1),ea=c(["data","selection","isselectable"],function(a){return!0}),la=c(["subchart","show"],!1), +sb=la?c(["subchart","size","height"],60):0,kb=c(["subchart","default"],null),Lc=c(["color","pattern"],null),na=c(["legend","show"],!0),Ba=c(["legend","item","width"],80),Ic=c(["legend","item","onclick"],function(){}),cc=c(["axis","x","type"],"indexed"),Sa=c(["axis","x","categories"],[]),dc=c(["axis","x","tick","centered"],!1),ic=c(["axis","y","max"],null),gc=c(["axis","y","min"],null),kc=c(["axis","y","center"],null),Bc=c(["axis","y","text"],null);c(["axis","y","rescale"],!0);var Xa=c(["axis","y", +"inner"],!1),yc=c(["axis","y","format"],function(a){return a}),va=c(["axis","y","padding"],null),xc=c(["axis","y","ticks"],10),ub=c(["axis","y2","show"],!1),hc=c(["axis","y2","max"],null),fc=c(["axis","y2","min"],null),jc=c(["axis","y2","center"],null);c(["axis","y2","text"],null);c(["axis","y2","rescale"],!0);var Wa=c(["axis","y2","inner"],!1),Ac=c(["axis","y2","format"],function(a){return a}),wa=c(["axis","y2","padding"],null),zc=c(["axis","y2","ticks"],10),e=c(["axis","rotated"],!1),Ub=c(["grid", +"x","show"],!1),Fc=c(["grid","x","type"],"tick"),fb=c(["grid","x","lines"],null),Vb=c(["grid","y","show"],!1);c(["grid","y","type"],"tick");var gb=c(["grid","y","lines"],null),hb=c(["point","show"],!0)?c(["point","r"],2.5):0,Cc=c(["point","focus","line","enabled"],!0),Wb=c(["point","focus","expand","enabled"],!0),Xb=c(["point","focus","expand","r"],Wb?4:hb),za=c(["point","focus","select","r"],8),Dc=c(["point","onclick"],function(){}),tc=c(["point","onselected"],function(){}),uc=c(["point","onunselected"], +function(){}),K=c(["regions"],[]),Yb=c(["tooltip","contents"],function(a){var b="",d,c,f;for(d=0;d";return b+"
"+(H?a[0].x.getFullYear()+"."+(a[0].x.getMonth()+1)+"."+a[0].x.getDate():fa?a[0].x
"+f+""+c+"
"}), +Ec=c(["tooltip","init","show"],!1),oa=c(["tooltip","init","x"],0),$b=c(["tooltip","init","position"],{top:"0px",left:"50px"}),mb=z.bindto.replace("#","")+"-clip",Pa="url(#"+mb+")",H="timeseries"===cc,fa="categorized"===cc,ib=null,Qa=!1,aa=na?40:0,Mc=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()}]]),ba=d3.time.format(Jc).parse,rb,wb,tb,vb,xb,t,v,ia,zb,Ab,Ya,Za,m,x,Q,y,Ha,Ia,D=fa?pb():d3.svg.axis(),ja=d3.svg.axis(),Ja=d3.svg.axis(),ka=fa?pb():d3.svg.axis();P();S(); +H&&D.tickFormat(Mc);fa?(D.categories(Sa).tickCentered(dc),ka.categories(Sa).tickCentered(dc)):(D.tickOffset=function(){return 0},ka.tickOffset=function(){return 0});fa&&function(){var a=m,b=y,c=Object.keys(m),g,f;m=function(b){return a(b)+D.tickOffset()};y=function(a){return b(a)+ka.tickOffset()};for(f=0;fa?0:a},R=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]}}(Kc,Lc),Ta=d3.select(z.bindto).append("svg").attr("width",t+G+C).attr("height",v+p+T),nb=Ta.append("defs"); nb.append("clipPath").attr("id",mb).append("rect").attr("y",p).attr("width",t).attr("height",v-p);nb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",t+2).attr("height",40);nb.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=Ta.append("g").attr("transform","translate("+G+","+p+")"),O=null;la&&(O=Ta.append("g").attr("transform","translate("+J+","+pa+")"));var Ca=null;na&& -(Ca=Ta.append("g").attr("transform","translate("+Ea+","+qb+")"));var da=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ma=d3.svg.brush().x(y).on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1})}),Sb=d3.behavior.zoom().on("zoom",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!1})}),Na=null,$a=null,Bb;l.focus=function(a){l.defocus();d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused", +(Ca=Ta.append("g").attr("transform","translate("+Ea+","+qb+")"));var da=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ma=d3.svg.brush().x(y).on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1})}),Tb=d3.behavior.zoom().on("zoom",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!1})}),Na=null,$a=null,Bb;l.focus=function(a){l.defocus();d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused", !0).transition().duration(100).style("opacity",1)};l.defocus=function(a){d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};l.revert=function(a){d3.selectAll(Da(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};l.show=function(a){d3.selectAll(Da(a)).transition().style("opacity",1)};l.hide=function(a){d3.selectAll(Da(a)).transition().style("opacity",0)};l.load=function(a){u(a.done)&& (a.done=function(){});if("cacheIds"in a&&ga(a.cacheIds))Aa(ha(a.cacheIds),a.done);else if("data"in a)Aa(M(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){Aa(M(c),a.done)});else if("rows"in a)Aa(M(qa(a.rows)),a.done);else if("columns"in a)Aa(M(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(),Ra(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= -Ka(function(b){return b.id==a});return 0