diff --git a/c3.min.js b/c3.min.js index 687b8e9..81ae211 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,18 +1,18 @@ -(function(Ha){function Za(){function w(c,k){c.attr("transform",function(c){return"translate("+(k(c)+Q)+",0)"})}function c(c,k){c.attr("transform",function(c){return"translate(0,"+k(c)+")"})}function m(c){var k=c[0];c=c[c.length-1];return ks[d].indexOf(p.id)))for(e=0;e=q;q+=diffx2)la+="M"+b(g(q))+" "+d(h(q))+" "+b(g(q+k))+" "+d(h(q+k));return la}function Qa(a){var b=h.data.targets= z(a),d,e;r.domain(d3.extent(a.map(function(a){return a.x})));A.domain(l(b,"y"));fa.domain(l(b,"y2"));D.domain(r.domain());La.domain(A.domain());Ka.domain(fa.domain());x.ticks(10>a.length?a.length:10);d=g.append("g").attr("clip-path",Ca).attr("class","grid");kb&&d.append("g").attr("class","xgrids");Ra&&(e=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Ra).enter().append("g").attr("class","xgrid-line"),e.append("line").attr("class",function(a){return""+a["class"]}),e.append("text").attr("class", function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-t.top).attr("dy",-6).text(function(a){return a.text}));Rb&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",f?0:-10).attr("x2",f?u:-10).attr("y1",f?-10:t.top).attr("y2",f?-10:v);lb&&d.append("g").attr("class","ygrids");Sa&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Sa).enter().append("line").attr("class",function(a){return"ygrid-line "+ @@ -31,27 +31,27 @@ null:v);e=ab(q,d,b);c=bb(n,b,f);a=g.selectAll(".-bars").selectAll(".-bar").data( 250:0).attr("d",Wb);a=g.selectAll(".-circles").selectAll(".-circle").data(Lb);a.transition().duration(withTransition?250:0).attr("cx",f?L:C).attr("cy",f?C:L);a.enter().append("circle").attr("class",H).attr("cx",f?L:C).attr("cy",f?C:L).attr("r",Ta);a.exit().remove();withSubchart&&pa&&(q=1.2*ha.tickOffset()/d,n=cb(qa,!0),e=ab(q,d,b,!0),c=bb(n,b,!1,!0),contextBar=M.selectAll(".-bars").selectAll(".-bar").data(db),contextBar.transition().duration(withTransition?250:0).attr("x",e).attr("y",c).attr("width", q).attr("height",n),contextBar.enter().append("rect").attr("class",xa).attr("x",e).attr("y",c).attr("width",q).attr("height",n).style("opacity",0).transition().style("opacity",1),contextBar.exit().transition().style("opacity",0).remove(),M.selectAll(".-line").transition().duration(withTransition?250:0).attr("d",Xb));g.selectAll(".selected-circles").filter(function(a){return ka(a)}).selectAll("circle").remove();g.selectAll(".selected-circle").transition().duration(withTransition?250:0).attr("cx",f? L:C).attr("cy",f?C:L);s=(f?v:u)*G()/(k()-1);b=function(a){return r(a.x)-s/2};g.selectAll(".event-rect").attr("x",f?0:b).attr("y",f?b:0).attr("width",f?u:s).attr("height",f?s:v);mainRegion=g.select(".regions").selectAll("rect.region").data(E);mainRegion.enter().append("rect");mainRegion.attr("class",ya).attr("x",f?0:qb).attr("y",f?qb:t.top).attr("width",f?u:rb).attr("height",f?rb:v).style("fill-opacity",function(a){return m(a.opacity)?a.opacity:0.1});mainRegion.exit().transition().duration(withTransition? -250:0).style("fill-opacity",0).remove()}function pb(a){var b;g.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity",0).append("g").attr("class",Z).style("fill",function(a){return U(a.id)}).style("stroke",function(a){return U(a.id)}).style("stroke-width",0).style("cursor",function(a){return ba(a)?"pointer":null});b=g.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class", -function(a){return"chart-line target target-"+a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class",Y).style("stroke",function(a){return U(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",O).style("fill",function(a){return U(a.id)}).style("cursor",function(a){return ba(a)?"pointer":null});a.forEach(function(a){g.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value= -a.values[b.x].value})});pa&&(b=M.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("opacity",0),b.append("g").attr("class",Z).style("fill",function(a){return U(a.id)}),b=M.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity",0),b.append("path").attr("class",Y).style("stroke",function(a){return U(a.id)})); +250:0).style("fill-opacity",0).remove()}function pb(a){var b;g.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity",0).append("g").attr("class",Z).style("fill",function(a){return Q(a.id)}).style("stroke",function(a){return Q(a.id)}).style("stroke-width",0).style("cursor",function(a){return ba(a)?"pointer":null});b=g.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class", +function(a){return"chart-line target target-"+a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class",Y).style("stroke",function(a){return Q(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",O).style("fill",function(a){return Q(a.id)}).style("cursor",function(a){return ba(a)?"pointer":null});a.forEach(function(a){g.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value= +a.values[b.x].value})});pa&&(b=M.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("opacity",0),b.append("g").attr("class",Z).style("fill",function(a){return Q(a.id)}),b=M.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity",0),b.append("path").attr("class",Y).style("stroke",function(a){return Q(a.id)})); ra&&Ya(a);d3.selectAll(".target").transition().style("opacity",1)}function sa(a,b){h.data.targets.forEach(function(b){for(var c=0;c",d,c,f;for(d=0;d"+f+""+c+"";return b+""}),wb=w.bindto.replace("#","")+"-clip",Ca="url(#"+wb+")",ga="timeseries"===ub,wa="categorized"===ub,Ua=null,Da=!1,ca=ra?40:0,cc=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()}]]), -t={top:0,right:ob&&!f?50:1,bottom:20+tb+ca,left:40},xb=Fa-tb-ca,dc=Fa-ca,u=Zb-t.left-t.right,v=Fa-t.top-t.bottom,qa=Fa-xb-(20+ca),Jb=d3.time.format($b).parse,ec=f?10:0,fc=f?v:u,yb=f?0:v,zb=f?u:1,r=(ga?d3.time.scale():d3.scale.linear()).range([ec,fc]),A=d3.scale.linear().range([yb,zb]),fa=d3.scale.linear().range([yb,zb]),D=(ga?d3.time.scale():d3.scale.linear()).range([0,u]),La=d3.scale.linear().range([qa,10]),Ka=d3.scale.linear().range([qa,10]),x=wa?Za():d3.svg.axis(),oa=d3.svg.axis(),Wa=d3.svg.axis(), -ha=wa?Za():d3.svg.axis();x.scale(r).orient(f?"left":"bottom");oa.scale(A).orient(f?"bottom":"left");Wa.scale(fa).orient(f?"top":"right");ha.scale(D).orient("bottom");ga&&x.tickFormat(cc);wa?(x.categories(Ga).tickCentered(vb),ha.categories(Ga).tickCentered(vb)):(x.tickOffset=function(){return 0},ha.tickOffset=function(){return 0});wa&&function(){var a=r,b=D,d=Object.keys(r),c,f;r=function(b){return a(b)+x.tickOffset()};D=function(a){return b(a)+ha.tickOffset()};for(f=0;fa?0:a},U=function(a,b){var d=[],c=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<=d.indexOf(b)||d.push(b);return c[d.indexOf(b)%c.length]}}(ac,bc),da=d3.select(w.bindto).append("svg").attr("width",u+t.left+t.right).attr("height",v+t.top+t.bottom);da.append("defs");da.select("defs").append("clipPath").attr("id",wb).append("rect").attr("y",t.top).attr("width",u).attr("height",v-t.top);da.select("defs").append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",u+2).attr("height",40);da.select("defs").append("clipPath").attr("id", +(ga?a[0].x.getFullYear()+"."+(a[0].x.getMonth()+1)+"."+a[0].x.getDate():wa?a[0].x",d,c,f;for(d=0;d"+f+""+c+"";return b+""}),wb=w.bindto.replace("#","")+"-clip",Ca="url(#"+wb+")",ga="timeseries"===ub,wa="categorized"===ub,Ua=null,Da=!1,ca=ra? +40:0,cc=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()}]]),t={top:0,right:ob&&!f?50:1,bottom:20+tb+ca,left:40},xb=Fa-tb-ca,dc=Fa-ca,u=Zb-t.left-t.right,v=Fa-t.top-t.bottom,qa=Fa-xb-(20+ca),Jb=d3.time.format($b).parse,ec=f?10:0,fc=f?v:u,yb=f?0:v,zb=f?u:1,r=(ga?d3.time.scale():d3.scale.linear()).range([ec,fc]),A=d3.scale.linear().range([yb,zb]),fa=d3.scale.linear().range([yb,zb]),D=(ga?d3.time.scale():d3.scale.linear()).range([0,u]),La=d3.scale.linear().range([qa,10]),Ka=d3.scale.linear().range([qa, +10]),x=wa?Za():d3.svg.axis(),oa=d3.svg.axis(),Wa=d3.svg.axis(),ha=wa?Za():d3.svg.axis();x.scale(r).orient(f?"left":"bottom");oa.scale(A).orient(f?"bottom":"left");Wa.scale(fa).orient(f?"top":"right");ha.scale(D).orient("bottom");ga&&x.tickFormat(cc);wa?(x.categories(Ga).tickCentered(vb),ha.categories(Ga).tickCentered(vb)):(x.tickOffset=function(){return 0},ha.tickOffset=function(){return 0});wa&&function(){var a=r,b=D,d=Object.keys(r),c,f;r=function(b){return a(b)+x.tickOffset()};D=function(a){return b(a)+ +ha.tickOffset()};for(f=0;fa?0:a},Q=function(a,b){var d=[],c=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<=d.indexOf(b)||d.push(b);return c[d.indexOf(b)%c.length]}}(ac,bc),da=d3.select(w.bindto).append("svg").attr("width",u+t.left+t.right).attr("height",v+t.top+t.bottom);da.append("defs");da.select("defs").append("clipPath").attr("id",wb).append("rect").attr("y",t.top).attr("width",u).attr("height",v-t.top);da.select("defs").append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",u+2).attr("height",40);da.select("defs").append("clipPath").attr("id", "yaxis-clip").append("rect").attr("x",-39).attr("y",t.top-1).attr("width",40).attr("height",v-t.top+2);var g=da.append("g").attr("transform","translate("+t.left+","+t.top+")"),M=null;pa&&(M=da.append("g").attr("transform","translate(40,"+xb+")"));var ua=null;ra&&(ua=da.append("g").attr("transform","translate(40,"+dc+")"));var Ea=d3.select(w.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ea=d3.svg.brush().x(D).on("brush", function(){N({withTransition:!1,withY:!1,withSubchart:!1})}),Ba=null,Ma=null;h.focus=function(a){h.defocus();d3.selectAll(va(a)).filter(function(a){return Ja(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};h.defocus=function(a){d3.selectAll(va(a)).filter(function(a){return Ja(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};h.revert=function(a){d3.selectAll(va(a)).filter(function(a){return Ja(a.id)}).classed("focused",!1).transition().duration(100).style("opacity", -1)};h.show=function(a){d3.selectAll(va(a)).transition().style("opacity",1)};h.hide=function(a){d3.selectAll(va(a)).transition().style("opacity",0)};h.load=function(a){n(a.done)&&(a.done=function(){});if("cacheIds"in a&&ja(a.cacheIds))sa(J(a.cacheIds),a.done);else if("data"in a)sa(z(data),a.done);else if("url"in a)d3.csv(a.url,function(b,d){sa(z(d),a.done)});else if("rows"in a)sa(z(P(a.rows)),a.done);else if("columns"in a)sa(z(Q(a.columns)),a.done);else throw Error("url or rows or columns is required."); +1)};h.show=function(a){d3.selectAll(va(a)).transition().style("opacity",1)};h.hide=function(a){d3.selectAll(va(a)).transition().style("opacity",0)};h.load=function(a){n(a.done)&&(a.done=function(){});if("cacheIds"in a&&ja(a.cacheIds))sa(J(a.cacheIds),a.done);else if("data"in a)sa(z(data),a.done);else if("url"in a)d3.csv(a.url,function(b,d){sa(z(d),a.done)});else if("rows"in a)sa(z(P(a.rows)),a.done);else if("columns"in a)sa(z(R(a.columns)),a.done);else throw Error("url or rows or columns is required."); };h.unload=function(a){h.data.targets=h.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();ra&&(d3.selectAll(".legend-item-"+a).remove(),Ya(h.data.targets));0b.classes.indexOf(a)})});return E};h.data.get=function(a){a=h.data.getAsTarget(a);return m(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=B(function(b){return b.id==a});return 0b.classes.indexOf(a)})});return E};h.data.get=function(a){a=h.data.getAsTarget(a);return m(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=B(function(b){return b.id==a});return 0