diff --git a/c3.js b/c3.js
index 896ee0d..dbce67f 100644
--- a/c3.js
+++ b/c3.js
@@ -133,13 +133,9 @@
var title = getXAxisTickFormat()(d[0].x),
text = "
";
@@ -269,6 +265,12 @@
function getYAxisClipHeight() {
return height - margin.top + 2 + getXAxisClipHeight();
}
+ function getEventRectWidth() {
+ var base = __axis_rotated ? height : width,
+ ratio = getXDomainRatio(),
+ maxDataCount = getMaxDataCount();
+ return maxDataCount > 1 ? (base * ratio) / (maxDataCount - 1) : base;
+ }
//-- Scales --//
@@ -568,8 +570,11 @@
}
function addName(data) {
- var name = __data_names[data.id];
- data.name = isDefined(name) ? name : data.id;
+ var name;
+ if (data) {
+ name = __data_names[data.id];
+ data.name = name ? name : data.id;
+ }
return data;
}
@@ -677,11 +682,25 @@
return i > 0 && c3.data.targets[0].values[i - 1] ? c3.data.targets[0].values[i - 1].x : undefined;
}
function getNextX(i) {
- return i < maxDataCount() - 1 ? c3.data.targets[0].values[i + 1].x : undefined;
+ return i < getMaxDataCount() - 1 ? c3.data.targets[0].values[i + 1].x : undefined;
}
- function maxDataCount() {
+ function getMaxDataCount() {
return d3.max(c3.data.targets, function (t) { return t.values.length; });
}
+ function getMaxDataCountTarget() {
+ var length = c3.data.targets.length, max = 0, maxTarget;
+ if (length > 1) {
+ c3.data.targets.forEach(function (t) {
+ if (t.values.length > max) {
+ maxTarget = t;
+ max = t.values.length;
+ }
+ });
+ } else {
+ maxTarget = length ? c3.data.targets[0] : null;
+ }
+ return maxTarget;
+ }
function getTargetIds(targets) {
targets = isUndefined(targets) ? c3.data.targets : targets;
return targets.map(function (d) { return d.id; });
@@ -711,6 +730,7 @@
function classCircle(d, i) { return classShape(d, i) + " -circle -circle-" + i; }
function classBar(d, i) { return classShape(d, i) + " -bar -bar-" + i; }
function classRegion(d, i) { return 'region region-' + i + ' ' + ('classes' in d ? [].concat(d.classes).join(' ') : ''); }
+ function classEvent(d, i) { return "event-rect event-rect-" + i; }
function xx(d) {
return x(d.x);
@@ -881,7 +901,7 @@
if (isCategorized) {
barW = barTargetsNum ? (axis.tickOffset() * 2 * 0.6) / barTargetsNum : 0;
} else {
- barW = (((__axis_rotated ? height : width) * getXDomainRatio(isSub)) / (maxDataCount() - 1)) * 0.6;
+ barW = (((__axis_rotated ? height : width) * getXDomainRatio(isSub)) / (getMaxDataCount() - 1)) * 0.6;
}
return barW;
}
@@ -1225,7 +1245,7 @@
};
zoom.orgScaleExtent = function () {
var extent = __zoom_extent ? __zoom_extent : [1, 10];
- return [extent[0], Math.max(maxDataCount() / extent[1], extent[1])];
+ return [extent[0], Math.max(getMaxDataCount() / extent[1], extent[1])];
};
zoom.updateScaleExtent = function () {
var ratio = diffDomain(x.orgDomain()) / diffDomain(orgXDomain), extent = this.orgScaleExtent();
@@ -1426,9 +1446,6 @@
.style('fill-opacity', 0)
.style('cursor', __zoom_enabled ? 'ew-resize' : null);
- // Generate rect for event handling
- __data_xs ? generateEventRectsForMultipleXs(eventRect) : generateEventRectsForSingleX(eventRect, data);
-
// Define g for bar chart area
main.select(".chart").append("g")
.attr("class", "chart-bars");
@@ -1526,14 +1543,11 @@
}
}
- function generateEventRectsForSingleX(eventRect, data) {
- eventRect
- .selectAll(".event-rects")
- .data(data)
- .enter().append("rect")
- .attr("class", function (d, i) { return "event-rect event-rect-" + i; })
+ function generateEventRectsForSingleX(eventRectEnter) {
+ eventRectEnter.append("rect")
+ .attr("class", classEvent)
.style("cursor", __data_selection_enabled && __data_selection_grouped ? "pointer" : null)
- .on('mouseover', function (d, i) {
+ .on('mouseover', function (_, i) {
if (dragging) { return; } // do nothing if dragging
if (hasArcType(c3.data.targets)) { return; }
@@ -1562,7 +1576,7 @@
// Show xgrid focus line
showXGridFocus(selectedData[0]);
})
- .on('mouseout', function (d, i) {
+ .on('mouseout', function (_, i) {
if (hasArcType(c3.data.targets)) { return; }
hideXGridFocus();
hideTooltip();
@@ -1570,7 +1584,7 @@
unexpandCircles(i);
unexpandBars();
})
- .on('mousemove', function (d, i) {
+ .on('mousemove', function (_, i) {
var selectedData;
if (dragging) { return; } // do nothing when dragging
@@ -1610,7 +1624,7 @@
svg.select('.event-rect-' + i).style('cursor', 'pointer');
});
})
- .on('click', function (d, i) {
+ .on('click', function (_, i) {
if (hasArcType(c3.data.targets)) { return; }
if (cancelClick) {
cancelClick = false;
@@ -1627,8 +1641,8 @@
.call(zoom).on("dblclick.zoom", null);
}
- function generateEventRectsForMultipleXs(eventRect) {
- eventRect.append('rect')
+ function generateEventRectsForMultipleXs(eventRectEnter) {
+ eventRectEnter.append('rect')
.attr('x', 0)
.attr('y', 0)
.attr('width', width)
@@ -1791,9 +1805,9 @@
}
function redraw(options) {
- var xgrid, xgridData, xgridLine;
- var mainCircle, mainBar;
- var barIndices = getBarIndices(), barTargetsNum = barIndices.__max__ + 1;
+ var xgrid, xgridData, xgridLine, ygrid;
+ var mainCircle, mainBar, mainRegion, contextBar, eventRectUpdate;
+ var barIndices = getBarIndices(), barTargetsNum = barIndices.__max__ + 1, maxDataCountTarget;
var barX, barY, barW, barH;
var rectX, rectW;
var withY, withSubchart, withTransition, withUpdateXDomain, withUpdateOrgXDomain;
@@ -1881,7 +1895,7 @@
}
// Y-Grid
if (withY && __grid_y_show) {
- var ygrid = main.select('.ygrids').selectAll(".ygrid")
+ ygrid = main.select('.ygrids').selectAll(".ygrid")
.data(y.ticks(10));
ygrid.enter().append('line')
.attr('class', 'ygrid');
@@ -1992,7 +2006,7 @@
barH = getBarH(height2, true);
barX = getBarX(barW, barTargetsNum, barIndices, true);
barY = getBarY(barH, barIndices, false, true);
- var contextBar = context.selectAll('.-bars').selectAll('.-bar')
+ contextBar = context.selectAll('.-bars').selectAll('.-bar')
.data(barData);
contextBar.transition().duration(duration)
.attr("x", barX).attr("y", barY).attr("width", barW).attr("height", barH);
@@ -2023,7 +2037,19 @@
.attr("cy", __axis_rotated ? circleX : circleY);
// rect for mouseover
- if (! __data_xs) {
+ if (__data_xs) {
+ eventRectUpdate = main.select('.event-rects').selectAll('.event-rect')
+ .data([0]);
+ // enter : only one rect will be added
+ generateEventRectsForMultipleXs(eventRectUpdate.enter());
+ // update
+ eventRectUpdate
+ .attr('x', 0)
+ .attr('y', 0)
+ .attr('width', width)
+ .attr('height', height);
+ // exit : not needed becuase always only one rect exists
+ } else {
if (isCustomX) {
rectW = function (d, i) {
var prevX = getPrevX(i), nextX = getNextX(i);
@@ -2034,18 +2060,31 @@
return (x(d.x) + x(prevX ? prevX : d.x - 50)) / 2;
};
} else {
- rectW = (((__axis_rotated ? height : width) * getXDomainRatio()) / (maxDataCount() - 1));
+ rectW = getEventRectWidth();
rectX = function (d) { return x(d.x) - (rectW / 2); };
}
- main.selectAll('.event-rect')
- .attr("x", __axis_rotated ? 0 : rectX)
- .attr("y", __axis_rotated ? rectX : 0)
- .attr("width", __axis_rotated ? width : rectW)
- .attr("height", __axis_rotated ? rectW : height);
+ // Set data
+ maxDataCountTarget = getMaxDataCountTarget();
+ main.select(".event-rects")
+ .datum(maxDataCountTarget ? maxDataCountTarget.values : []);
+ // Update rects
+ eventRectUpdate = main.select('.event-rects').selectAll('.event-rect')
+ .data(function (d) { return d; });
+ // enter
+ generateEventRectsForSingleX(eventRectUpdate.enter());
+ // update
+ eventRectUpdate
+ .attr('class', classEvent)
+ .attr("x", __axis_rotated ? 0 : rectX)
+ .attr("y", __axis_rotated ? rectX : 0)
+ .attr("width", __axis_rotated ? width : rectW)
+ .attr("height", __axis_rotated ? rectW : height);
+ // exit
+ eventRectUpdate.exit().remove();
}
// rect for regions
- var mainRegion = main.select('.regions').selectAll('rect.region')
+ mainRegion = main.select('.regions').selectAll('rect.region')
.data(__regions);
mainRegion.enter().append('rect');
mainRegion
diff --git a/c3.min.js b/c3.min.js
index 44820f2..0eda725 100644
--- a/c3.min.js
+++ b/c3.min.js
@@ -1,83 +1,84 @@
-(function(L){function hd(){function p(d,e){d.attr("transform",function(d){return"translate("+(e(d)+da)+", 0)"})}function v(d,e){d.attr("transform",function(d){return"translate(0,"+e(d)+")"})}function L(d){var e=d[0];d=d[d.length-1];return ea?0:a}function pc(a){return pa&&a===pa||aa&&Cd(aa,a)}function Dd(a){return!pc(a)}
-function mb(a){var b=Na[a.id];a.name=p(b)?b:a.id;return a}function qc(a){var b=a[0],c={},f=[],m,d;for(m=1;ms[c].indexOf(m.id)))for(f=0;fb?a-b:0};return function(a){var d=b?X(a.id):x(a.id);return c(d(a.value))}}function Sa(a,b){var c=v(a)?nb():a;"string"===typeof c&&(c=[c]);for(var f=0;f=e;e+=t)h+=f(a[d-1],a[d],e,n)}return h}function Lb(a){var b,c;ob=d.select(va);if(ob.empty())L.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');
-else{ob.html("");h.data.x={};h.data.targets=Oa(a);ta();Wb();l.domain(d.extent(kb(h.data.targets)));y.domain(ib("y"));Z.domain(ib("y2"));S.domain(l.domain());db.domain(y.domain());eb.domain(Z.domain());G.ticks(10>a.length?a.length:10);na.ticks(Rd).outerTickSize(0).tickFormat(Sd);fb.ticks(Td).outerTickSize(0).tickFormat(Ud);T=l.domain();H.x(S);qa&&D.x(l);q=d.select(va).append("svg").attr("width",r+F+ea).attr("height",t+u+K).on("mouseenter",Vd).on("mouseleave",Wd);pb=q.append("defs");pb.append("clipPath").attr("id",
-Mb).append("rect").attr("y",u).attr("width",r).attr("height",t-u);pb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-F).attr("y",-20).attr("width",W).attr("height",V);pb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-F+1).attr("y",u-1).attr("width",ka).attr("height",sb);k=q.append("g").attr("transform",I.main);z=ya?q.append("g").attr("transform",I.context):null;za=Aa?q.append("g").attr("transform",I.legend):null;U=d.select(va).style("position","relative").append("div").style("position",
-"absolute").style("z-index","10").style("display","none");k.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",I.x).call(g?na:G).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text(Xd);k.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?G:na).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Yd);cc&&
-k.append("g").attr("class","y2 axis").attr("transform",I.y2).call(fb);b=k.append("g").attr("clip-path",Ua).attr("class","grid");Uc&&b.append("g").attr("class","xgrids");Nb&&(c=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Nb).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:-u).attr("dy",-6).text(function(a){return a.text}));Zd&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?r:-10).attr("y1",g?-10:u).attr("y2",g?-10:t);Vc&&b.append("g").attr("class","ygrids");Ob&&b.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Ob).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Ua).attr("class","regions");k.append("g").attr("clip-path",
-Ua).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",qa?"ew-resize":null);aa?$d(b):ae(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");k.select(".chart").append("g").attr("class","chart-arcs").attr("transform",I.arc);if(qa)k.insert("rect",be?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(D).on("dblclick.zoom",
-null);null!==qb&&H.extent("function"!==typeof qb?qb:qb(kb()));ya&&(z.append("g").attr("clip-path",Ua).attr("class","chart"),z.select(".chart").append("g").attr("class","chart-bars"),z.select(".chart").append("g").attr("class","chart-lines"),z.append("g").attr("clip-path",Ua).attr("class","x brush").call(H).selectAll("rect").attr("height",ma),z.append("g").attr("class","x axis").attr("transform",I.subx).call(Ha));Aa&&rb(h.data.targets);Wc(h.data.targets);E({withTransition:!1,withUpdateXDomain:!0});
-if(ce){if(A&&"string"===typeof Ba){Ba=oa(Ba);for(a=0;aDb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;B(h.data.targets)||(a=d.mouse(this),c=Bc(h.data.targets,
-a),100>Db(c,a)&&k.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){Yc(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){Zc(d.mouse(this))}).on("dragstart",function(){$c(d.mouse(this))}).on("dragend",function(){ad()})).call(D).on("dblclick.zoom",null)}function Yc(a,b,c){var f=d.select(a),e=f.classed(ja),h=!1,g;"circle"===a.nodeName?(h=Mc(a,1.5*Ta),g=Pc):"rect"===a.nodeName&&(h=Nc(a),g=Rc);if(ra||h)ha&&ia(b)&&(f.classed(ja,!e),g(!e,f,b,c)),fe(b,f)}
-function Zc(a){var b,c,f,e,g,l,n;B(h.data.targets)||!ha||qa&&!D.altDomain||(b=Sb[0],c=Sb[1],f=a[0],a=a[1],e=Math.min(b,f),g=Math.max(b,f),l=ra?u:Math.min(c,a),n=ra?t:Math.max(c,a),k.select(".dragarea").attr("x",e).attr("y",l).attr("width",g-e).attr("height",n-l),k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ia(a)}).each(function(a,b){var c=d.select(this),f=c.classed(ja),h=c.classed(Tb),k,p,r,q;k=!1;"circle"===this.nodeName?(k=1*c.attr("cx"),p=1*c.attr("cy"),q=Pc,k=e",c,d,e;for(c=0;c"+e+" | "+d+" | ";return b+""}),ce=e(["tooltip","init","show"],!1),Ba=e(["tooltip","init","x"],0),Xc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Mb=va.replace("#","")+"-clip",Ua="url(#"+Mb+")",A="timeseries"===gd,$="categorized"===gd,Cb=!A&&(pa||aa),Sb=null,Va=!1,Rb=!1,la=Aa?40:0,O=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]}}(me,ne),pd=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)}}(),Zb,fc,ac,bb,ec,gc,r,t,ma,tb,ua,cb,wb,gb,kc,lc,zb,ic,jc,xb,yb,l,y,Z,S,db,eb,G,na,fb,Ha,kd=g?"left":"bottom",ld=g?vb?"top":"bottom":vb?"right":"left",md=g?ub?"bottom":"top":ub?"left":"right",nd="bottom",I={main:function(){return"translate("+F+","+u+")"},context:function(){return"translate("+n+","+Ca+")"},legend:function(){return"translate("+Yb+","+Xb+")"},
-y2:function(){return"translate("+(g?0:r)+","+(g?10:0)+")"},x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+ma+")"},arc:function(){return"translate("+r/2+","+t/2+")"}};zb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var he=function(){var a=d.svg.line().x(g?function(a){return x(a.id)(a.value)}:xa).y(g?xa:function(a){return x(a.id)(a.value)});return function(b){var c=Hb(b.values),d;if(Eb(b))return Jc(b)?a.interpolate("cardinal"):
-a.interpolate("linear"),fd[b.id]?Qd(c,l,x(b.id),fd[b.id]):a(c);d=l(c[0].x);b=x(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),ie=function(){var a;a=g?d.svg.area().x0(function(a){return x(a.id)(0)}).x1(function(a){return x(a.id)(a.value)}).y(xa):d.svg.area().x(xa).y0(function(a){return x(a.id)(0)}).y1(function(a){return x(a.id)(a.value)});return function(b){var c=Hb(b.values),d;if(Ma([b],"area")||Ma([b],"area-spline"))return Jc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=
-l(c[0].x);b=x(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),je=function(){var a=d.svg.line().x(function(a){return S(a.x)}).y(function(a){return X(a.id)(a.value)});return function(b){var c=Hb(b.values);return Eb(b)?a(c):"M "+S(c[0].x)+" "+X(b.id)(c[0].value)}}(),H=d.svg.brush().on("brush",function(){E({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),D=d.behavior.zoom().on("zoomstart",function(){D.altDomain=d.event.sourceEvent.altKey?l.orgDomain():null}).on("zoom",qa?
-ke:null);H.update=function(){z&&z.select(".x.brush").call(this);return this};D.orgScaleExtent=function(){var a=ed?ed:[1,10];return[a[0],Math.max(Pa()/a[1],a[1])]};D.updateScaleExtent=function(){var a=l.orgDomain(),a=(a[1]-a[0])/(T[1]-T[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,pb,k,z,za,U,ob,T;h.focus=function(a){var b=q.selectAll(Ya(a)),c=b.filter(Ub),b=b.filter(Vb);h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",
-1);B(h.data.targets)&&Fa(a,!0)};h.defocus=function(a){var b=q.selectAll(Ya(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);B(h.data.targets)&&Ga(a)};h.revert=function(a){var b=q.selectAll(Ya(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);B(h.data.targets)&&Ga(a)};h.show=function(a){q.selectAll(Ya(a)).transition().style("opacity",
-1)};h.hide=function(a){q.selectAll(Ya(a)).transition().style("opacity",0)};h.unzoom=function(){H.clear().update();E({withUpdateXDomain:!0})};h.load=function(a){v(a.done)&&(a.done=function(){});"categories"in a&&$&&(Ia=a.categories,G.categories(Ia));if("cacheIds"in a&&Ad(a.cacheIds))Wa(Bd(a.cacheIds),a.done);else if("data"in a)Wa(Oa(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Wa(Oa(c),a.done)});else if("rows"in a)Wa(Oa(qc(a.rows)),a.done);else if("columns"in a)Wa(Oa(rc(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();Aa&&(q.selectAll(".legend-item-"+a).remove(),rb(h.data.targets));0b.classes.indexOf(a)})});return P};h.data.get=function(a){a=h.data.getAsTarget(a);return p(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=jb(function(b){return b.id===a});return 0a?0:a}function qc(a){return qa&&a===qa||da&&Ed(da,a)}function Fd(a){return!qc(a)}function lb(a){var b;a&&(b=La[a.id],a.name=b?b:a.id);return a}function rc(a){var b=a[0],c={},f=[],l,d;for(l=1;lb&&(c=a,b=a.values.length)}):c=a?g.data.targets[0]:null;return c}function mb(a){a=t(a)?g.data.targets:a;return a.map(function(a){return a.id})}function uc(a){var b=mb(),c;for(c=0;cv[c].indexOf(l.id)))for(f=0;fb?a-b:0};return function(a){var d=b?L(a.id):x(a.id);return c(d(a.value))}}function Pa(a,b){var c=t(a)?mb():a;"string"===
+typeof c&&(c=[c]);for(var f=0;f=e;e+=s)g+=f(a[d-1],a[d],e,m)}return g}function Lb(a){var b;nb=d.select(va);if(nb.empty())N.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{nb.html("");g.data.x={};g.data.targets=Ma(a);ta();Q();n.domain(d.extent(jb(g.data.targets)));y.domain(hb("y"));X.domain(hb("y2"));
+T.domain(n.domain());cb.domain(y.domain());db.domain(X.domain());H.ticks(10>a.length?a.length:10);oa.ticks(Ud).outerTickSize(0).tickFormat(Vd);eb.ticks(Wd).outerTickSize(0).tickFormat(Xd);U=n.domain();I.x(T);ra&&E.x(n);p=d.select(va).append("svg").attr("width",r+G+ca).attr("height",s+u+M).on("mouseenter",Yd).on("mouseleave",Zd);ob=p.append("defs");ob.append("clipPath").attr("id",Mb).append("rect").attr("y",u).attr("width",r).attr("height",s-u);ob.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",
+-1-G).attr("y",-20).attr("width",K).attr("height",ba);ob.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+1).attr("y",u-1).attr("width",ja).attr("height",sb);k=p.append("g").attr("transform",J.main);z=ya?p.append("g").attr("transform",J.context):null;za=Aa?p.append("g").attr("transform",J.legend):null;V=d.select(va).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none");k.append("g").attr("class","x axis").attr("clip-path",
+h?"":"url(#xaxis-clip)").attr("transform",J.x).call(h?oa:H).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text($d);k.append("g").attr("class","y axis").attr("clip-path",h?"url(#yaxis-clip)":"").call(h?H:oa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(ae);dc&&k.append("g").attr("class","y2 axis").attr("transform",J.y2).call(eb);a=k.append("g").attr("clip-path",Ra).attr("class",
+"grid");Wc&&a.append("g").attr("class","xgrids");Nb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Nb).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",h?"":"rotate(-90)").attr("dx",h?0:-u).attr("dy",-6).text(function(a){return a.text}));be&&a.append("g").attr("class","xgrid-focus").append("line").attr("class",
+"xgrid-focus").attr("x1",h?0:-10).attr("x2",h?r:-10).attr("y1",h?-10:u).attr("y2",h?-10:s);Xc&&a.append("g").attr("class","ygrids");Ob&&a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Ob).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Ra).attr("class","regions");k.append("g").attr("clip-path",Ra).attr("class","chart");k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",
+ra?"ew-resize":null);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");k.select(".chart").append("g").attr("class","chart-arcs").attr("transform",J.arc);if(ra)k.insert("rect",ce?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",s).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom",null);null!==pb&&I.extent("function"!==typeof pb?pb:pb(jb()));ya&&(z.append("g").attr("clip-path",Ra).attr("class",
+"chart"),z.select(".chart").append("g").attr("class","chart-bars"),z.select(".chart").append("g").attr("class","chart-lines"),z.append("g").attr("clip-path",Ra).attr("class","x brush").call(I).selectAll("rect").attr("height",na),z.append("g").attr("class","x axis").attr("transform",J.subx).call(Fa));Aa&&qb(g.data.targets);Yc(g.data.targets);F({withTransition:!1,withUpdateXDomain:!0});if(de){if(A&&"string"===typeof Ba){Ba=pa(Ba);for(a=0;aDb(c,a)?p.select(".event-rect").style("cursor","pointer"):p.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;B(g.data.targets)||(a=d.mouse(this),c=Dc(g.data.targets,a),100>Db(c,a)&&k.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){$c(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){ad(d.mouse(this))}).on("dragstart",function(){bd(d.mouse(this))}).on("dragend",
+function(){cd()})).call(E).on("dblclick.zoom",null)}function $c(a,b,c){var f=d.select(a),e=f.classed(ia),g=!1,h;"circle"===a.nodeName?(g=Oc(a,1.5*Qa),h=Rc):"rect"===a.nodeName&&(g=Pc(a),h=Tc);if(sa||g)ga&&ha(b)&&(f.classed(ia,!e),h(!e,f,b,c)),ie(b,f)}function ad(a){var b,c,f,e,h,n,m;B(g.data.targets)||!ga||ra&&!E.altDomain||(b=Sb[0],c=Sb[1],f=a[0],a=a[1],e=Math.min(b,f),h=Math.max(b,f),n=sa?u:Math.min(c,a),m=sa?s:Math.max(c,a),k.select(".dragarea").attr("x",e).attr("y",n).attr("width",h-e).attr("height",
+m-n),k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ha(a)}).each(function(a,b){var c=d.select(this),f=c.classed(ia),g=c.classed(Tb),k,p,q,r;k=!1;"circle"===this.nodeName?(k=1*c.attr("cx"),p=1*c.attr("cy"),r=Rc,k=e",c,d,e;for(c=0;c"+e+" | "+d+" | ");return b+""}),de=e(["tooltip","init","show"],!1),Ba=e(["tooltip","init","x"],0),Zc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Mb=va.replace("#","")+"-clip",Ra="url(#"+Mb+")",A="timeseries"===id,Y="categorized"===id,Cb=!A&&(qa||da),Sb=null,Sa=!1,Rb=!1,ma=Aa?40:0,O=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]}}(pe,qe),qd=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)}}(),$b,gc,bc,ab,fc,hc,r,s,na,tb,ua,bb,wb,fb,lc,mc,Ab,jc,kc,yb,zb,n,y,X,T,cb,db,H,oa,eb,Fa,ld=h?"left":"bottom",md=h?vb?"top":"bottom":vb?"right":"left",nd=h?ub?"bottom":"top":ub?"left":"right",od="bottom",J={main:function(){return"translate("+G+","+u+")"},context:function(){return"translate("+m+","+Ca+")"},legend:function(){return"translate("+Xb+","+Wb+")"},
+y2:function(){return"translate("+(h?0:r)+","+(h?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+na+")"},arc:function(){return"translate("+r/2+","+s/2+")"}};Ab=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var ke=function(){var a=d.svg.line().x(h?function(a){return x(a.id)(a.value)}:xa).y(h?xa:function(a){return x(a.id)(a.value)});return function(b){var c=Hb(b.values),d;if(Eb(b))return Lc(b)?a.interpolate("cardinal"):
+a.interpolate("linear"),hd[b.id]?Td(c,n,x(b.id),hd[b.id]):a(c);d=n(c[0].x);b=x(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),le=function(){var a;a=h?d.svg.area().x0(function(a){return x(a.id)(0)}).x1(function(a){return x(a.id)(a.value)}).y(xa):d.svg.area().x(xa).y0(function(a){return x(a.id)(0)}).y1(function(a){return x(a.id)(a.value)});return function(b){var c=Hb(b.values),d;if(Ka([b],"area")||Ka([b],"area-spline"))return Lc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=
+n(c[0].x);b=x(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),me=function(){var a=d.svg.line().x(function(a){return T(a.x)}).y(function(a){return L(a.id)(a.value)});return function(b){var c=Hb(b.values);return Eb(b)?a(c):"M "+T(c[0].x)+" "+L(b.id)(c[0].value)}}(),I=d.svg.brush().on("brush",function(){F({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?n.orgDomain():null}).on("zoom",ra?
+ne:null);I.update=function(){z&&z.select(".x.brush").call(this);return this};E.orgScaleExtent=function(){var a=gd?gd:[1,10];return[a[0],Math.max(Ea()/a[1],a[1])]};E.updateScaleExtent=function(){var a=n.orgDomain(),a=(a[1]-a[0])/(U[1]-U[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var p,ob,k,z,za,V,nb,U;g.focus=function(a){var b=p.selectAll(Va(a)),c=b.filter(Ub),b=b.filter(Vb);g.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",
+1);B(g.data.targets)&&Za(a,!0)};g.defocus=function(a){var b=p.selectAll(Va(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);B(g.data.targets)&&rb(a)};g.revert=function(a){var b=p.selectAll(Va(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);B(g.data.targets)&&rb(a)};g.show=function(a){p.selectAll(Va(a)).transition().style("opacity",
+1)};g.hide=function(a){p.selectAll(Va(a)).transition().style("opacity",0)};g.unzoom=function(){I.clear().update();F({withUpdateXDomain:!0})};g.load=function(a){t(a.done)&&(a.done=function(){});"categories"in a&&Y&&(Ga=a.categories,H.categories(Ga));if("cacheIds"in a&&Cd(a.cacheIds))Ta(Dd(a.cacheIds),a.done);else if("data"in a)Ta(Ma(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Ta(Ma(c),a.done)});else if("rows"in a)Ta(Ma(rc(a.rows)),a.done);else if("columns"in a)Ta(Ma(sc(a.columns)),
+a.done);else throw Error("url or rows or columns is required.");};g.unload=function(a){g.data.targets=g.data.targets.filter(function(b){return b.id!==a});p.selectAll(".target-"+a).transition().style("opacity",0).remove();Aa&&(p.selectAll(".legend-item-"+a).remove(),qb(g.data.targets));0b.classes.indexOf(a)})});return P};g.data.get=function(a){a=g.data.getAsTarget(a);return q(a)?a.values.map(function(a){return a.value}):void 0};g.data.getAsTarget=function(a){var b=ib(function(b){return b.id===a});return 0