diff --git a/c3.js b/c3.js index 5c8f81d..b9ecf97 100644 --- a/c3.js +++ b/c3.js @@ -177,7 +177,7 @@ /*-- Set Chart Params --*/ var margin, margin2, margin3, width, width2, height, height2, height3, currentWidth, currentHeight; - var radius, radiusExpanded, svgArc, svgArcExpanded, svgArcExpandedSub, pie; + var radius, radiusExpanded, innerRadius, svgArc, svgArcExpanded, svgArcExpandedSub, pie; var xMin, xMax, yMin, yMax, subXMin, subXMax, subYMin, subYMax; var x, y, y2, subX, subY, subY2, xAxis, yAxis, yAxis2, subXAxis; @@ -238,6 +238,7 @@ radiusExpanded = height / 2; radius = radiusExpanded * 0.95; + innerRadius = hasDountType(c3.data.targets) ? radius * 0.6 : 0; } function getCurrentWidth() { return __size_width === null ? getParentWidth() : __size_width; @@ -408,7 +409,7 @@ } function getSvgArc() { - var arc = d3.svg.arc().outerRadius(radius).innerRadius(0), + var arc = d3.svg.arc().outerRadius(radius).innerRadius(innerRadius), newArc = function (d, withoutUpdate) { var updated; if (withoutUpdate) { return arc(d); } // for interpolate @@ -420,7 +421,7 @@ return newArc; } function getSvgArcExpanded(rate) { - var arc = d3.svg.arc().outerRadius(radiusExpanded * (rate ? rate : 1)).innerRadius(0); + var arc = d3.svg.arc().outerRadius(radiusExpanded * (rate ? rate : 1)).innerRadius(innerRadius); return function (d) { var updated = updateAngle(d); return updated ? arc(updated) : "M 0 0"; @@ -709,6 +710,11 @@ }); }); + // set target types + if (__data_type) { + setTargetType(getTargetIds(targets).filter(function (id) { return ! (id in __data_types); }), __data_type); + } + // cache as original id keyed targets.forEach(function (d) { addCache(d.id_org, d); @@ -1035,9 +1041,15 @@ function hasScatterType(targets) { return hasType(targets, 'scatter'); } - function hasArcType(targets) { + function hasPieType(targets) { return hasType(targets, 'pie'); } + function hasDountType(targets) { + return hasType(targets, 'dount'); + } + function hasArcType(targets) { + return hasPieType(targets) || hasDountType(targets); + } function isLineType(d) { var id = (typeof d === 'string') ? d : d.id; return !(id in __data_types) || __data_types[id] === 'line' || __data_types[id] === 'spline' || __data_types[id] === 'area' || __data_types[id] === 'area-spline'; @@ -1056,7 +1068,7 @@ } function isArcType(d) { var id = (typeof d === 'string') ? d : d.id; - return __data_types[id] === 'pie'; + return __data_types[id] === 'pie' || __data_types[id] === 'dount'; } /* not used function lineData(d) { @@ -1920,7 +1932,7 @@ var barIndices = getBarIndices(), barTargetsNum = barIndices.__max__ + 1, maxDataCountTarget; var rectX, rectW; var withY, withSubchart, withTransition, withUpdateXDomain, withUpdateOrgXDomain; - var isPieChart; + var hideAxis = hasArcType(c3.data.targets); var duration; options = isDefined(options) ? options : {}; @@ -1929,7 +1941,6 @@ withTransition = isDefined(options.withTransition) ? options.withTransition : true; withUpdateXDomain = isDefined(options.withUpdateXDomain) ? options.withUpdateXDomain : false; withUpdateOrgXDomain = isDefined(options.withUpdateOrgXDomain) ? options.withUpdateOrgXDomain : false; - isPieChart = hasArcType(c3.data.targets); duration = withTransition ? 250 : 0; @@ -1950,9 +1961,9 @@ y2.domain(getYDomain('y2')); // axis - main.select(".x.axis").transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : xAxis).style("opacity", isPieChart ? 0 : 1); - main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis).style("opacity", isPieChart ? 0 : 1); - main.select(".y2.axis").transition().call(yAxis2).style("opacity", isPieChart ? 0 : 1); + main.select(".x.axis").transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : xAxis).style("opacity", hideAxis ? 0 : 1); + main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis).style("opacity", hideAxis ? 0 : 1); + main.select(".y2.axis").transition().call(yAxis2).style("opacity", hideAxis ? 0 : 1); // Update label position main.select(".x.axis .-axis-x-label").attr("x", width); @@ -2314,11 +2325,6 @@ /*-- Main --*/ - // Set data type if data.type is specified - if (__data_type) { - setTargetType(getTargetIds(targets).filter(function (id) { return ! (id in __data_types); }), __data_type); - } - //-- Bar --// mainBarUpdate = main.select('.chart-bars') .selectAll('.chart-bar') diff --git a/c3.min.js b/c3.min.js index ab99ea1..b83137c 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,86 +1,86 @@ -(function(P){function kd(){function u(d,f){d.attr("transform",function(d){return"translate("+(f(d)+ca)+", 0)"})}function x(d,f){d.attr("transform",function(d){return"translate(0,"+f(d)+")"})}function P(d){var f=d[0];d=d[d.length-1];return fa?a:0}),c=1;c+a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function mb(a){var b=nb(function(b){return y(b.id)===a}),c="y2"===a?wd:xd,e="y2"===a?yd:zd,c=c?c:td(b),e=e?e:ud(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?Ad:Bd;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ga&&(d=Ga.top?Ga.top:k,f=Ga.bottom?Ga.bottom:k);"y2"===a&&Ha&&(d=Ha.top?Ha.top:k,f=Ha.bottom?Ha.bottom:k);Ia(b,"bar")&&!qc(b)&&(f=c);return[c-f,e+d]}function Cd(a){return d.min(a, -function(a){return d.min(a.values,function(a){return a.x})})}function Dd(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function ob(a){var b=[Cd(a),Dd(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function ta(a){return a[1]-a[0]}function Ed(a){for(var b=0;ba?0:a}function tc(a){return na&&a===na||$&&Gd($,a)}function Hd(a){return!tc(a)}function Id(a){Object.keys(a).forEach(function(b){$[b]=a[b]})}function qb(a){var b;a&&(b=Ja[a.id],a.name=b?b:a.id);return a}function uc(a){var b=a[0],c={},e=[],k,d;for(k=1;kb&&(c=a,b=a.values.length)}):c=a?h.data.targets[0]:null;return c}function rb(a){a=x(a)?h.data.targets:a;return a.map(function(a){return a.id})}function xc(a){var b=rb(),c;for(c=0;ca})}function vd(a){return yc(a,function(a){return 0k&&(d-=c+30)),c=b[1]+15+es[c].indexOf(k.id)))for(e=0;e=f;f+=q)h+=e(a[d-1],a[d],f,ya)}return h}function Vb(a){var b;tb=d.select(sa);if(tb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); -else{tb.html("");h.data.x={};h.data.targets=Ka(a);qa();R();m.domain(d.extent(ob(h.data.targets)));z.domain(mb("y"));Z.domain(mb("y2"));V.domain(m.domain());hb.domain(z.domain());ib.domain(Z.domain());J.ticks(10>a.length?a.length:10);ua.ticks(ae).outerTickSize(0).tickFormat(be);jb.ticks(ce).outerTickSize(0).tickFormat(de);U=m.domain();L.scale(V);oa&&D.scale(m);q=d.select(sa).append("svg").attr("width",p+A+Y).attr("height",t+r+O).on("mouseenter",ee).on("mouseleave",fe);ub=q.append("defs");ub.append("clipPath").attr("id", -Wb).append("rect").attr("y",r).attr("width",p).attr("height",t-r);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",N).attr("height",da);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-A+1).attr("y",r-1).attr("width",ia).attr("height",yb);l=q.append("g").attr("transform",M.main);E=za?q.append("g").attr("transform",M.context):null;Aa=Ba?q.append("g").attr("transform",M.legend):null;W=d.select(sa).style("position","relative").append("div").style("position", -"absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",M.x).call(g?ua:J).append("text").attr("class","-axis-x-label").attr("x",p).attr("dy","-.5em").style("text-anchor","end").text(ge);l.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?J:ua).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(he);Bb&& -l.append("g").attr("class","y2 axis").attr("transform",M.y2).call(jb);a=l.append("g").attr("clip-path",Qa).attr("class","grid");Xc&&a.append("g").attr("class","xgrids");Xb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Xb).enter().append("g").attr("class","xgrid-line"),b.append("line").attr("class",function(a){return""+a["class"]}),b.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g? -0:-r).attr("dy",-5).text(function(a){return a.text}));ie&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?p:-10).attr("y1",g?-10:r).attr("y2",g?-10:t);Yc&&a.append("g").attr("class","ygrids");Yb&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Yb).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+ -a["class"]}).attr("text-anchor","end").attr("transform",g?"rotate(-90)":"").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Qa).attr("class","regions");l.append("g").attr("clip-path",Qa).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",oa?"ew-resize":null);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines");l.select(".chart").append("g").attr("class", -"chart-arcs").attr("transform",M.arc);if(oa)l.insert("rect",je?null:"g.grid").attr("class","zoom-rect").attr("width",p).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(D).on("dblclick.zoom",null);null!==vb&&L.extent("function"!==typeof vb?vb:vb(ob()));za&&(E.append("g").attr("clip-path",Qa).attr("class","chart"),E.select(".chart").append("g").attr("class","chart-bars"),E.select(".chart").append("g").attr("class","chart-lines"),E.append("g").attr("clip-path",Qa).attr("class","x brush").call(L).selectAll("rect").attr(g? -"width":"height",g?Cb:db),E.append("g").attr("class","x axis").attr("transform",M.subx).attr("clip-path",g?"url(#yaxis-clip)":"").call(gb));Ba&&wb(h.data.targets);Zc(h.data.targets);I({withTransition:!1,withUpdateXDomain:!0});if(ke){if(B&&"string"===typeof Ca){Ca=ma(Ca);for(a=0;aNb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor", -null))}).on("click",function(){var a,c;C(h.data.targets)||(a=d.mouse(this),c=Ic(h.data.targets,a),100>Nb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){ad(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){bd(d.mouse(this))}).on("dragstart",function(){cd(d.mouse(this))}).on("dragend",function(){dd()})).call(D).on("dblclick.zoom",null)}function ad(a,b,c){var e=d.select(a),f=e.classed(ha),g=!1,h;"circle"===a.nodeName?(g=Qc(a,1.5*Pa),h=Tc): -"rect"===a.nodeName&&(g=Rc(a),h=Vc);if(pa||g)fa&&ga(b)&&(e.classed(ha,!f),h(!f,e,b,c)),pe(b,e)}function bd(a){var b,c,e,f,g,m,p;C(h.data.targets)||!fa||oa&&!D.altDomain||(b=bc[0],c=bc[1],e=a[0],a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=pa?r:Math.min(c,a),p=pa?t:Math.max(c,a),l.select(".dragarea").attr("x",f).attr("y",m).attr("width",g-f).attr("height",p-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ga(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ha),h=c.classed(cc), -l,n,r,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=Tc,l=f",c,d,f;for(c=0;c"+f+""+d+"");return b+ -""}),ke=f(["tooltip","init","show"],!1),Ca=f(["tooltip","init","x"],0),$c=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Wb=sa.replace("#","")+"-clip",Qa="url(#"+Wb+")",B="timeseries"===jd,ea="categorized"===jd,Mb=!B&&(na||$),bc=null,Ra=!1,ac=!1,la=Ba?40:0,K=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in a)return a[b];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(we, -xe),rd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"),function(a){return a.getSeconds()}],[d.time.format(".%L"),function(a){return a.getMilliseconds()}]]; -return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),p,Cb,t,db,zb,ra,eb,Db,kb,mc,nc,Kb,Eb,Fb,Gb,Hb,Ib,Jb,m,z,Z,V,hb,ib,J,ua,jb,gb,md=g?"left":"bottom",nd=g?ab?"top":"bottom":ab?"right":"left",od=g?cb?"bottom":"top":cb?"left":"right",pd=g?"left":"bottom",M={main:function(){return"translate("+A+","+r+")"},context:function(){return"translate("+Ea+","+Da+")"},legend:function(){return"translate("+gc+","+fc+")"},y2:function(){return"translate("+(g?0:p)+","+(g?10:0)+")"}, -x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+(g?0:db)+")"},arc:function(){return"translate("+p/2+","+t/2+")"}},kc=40,jc=20;Kb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var re=function(){var a=d.svg.line().x(g?function(a){return w(a.id)(a.value)}:va).y(g?va:function(a){return w(a.id)(a.value)});return function(b){var c=Rb(b.values),d;if(Ob(b))return Nc(b)?a.interpolate("cardinal"):a.interpolate("linear"),id[b.id]?$d(c, -m,w(b.id),id[b.id]):a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),se=function(){var a;a=g?d.svg.area().x0(function(a){return w(a.id)(0)}).x1(function(a){return w(a.id)(a.value)}).y(va):d.svg.area().x(va).y0(function(a){return w(a.id)(0)}).y1(function(a){return w(a.id)(a.value)});return function(b){var c=Rb(b.values),d;if(Ia([b],"area")||Ia([b],"area-spline"))return Nc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g? -"M "+b+" "+d:"M "+d+" "+b}}(),te=function(){var a=d.svg.line().x(g?function(a){return F(a.id)(a.value)}:Ec).y(g?Ec:function(a){return F(a.id)(a.value)});return function(b){var c=Rb(b.values);return Ob(b)?a(c):"M "+V(c[0].x)+" "+F(b.id)(c[0].value)}}(),L=d.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),D=d.behavior.zoom().on("zoomstart",function(){D.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",oa?ue:null);L.update=function(){E&& -E.select(".x.brush").call(this);return this};L.scale=function(a){return g?this.y(a):this.x(a)};D.scale=function(a){return g?this.y(a):this.x(a)};D.orgScaleExtent=function(){var a=hd?hd:[1,10];return[a[0],Math.max(fb()/a[1],a[1])]};D.updateScaleExtent=function(){var a=ta(m.orgDomain())/ta(U),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,ub,l,E,Aa,W,tb,U;h.focus=function(a){var b=q.selectAll(Ua(a)),c=b.filter(dc),b=b.filter(ec);h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity", -1);b.transition().duration(100).style("opacity",1);C(h.data.targets)&&Ya(a,!0)};h.defocus=function(a){var b=q.selectAll(Ua(a)),c=b.filter(dc),b=b.filter(ec);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);C(h.data.targets)&&xb(a)};h.revert=function(a){var b=q.selectAll(Ua(a)),c=b.filter(dc),b=b.filter(ec);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);C(h.data.targets)&& -xb(a)};h.show=function(a){q.selectAll(Ua(a)).transition().style("opacity",1)};h.hide=function(a){q.selectAll(Ua(a)).transition().style("opacity",0)};h.unzoom=function(){L.clear().update();I({withUpdateXDomain:!0})};h.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Id(a.xs);"categories"in a&&ea&&(Fa=a.categories,J.categories(Fa));if("cacheIds"in a&&Ed(a.cacheIds))Sa(Fd(a.cacheIds),a.done);else if("data"in a)Sa(Ka(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Sa(Ka(c), -a.done)});else if("rows"in a)Sa(Ka(uc(a.rows)),a.done);else if("columns"in a)Sa(Ka(vc(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});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(q.selectAll(".legend-item-"+a).remove(),wb(h.data.targets));0b.classes.indexOf(a)})});return Q};h.data.get=function(a){a=h.data.getAsTarget(a);return u(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=nb(function(b){return b.id===a});return 0a?a:0}),c=1;c+a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function mb(a){var b=nb(function(b){return y(b.id)===a}),c="y2"===a?xd:yd,e="y2"===a?zd:Ad,c=c?c:ud(b),e=e?e:vd(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?Bd:Cd;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ia&&(d=Ia.top?Ia.top:k,f=Ia.bottom?Ia.bottom:k);"y2"===a&&Ja&&(d=Ja.top?Ja.top:k,f=Ja.bottom? +Ja.bottom:k);ma(b,"bar")&&!rc(b)&&(f=c);return[c-f,e+d]}function Dd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.x})})}function Ed(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function ob(a){var b=[Dd(a),Ed(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function ua(a){return a[1]-a[0]}function Fd(a){for(var b=0;ba?0:a}function uc(a){return oa&&a===oa||$&&Hd($,a)}function Id(a){return!uc(a)}function Jd(a){Object.keys(a).forEach(function(b){$[b]=a[b]})}function qb(a){var b;a&&(b=Ka[a.id],a.name=b?b:a.id);return a}function vc(a){var b=a[0],c={},e=[],k,d;for(k=1;kb&&(c=a,b=a.values.length)}):c=a?h.data.targets[0]:null;return c}function rb(a){a=x(a)?h.data.targets: +a;return a.map(function(a){return a.id})}function zc(a){var b=rb(),c;for(c=0;ca})} +function wd(a){return Ac(a,function(a){return 0k&&(d-=c+30)),c=b[1]+15+et[c].indexOf(k.id)))for(e=0;e=f;f+=q)h+=e(a[d-1],a[d],f,za)}return h}function Wb(a){var b;tb=d.select(ta);if(tb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{tb.html("");h.data.x={};h.data.targets=La(a);ra();R();m.domain(d.extent(ob(h.data.targets)));z.domain(mb("y"));Z.domain(mb("y2"));V.domain(m.domain());hb.domain(z.domain());ib.domain(Z.domain());J.ticks(10>a.length?a.length:10);va.ticks(be).outerTickSize(0).tickFormat(ce); +jb.ticks(de).outerTickSize(0).tickFormat(ee);U=m.domain();L.scale(V);pa&&E.scale(m);q=d.select(ta).append("svg").attr("width",p+A+Y).attr("height",s+r+O).on("mouseenter",fe).on("mouseleave",ge);ub=q.append("defs");ub.append("clipPath").attr("id",Xb).append("rect").attr("y",r).attr("width",p).attr("height",s-r);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",N).attr("height",da);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x", +-A+1).attr("y",r-1).attr("width",ia).attr("height",yb);l=q.append("g").attr("transform",M.main);F=Aa?q.append("g").attr("transform",M.context):null;Ba=Ca?q.append("g").attr("transform",M.legend):null;W=d.select(ta).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",M.x).call(g?va:J).append("text").attr("class","-axis-x-label").attr("x", +p).attr("dy","-.5em").style("text-anchor","end").text(he);l.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?J:va).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(ie);Bb&&l.append("g").attr("class","y2 axis").attr("transform",M.y2).call(jb);a=l.append("g").attr("clip-path",Ra).attr("class","grid");Zc&&a.append("g").attr("class","xgrids");Yb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Yb).enter().append("g").attr("class", +"xgrid-line"),b.append("line").attr("class",function(a){return""+a["class"]}),b.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));je&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?p:-10).attr("y1",g?-10:r).attr("y2",g?-10:s);$c&&a.append("g").attr("class","ygrids");Zb&&(a=a.append("g").attr("class", +"ygrid-lines").selectAll("ygrid-line").data(Zb).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"rotate(-90)":"").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Ra).attr("class","regions");l.append("g").attr("clip-path",Ra).attr("class","chart");l.select(".chart").append("g").attr("class", +"event-rects").style("fill-opacity",0).style("cursor",pa?"ew-resize":null);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines");l.select(".chart").append("g").attr("class","chart-arcs").attr("transform",M.arc);if(pa)l.insert("rect",ke?null:"g.grid").attr("class","zoom-rect").attr("width",p).attr("height",s).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom",null);null!==vb&&L.extent("function"!==typeof vb?vb:vb(ob())); +Aa&&(F.append("g").attr("clip-path",Ra).attr("class","chart"),F.select(".chart").append("g").attr("class","chart-bars"),F.select(".chart").append("g").attr("class","chart-lines"),F.append("g").attr("clip-path",Ra).attr("class","x brush").call(L).selectAll("rect").attr(g?"width":"height",g?Cb:eb),F.append("g").attr("class","x axis").attr("transform",M.subx).attr("clip-path",g?"url(#yaxis-clip)":"").call(gb));Ca&&wb(h.data.targets);ad(h.data.targets);I({withTransition:!1,withUpdateXDomain:!0});if(le){if(B&& +"string"===typeof Da){Da=na(Da);for(a=0;aOb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;D(h.data.targets)||(a=d.mouse(this),c=Kc(h.data.targets,a),100>Ob(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){cd(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){dd(d.mouse(this))}).on("dragstart", +function(){ed(d.mouse(this))}).on("dragend",function(){fd()})).call(E).on("dblclick.zoom",null)}function cd(a,b,c){var e=d.select(a),f=e.classed(ha),g=!1,h;"circle"===a.nodeName?(g=Sc(a,1.5*Qa),h=Vc):"rect"===a.nodeName&&(g=Tc(a),h=Xc);if(qa||g)fa&&ga(b)&&(e.classed(ha,!f),h(!f,e,b,c)),qe(b,e)}function dd(a){var b,c,e,f,g,m,p;D(h.data.targets)||!fa||pa&&!E.altDomain||(b=cc[0],c=cc[1],e=a[0],a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=qa?r:Math.min(c,a),p=qa?s:Math.max(c,a),l.select(".dragarea").attr("x", +f).attr("y",m).attr("width",g-f).attr("height",p-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ga(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ha),h=c.classed(dc),l,n,r,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=Vc,l=f",c,d,f;for(c=0;c"+f+""+d+"");return b+""}),le=f(["tooltip","init","show"],!1),Da=f(["tooltip","init","x"],0),bd=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Xb=ta.replace("#","")+"-clip",Ra="url(#"+Xb+")",B="timeseries"===kd,ea="categorized"===kd,Nb=!B&&(oa||$),cc=null,Sa=!1,bc=!1,la=Ca?40:0,K=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" "); +return function(b){if(b in a)return a[b];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(xe,ye),sd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"), +function(a){return a.getSeconds()}],[d.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),p,Cb,s,eb,zb,sa,Ga,Db,Eb,kb,nc,oc,Lb,Fb,Gb,Hb,Ib,Jb,Kb,m,z,Z,V,hb,ib,J,va,jb,gb,nd=g?"left":"bottom",od=g?bb?"top":"bottom":bb?"right":"left",pd=g?db?"bottom":"top":db?"left":"right",qd=g?"left":"bottom",M={main:function(){return"translate("+A+","+r+")"},context:function(){return"translate("+Fa+","+Ea+")"},legend:function(){return"translate("+ +hc+","+gc+")"},y2:function(){return"translate("+(g?0:p)+","+(g?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+(g?0:eb)+")"},arc:function(){return"translate("+p/2+","+s/2+")"}},lc=40,kc=20;Lb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var se=function(){var a=d.svg.line().x(g?function(a){return w(a.id)(a.value)}:wa).y(g?wa:function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(Pb(b))return Pc(b)? +a.interpolate("cardinal"):a.interpolate("linear"),jd[b.id]?ae(c,m,w(b.id),jd[b.id]):a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),te=function(){var a;a=g?d.svg.area().x0(function(a){return w(a.id)(0)}).x1(function(a){return w(a.id)(a.value)}).y(wa):d.svg.area().x(wa).y0(function(a){return w(a.id)(0)}).y1(function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(ma([b],"area")||ma([b],"area-spline"))return Pc(b)?a.interpolate("cardinal"):a.interpolate("linear"), +a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),ue=function(){var a=d.svg.line().x(g?function(a){return G(a.id)(a.value)}:Gc).y(g?Gc:function(a){return G(a.id)(a.value)});return function(b){var c=Sb(b.values);return Pb(b)?a(c):"M "+V(c[0].x)+" "+G(b.id)(c[0].value)}}(),L=d.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?m.orgDomain(): +null}).on("zoom",pa?ve:null);L.update=function(){F&&F.select(".x.brush").call(this);return this};L.scale=function(a){return g?this.y(a):this.x(a)};E.scale=function(a){return g?this.y(a):this.x(a)};E.orgScaleExtent=function(){var a=id?id:[1,10];return[a[0],Math.max(fb()/a[1],a[1])]};E.updateScaleExtent=function(){var a=ua(m.orgDomain())/ua(U),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,ub,l,F,Ba,W,tb,U;h.focus=function(a){var b=q.selectAll(Va(a)),c=b.filter(ec),b=b.filter(fc); +h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&Za(a,!0)};h.defocus=function(a){var b=q.selectAll(Va(a)),c=b.filter(ec),b=b.filter(fc);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);D(h.data.targets)&&xb(a)};h.revert=function(a){var b=q.selectAll(Va(a)),c=b.filter(ec),b=b.filter(fc);c.classed("focused",!1).transition().duration(100).style("opacity", +1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&xb(a)};h.show=function(a){q.selectAll(Va(a)).transition().style("opacity",1)};h.hide=function(a){q.selectAll(Va(a)).transition().style("opacity",0)};h.unzoom=function(){L.clear().update();I({withUpdateXDomain:!0})};h.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Jd(a.xs);"categories"in a&&ea&&(Ha=a.categories,J.categories(Ha));if("cacheIds"in a&&Fd(a.cacheIds))Ta(Gd(a.cacheIds),a.done);else if("data"in +a)Ta(La(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Ta(La(c),a.done)});else if("rows"in a)Ta(La(vc(a.rows)),a.done);else if("columns"in a)Ta(La(wc(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});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Ca&&(q.selectAll(".legend-item-"+a).remove(),wb(h.data.targets));0b.classes.indexOf(a)})});return Q};h.data.get=function(a){a=h.data.getAsTarget(a);return u(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget= +function(a){var b=nb(function(b){return b.id===a});return 0