Browse Source

Add legend.positon - #48

pull/51/head
Masayuki Tanaka 11 years ago
parent
commit
5a9dd93ee2
  1. 224
      c3.js
  2. 188
      c3.min.js

224
c3.js

@ -76,7 +76,7 @@
// legend
var __legend_show = getConfig(['legend', 'show'], true),
__legend_item_width = getConfig(['legend', 'item', 'width'], 80), // TODO: auto
__legend_position = getConfig(['legend', 'position'], 'bottom'),
__legend_item_onclick = getConfig(['legend', 'item', 'onclick'], function () {});
// axis
@ -173,8 +173,6 @@
var dragStart = null, dragging = false, cancelClick = false;
var legendHeight = __legend_show ? 40 : 0;
var color = generateColor(__data_colors, __color_pattern);
var defaultTimeFormat = (function () {
@ -197,7 +195,7 @@
/*-- Set Chart Params --*/
var margin, margin2, margin3, width, width2, height, height2, height3, currentWidth, currentHeight;
var margin, margin2, margin3, width, width2, height, height2, currentWidth, currentHeight, legendHeight, legendWidth;
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;
@ -211,14 +209,40 @@
main : function () { return "translate(" + margin.left + "," + margin.top + ")"; },
context : function () { return "translate(" + margin2.left + "," + margin2.top + ")"; },
legend : function () { return "translate(" + margin3.left + "," + margin3.top + ")"; },
y2 : function () { return "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 10 : 0) + ")"; },
y2 : function () { return "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 1 : 0) + ")"; },
x : function () { return "translate(0," + height + ")"; },
subx : function () { return "translate(0," + (__axis_rotated ? 0 : height2) + ")"; },
arc: function () { return "translate(" + width / 2 + "," + height / 2 + ")"; }
};
var isLegendRight = __legend_position === 'right';
/*-- Define Functions --*/
function transformMain() {
main.attr("transform", translate.main);
main.select('.x.axis').attr("transform", translate.x);
main.select('.y2.axis').attr("transform", translate.y2);
main.select('.chart-arcs').attr("transform", translate.arc);
}
function transformContext() {
if (__subchart_show) {
context.attr("transform", translate.context);
context.select('.x.axis').attr("transform", translate.subx);
}
}
function transformLegend(withTransition) {
var duration = withTransition !== false ? 250 : 0;
if (__legend_show) {
legend.transition().duration(duration).attr("transform", translate.legend);
}
}
function transformAll(withTransition) {
transformMain(withTransition);
transformContext(withTransition);
transformLegend(withTransition);
}
//-- Sizes --//
// TODO: configurabale
@ -227,38 +251,43 @@
function updateSizes() {
currentWidth = getCurrentWidth();
currentHeight = getCurrentHeight();
legendHeight = getLegendHeight();
legendWidth = getLegendWidth();
// for main
margin = {
top: 0,
left: (__axis_rotated ? __subchart_size_height + rotated_padding_right : 0) + getCurrentPaddingLeft(),
bottom: 20 + (__axis_rotated ? 0 : __subchart_size_height) + legendHeight,
right: getCurrentPaddingRight()
top: __axis_rotated && __axis_y2_show ? 20 : 0,
right: getCurrentPaddingRight(),
bottom: 20 + (__axis_rotated ? 0 : __subchart_size_height) + (isLegendRight ? 0 : legendHeight),
left: (__axis_rotated ? __subchart_size_height + rotated_padding_right : 0) + getCurrentPaddingLeft()
};
width = currentWidth - margin.left - margin.right;
height = currentHeight - margin.top - margin.bottom;
// for context
margin2 = {
top: __axis_rotated ? margin.top : (currentHeight - __subchart_size_height - legendHeight),
left: __axis_rotated ? rotated_padding_left : margin.left,
bottom: 20 + legendHeight,
right: NaN
top: __axis_rotated ? margin.top : (currentHeight - __subchart_size_height - (isLegendRight ? 0 : legendHeight)),
right: NaN,
bottom: 20 + (isLegendRight ? 0 : legendHeight),
left: __axis_rotated ? rotated_padding_left : margin.left
};
width2 = __axis_rotated ? margin.left - rotated_padding_left - rotated_padding_right : width;
height2 = __axis_rotated ? height : currentHeight - margin2.top - margin2.bottom;
// for legend
margin3 = {
top: currentHeight - legendHeight,
top: isLegendRight ? margin.top : currentHeight - legendHeight,
right: NaN,
bottom: 0,
left: margin.left
left: isLegendRight ? currentWidth - legendWidth : 0
};
height3 = currentHeight - margin3.top - margin3.bottom;
// for arc
updateRadius();
if (isLegendRight && hasArcType(c3.data.targets)) {
margin3.left = width / 2 + radiusExpanded;
}
}
function updateRadius() {
radiusExpanded = height / 2;
@ -277,15 +306,21 @@
return h > 0 ? h : 320;
}
function getCurrentPaddingLeft() {
if (__padding_left) {
if (hasArcType(c3.data.targets)) {
return 0;
} else if (__padding_left) {
return __padding_left;
} else {
return __axis_y_inner ? 1 : getDefaultPaddingWithAxisId('y');
}
}
function getCurrentPaddingRight() {
if (__padding_right) {
if (hasArcType(c3.data.targets)) {
return 0;
} else if (__padding_right) {
return __padding_right;
} else if (isLegendRight) {
return legendWidth * (__axis_y2_show && !__axis_rotated ? 1.25 : 1);
} else if (__axis_y2_show) {
return __axis_y2_inner || __axis_rotated ? 1 : getDefaultPaddingWithAxisId('y2');
} else {
@ -302,7 +337,7 @@
return +d3.select(__bindto).style('height').replace('px', ''); // TODO: if rotated, use width
}
function getXAxisClipWidth() {
return width + 2 + margin.left + margin.right;
return width + 2;
}
function getXAxisClipHeight() {
return 40;
@ -311,7 +346,7 @@
return margin.left + 20;
}
function getYAxisClipHeight() {
return height - margin.top + 2;
return height + 2;
}
function getEventRectWidth() {
var base = __axis_rotated ? height : width,
@ -319,6 +354,12 @@
maxDataCount = getMaxDataCount();
return maxDataCount > 1 ? (base * ratio) / (maxDataCount - 1) : base;
}
function getLegendWidth() {
return __legend_show ? isLegendRight ? 150 : currentWidth : 0;
}
function getLegendHeight() {
return __legend_show ? isLegendRight ? currentHeight : 40 : 0;
}
//-- Scales --//
@ -1613,13 +1654,12 @@
defs.append("clipPath")
.attr("id", clipId)
.append("rect")
.attr("y", margin.top)
.attr("width", width)
.attr("height", height - margin.top);
.attr("height", height);
defs.append("clipPath")
.attr("id", "xaxis-clip")
.append("rect")
.attr("x", -1 - margin.left)
.attr("x", -1)
.attr("y", -20)
.attr("width", getXAxisClipWidth)
.attr("height", getXAxisClipHeight);
@ -1627,7 +1667,6 @@
.attr("id", "yaxis-clip")
.append("rect")
.attr("x", -margin.left + 1)
.attr("y", margin.top - 1)
.attr("width", getYAxisClipWidth)
.attr("height", getYAxisClipHeight);
@ -1818,7 +1857,9 @@
/*-- Legend Region --*/
if (__legend_show) { updateLegend(c3.data.targets); }
if (__legend_show) {
updateLegend(c3.data.targets);
}
// Set targets
updateTargets(c3.data.targets);
@ -1848,7 +1889,7 @@
window.onresize = generateResize();
}
if (window.onresize.add) {
window.onresize.add(resize);
window.onresize.add(updateAndRedraw);
}
}
@ -2121,7 +2162,7 @@
var withY, withSubchart, withTransition, withTransform, withUpdateXDomain, withUpdateOrgXDomain;
var hideAxis = hasArcType(c3.data.targets);
var drawBar, drawBarOnSub, xForText, yForText;
var duration;
var duration, durationForExit;
options = isDefined(options) ? options : {};
withY = isDefined(options.withY) ? options.withY : true;
@ -2132,6 +2173,7 @@
withUpdateOrgXDomain = isDefined(options.withUpdateOrgXDomain) ? options.withUpdateOrgXDomain : false;
duration = withTransition ? __transition_duration : 0;
durationForExit = isDefined(options.durationForExit) ? options.durationForExit : duration;
if (withUpdateOrgXDomain) {
x.domain(d3.extent(getXDomain(c3.data.targets)));
@ -2247,7 +2289,7 @@
.transition().duration(duration)
.attr('d', drawBar)
.style("opacity", 1);
mainBar.exit().transition().duration(duration)
mainBar.exit().transition().duration(durationForExit)
.style('opacity', 0)
.remove();
@ -2266,7 +2308,7 @@
.attr('y', yForText)
.style("fill-opacity", opacityForText);
mainText.exit()
.transition().duration(duration)
.transition().duration(durationForExit)
.style('fill-opacity', 0)
.remove();
@ -2443,6 +2485,9 @@
.style("fill-opacity", 0)
.remove();
// update legend
updateLegend(c3.data.targets, {withTransition: withTransition});
// update fadein condition
getTargetIds().forEach(function (id) {
withoutFadeIn[id] = true;
@ -2487,7 +2532,11 @@
};
return callResizeFunctions;
}
function resize() {
function updateAndRedraw(options) {
var withTransition, withTransform;
options = isDefined(options) ? options : {};
withTransition = isDefined(options.withTransition) ? options.withTransition : false;
withTransform = isDefined(options.withTransform) ? options.withTransform : false;
// Update sizes and scales
updateSizes();
updateScales();
@ -2500,22 +2549,15 @@
svg.select('#' + clipId).select('rect').attr('width', width).attr('height', height);
svg.select('#xaxis-clip').select('rect').attr('width', getXAxisClipWidth);
svg.select('.zoom-rect').attr('width', width).attr('height', height);
// Update main positions
main.select('.x.axis').attr("transform", translate.x);
main.select('.y2.axis').attr("transform", translate.y2);
main.select('.chart-arcs').attr("transform", translate.arc);
// Update context sizes and positions
if (__subchart_show) {
context.attr("transform", translate.context);
context.select('.x.axis').attr("transform", translate.subx);
}
// Update legend positions
if (__legend_show) {
legend.attr("transform", translate.legend);
updateLegend(c3.data.targets, {withTransition: false});
}
// Update g positions
transformAll(withTransition);
// Draw with new sizes & scales
redraw({withTransition: false, withUpdateXDomain: true});
redraw({
withTransition: withTransition,
withUpdateXDomain: true,
withTransform: withTransform,
durationForExit: 0
});
}
function updateTargets(targets) {
@ -2698,13 +2740,41 @@
function updateLegend(targets, options) {
var ids = getTargetIds(targets), l;
var padding = width / 2 - __legend_item_width * Object.keys(targets).length / 2;
var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect;
var item_height = 0, item_width = 0, paddingTop = 4, paddingRight = 30, margin, updateSizes;
var withTransition;
options = isUndefined(options) ? {} : options;
withTransition = isDefined(options.withTransition) ? options.withTransition : true;
if (isLegendRight) {
xForLegend = function () { return legendWidth * 0.2; };
yForLegend = function (d, i) { return margin + item_height * i; };
} else {
xForLegend = function (d, i) { return margin + item_width * i; };
yForLegend = function () { return legendHeight * 0.2; };
}
xForLegendText = function (d, i) { return xForLegend(d, i) + 14; };
yForLegendText = function (d, i) { return yForLegend(d, i) + 9; };
xForLegendRect = function (d, i) { return xForLegend(d, i) - 4; };
yForLegendRect = function (d, i) { return yForLegend(d, i) - 7; };
updateSizes = function (offsetWidth, offsetHeight) {
var width = Math.ceil((offsetWidth + paddingRight) / 10) * 10,
height = Math.ceil((offsetHeight + paddingTop) / 10) * 10;
if (width > item_width) {
item_width = width;
if (! isLegendRight) {
margin = (legendWidth - item_width * Object.keys(targets).length) / 2;
}
}
if (height > item_height) {
item_height = height;
if (isLegendRight) {
margin = (legendHeight - item_height * Object.keys(targets).length) / 2;
}
}
};
// Define g for legend area
l = legend.selectAll('.legend-item')
.data(ids)
@ -2722,41 +2792,47 @@
revertLegend();
c3.revert();
});
l.append('text')
.text(function (d) { return isDefined(__data_names[d]) ? __data_names[d] : d; })
.each(function () { updateSizes(this.offsetWidth, this.offsetHeight); })
.style("pointer-events", "none")
.attr('x', isLegendRight ? xForLegendText : -200)
.attr('y', isLegendRight ? -200 : yForLegend);
l.append('rect')
.attr("class", "legend-item-event")
.style('fill-opacity', 0)
.attr('x', -200)
.attr('y', function () { return legendHeight / 2 - 16; })
.attr('width', __legend_item_width)
.attr('x', isLegendRight ? xForLegendRect : -200)
.attr('y', isLegendRight ? -200 : yForLegendRect)
.attr('width', item_width + 14)
.attr('height', 24);
l.append('rect')
.attr("class", "legend-item-tile")
.style("pointer-events", "none")
.style('fill', function (d) { return color(d); })
.attr('x', -200)
.attr('y', function () { return legendHeight / 2 - 9; })
.attr('x', isLegendRight ? xForLegendText : -200)
.attr('y', isLegendRight ? -200 : yForLegendText)
.attr('width', 10)
.attr('height', 10);
l.append('text')
.text(function (d) { return isDefined(__data_names[d]) ? __data_names[d] : d; })
.style("pointer-events", "none")
.attr('x', -200)
.attr('y', function () { return legendHeight / 2; });
legend.selectAll('rect.legend-item-event')
legend.selectAll('text')
.data(ids)
.each(function () { updateSizes(this.offsetWidth, this.offsetHeight); })
.transition().duration(withTransition ? 250 : 0)
.attr('x', function (d, i) { return padding + __legend_item_width * i; });
.attr('x', xForLegendText)
.attr('y', yForLegendText);
legend.selectAll('rect.legend-item-tile')
legend.selectAll('rect.legend-item-event')
.data(ids)
.transition().duration(withTransition ? 250 : 0)
.attr('x', function (d, i) { return padding + __legend_item_width * i; });
.attr('x', xForLegendRect)
.attr('y', yForLegendRect);
legend.selectAll('text')
legend.selectAll('rect.legend-item-tile')
.data(ids)
.transition().duration(withTransition ? 250 : 0)
.attr('x', function (d, i) { return padding + __legend_item_width * i + 14; });
.attr('x', xForLegend)
.attr('y', yForLegend);
}
/*-- Event Handling --*/
@ -2935,46 +3011,42 @@
c3.toLine = function (targets) {
setTargetType(targets, 'line');
redraw();
updateAndRedraw({withTransition: true});
};
c3.toSpline = function (targets) {
setTargetType(targets, 'spline');
redraw();
updateAndRedraw({withTransition: true});
};
c3.toBar = function (targets) {
setTargetType(targets, 'bar');
redraw();
updateAndRedraw({withTransition: true});
};
c3.toScatter = function (targets) {
setTargetType(targets, 'scatter');
redraw();
updateAndRedraw({withTransition: true});
};
c3.toArea = function (targets) {
setTargetType(targets, 'area');
redraw();
updateAndRedraw({withTransition: true});
};
c3.toAreaSpline = function (targets) {
setTargetType(targets, 'area-spline');
redraw();
updateAndRedraw({withTransition: true});
};
c3.toPie = function (targets) {
setTargetType(targets, 'pie');
updateRadius();
updateArc();
redraw({withTransform: true});
updateAndRedraw({withTransition: true, withTransform: true});
};
c3.toDonut = function (targets) {
setTargetType(targets, 'donut');
updateRadius();
updateArc();
redraw({withTransform: true});
updateAndRedraw({withTransition: true, withTransform: true});
};
c3.groups = function (groups) {
@ -3024,7 +3096,7 @@
c3.resize = function (size) {
__size_width = size ? size.width : null;
__size_height = size ? size.height : null;
resize();
updateAndRedraw();
};
c3.destroy = function () {

188
c3.min.js vendored

@ -1,93 +1,95 @@
(function(K){function Ad(){function O(d,e){d.attr("transform",function(d){return"translate("+(e(d)+ga)+", 0)"})}function w(d,e){d.attr("transform",function(d){return"translate(0,"+e(d)+")"})}function z(d){var e=d[0];d=d[d.length-1];return e<d?[e,d]:[d,e]}function A(d){for(var e=[],m=Math.ceil(d[0]);m<d[1];m++)e.push(m);0<e.length&&0<e[0]&&e.unshift(e[0]-(e[1]-e[0]));return e}function K(d,e){var m=d.length-1;return m<=W||0===e%Math.ceil(m/W)}function La(d){d=d<X.length?X[d]:d;return P?P(d):d}function m(m){m.each(function(){var m=
e.select(this),Ka=A(t.domain()),Q=m.selectAll(".tick.major").data(Ka,String),R=Q.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),ha=e.transition(Q.exit()).style("opacity",1E-6).remove(),S=e.transition(Q).style("opacity",1),u,L=t.rangeExtent?t.rangeExtent():z(t.range()),m=m.selectAll(".domain").data([0]);m.enter().append("path").attr("class","domain");var m=e.transition(m),M=t.copy(),Y=this.__chart__||M;this.__chart__=M;R.append("line");R.append("text");var P=R.select("line"),
W=S.select("line"),Z=Q.select("text"),X=R.select("text"),ia=S.select("text");ga=(M(1)-M(0))/2;Q=oa?0:ga;switch(pa){case "bottom":u=O;P.attr("y2",H);X.attr("y",Math.max(H,0)+qa);W.attr("x1",Q).attr("x2",Q).attr("y2",H);ia.attr("x",0).attr("y",Math.max(H,0)+qa);Z.attr("dy",".71em").style("text-anchor","middle");Z.text(function(d){return K(Ka,d)?La(d):""});m.attr("d","M"+L[0]+","+d+"V0H"+L[1]+"V"+d);break;case "left":u=w,P.attr("x2",-H),X.attr("x",-(Math.max(H,0)+qa)),W.attr("x2",-H).attr("y2",0),ia.attr("x",
-(Math.max(H,0)+qa)).attr("y",ga),Z.attr("dy",".32em").style("text-anchor","end"),Z.text(function(d){return K(Ka,d)?La(d):""}),m.attr("d","M"+-d+","+L[0]+"H0V"+L[1]+"H"+-d)}if(t.ticks)R.call(u,Y),S.call(u,M),ha.call(u,M);else{var wb=M.rangeBand()/2,ha=function(d){return M(d)+wb};R.call(u,ha);S.call(u,ha)}})}var t=e.scale.linear(),pa="bottom",H=6,d=6,qa=3,oa=!1,W=10,ga=0,P=null,ia=!0,X=[];m.scale=function(d){if(!arguments.length)return t;t=d;return m};m.orient=function(d){if(!arguments.length)return pa;
pa=d in{top:1,right:1,bottom:1,left:1}?d+"":"bottom";return m};m.categories=function(d){if(!arguments.length)return X;X=d;return m};m.tickCentered=function(d){if(!arguments.length)return oa;oa=d;return m};m.tickFormat=function(d){if(!arguments.length)return P;P=d;return m};m.tickOffset=function(){return ga};m.ticks=function(d){if(!arguments.length)return W;W=d;return m};m.tickCulling=function(d){if(!arguments.length)return ia;ia=d;return m};return m}function A(e){return e||0===e}function w(e){return"undefined"===
typeof e}function z(e){return"undefined"!==typeof e}var xb=K.c3={},e=K.d3;xb.generate=function(O){var oc,pc,vb,qc,La,m,t,pa,H;function d(a,b){for(var c=O,f=0;f<a.length;f++){if(!(a[f]in c))return b;c=c[a[f]]}return c}function qa(){yb=Ma?Ma:P();wa=ga();m=0;t=(h?zb+tc:0)+(bb?bb:cb?1:40);pa=20+(h?0:zb)+ra;H=db?db:Ab?eb||h?1:40:1;r=yb-t-H;q=wa-m-pa;vb=h?m:wa-zb-ra;qc=h?uc:t;La=20+ra;Bb=h?t-uc-tc:r;fb=h?q:wa-vb-La;oc=wa-ra;pc=t;oa()}function oa(){Cb=q/2;Na=0.95*Cb;Db=$(g.data.targets,"donut")?0.6*Na:0}
function W(){var a=p.property("offsetLeft");return a?a:0}function ga(){var a=Eb?Eb:+e.select(xa).style("height").replace("px","");return 0<a?a:320}function P(){return+e.select(xa).style("width").replace("px","")}function ia(){return r+2+t+H}function X(){return 40}function Ka(){return t+20}function xb(){return q-m+2}function Bd(){var a=h?q:r,b=ya(aa)/ya(n.domain()),c=za();return 1<c?a*b/(c-1):a}function Q(){var a,b;Fb=h?1:0;Gb=h?q:r;Hb=h?0:q;Ib=h?r:1;Jb=h?0:fb;Kb=h?Bb:1;n=ha(Fb,Gb,n?n.domain():void 0,
function(){return T.tickOffset()});B=S(Hb,Ib,B?B.domain():void 0);ba=S(Hb,Ib,ba?ba.domain():void 0);U=ha(Fb,Gb,aa,function(a){return a%1?0:Lb.tickOffset()});gb=S(Jb,Kb);hb=S(Jb,Kb);a=rc();b=Cd();T=M(n,Fd,a,b);Lb=M(U,Gd,a,b);Mb=e.svg.axis().scale(B).orient(Hd).tickFormat(Nb).ticks(Id).outerTickSize(0);vc=e.svg.axis().scale(ba).orient(Jd).tickFormat(Kd).ticks(Ld).outerTickSize(0);R()}function R(){ib=Dd();wc=sc();xc=sc(0.98)}function ha(a,b,c,f){var k=(D?e.time.scale():e.scale.linear()).range([a,b]);
k.orgDomain=function(){return k.domain()};z(c)&&k.domain(c);w(f)&&(f=function(){return 0});if(ja){var d=k,s,k=function(a){return d(a)+f(a)};for(s in d)k[s]=d[s];k.orgDomain=function(){return d.domain()};k.domain=function(a){if(!arguments.length)return a=d.domain(),[a[0],a[1]+1];d.domain(a);return k}}return k}function S(a,b){return e.scale.linear().range([a,b])}function u(a){return"y2"===Y(a)?ba:B}function L(a){return"y2"===Y(a)?hb:gb}function M(a,b,c,f){a=(ja?Ad():e.svg.axis()).scale(a).orient(b);
a.tickFormat(c).ticks(f);ja?a.tickCentered(Md):a.tickOffset=function(){return(h?q:r)*(ya(aa)/ya(n.domain()))/za()/2};ja&&a.categories(Oa);return a}function Y(a){return a in yc?yc[a]:"y"}function rc(){var a=D?Nd:ja?Od:null;jb&&("function"===typeof jb?a=jb:D&&(a=function(a){return e.time.format(jb)(a)}));return a}function Cd(){var a=za();return Pd&&a>zc?zc:a}function Z(a){var b=!1;Ob(g.data.targets).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function Dd(){var a=e.svg.arc().outerRadius(Na).innerRadius(Db),
b=function(b,f){var k;return f?a(b):(k=Z(b))?a(k):"M 0 0"};b.centroid=a.centroid;return b}function sc(a){var b=e.svg.arc().outerRadius(Cb*(a?a:1)).innerRadius(Db);return function(a){return(a=Z(a))?b(a):"M 0 0"}}function wb(a){a=Z(a);var b,c;b="";a&&(b=ib.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*Na+","+0.8*(b/c)*Na+")");return b}function Ed(a){return Qd(a,(a.endAngle-a.startAngle)/(2*Math.PI))}function Ac(a,b){var c=p.selectAll(".chart-arc"+ka(a)),f=p.selectAll(".-arc").filter(function(b){return b.data.id!==
a});c.selectAll("path").transition().duration(50).attr("d",wc).transition().duration(100).attr("d",xc).each(function(a){Pb(a.data)});b||f.style("opacity",0.3)}function Qb(a){p.selectAll(".chart-arc"+ka(a)).selectAll("path").transition().duration(50).attr("d",ib);p.selectAll(".-arc").style("opacity",1)}function Rd(a){var b=Bc(a),c,f,k,d;if(0<v.length)for(d=Cc(a),a=0;a<v.length;a++)for(f=v[a][0],d&&b[f]&&b[f].forEach(function(a,c){b[f][c]=0>a?a:0}),c=1;c<v[a].length;c++)k=v[a][c],b[k]&&b[k].forEach(function(a,
c){Y(k)!==Y(f)||!b[f]||d&&0<+a||(b[f][c]+=+a)});return e.min(Object.keys(b).map(function(a){return e.min(b[a])}))}function Sd(a){var b=Bc(a),c,f,k,d;if(0<v.length)for(d=Td(a),a=0;a<v.length;a++)for(f=v[a][0],d&&b[f]&&b[f].forEach(function(a,c){b[f][c]=0<a?a:0}),c=1;c<v[a].length;c++)k=v[a][c],b[k]&&b[k].forEach(function(a,c){Y(k)!==Y(f)||!b[f]||d&&0>+a||(b[f][c]+=+a)});return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))}function kb(a){var b=lb(function(b){return Y(b.id)===a}),c="y2"===
a?Ud:Vd,f="y2"===a?Wd:Xd,c=c?c:Rd(b),f=f?f:Sd(b),k=0.22*Math.abs(f-c),d=k,e=k,h="y2"===a?Yd:Zd;h&&(c=Math.max(Math.abs(c),Math.abs(f)),f=c-h,c=h-c);"y"===a&&Pa&&(d=A(Pa.top)?Pa.top:k,e=A(Pa.bottom)?Pa.bottom:k);"y2"===a&&Qa&&(d=A(Qa.top)?Qa.top:k,e=A(Qa.bottom)?Qa.bottom:k);$(b,"bar")&&!Cc(b)&&(e=c);return[c-e,f+d]}function $d(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.x})})}function ae(a){return e.max(a,function(a){return e.max(a.values,function(a){return a.x})})}function mb(a){var b=
[$d(a),ae(a)],c=b[0],f=b[1],b=Math.abs(b[0]-b[1]);a=ja?0:$(a,"bar")?b/(za()-1)/2:0.01*b;c=D?new Date(c.getTime()-a):c-a;f=D?new Date(f.getTime()+a):f+a;return[c,f]}function ya(a){return a[1]-a[0]}function be(a){for(var b=0;b<a.length;b++)if(!(a[b]in nb))return!1;return!0}function ce(a){for(var b=[],c=0;c<a.length;c++)a[c]in nb&&b.push(Dc(nb[a[c]]));return b}function Rb(a){return"start"in a?n(D?sa(a.start):a.start):0}function Ec(a){var b=Rb(a);a=("end"in a?n(D?sa(a.end):a.end):r)-b;return 0>a?0:a}
function Fc(a){return ta&&a===ta||ca&&de(ca,a)}function ee(a){return!Fc(a)}function fe(a){Object.keys(a).forEach(function(b){ca[b]=a[b]})}function ob(a){var b;a&&(b=Ra[a.id],a.name=b?b:a.id);return a}function Gc(a){var b=a[0],c={},f=[],k,d;for(k=1;k<a.length;k++){c={};for(d=0;d<a[k].length;d++)c[b[d]]=a[k][d];f.push(c)}return f}function Hc(a){var b=[],c,f,k;for(c=0;c<a.length;c++)for(k=a[c][0],f=1;f<a[c].length;f++)w(b[f-1])&&(b[f-1]={}),b[f-1][k]=a[c][f];return b}function Sa(a){var b=e.keys(a[0]).filter(ee),
c=e.keys(a[0]).filter(Fc);if(D&&0===c.length)return K.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[];Sb&&b.forEach(function(b){var k=ta?ta:ca?ca[b]:null;0<=c.indexOf(k)?g.data.x[b]=a.map(function(a){return a[k]}):g.data.x[b]=g.data.x[Object.keys(g.data.x)[0]]});b=b.map(function(b){var c=ge(b);return{id:c,id_org:b,values:a.map(function(a,d){var e;e=ta?ta:ca?ca[b]:null;e=D?sa(a[e]):Sb?a[e]?+a[e]:b in g.data.x&&g.data.x[b]&&g.data.x[b][d]?g.data.x[b][d]:d:d;a.x=e;return{x:e,
value:null===a[b]||isNaN(a[b])?null:+a[b],id:c}})}});b.forEach(function(a){var b;a.values=a.values.sort(function(a,b){return(a.x||0===a.x?a.x:Infinity)-(b.x||0===b.x?b.x:Infinity)});b=0;a.values.forEach(function(a){a.index=b++})});Ic&&da(Ta(b).filter(function(a){return!(a in y)}),Ic);b.forEach(function(a){nb[a.id_org]=Dc(a)});return b}function Dc(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function Jc(a){return 0<a&&g.data.targets[0].values[a-
1]?g.data.targets[0].values[a-1].x:void 0}function za(){return e.max(g.data.targets,function(a){return a.values.length})}function he(){var a=g.data.targets.length,b=0,c;1<a?g.data.targets.forEach(function(a){a.values.length>b&&(c=a,b=a.values.length)}):c=a?g.data.targets[0]:null;return c}function Ta(a){a=w(a)?g.data.targets:a;return a.map(function(a){return a.id})}function Kc(a){var b=Ta(),c;for(c=0;c<b.length;c++)if(b[c]===a)return!0;return!1}function lb(a){return z(a)?g.data.targets.filter(a):g.data.targets}
function Bc(a){var b={};a.forEach(function(a){b[a.id]=[];a.values.forEach(function(f){b[a.id].push(f.value)})});return b}function Lc(a,b){var c=Object.keys(a),f,k,d;for(f=0;f<c.length;f++)for(d=a[c[f]].values,k=0;k<d.length;k++)if(b(d[k].value))return!0;return!1}function Cc(a){return Lc(a,function(a){return 0>a})}function Td(a){return Lc(a,function(a){return 0<a})}function Od(a){return a<Oa.length?Oa[a]:a}function ie(a){return"-text -text-"+a.id}function je(a){return"-texts -texts-"+a.id}function Ua(a){return"-shapes -shapes-"+
a.id}function Mc(a){return Ua(a)+" -line -line-"+a.id}function ke(a){return Ua(a)+" -circles -circles-"+a.id}function Nc(a){return Ua(a)+" -bars -bars-"+a.id}function le(a){return Ua(a.data)+" -arc -arc-"+a.data.id}function me(a){return Ua(a)+" -area -area-"+a.id}function ne(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function Oc(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function oe(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function Pc(a,b){return"event-rect event-rect-"+
b}function Aa(a){return Tb[a.id]?1:0}function pe(a){var b=Qc(a);return Aa(a)*b}function qe(a){return A(a.value)?Rc(a)?0.5:1:0}function Qc(a){return"boolean"===typeof Ba&&Ba||"boolean"===Ba[a.id]&&Ba[a.id]||Ba[a.id]&&Ba[a.id].show?1:0}function Ca(a){return a?n(a.x):null}function Va(a){return n(D?sa(a.value):a.value)}function Wa(a){return B(a.value)}function Sc(a){return U(a.x)}function Tc(a){return(Nb?Nb:function(a){return+a})(a)}function Uc(a,b){var c,f=a[b].x,k=[];for(c=b-1;0<=c&&f===a[c].x;c--)k.push(a[c]);
for(c=b;c<a.length&&f===a[c].x;c++)k.push(a[c]);return k}function Vc(a,b,c,f){c=c?c:0;f=f?f:a.length-1;var k=Math.floor((f-c)/2)+c;0<n(a[k].x)-b[0]?f=k:c=k;return 1===f-c?(k=[],a[c].x&&(k=k.concat(Uc(a,c))),a[f].x&&(k=k.concat(Uc(a,f))),Wc(k,b)):Vc(a,b,c,f)}function Xc(a,b){var c;c=a.map(function(a){return Vc(a.values,b)});return Wc(c,b)}function Wc(a,b){var c,f;a.forEach(function(a){var d=Ub(a,b);if(d<c||!c)c=d,f=a});return f}function re(a){var b=Da&&"asc"===Da.toLowerCase(),c=Da&&"desc"===Da.toLowerCase();
b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),d=c.values.reduce(d,0);return b?d-e:e-d}):"function"===typeof Da&&a.sort(Da);return a}function Yc(a,b){var c,f,k,d,e;d=a.filter(function(a){return a&&A(a.value)});Zc&&0!==d.length&&(V.html($c(a)).style("visibility","hidden").style("display","block"),c=V.property("offsetWidth"),f=V.property("offsetHeight"),h?d=b[0]:(k=W(),d=k+(bb?bb:cb?1:40)+n(d[0].x)+20,e=d+c,k=k+(Ma?Ma:P())-(db?db:Ab?eb||h?1:40:1),e>
k&&(d-=c+30)),c=b[1]+15+f<ga()?b[1]+15:b[1]-f,V.style("top",c+"px").style("left",d+"px").style("visibility","visible"))}function ad(a){a=a.filter(function(a){return a&&A(a.value)});Zc&&($(g.data.targets,"scatter")||E(g.data.targets)||l.selectAll("line.xgrid-focus").style("visibility","visible").data([a[0]]).attr(h?"y1":"x1",Ca).attr(h?"y2":"x2",Ca))}function bd(){l.select("line.xgrid-focus").style("visibility","hidden")}function Ea(a){return a.x||0===a.x?n(a.x):null}function Fa(a){return u(a.id)(a.value)}
function se(){var a={},b=0,c,f;lb(ua).forEach(function(k){for(c=0;c<v.length;c++)if(!(0>v[c].indexOf(k.id)))for(f=0;f<v[c].length;f++)if(v[c][f]in a){a[k.id]=a[v[c][f]];break}w(a[k.id])&&(a[k.id]=b++)});a.__max__=b-1;return a}function te(a,b,c,f){var k=f?U:n;return function(f){var d=f.id in c?c[f.id]:0;return f.x||0===f.x?k(f.x)-a*(b/2-d):0}}function ue(a){return function(b){return(a?L(b.id):u(b.id))(b.value)}}function ve(a,b){var c=re(lb(ua)),f=c.map(function(a){return a.id});return function(k,d){var e=
b?L(k.id):u(k.id),h=e(0),g=h;c.forEach(function(b){b.id!==k.id&&a[b.id]===a[k.id]&&f.indexOf(b.id)<f.indexOf(k.id)&&0<b.values[d].value*k.value&&(g+=e(b.values[d].value)-h)});return g}}function da(a,b){var c=w(a)?Ta():a;"string"===typeof c&&(c=[c]);for(var f=0;f<c.length;f++)Tb[c[f]]=b===y[c[f]],y[c[f]]=b}function $(a,b){var c=!1;a.forEach(function(a){y[a.id]===b&&(c=!0);a.id in y||"line"!==b||(c=!0)});return c}function E(a){return $(a,"pie")||$(a,"donut")}function pb(a){a="string"===typeof a?a:a.id;
return!(a in y)||"line"===y[a]||"spline"===y[a]||"area"===y[a]||"area-spline"===y[a]}function cd(a){a="string"===typeof a?a:a.id;return"spline"===y[a]||"area-spline"===y[a]}function ua(a){return"bar"===y["string"===typeof a?a:a.id]}function Rc(a){return"scatter"===y["string"===typeof a?a:a.id]}function dd(a){return"pie"===y["string"===typeof a?a:a.id]}function Pb(a){return"donut"===y["string"===typeof a?a:a.id]}function ed(a){return ua(a)?a.values:[]}function we(a){return pb(a)||Rc(a)?a.values:[]}
function xe(a){return ua(a)||pb(a)?a.values:[]}function sa(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+Vb+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");b=e.time.format(Vb).parse(a);if(!b)throw Error("Failed to parse '"+a+"' with format "+Vb);return b}function fd(a,b){var c=e.mouse(a),f=e.select(a),d=1*f.attr("cx"),f=1*f.attr("cy");return Math.sqrt(Math.pow(d-c[0],2)+Math.pow(f-c[1],2))<b}function gd(a){var b=e.mouse(a),c=e.select(a);a=1*c.attr("x");
var f=1*c.attr("y"),c=1*c.attr("width");return a-10<b[0]&&b[0]<a+c+10&&f-10<b[1]}function ye(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function de(a,b){var c=!1;Object.keys(a).forEach(function(f){a[f]===b&&(c=!0)});return c}function Ub(a,b){return Math.pow(n(a.x)-b[0],2)+Math.pow(B(a.value)-b[1],2)}function hd(a,b,c){ze(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+
c}).attr("cx",h?Fa:Ea).attr("cy",h?Ea:Fa).attr("stroke",function(){return I(b.id)}).attr("r",1.4*Xa).transition().duration(100).attr("r",Xa)}function Wb(a,b,c){Ae(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",0).remove()}function id(a,b,c,f){a?hd(b,c,f):Wb(b,c,f)}function Be(){}function jd(){}function kd(a,b,c,f){}function Xb(a){return a.filter(function(a){return A(a.value)})}function Yb(a,b){return(b?l.selectAll(".-circles-"+b):l).selectAll(".-circle"+
(A(a)?"-"+a:""))}function Zb(a){Yb(a).filter(function(){return e.select(this).classed(ea)}).classed(ea,!1).attr("r",$b)}function ld(a,b){var c=md(a,b);return function(a,b){var d=c(a,b),e=h?1:0,g=h?0:1;return"M "+d[0][e]+","+d[0][g]+" L"+d[1][e]+","+d[1][g]+" L"+d[2][e]+","+d[2][g]+" L"+d[3][e]+","+d[3][g]+" z"}}function nd(a,b){var c=md(a,!1),f=b?Ce:De;return function(a,b){return f(c(a,b),a,this)}}function Ce(a,b){var c;return h?(c=ua(b)?4:6,a[2][1]+c*(0>b.value?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}
function De(a,b,c){return h?(a[0][0]+a[2][0]+0.6*c.offsetHeight)/2:a[2][1]+(0>b.value?c.offsetHeight:ua(b)?-3:-6)}function md(a,b){var c=a.__max__+1,f=c?1.2*T.tickOffset()/c:0,d=te(f,c,a,!!b),e=ue(!!b),h=ve(a,!!b),g=b?L:u;return function(a,b){var c=g(a.id)(0),l=h(a,b)||c;return[[d(a),l],[d(a),e(a)-(c-l)],[d(a)+f,e(a)-(c-l)],[d(a)+f,l]]}}function Ee(a,b,c,f){var d,e,g="M",l,m,n,p,r,q=[];if(z(f))for(d=0;d<f.length;d++)q[d]={},w(f[d].start)?q[d].start=a[0].x:q[d].start=D?sa(f[d].start):f[d].start,w(f[d].end)?
q[d].end=a[a.length-1].x:q[d].end=D?sa(f[d].end):f[d].end;p=h?function(a){return c(a.value)}:function(a){return b(a.x)};r=h?function(a){return b(a.x)}:function(a){return c(a.value)};f=D?function(a,d,f,k){var e=a.x.getTime();a=d.x-a.x;d=new Date(e+a*(f+k));return"M"+b(new Date(e+a*f))+" "+c(m(f))+" "+b(d)+" "+c(m(f+k))}:function(a,d,f,k){return"M"+b(l(f))+" "+c(m(f))+" "+b(l(f+k))+" "+c(m(f+k))};for(d=0;d<a.length;d++)if(w(q)||!ye(a[d].x,q))g+=" "+p(a[d])+" "+r(a[d]);else{l=ha(a[d-1].x,a[d].x);m=S(a[d-
1].value,a[d].value);e=b(a[d].x)-b(a[d-1].x);n=c(a[d].value)-c(a[d-1].value);e=Math.sqrt(Math.pow(e,2)+Math.pow(n,2));n=2/e;var Fe=2*n;for(e=n;1>=e;e+=Fe)g+=f(a[d-1],a[d],e,n)}return g}function ac(a){var b;qb=e.select(xa);if(qb.empty())K.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{qb.html("");g.data.x={};g.data.targets=Sa(a);qa();Q();n.domain(e.extent(mb(g.data.targets)));B.domain(kb("y"));ba.domain(kb("y2"));
U.domain(n.domain());gb.domain(B.domain());hb.domain(ba.domain());aa=n.domain();G.scale(U);fa&&C.scale(n);p=e.select(xa).append("svg").attr("width",r+t+H).attr("height",q+m+pa).on("mouseenter",Ge).on("mouseleave",He);rb=p.append("defs");rb.append("clipPath").attr("id",bc).append("rect").attr("y",m).attr("width",r).attr("height",q-m);rb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-t).attr("y",-20).attr("width",ia).attr("height",X);rb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",
-t+1).attr("y",m-1).attr("width",Ka).attr("height",xb);l=p.append("g").attr("transform",J.main);F=Ga?p.append("g").attr("transform",J.context):null;Ha=Ia?p.append("g").attr("transform",J.legend):null;V=e.select(xa).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",h?"":"url("+document.URL+"#xaxis-clip)").attr("transform",J.x).append("text").attr("class","-axis-x-label").attr("x",
r).attr("dy","-.5em").style("text-anchor","end").text(Ie);l.append("g").attr("class","y axis").attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Je);Ab&&l.append("g").attr("class","y2 axis").attr("transform",J.y2);a=l.append("g").attr("clip-path",Ya).attr("class","grid");od&&a.append("g").attr("class","xgrids");cc&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(cc).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:-m).attr("dy",-5).text(function(a){return a.text}));Ke&&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:m).attr("y2",h?-10:q);pd&&a.append("g").attr("class","ygrids");dc&&(a=a.append("g").attr("class",
"ygrid-lines").selectAll("ygrid-line").data(dc).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",h?"rotate(-90)":"").attr("dx",h?0:-m).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Ya).attr("class","regions");l.append("g").attr("clip-path",Ya).attr("class","chart");l.select(".chart").append("g").attr("class",
"event-rects").style("fill-opacity",0).style("cursor",fa?h?"ns-resize":"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",J.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(Le);l.select(".chart").append("g").attr("class","chart-texts");if(fa)l.insert("rect",Me?null:"g.grid").attr("class","zoom-rect").attr("width",
r).attr("height",q).style("opacity",0).style("cursor",h?"ns-resize":"ew-resize").call(C).on("dblclick.zoom",null);null!==sb&&G.extent("function"!==typeof sb?sb:sb(mb()));Ga&&(F.append("g").attr("clip-path",Ya).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",Ya).attr("class","x brush").call(G).selectAll("rect").attr(h?"width":"height",h?Bb:fb),F.append("g").attr("class","x axis").attr("transform",
J.subx).attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":""));Ia&&tb(g.data.targets);qd(g.data.targets);x({withTransform:!0,withUpdateXDomain:!0});if(Ne){if(D&&"string"===typeof Ja){Ja=sa(Ja);for(a=0;a<g.data.targets[0].values.length&&0!==g.data.targets[0].values[a].x-Ja;a++);Ja=a}V.html($c(g.data.targets.map(function(a){return ob(a.values[Ja])})));V.style("top",rd.top).style("left",rd.left).style("display","block")}null==K.onresize&&(K.onresize=Oe());K.onresize.add&&K.onresize.add(sd)}}function Pe(a){a.append("rect").attr("class",
Pc).style("cursor",la&&va?"pointer":null).on("mouseover",function(a,c){if(!Za&&!E(g.data.targets)){var f=g.data.targets.map(function(a){return ob(a.values[c])}),d,e;if(0<Object.keys(Ra).length){e=[];for(var h in Ra)for(d=0;d<f.length;d++)if(f[d].id===h){e.push(f[d]);f.shift(d);break}f=e.concat(f)}ec&&Yb(c,void 0).classed(ea,!0).attr("r",fc);l.selectAll(".-bar"+(A(c)?"-"+c:"")).classed(ea,!1);ad(f)}}).on("mouseout",function(a,c){E(g.data.targets)||(bd(),V.style("display","none"),Zb(c),l.selectAll(".-bar"+
(A(void 0)?"-undefined":"")).classed(ea,!1))}).on("mousemove",function(a,c){var d;Za||E(g.data.targets)||(d=g.data.targets.map(function(a){return ob(a.values[c])}),Yc(d,e.mouse(this)),la&&(va||l.selectAll(".-shape-"+c).filter(function(a){return ma(a)}).each(function(){var a=e.select(this).classed(ea,!0);"circle"===this.nodeName&&a.attr("r",fc);p.select(".event-rect-"+c).style("cursor",null)}).filter(function(){var a=e.select(this);if("circle"===this.nodeName)return fd(this,Xa);if("rect"===this.nodeName)return gd(this,
a.attr("x"),a.attr("y"))}).each(function(){var a=e.select(this);a.classed(ea)||(a.classed(ea,!0),"circle"===this.nodeName&&a.attr("r",Xa));p.select(".event-rect-"+c).style("cursor","pointer")})))}).on("click",function(a,c){E(g.data.targets)||(gc?gc=!1:l.selectAll(".-shape-"+c).each(function(a){td(this,a,c)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){ud(e.mouse(this))}).on("dragstart",function(){vd(e.mouse(this))}).on("dragend",function(){wd()})).call(C).on("dblclick.zoom",null)}
function Qe(a){a.append("rect").attr("x",0).attr("y",0).attr("width",r).attr("height",q).attr("class","event-rect").on("mouseout",function(){E(g.data.targets)||(bd(),V.style("display","none"),Zb())}).on("mousemove",function(){var a,c,d;Za||E(g.data.targets)||(a=e.mouse(this),c=Xc(g.data.targets,a),d=[ob(c)],Yc(d,a),ec&&(Zb(),Yb(c.index,c.id).classed(ea,!0).attr("r",fc)),ad(d),100>Ub(c,a)?p.select(".event-rect").style("cursor","pointer"):p.select(".event-rect").style("cursor",null))}).on("click",function(){var a,
c;E(g.data.targets)||(a=e.mouse(this),c=Xc(g.data.targets,a),100>Ub(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){td(this,c,c.index)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){ud(e.mouse(this))}).on("dragstart",function(){vd(e.mouse(this))}).on("dragend",function(){wd()})).call(C).on("dblclick.zoom",null)}function td(a,b,c){var d=e.select(a),k=d.classed(na),g=!1,h;"circle"===a.nodeName?(g=fd(a,1.5*Xa),h=id):"rect"===a.nodeName&&(g=gd(a),h=kd);if(va||
g)la&&ma(b)&&(d.classed(na,!k),h(!k,d,b,c)),Re(b,d)}function ud(a){var b,c,d,k,h,n,p;E(g.data.targets)||!la||fa&&!C.altDomain||(b=hc[0],c=hc[1],d=a[0],a=a[1],k=Math.min(b,d),h=Math.max(b,d),n=va?m:Math.min(c,a),p=va?q:Math.max(c,a),l.select(".dragarea").attr("x",k).attr("y",n).attr("width",h-k).attr("height",p-n),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ma(a)}).each(function(a,b){var c=e.select(this),d=c.classed(na),f=c.classed(ic),g,l,m,q;g=!1;"circle"===this.nodeName?
(g=1*c.attr("cx"),l=1*c.attr("cy"),q=id,g=k<g&&g<h&&n<l&&l<p):"rect"===this.nodeName&&(g=1*c.attr("x"),l=1*c.attr("y"),m=1*c.attr("width"),q=kd,g=k<g+m&&g<h&&l<p);g^f&&(c.classed(ic,!f),c.classed(na,!d),q(!d,c,a,b))}))}function vd(a){!E(g.data.targets)&&la&&(hc=a,l.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),Za=!0)}function wd(){!E(g.data.targets)&&la&&(l.select(".dragarea").transition().duration(100).style("opacity",0).remove(),l.selectAll(".-shape").classed(ic,
!1),Za=!1)}function x(a){var b,c,d,k;d=se();var p,s,u,t,v=E(g.data.targets),x;a=z(a)?a:{};c=z(a.withY)?a.withY:!0;k=z(a.withSubchart)?a.withSubchart:!0;s=z(a.withTransition)?a.withTransition:!0;u=z(a.withTransform)?a.withTransform:!1;t=z(a.withUpdateXDomain)?a.withUpdateXDomain:!1;a=z(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1;s=s?Se:0;a&&(n.domain(e.extent(mb(g.data.targets))),aa=n.domain(),fa&&C.scale(n).updateScaleExtent(),U.domain(n.domain()),G.scale(U));t&&(n.domain(G.empty()?aa:G.extent()),
fa&&C.scale(n).updateScaleExtent());B.domain(kb("y"));ba.domain(kb("y2"));l.select(".x.axis").style("opacity",v?0:1).transition().duration(h?s:0).call(h?Mb:T);l.select(".y.axis").style("opacity",v?0:1).transition().duration(h?0:s).call(h?T:Mb);l.select(".y2.axis").style("opacity",v?0:1).transition().call(vc);x=ld(d);t=nd(d,!0);a=nd(d,!1);l.select(".x.axis .-axis-x-label").attr("x",r);gb.domain(B.domain());hb.domain(ba.domain());V.style("display","none");l.select("line.xgrid-focus").style("visibility",
"hidden").attr("y2",q);if(od){if("year"===Te){b=[];for(var w=mb(),y=w[0].getFullYear(),w=w[1].getFullYear();y<=w;y++)b.push(new Date(y+"-01-01 00:00:00"))}else b=n.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class","xgrid");b.attr("x1",h?0:function(a){return n(a)-T.tickOffset()}).attr("x2",h?r:function(a){return n(a)-T.tickOffset()}).attr("y1",h?function(a){return n(a)-T.tickOffset()}:m).attr("y2",h?function(a){return n(a)-T.tickOffset()}:q).style("opacity",
function(){return+e.select(this).attr(h?"y1":"x1")===(h?q:0)?0:1});b.exit().remove()}cc&&(b=l.selectAll(".xgrid-lines"),b.selectAll("line").transition().duration(s).attr("x1",h?0:Va).attr("x2",h?r:Va).attr("y1",h?Va:m).attr("y2",h?Va:q),b.selectAll("text").attr("x",h?r:0).attr("y",Va));c&&pd&&(b=l.select(".ygrids").selectAll(".ygrid").data(B.ticks(10)),b.enter().append("line").attr("class","ygrid"),b.attr("x1",h?B:0).attr("x2",h?B:r).attr("y1",h?0:B).attr("y2",h?q:B),b.exit().remove());c&&dc&&(c=
l.select(".ygrid-lines"),c.selectAll("line").transition().duration(s).attr("x1",h?Wa:0).attr("x2",h?Wa:r).attr("y1",h?0:Wa).attr("y2",h?q:Wa),c.selectAll("text").attr("x",h?0:r).attr("y",Wa));c=l.selectAll(".-bars").selectAll(".-bar").data(ed);c.enter().append("path").attr("d",x).style("stroke","none").style("opacity",0).style("fill",function(a){return I(a.id)}).attr("class",Oc);c.style("opacity",Aa).transition().duration(s).attr("d",x).style("opacity",1);c.exit().transition().duration(s).style("opacity",
0).remove();c=l.selectAll(".-texts").selectAll(".-text").data(xe);c.enter().append("text").attr("class",ie).attr("text-anchor",function(a){return h?0>a.value?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return Tc(a.value)});c.style("fill-opacity",pe).transition().duration(s).attr("x",t).attr("y",a).style("fill-opacity",Qc);c.exit().transition().duration(s).style("fill-opacity",0).remove();l.selectAll(".-line").style("opacity",Aa).transition().duration(s).attr("d",
Ue).style("opacity",1);l.selectAll(".-area").style("opacity",0).transition().duration(s).attr("d",Ve).style("opacity",xd);c=l.selectAll(".-circles").selectAll(".-circle").data(we);c.enter().append("circle").attr("class",ne).style("opacity",0).attr("r",$b);c.style("opacity",Aa).transition().duration(s).style("opacity",qe).attr("cx",h?Fa:Ea).attr("cy",h?Ea:Fa);c.exit().remove();l.selectAll(".chart-arc").select(".-arc").attr("transform",u?"scale(0)":"").style("opacity",function(a){return a===this._current?
0:1}).transition().duration(s).attrTween("d",function(a){a=Z(a);if(!a)return function(){return"M 0 0"};var b=e.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return dd(a.data)||Pb(a.data)?ib(a,!0):"M 0 0"}}).attr("transform",u?"scale(1)":"").style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform",wb).style("opacity",0).transition().duration(s).text(Ed).style("opacity",function(a){return dd(a.data)||Pb(a.data)?1:0});l.select(".chart-arcs-title").style("opacity",
$(g.data.targets,"donut")?1:0);Ga&&(null!==e.event&&"zoom"===e.event.type&&G.extent(n.orgDomain()).update(),k&&(F.select(".x.axis").style("opacity",v?0:1).transition().duration(h?s:0).call(Lb),G.empty()||G.extent(n.orgDomain()).update(),k=ld(d,!0),d=F.selectAll(".-bars").selectAll(".-bar").data(ed),d.enter().append("path").attr("d",k).style("stroke","none").style("fill",function(a){return I(a.id)}).attr("class",Oc),d.style("opacity",Aa).transition().duration(s).attr("d",k).style("opacity",1),d.exit().transition().duration(s).style("opacity",
0).remove(),F.selectAll(".-line").style("opacity",Aa).transition().duration(s).attr("d",We).style("opacity",1)));l.selectAll(".selected-circles").filter(function(a){return ua(a)}).selectAll("circle").remove();l.selectAll(".selected-circle").transition().duration(s).attr("cx",h?Fa:Ea).attr("cy",h?Ea:Fa);ca?(k=l.select(".event-rects").selectAll(".event-rect").data([0]),Qe(k.enter()),k.attr("x",0).attr("y",0).attr("width",r).attr("height",q)):(Sb?(p=function(a,b){var c=Jc(b),d=b<za()-1?g.data.targets[0].values[b+
1].x:void 0;return(n(d?d:a.x+50)-n(c?c:a.x-50))/2},d=function(a,b){var c=Jc(b);return(n(a.x)+n(c?c:a.x-50))/2}):(p=Bd(),d=function(a){return n(a.x)-p/2}),k=he(),l.select(".event-rects").datum(k?k.values:[]),k=l.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),Pe(k.enter()),k.attr("class",Pc).attr("x",h?0:d).attr("y",h?d:0).attr("width",h?r:p).attr("height",h?p:q),k.exit().remove());d=l.select(".regions").selectAll("rect.region").data(N);d.enter().append("rect").style("fill-opacity",
0);d.attr("class",oe).attr("x",h?0:Rb).attr("y",h?Rb:m).attr("width",h?r:Ec).attr("height",h?Ec:q).transition().duration(s).style("fill-opacity",function(a){return A(a.opacity)?a.opacity:0.1});d.exit().transition().duration(s).style("fill-opacity",0).remove();Ta().forEach(function(a){Tb[a]=!0})}function Xe(){"mousemove"===e.event.sourceEvent.type&&C.altDomain?(n.domain(C.altDomain),C.scale(n).updateScaleExtent()):(ja&&n.orgDomain()[0]===aa[0]&&n.domain([aa[0]-1E-10,n.orgDomain()[1]]),x({withTransition:!1,
withY:!1,withSubchart:!1}),"mousemove"===e.event.sourceEvent.type&&(gc=!0))}function Oe(){function a(){b.forEach(function(a){a()})}var b=[];a.add=function(a){b.push(a)};return a}function sd(){qa();Q();G.scale(U);fa&&C.scale(n);p.attr("width",yb).attr("height",wa);p.select("#"+bc).select("rect").attr("width",r).attr("height",q);p.select("#xaxis-clip").select("rect").attr("width",ia);p.select(".zoom-rect").attr("width",r).attr("height",q);l.select(".x.axis").attr("transform",J.x);l.select(".y2.axis").attr("transform",
J.y2);l.select(".chart-arcs").attr("transform",J.arc);Ga&&(F.attr("transform",J.context),F.select(".x.axis").attr("transform",J.subx));Ia&&(Ha.attr("transform",J.legend),tb(g.data.targets,{withTransition:!1}));x({withTransition:!1,withUpdateXDomain:!0})}function qd(a){var b;l.select(".chart-texts").selectAll(".chart-text").data(a).enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none").append("g").attr("class",je).style("fill",function(a){return I(a.id)});
l.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").append("g").attr("class",Nc).style("fill",function(a){return I(a.id)}).style("stroke","none").style("cursor",function(a){return ma(a)?"pointer":null});b=l.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");b.append("path").attr("class",
Mc).style("opacity",0).style("stroke",function(a){return I(a.id)});b.append("path").attr("class",me).style("opacity",function(){xd=+e.select(this).style("opacity");return 0}).style("fill",function(a){return I(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",ke).style("fill",function(a){return I(a.id)}).style("cursor",function(a){return ma(a)?"pointer":null});a.forEach(function(a){var b=ub(a.id);l.selectAll(".selected-circles"+
b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});b=l.select(".chart-arcs").selectAll(".chart-arc").data(Ob(a)).enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id});b.append("path").attr("class",le).style("opacity",0).style("fill",function(a){return I(a.data.id)}).style("cursor",function(a){return ma(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){Ac(a.data.id);jc(a.data.id)}).on("mouseout",function(a){Qb(a.data.id);
kc()});b.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none");Ga&&(b=F.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),b.append("g").attr("class",Nc).style("fill",function(a){return I(a.id)}),b=F.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),b.append("path").attr("class",
Mc).style("opacity",0).style("stroke",function(a){return I(a.id)}));Ia&&tb(a);p.selectAll(".target").transition().style("opacity",1)}function $a(a,b){g.data.targets.forEach(function(b){for(var d=0;d<a.length;d++)if(b.id===a[d].id){b.values=a[d].values;a.splice(d,1);break}});g.data.targets=g.data.targets.concat(a);qd(g.data.targets);x({withUpdateOrgXDomain:!0,withUpdateXDomain:!0});b()}function jc(a){var b=p.selectAll(".legend-item"),c=function(b){return!a||b===a};b.filter(function(a){return!c(a)}).transition().duration(100).style("opacity",
0.3);b.filter(c).transition().duration(100).style("opacity",1)}function Ye(a){var b=p.selectAll(".legend-item"),c=function(b){return!a||b===a};b.filter(function(a){return!c(a)}).transition().duration(100).style("opacity",1);b.filter(c).transition().duration(100).style("opacity",0.3)}function kc(){p.selectAll(".legend-item").transition().duration(100).style("opacity",1)}function tb(a,b){var c=Ta(a),d,e=r/2-ab*Object.keys(a).length/2,h;b=w(b)?{}:b;h=z(b.withTransition)?b.withTransition:!0;d=Ha.selectAll(".legend-item").data(c).enter().append("g").attr("class",
function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){Ze(a)}).on("mouseover",function(a){jc(a);g.focus(a)}).on("mouseout",function(){kc();g.revert()});d.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return ra/2-16}).attr("width",ab).attr("height",24);d.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return I(a)}).attr("x",-200).attr("y",
function(){return ra/2-9}).attr("width",10).attr("height",10);d.append("text").text(function(a){return z(Ra[a])?Ra[a]:a}).style("pointer-events","none").attr("x",-200).attr("y",function(){return ra/2});Ha.selectAll("rect.legend-item-event").data(c).transition().duration(h?250:0).attr("x",function(a,b){return e+ab*b});Ha.selectAll("rect.legend-item-tile").data(c).transition().duration(h?250:0).attr("x",function(a,b){return e+ab*b});Ha.selectAll("text").data(c).transition().duration(h?250:0).attr("x",
function(a,b){return e+ab*b+14})}function ub(a){return a?"-"+a.replace(/\./g,"\\."):""}function ka(a){return".target"+ub(a)}function lc(a){return Kc(a.id)}function mc(a){return"data"in a&&Kc(a.data.id)}var g={data:{}},nb={},ea="_expanded_",na="_selected_",ic="_included_",xa=d(["bindto"],"#chart"),Ma=d(["size","width"],null),Eb=d(["size","height"],null),bb=d(["padding","left"],null),db=d(["padding","right"],null),fa=d(["zoom","enabled"],!1),yd=d(["zoom","extent"],null),Me=d(["zoom","privileged"],!1),
Ge=d(["onenter"],function(){}),He=d(["onleave"],function(){}),Se=d(["transition","duration"],350);if(!("data"in O))throw Error("data is required in config");var ta=d(["data","x"],null),ca=d(["data","xs"],null),Vb=d(["data","x_format"],"%Y-%m-%d"),ge=d(["data","id_converter"],function(a){return a}),Ra=d(["data","names"],{}),v=d(["data","groups"],[]),yc=d(["data","axes"],{}),Ic=d(["data","type"],null),y=d(["data","types"],{}),Ba=d(["data","labels"],{}),Da=d(["data","order"],null),zd=d(["data","regions"],
{}),$e=d(["data","colors"],{}),la=d(["data","selection","enabled"],!1),va=d(["data","selection","grouped"],!1),ma=d(["data","selection","isselectable"],function(){return!0}),Ga=d(["subchart","show"],!1),zb=Ga?d(["subchart","size","height"],60):0,af=d(["color","pattern"],null),Ia=d(["legend","show"],!0),ab=d(["legend","item","width"],80),Ze=d(["legend","item","onclick"],function(){}),h=d(["axis","rotated"],!1),nc=d(["axis","x","type"],"indexed"),Oa=d(["axis","x","categories"],[]),Md=d(["axis","x",
"tick","centered"],!1),jb=d(["axis","x","tick","format"],null),Pd=d(["axis","x","tick","culling"],h||"categorized"===nc?!1:!0),zc=d(["axis","x","tick","count"],10),sb=d(["axis","x","default"],null),Ie=d(["axis","x","label"],null),Xd=d(["axis","y","max"],null),Vd=d(["axis","y","min"],null),Zd=d(["axis","y","center"],null),Je=d(["axis","y","label"],null),cb=d(["axis","y","inner"],!1),Nb=d(["axis","y","tick","format"],null),Pa=d(["axis","y","padding"],null),Id=d(["axis","y","ticks"],10),Ab=d(["axis",
"y2","show"],!1),Wd=d(["axis","y2","max"],null),Ud=d(["axis","y2","min"],null),Yd=d(["axis","y2","center"],null),eb=d(["axis","y2","inner"],!1),Kd=d(["axis","y2","tick","format"],null),Qa=d(["axis","y2","padding"],null),Ld=d(["axis","y2","ticks"],10),od=d(["grid","x","show"],!1),Te=d(["grid","x","type"],"tick"),cc=d(["grid","x","lines"],null),pd=d(["grid","y","show"],!1),dc=d(["grid","y","lines"],null),$b=d(["point","show"],!0)?d(["point","r"],2.5):0,Ke=d(["point","focus","line","enabled"],!0),ec=
d(["point","focus","expand","enabled"],!0),fc=d(["point","focus","expand","r"],ec?4:$b),Xa=d(["point","focus","select","r"],8),Re=d(["point","onclick"],function(){}),ze=d(["point","onselected"],function(){}),Ae=d(["point","onunselected"],function(){}),Qd=d(["arc","label","format"],function(a,b){return(100*b).toFixed(1)+"%"}),Le=d(["arc","title"],""),N=d(["regions"],[]),Zc=d(["tooltip","enabled"],!0),$c=d(["tooltip","contents"],function(a){var b=rc(),c,d,e,g;for(d=0;d<a.length;d++)a[d]&&A(a[d].value)&&
(c||(c=b?b(a[d].x):a[d].x,c="<table class='-tooltip'><tr><th colspan='2'>"+c+"</th></tr>"),g=a[d].name,e=Tc(a[d].value),c+="<tr class='-tooltip-name-"+a[d].id+"'><td class='name'><span style='background-color:"+I(a[d].id)+"'></span>"+g+"</td><td class='value'>"+e+"</td></tr>");return c+"</table>"}),Ne=d(["tooltip","init","show"],!1),Ja=d(["tooltip","init","x"],0),rd=d(["tooltip","init","position"],{top:"0px",left:"50px"}),bc=xa.replace("#","")+"-clip",Ya="url("+document.URL+"#"+bc+")",D="timeseries"===
nc,ja="categorized"===nc,Sb=!D&&(ta||ca),hc=null,Za=!1,gc=!1,ra=Ia?40:0,I=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]}}($e,af),Nd=function(){var a=[[e.time.format("%Y/%-m/%-d"),function(){return!0}],[e.time.format("%-m/%-d"),function(a){return a.getMonth()}],[e.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],
[e.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[e.time.format("%I %p"),function(a){return a.getHours()}],[e.time.format("%I:%M"),function(a){return a.getMinutes()}],[e.time.format(":%S"),function(a){return a.getSeconds()}],[e.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)}}(),r,Bb,q,fb,yb,wa,Na,Cb,Db,ib,wc,xc,Ob,Fb,Gb,Hb,Ib,Jb,Kb,n,B,ba,U,gb,hb,T,Mb,vc,Lb,Fd=h?"left":"bottom",
Hd=h?cb?"top":"bottom":cb?"right":"left",Jd=h?eb?"bottom":"top":eb?"left":"right",Gd=h?"left":"bottom",J={main:function(){return"translate("+t+","+m+")"},context:function(){return"translate("+qc+","+vb+")"},legend:function(){return"translate("+pc+","+oc+")"},y2:function(){return"translate("+(h?0:r)+","+(h?10:0)+")"},x:function(){return"translate(0,"+q+")"},subx:function(){return"translate(0,"+(h?0:fb)+")"},arc:function(){return"translate("+r/2+","+q/2+")"}},uc=40,tc=20;Ob=e.layout.pie().value(function(a){return a.values.reduce(function(a,
c){return a+c.value},0)});var Ue=function(){var a=e.svg.line().x(h?function(a){return u(a.id)(a.value)}:Ca).y(h?Ca:function(a){return u(a.id)(a.value)});return function(b){var c=Xb(b.values),d;if(pb(b))return cd(b)?a.interpolate("cardinal"):a.interpolate("linear"),zd[b.id]?Ee(c,n,u(b.id),zd[b.id]):a(c);d=n(c[0].x);b=u(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),Ve=function(){var a;a=h?e.svg.area().x0(function(a){return u(a.id)(0)}).x1(function(a){return u(a.id)(a.value)}).y(Ca):e.svg.area().x(Ca).y0(function(a){return u(a.id)(0)}).y1(function(a){return u(a.id)(a.value)});
return function(b){var c=Xb(b.values),d;if($([b],"area")||$([b],"area-spline"))return cd(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=n(c[0].x);b=u(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),We=function(){var a=e.svg.line().x(h?function(a){return L(a.id)(a.value)}:Sc).y(h?Sc:function(a){return L(a.id)(a.value)});return function(b){var c=Xb(b.values);return pb(b)?a(c):"M "+U(c[0].x)+" "+L(b.id)(c[0].value)}}(),G,C=function(){};G=e.svg.brush().on("brush",function(){x({withTransition:!1,
withY:!1,withSubchart:!1,withUpdateXDomain:!0})});G.update=function(){F&&F.select(".x.brush").call(this);return this};G.scale=function(a){return h?this.y(a):this.x(a)};fa&&(C=e.behavior.zoom().on("zoomstart",function(){C.altDomain=e.event.sourceEvent.altKey?n.orgDomain():null}).on("zoom",fa?Xe:null),C.scale=function(a){return h?this.y(a):this.x(a)},C.orgScaleExtent=function(){var a=yd?yd:[1,10];return[a[0],Math.max(za()/a[1],a[1])]},C.updateScaleExtent=function(){var a=ya(n.orgDomain())/ya(aa),b=
this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this});var p,rb,l,F,Ha,V,qb,aa,xd,Tb={};g.focus=function(a){var b=p.selectAll(ka(a)),c=b.filter(lc),b=b.filter(mc);g.revert();g.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);E(g.data.targets)&&Ac(a,!0);jc(a)};g.defocus=function(a){var b=p.selectAll(ka(a)),c=b.filter(lc),b=b.filter(mc);g.revert();c.classed("focused",!1).transition().duration(100).style("opacity",
0.3);b.transition().duration(100).style("opacity",0.3);E(g.data.targets)&&Qb(a);Ye(a)};g.revert=function(a){var b=p.selectAll(ka(a)),c=b.filter(lc),b=b.filter(mc);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);E(g.data.targets)&&Qb(a);kc()};g.show=function(a){p.selectAll(ka(a)).transition().style("opacity",1)};g.hide=function(a){p.selectAll(ka(a)).transition().style("opacity",0)};g.unzoom=function(){G.clear().update();x({withUpdateXDomain:!0})};
g.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&fe(a.xs);"categories"in a&&ja&&(Oa=a.categories,T.categories(Oa));if("cacheIds"in a&&be(a.cacheIds))$a(ce(a.cacheIds),a.done);else if("data"in a)$a(Sa(a.data),a.done);else if("url"in a)e.csv(a.url,function(b,c){$a(Sa(c),a.done)});else if("rows"in a)$a(Sa(Gc(a.rows)),a.done);else if("columns"in a)$a(Sa(Hc(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(ka(a)).transition().style("opacity",0).remove();Ia&&(p.selectAll(".legend-item"+ub(a)).remove(),tb(g.data.targets));0<g.data.targets.length&&x({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})};g.selected=function(a){a=ub(a);return e.merge(l.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return e.select(this).classed(na)}).map(function(a){return a.map(function(a){return a.__data__})}))};g.select=function(a,b,c){la&&l.selectAll(".-shapes").selectAll(".-shape").each(function(d,
g){var h="circle"===this.nodeName?hd:Be,l="circle"===this.nodeName?Wb:jd;0<=b.indexOf(g)?ma(d)&&(va||w(a)||0<=a.indexOf(d.id))&&h(e.select(this).classed(na,!0),d,g):z(c)&&c&&l(e.select(this).classed(na,!1),d,g)})};g.unselect=function(a,b){la&&l.selectAll(".-shapes").selectAll(".-shape").each(function(c,d){var g="circle"===this.nodeName?Wb:jd;(w(b)||0<=b.indexOf(d))&&ma(c)&&(va||w(a)||0<=a.indexOf(c.id))&&g(e.select(this).classed(na,!1),c,d)})};g.toLine=function(a){da(a,"line");x()};g.toSpline=function(a){da(a,
"spline");x()};g.toBar=function(a){da(a,"bar");x()};g.toScatter=function(a){da(a,"scatter");x()};g.toArea=function(a){da(a,"area");x()};g.toAreaSpline=function(a){da(a,"area-spline");x()};g.toPie=function(a){da(a,"pie");oa();R();x({withTransform:!0})};g.toDonut=function(a){da(a,"donut");oa();R();x({withTransform:!0})};g.groups=function(a){if(w(a))return v;v=a;x();return v};g.regions=function(a){if(w(a))return N;N=a;x();return N};g.regions.add=function(a){if(w(a))return N;N=N.concat(a);x();return N};
g.regions.remove=function(a,b){var c=[].concat(a);b=z(b)?b:{};c.forEach(function(a){var c=A(b.duration)?b.duration:0;p.selectAll("."+a).transition().duration(c).style("fill-opacity",0).remove();N=N.filter(function(b){return 0>b.classes.indexOf(a)})});return N};g.data.get=function(a){a=g.data.getAsTarget(a);return z(a)?a.values.map(function(a){return a.value}):void 0};g.data.getAsTarget=function(a){var b=lb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};g.resize=function(a){Ma=a?a.width:
null;Eb=a?a.height:null;sd()};g.destroy=function(){g.data.targets=void 0;g.data.x={};qb.html("");K.onresize=null};if("url"in O.data)e.csv(O.data.url,function(a,b){ac(b)});else if("rows"in O.data)ac(Gc(O.data.rows));else if("columns"in O.data)ac(Hc(O.data.columns));else throw Error("url or rows or columns is required.");return g}})(window);
(function(N){function Fd(){function y(d,e){d.attr("transform",function(d){return"translate("+(e(d)+ga)+", 0)"})}function w(d,e){d.attr("transform",function(d){return"translate(0,"+e(d)+")"})}function F(d){var e=d[0];d=d[d.length-1];return e<d?[e,d]:[d,e]}function N(d){for(var e=[],n=Math.ceil(d[0]);n<d[1];n++)e.push(n);0<e.length&&0<e[0]&&e.unshift(e[0]-(e[1]-e[0]));return e}function La(d,e){var n=d.length-1;return n<=L||0===e%Math.ceil(n/L)}function Ma(d){d=d<X.length?X[d]:d;return Y?Y(d):d}function n(n){n.each(function(){var n=
e.select(this),Ka=N(M.domain()),P=n.selectAll(".tick.major").data(Ka,String),Q=P.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),R=e.transition(P.exit()).style("opacity",1E-6).remove(),t=e.transition(P).style("opacity",1),H,L=M.rangeExtent?M.rangeExtent():F(M.range()),n=n.selectAll(".domain").data([0]);n.enter().append("path").attr("class","domain");var n=e.transition(n),A=M.copy(),Y=this.__chart__||A;this.__chart__=A;Q.append("line");Q.append("text");var X=Q.select("line"),
na=t.select("line"),xa=P.select("text"),ha=Q.select("text"),eb=t.select("text");ga=(A(1)-A(0))/2;P=Na?0:ga;switch(oa){case "bottom":H=y;X.attr("y2",v);ha.attr("y",Math.max(v,0)+pa);na.attr("x1",P).attr("x2",P).attr("y2",v);eb.attr("x",0).attr("y",Math.max(v,0)+pa);xa.attr("dy",".71em").style("text-anchor","middle");xa.text(function(d){return La(Ka,d)?Ma(d):""});n.attr("d","M"+L[0]+","+d+"V0H"+L[1]+"V"+d);break;case "left":H=w,X.attr("x2",-v),ha.attr("x",-(Math.max(v,0)+pa)),na.attr("x2",-v).attr("y2",
0),eb.attr("x",-(Math.max(v,0)+pa)).attr("y",ga),xa.attr("dy",".32em").style("text-anchor","end"),xa.text(function(d){return La(Ka,d)?Ma(d):""}),n.attr("d","M"+-d+","+L[0]+"H0V"+L[1]+"H"+-d)}if(M.ticks)Q.call(H,Y),t.call(H,A),R.call(H,A);else{var Cb=A.rangeBand()/2,R=function(d){return A(d)+Cb};Q.call(H,R);t.call(H,R)}})}var M=e.scale.linear(),oa="bottom",v=6,d=6,pa=3,Na=!1,L=10,ga=0,Y=null,ha=!0,X=[];n.scale=function(d){if(!arguments.length)return M;M=d;return n};n.orient=function(d){if(!arguments.length)return oa;
oa=d in{top:1,right:1,bottom:1,left:1}?d+"":"bottom";return n};n.categories=function(d){if(!arguments.length)return X;X=d;return n};n.tickCentered=function(d){if(!arguments.length)return Na;Na=d;return n};n.tickFormat=function(d){if(!arguments.length)return Y;Y=d;return n};n.tickOffset=function(){return ga};n.ticks=function(d){if(!arguments.length)return L;L=d;return n};n.tickCulling=function(d){if(!arguments.length)return ha;ha=d;return n};return n}function F(e){return e||0===e}function w(e){return"undefined"===
typeof e}function y(e){return"undefined"!==typeof e}var Db=N.c3={},e=N.d3;Db.generate=function(fa){var tc,zb,Ab,La,Ma,n,M,oa,v;function d(a,b){for(var c=fa,g=0;g<a.length;g++){if(!(a[g]in c))return b;c=c[a[g]]}return c}function pa(){Oa=Pa?Pa:Y();qa=L();ra=sa?x?qa:40:0;Qa=sa?x?150:Oa:0;n=h&&fb?20:0;M=ga();oa=20+(h?0:Eb)+(x?0:ra);v=(h?Eb+xc:0)+(B(f.data.targets)?0:gb?gb:hb?1:40);q=Oa-v-M;r=qa-n-oa;Ab=h?n:qa-Eb-(x?0:ra);La=20+(x?0:ra);Ma=h?yc:v;Fb=h?v-yc-xc:q;ib=h?r:qa-Ab-La;tc=x?n:qa-ra;zb=x?Oa-Qa:
0;jb=r/2;Ra=0.95*jb;Gb=Z(f.data.targets,"donut")?0.6*Ra:0;x&&B(f.data.targets)&&(zb=q/2+jb)}function Na(){var a=p.property("offsetLeft");return a?a:0}function L(){var a=Hb?Hb:+e.select(ya).style("height").replace("px","");return 0<a?a:320}function ga(){return B(f.data.targets)?0:zc?zc:x?Qa*(fb&&!h?1.25:1):fb?Ib||h?1:40:1}function Y(){return+e.select(ya).style("width").replace("px","")}function ha(){return q+2}function X(){return 40}function Ka(){return v+20}function Db(){return r+2}function Gd(){var a=
h?r:q,b=za($)/za(m.domain()),c=Aa();return 1<c?a*b/(c-1):a}function P(){var a,b;Jb=h?1:0;Kb=h?r:q;Lb=h?0:r;Mb=h?q:1;Nb=h?0:ib;Ob=h?Fb:1;m=Q(Jb,Kb,m?m.domain():void 0,function(){return S.tickOffset()});D=R(Lb,Mb,D?D.domain():void 0);aa=R(Lb,Mb,aa?aa.domain():void 0);T=Q(Jb,Kb,$,function(a){return a%1?0:Pb.tickOffset()});kb=R(Nb,Ob);lb=R(Nb,Ob);a=Bb();b=Hd();S=uc(m,Id,a,b);Pb=uc(T,Jd,a,b);Qb=e.svg.axis().scale(D).orient(Kd).tickFormat(Rb).ticks(Ld).outerTickSize(0);Ac=e.svg.axis().scale(aa).orient(Md).tickFormat(Nd).ticks(Od).outerTickSize(0);
mb=xa();Bc=vc();Cc=vc(0.98)}function Q(a,b,c,g){var k=(C?e.time.scale():e.scale.linear()).range([a,b]);k.orgDomain=function(){return k.domain()};y(c)&&k.domain(c);w(g)&&(g=function(){return 0});if(ia){var d=k,f,k=function(a){return d(a)+g(a)};for(f in d)k[f]=d[f];k.orgDomain=function(){return d.domain()};k.domain=function(a){if(!arguments.length)return a=d.domain(),[a[0],a[1]+1];d.domain(a);return k}}return k}function R(a,b){return e.scale.linear().range([a,b])}function t(a){return"y2"===A(a)?aa:
D}function H(a){return"y2"===A(a)?lb:kb}function uc(a,b,c,g){a=(ia?Fd():e.svg.axis()).scale(a).orient(b);a.tickFormat(c).ticks(g);ia?a.tickCentered(Pd):a.tickOffset=function(){return(h?r:q)*(za($)/za(m.domain()))/Aa()/2};ia&&a.categories(Sa);return a}function A(a){return a in Dc?Dc[a]:"y"}function Bb(){var a=C?Qd:ia?Rd:null;nb&&("function"===typeof nb?a=nb:C&&(a=function(a){return e.time.format(nb)(a)}));return a}function Hd(){var a=Aa();return Sd&&a>Ec?Ec:a}function na(a){var b=!1;Sb(f.data.targets).forEach(function(c){b||
c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function xa(){var a=e.svg.arc().outerRadius(Ra).innerRadius(Gb),b=function(b,g){var k;return g?a(b):(k=na(b))?a(k):"M 0 0"};b.centroid=a.centroid;return b}function vc(a){var b=e.svg.arc().outerRadius(jb*(a?a:1)).innerRadius(Gb);return function(a){return(a=na(a))?b(a):"M 0 0"}}function eb(a){a=na(a);var b,c;b="";a&&(b=mb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*Ra+","+0.8*(b/c)*Ra+")");return b}function Cb(a){return Td(a,
(a.endAngle-a.startAngle)/(2*Math.PI))}function wc(a,b){var c=p.selectAll(".chart-arc"+ja(a)),g=p.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",Bc).transition().duration(100).attr("d",Cc).each(function(a){Tb(a.data)});b||g.style("opacity",0.3)}function Ub(a){p.selectAll(".chart-arc"+ja(a)).selectAll("path").transition().duration(50).attr("d",mb);p.selectAll(".-arc").style("opacity",1)}function Ud(a){var b=Fc(a),c,g,k,d;if(0<u.length)for(d=
Gc(a),a=0;a<u.length;a++)for(g=u[a][0],d&&b[g]&&b[g].forEach(function(a,c){b[g][c]=0>a?a:0}),c=1;c<u[a].length;c++)k=u[a][c],b[k]&&b[k].forEach(function(a,c){A(k)!==A(g)||!b[g]||d&&0<+a||(b[g][c]+=+a)});return e.min(Object.keys(b).map(function(a){return e.min(b[a])}))}function Vd(a){var b=Fc(a),c,g,k,d;if(0<u.length)for(d=Wd(a),a=0;a<u.length;a++)for(g=u[a][0],d&&b[g]&&b[g].forEach(function(a,c){b[g][c]=0<a?a:0}),c=1;c<u[a].length;c++)k=u[a][c],b[k]&&b[k].forEach(function(a,c){A(k)!==A(g)||!b[g]||
d&&0>+a||(b[g][c]+=+a)});return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))}function ob(a){var b=pb(function(b){return A(b.id)===a}),c="y2"===a?Xd:Yd,g="y2"===a?Zd:$d,c=c?c:Ud(b),g=g?g:Vd(b),k=0.22*Math.abs(g-c),d=k,e=k,f="y2"===a?ae:be;f&&(c=Math.max(Math.abs(c),Math.abs(g)),g=c-f,c=f-c);"y"===a&&Ta&&(d=F(Ta.top)?Ta.top:k,e=F(Ta.bottom)?Ta.bottom:k);"y2"===a&&Ua&&(d=F(Ua.top)?Ua.top:k,e=F(Ua.bottom)?Ua.bottom:k);Z(b,"bar")&&!Gc(b)&&(e=c);return[c-e,g+d]}function ce(a){return e.min(a,
function(a){return e.min(a.values,function(a){return a.x})})}function de(a){return e.max(a,function(a){return e.max(a.values,function(a){return a.x})})}function qb(a){var b=[ce(a),de(a)],c=b[0],g=b[1],b=Math.abs(b[0]-b[1]);a=ia?0:Z(a,"bar")?b/(Aa()-1)/2:0.01*b;c=C?new Date(c.getTime()-a):c-a;g=C?new Date(g.getTime()+a):g+a;return[c,g]}function za(a){return a[1]-a[0]}function ee(a){for(var b=0;b<a.length;b++)if(!(a[b]in rb))return!1;return!0}function fe(a){for(var b=[],c=0;c<a.length;c++)a[c]in rb&&
b.push(Hc(rb[a[c]]));return b}function Vb(a){return"start"in a?m(C?ta(a.start):a.start):0}function Ic(a){var b=Vb(a);a=("end"in a?m(C?ta(a.end):a.end):q)-b;return 0>a?0:a}function Jc(a){return ua&&a===ua||ba&&ge(ba,a)}function he(a){return!Jc(a)}function ie(a){Object.keys(a).forEach(function(b){ba[b]=a[b]})}function sb(a){var b;a&&(b=Va[a.id],a.name=b?b:a.id);return a}function Kc(a){var b=a[0],c={},g=[],k,d;for(k=1;k<a.length;k++){c={};for(d=0;d<a[k].length;d++)c[b[d]]=a[k][d];g.push(c)}return g}
function Lc(a){var b=[],c,g,k;for(c=0;c<a.length;c++)for(k=a[c][0],g=1;g<a[c].length;g++)w(b[g-1])&&(b[g-1]={}),b[g-1][k]=a[c][g];return b}function Wa(a){var b=e.keys(a[0]).filter(he),c=e.keys(a[0]).filter(Jc);if(C&&0===c.length)return N.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[];Wb&&b.forEach(function(b){var k=ua?ua:ba?ba[b]:null;0<=c.indexOf(k)?f.data.x[b]=a.map(function(a){return a[k]}):f.data.x[b]=f.data.x[Object.keys(f.data.x)[0]]});b=b.map(function(b){var c=
je(b);return{id:c,id_org:b,values:a.map(function(a,d){var e;e=ua?ua:ba?ba[b]:null;e=C?ta(a[e]):Wb?a[e]?+a[e]:b in f.data.x&&f.data.x[b]&&f.data.x[b][d]?f.data.x[b][d]:d:d;a.x=e;return{x:e,value:null===a[b]||isNaN(a[b])?null:+a[b],id:c}})}});b.forEach(function(a){var b;a.values=a.values.sort(function(a,b){return(a.x||0===a.x?a.x:Infinity)-(b.x||0===b.x?b.x:Infinity)});b=0;a.values.forEach(function(a){a.index=b++})});Mc&&ca(Xa(b).filter(function(a){return!(a in z)}),Mc);b.forEach(function(a){rb[a.id_org]=
Hc(a)});return b}function Hc(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function Nc(a){return 0<a&&f.data.targets[0].values[a-1]?f.data.targets[0].values[a-1].x:void 0}function Aa(){return e.max(f.data.targets,function(a){return a.values.length})}function ke(){var a=f.data.targets.length,b=0,c;1<a?f.data.targets.forEach(function(a){a.values.length>b&&(c=a,b=a.values.length)}):c=a?f.data.targets[0]:null;return c}function Xa(a){a=w(a)?f.data.targets:
a;return a.map(function(a){return a.id})}function Oc(a){var b=Xa(),c;for(c=0;c<b.length;c++)if(b[c]===a)return!0;return!1}function pb(a){return y(a)?f.data.targets.filter(a):f.data.targets}function Fc(a){var b={};a.forEach(function(a){b[a.id]=[];a.values.forEach(function(g){b[a.id].push(g.value)})});return b}function Pc(a,b){var c=Object.keys(a),g,k,d;for(g=0;g<c.length;g++)for(d=a[c[g]].values,k=0;k<d.length;k++)if(b(d[k].value))return!0;return!1}function Gc(a){return Pc(a,function(a){return 0>a})}
function Wd(a){return Pc(a,function(a){return 0<a})}function Rd(a){return a<Sa.length?Sa[a]:a}function le(a){return"-text -text-"+a.id}function me(a){return"-texts -texts-"+a.id}function Ya(a){return"-shapes -shapes-"+a.id}function Qc(a){return Ya(a)+" -line -line-"+a.id}function ne(a){return Ya(a)+" -circles -circles-"+a.id}function Rc(a){return Ya(a)+" -bars -bars-"+a.id}function oe(a){return Ya(a.data)+" -arc -arc-"+a.data.id}function pe(a){return Ya(a)+" -area -area-"+a.id}function qe(a,b){return"-shape -shape-"+
b+" -circle -circle-"+b}function Sc(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function re(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function Tc(a,b){return"event-rect event-rect-"+b}function Ba(a){return Xb[a.id]?1:0}function se(a){var b=Uc(a);return Ba(a)*b}function te(a){return F(a.value)?Vc(a)?0.5:1:0}function Uc(a){return"boolean"===typeof Ca&&Ca||"boolean"===Ca[a.id]&&Ca[a.id]||Ca[a.id]&&Ca[a.id].show?1:0}function Da(a){return a?m(a.x):null}function Za(a){return m(C?
ta(a.value):a.value)}function $a(a){return D(a.value)}function Wc(a){return T(a.x)}function Yb(a){return(Rb?Rb:function(a){return+a})(a)}function Xc(a,b){var c,g=a[b].x,k=[];for(c=b-1;0<=c&&g===a[c].x;c--)k.push(a[c]);for(c=b;c<a.length&&g===a[c].x;c++)k.push(a[c]);return k}function Yc(a,b,c,g){c=c?c:0;g=g?g:a.length-1;var k=Math.floor((g-c)/2)+c;0<m(a[k].x)-b[0]?g=k:c=k;return 1===g-c?(k=[],a[c].x&&(k=k.concat(Xc(a,c))),a[g].x&&(k=k.concat(Xc(a,g))),Zc(k,b)):Yc(a,b,c,g)}function $c(a,b){var c;c=
a.map(function(a){return Yc(a.values,b)});return Zc(c,b)}function Zc(a,b){var c,g;a.forEach(function(a){var d=Zb(a,b);if(d<c||!c)c=d,g=a});return g}function ue(a){var b=Ea&&"asc"===Ea.toLowerCase(),c=Ea&&"desc"===Ea.toLowerCase();b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),d=c.values.reduce(d,0);return b?d-e:e-d}):"function"===typeof Ea&&a.sort(Ea);return a}function ad(a,b){var c,g,k,d,e;d=a.filter(function(a){return a&&F(a.value)});bd&&0!==d.length&&
(U.html(cd(a,Bb(),Yb,I)).style("visibility","hidden").style("display","block"),c=U.property("offsetWidth"),g=U.property("offsetHeight"),h?d=b[0]:(k=Na(),d=k+(B(f.data.targets)?0:gb?gb:hb?1:40)+m(d[0].x)+20,e=d+c,k=k+(Pa?Pa:Y())-ga(),e>k&&(d-=c+30)),c=b[1]+15+g<L()?b[1]+15:b[1]-g,U.style("top",c+"px").style("left",d+"px").style("visibility","visible"))}function dd(a){a=a.filter(function(a){return a&&F(a.value)});bd&&(Z(f.data.targets,"scatter")||B(f.data.targets)||l.selectAll("line.xgrid-focus").style("visibility",
"visible").data([a[0]]).attr(h?"y1":"x1",Da).attr(h?"y2":"x2",Da))}function ed(){l.select("line.xgrid-focus").style("visibility","hidden")}function Fa(a){return a.x||0===a.x?m(a.x):null}function Ga(a){return t(a.id)(a.value)}function ve(){var a={},b=0,c,g;pb(va).forEach(function(k){for(c=0;c<u.length;c++)if(!(0>u[c].indexOf(k.id)))for(g=0;g<u[c].length;g++)if(u[c][g]in a){a[k.id]=a[u[c][g]];break}w(a[k.id])&&(a[k.id]=b++)});a.__max__=b-1;return a}function we(a,b,c,g){var k=g?T:m;return function(g){var d=
g.id in c?c[g.id]:0;return g.x||0===g.x?k(g.x)-a*(b/2-d):0}}function xe(a){return function(b){return(a?H(b.id):t(b.id))(b.value)}}function ye(a,b){var c=ue(pb(va)),g=c.map(function(a){return a.id});return function(k,d){var e=b?H(k.id):t(k.id),f=e(0),h=f;c.forEach(function(b){b.id!==k.id&&a[b.id]===a[k.id]&&g.indexOf(b.id)<g.indexOf(k.id)&&0<b.values[d].value*k.value&&(h+=e(b.values[d].value)-f)});return h}}function ca(a,b){var c=w(a)?Xa():a;"string"===typeof c&&(c=[c]);for(var g=0;g<c.length;g++)Xb[c[g]]=
b===z[c[g]],z[c[g]]=b}function Z(a,b){var c=!1;a.forEach(function(a){z[a.id]===b&&(c=!0);a.id in z||"line"!==b||(c=!0)});return c}function B(a){return Z(a,"pie")||Z(a,"donut")}function tb(a){a="string"===typeof a?a:a.id;return!(a in z)||"line"===z[a]||"spline"===z[a]||"area"===z[a]||"area-spline"===z[a]}function fd(a){a="string"===typeof a?a:a.id;return"spline"===z[a]||"area-spline"===z[a]}function va(a){return"bar"===z["string"===typeof a?a:a.id]}function Vc(a){return"scatter"===z["string"===typeof a?
a:a.id]}function gd(a){return"pie"===z["string"===typeof a?a:a.id]}function Tb(a){return"donut"===z["string"===typeof a?a:a.id]}function hd(a){return va(a)?a.values:[]}function ze(a){return tb(a)||Vc(a)?a.values:[]}function Ae(a){return va(a)||tb(a)?a.values:[]}function ta(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+$b+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");b=e.time.format($b).parse(a);if(!b)throw Error("Failed to parse '"+a+"' with format "+
$b);return b}function id(a,b){var c=e.mouse(a),g=e.select(a),k=1*g.attr("cx"),g=1*g.attr("cy");return Math.sqrt(Math.pow(k-c[0],2)+Math.pow(g-c[1],2))<b}function jd(a){var b=e.mouse(a),c=e.select(a);a=1*c.attr("x");var g=1*c.attr("y"),c=1*c.attr("width");return a-10<b[0]&&b[0]<a+c+10&&g-10<b[1]}function Be(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function ge(a,b){var c=!1;Object.keys(a).forEach(function(g){a[g]===b&&(c=!0)});return c}function Zb(a,b){return Math.pow(m(a.x)-
b[0],2)+Math.pow(D(a.value)-b[1],2)}function kd(a,b,c){Ce(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+c}).attr("cx",h?Ga:Fa).attr("cy",h?Fa:Ga).attr("stroke",function(){return I(b.id)}).attr("r",1.4*ab).transition().duration(100).attr("r",ab)}function ac(a,b,c){De(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",
0).remove()}function ld(a,b,c,g){a?kd(b,c,g):ac(b,c,g)}function Ee(){}function md(){}function nd(a,b,c,g){}function bc(a){return a.filter(function(a){return F(a.value)})}function cc(a,b){return(b?l.selectAll(".-circles-"+b):l).selectAll(".-circle"+(F(a)?"-"+a:""))}function dc(a){cc(a).filter(function(){return e.select(this).classed(da)}).classed(da,!1).attr("r",ec)}function od(a,b){var c=pd(a,b);return function(a,b){var d=c(a,b),e=h?1:0,f=h?0:1;return"M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+
" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z"}}function qd(a,b){var c=pd(a,!1),g=b?Fe:Ge;return function(a,b){return g(c(a,b),a,this)}}function Fe(a,b){var c;return h?(c=va(b)?4:6,a[2][1]+c*(0>b.value?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function Ge(a,b,c){return h?(a[0][0]+a[2][0]+0.6*c.offsetHeight)/2:a[2][1]+(0>b.value?c.offsetHeight:va(b)?-3:-6)}function pd(a,b){var c=a.__max__+1,g=c?1.2*S.tickOffset()/c:0,d=we(g,c,a,!!b),e=xe(!!b),f=ye(a,!!b),h=b?H:t;return function(a,b){var c=h(a.id)(0),
l=f(a,b)||c;return[[d(a),l],[d(a),e(a)-(c-l)],[d(a)+g,e(a)-(c-l)],[d(a)+g,l]]}}function He(a,b,c,g){var d,e,f="M",l,n,m,p,q,s=[];if(y(g))for(d=0;d<g.length;d++)s[d]={},w(g[d].start)?s[d].start=a[0].x:s[d].start=C?ta(g[d].start):g[d].start,w(g[d].end)?s[d].end=a[a.length-1].x:s[d].end=C?ta(g[d].end):g[d].end;p=h?function(a){return c(a.value)}:function(a){return b(a.x)};q=h?function(a){return b(a.x)}:function(a){return c(a.value)};g=C?function(a,d,g,k){var e=a.x.getTime();a=d.x-a.x;d=new Date(e+a*(g+
k));return"M"+b(new Date(e+a*g))+" "+c(n(g))+" "+b(d)+" "+c(n(g+k))}:function(a,d,g,k){return"M"+b(l(g))+" "+c(n(g))+" "+b(l(g+k))+" "+c(n(g+k))};for(d=0;d<a.length;d++)if(w(s)||!Be(a[d].x,s))f+=" "+p(a[d])+" "+q(a[d]);else{l=Q(a[d-1].x,a[d].x);n=R(a[d-1].value,a[d].value);e=b(a[d].x)-b(a[d-1].x);m=c(a[d].value)-c(a[d-1].value);e=Math.sqrt(Math.pow(e,2)+Math.pow(m,2));m=2/e;var r=2*m;for(e=m;1>=e;e+=r)f+=g(a[d-1],a[d],e,m)}return f}function fc(a){var b;ub=e.select(ya);if(ub.empty())N.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');
else{ub.html("");f.data.x={};f.data.targets=Wa(a);pa();P();m.domain(e.extent(qb(f.data.targets)));D.domain(ob("y"));aa.domain(ob("y2"));T.domain(m.domain());kb.domain(D.domain());lb.domain(aa.domain());$=m.domain();J.scale(T);ea&&E.scale(m);p=e.select(ya).append("svg").attr("width",q+v+M).attr("height",r+n+oa).on("mouseenter",Ie).on("mouseleave",Je);vb=p.append("defs");vb.append("clipPath").attr("id",gc).append("rect").attr("width",q).attr("height",r);vb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",
-1).attr("y",-20).attr("width",ha).attr("height",X);vb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-v+1).attr("width",Ka).attr("height",Db);l=p.append("g").attr("transform",K.main);G=Ha?p.append("g").attr("transform",K.context):null;Ia=sa?p.append("g").attr("transform",K.legend):null;U=e.select(ya).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",h?"":"url("+
document.URL+"#xaxis-clip)").attr("transform",K.x).append("text").attr("class","-axis-x-label").attr("x",q).attr("dy","-.5em").style("text-anchor","end").text(Ke);l.append("g").attr("class","y axis").attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Le);fb&&l.append("g").attr("class","y2 axis").attr("transform",K.y2);a=l.append("g").attr("clip-path",bb).attr("class","grid");
sd&&a.append("g").attr("class","xgrids");hc&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(hc).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:-n).attr("dy",-5).text(function(a){return a.text}));Me&&a.append("g").attr("class","xgrid-focus").append("line").attr("class",
"xgrid-focus").attr("x1",h?0:-10).attr("x2",h?q:-10).attr("y1",h?-10:n).attr("y2",h?-10:r);td&&a.append("g").attr("class","ygrids");ic&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(ic).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",h?"rotate(-90)":"").attr("dx",h?0:-n).attr("dy",-5).text(function(a){return a.text}));
l.append("g").attr("clip-path",bb).attr("class","regions");l.append("g").attr("clip-path",bb).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ea?h?"ns-resize":"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",K.arc).append("text").attr("class","chart-arcs-title").style("text-anchor",
"middle").text(Ne);l.select(".chart").append("g").attr("class","chart-texts");if(ea)l.insert("rect",Oe?null:"g.grid").attr("class","zoom-rect").attr("width",q).attr("height",r).style("opacity",0).style("cursor",h?"ns-resize":"ew-resize").call(E).on("dblclick.zoom",null);null!==wb&&J.extent("function"!==typeof wb?wb:wb(qb()));Ha&&(G.append("g").attr("clip-path",bb).attr("class","chart"),G.select(".chart").append("g").attr("class","chart-bars"),G.select(".chart").append("g").attr("class","chart-lines"),
G.append("g").attr("clip-path",bb).attr("class","x brush").call(J).selectAll("rect").attr(h?"width":"height",h?Fb:ib),G.append("g").attr("class","x axis").attr("transform",K.subx).attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":""));sa&&xb(f.data.targets);ud(f.data.targets);V({withTransform:!0,withUpdateXDomain:!0});if(Pe){if(C&&"string"===typeof Ja){Ja=ta(Ja);for(a=0;a<f.data.targets[0].values.length&&0!==f.data.targets[0].values[a].x-Ja;a++);Ja=a}U.html(cd(f.data.targets.map(function(a){return sb(a.values[Ja])}),
Bb(),Yb,I));U.style("top",vd.top).style("left",vd.left).style("display","block")}null==N.onresize&&(N.onresize=Qe());N.onresize.add&&N.onresize.add(W)}}function Re(a){a.append("rect").attr("class",Tc).style("cursor",ka&&wa?"pointer":null).on("mouseover",function(a,c){if(!cb&&!B(f.data.targets)){var d=f.data.targets.map(function(a){return sb(a.values[c])}),k,e;if(0<Object.keys(Va).length){e=[];for(var h in Va)for(k=0;k<d.length;k++)if(d[k].id===h){e.push(d[k]);d.shift(k);break}d=e.concat(d)}jc&&cc(c,
void 0).classed(da,!0).attr("r",kc);l.selectAll(".-bar"+(F(c)?"-"+c:"")).classed(da,!1);dd(d)}}).on("mouseout",function(a,c){B(f.data.targets)||(ed(),U.style("display","none"),dc(c),l.selectAll(".-bar"+(F(void 0)?"-undefined":"")).classed(da,!1))}).on("mousemove",function(a,c){var d;cb||B(f.data.targets)||(d=f.data.targets.map(function(a){return sb(a.values[c])}),ad(d,e.mouse(this)),ka&&(wa||l.selectAll(".-shape-"+c).filter(function(a){return la(a)}).each(function(){var a=e.select(this).classed(da,
!0);"circle"===this.nodeName&&a.attr("r",kc);p.select(".event-rect-"+c).style("cursor",null)}).filter(function(){var a=e.select(this);if("circle"===this.nodeName)return id(this,ab);if("rect"===this.nodeName)return jd(this,a.attr("x"),a.attr("y"))}).each(function(){var a=e.select(this);a.classed(da)||(a.classed(da,!0),"circle"===this.nodeName&&a.attr("r",ab));p.select(".event-rect-"+c).style("cursor","pointer")})))}).on("click",function(a,c){B(f.data.targets)||(lc?lc=!1:l.selectAll(".-shape-"+c).each(function(a){wd(this,
a,c)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){xd(e.mouse(this))}).on("dragstart",function(){yd(e.mouse(this))}).on("dragend",function(){zd()})).call(E).on("dblclick.zoom",null)}function Se(a){a.append("rect").attr("x",0).attr("y",0).attr("width",q).attr("height",r).attr("class","event-rect").on("mouseout",function(){B(f.data.targets)||(ed(),U.style("display","none"),dc())}).on("mousemove",function(){var a,c,d;cb||B(f.data.targets)||(a=e.mouse(this),c=$c(f.data.targets,a),d=
[sb(c)],ad(d,a),jc&&(dc(),cc(c.index,c.id).classed(da,!0).attr("r",kc)),dd(d),100>Zb(c,a)?p.select(".event-rect").style("cursor","pointer"):p.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;B(f.data.targets)||(a=e.mouse(this),c=$c(f.data.targets,a),100>Zb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){wd(this,c,c.index)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){xd(e.mouse(this))}).on("dragstart",function(){yd(e.mouse(this))}).on("dragend",
function(){zd()})).call(E).on("dblclick.zoom",null)}function wd(a,b,c){var d=e.select(a),k=d.classed(ma),f=!1,h;"circle"===a.nodeName?(f=id(a,1.5*ab),h=ld):"rect"===a.nodeName&&(f=jd(a),h=nd);if(wa||f)ka&&la(b)&&(d.classed(ma,!k),h(!k,d,b,c)),Te(b,d)}function xd(a){var b,c,d,k,h,m,p;B(f.data.targets)||!ka||ea&&!E.altDomain||(b=mc[0],c=mc[1],d=a[0],a=a[1],k=Math.min(b,d),h=Math.max(b,d),m=wa?n:Math.min(c,a),p=wa?r:Math.max(c,a),l.select(".dragarea").attr("x",k).attr("y",m).attr("width",h-k).attr("height",
p-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return la(a)}).each(function(a,b){var c=e.select(this),d=c.classed(ma),g=c.classed(nc),f,l,rd,n;f=!1;"circle"===this.nodeName?(f=1*c.attr("cx"),l=1*c.attr("cy"),n=ld,f=k<f&&f<h&&m<l&&l<p):"rect"===this.nodeName&&(f=1*c.attr("x"),l=1*c.attr("y"),rd=1*c.attr("width"),n=nd,f=k<f+rd&&f<h&&l<p);f^g&&(c.classed(nc,!g),c.classed(ma,!d),n(!d,c,a,b))}))}function yd(a){!B(f.data.targets)&&ka&&(mc=a,l.select(".chart").append("rect").attr("class",
"dragarea").style("opacity",0.1),cb=!0)}function zd(){!B(f.data.targets)&&ka&&(l.select(".dragarea").transition().duration(100).style("opacity",0).remove(),l.selectAll(".-shape").classed(nc,!1),cb=!1)}function V(a){var b,c,d,k;d=ve();var p,t,x,u,v,w=B(f.data.targets),A,s;a=y(a)?a:{};c=y(a.withY)?a.withY:!0;k=y(a.withSubchart)?a.withSubchart:!0;t=y(a.withTransition)?a.withTransition:!0;x=y(a.withTransform)?a.withTransform:!1;u=y(a.withUpdateXDomain)?a.withUpdateXDomain:!1;v=y(a.withUpdateOrgXDomain)?
a.withUpdateOrgXDomain:!1;s=t?Ue:0;a=y(a.durationForExit)?a.durationForExit:s;v&&(m.domain(e.extent(qb(f.data.targets))),$=m.domain(),ea&&E.scale(m).updateScaleExtent(),T.domain(m.domain()),J.scale(T));u&&(m.domain(J.empty()?$:J.extent()),ea&&E.scale(m).updateScaleExtent());D.domain(ob("y"));aa.domain(ob("y2"));l.select(".x.axis").style("opacity",w?0:1).transition().duration(h?s:0).call(h?Qb:S);l.select(".y.axis").style("opacity",w?0:1).transition().duration(h?0:s).call(h?S:Qb);l.select(".y2.axis").style("opacity",
w?0:1).transition().call(Ac);A=od(d);u=qd(d,!0);v=qd(d,!1);l.select(".x.axis .-axis-x-label").attr("x",q);kb.domain(D.domain());lb.domain(aa.domain());U.style("display","none");l.select("line.xgrid-focus").style("visibility","hidden").attr("y2",r);if(sd){if("year"===Ve){b=[];for(var z=qb(),C=z[0].getFullYear(),z=z[1].getFullYear();C<=z;C++)b.push(new Date(C+"-01-01 00:00:00"))}else b=m.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class","xgrid");b.attr("x1",
h?0:function(a){return m(a)-S.tickOffset()}).attr("x2",h?q:function(a){return m(a)-S.tickOffset()}).attr("y1",h?function(a){return m(a)-S.tickOffset()}:n).attr("y2",h?function(a){return m(a)-S.tickOffset()}:r).style("opacity",function(){return+e.select(this).attr(h?"y1":"x1")===(h?r:0)?0:1});b.exit().remove()}hc&&(b=l.selectAll(".xgrid-lines"),b.selectAll("line").transition().duration(s).attr("x1",h?0:Za).attr("x2",h?q:Za).attr("y1",h?Za:n).attr("y2",h?Za:r),b.selectAll("text").attr("x",h?q:0).attr("y",
Za));c&&td&&(b=l.select(".ygrids").selectAll(".ygrid").data(D.ticks(10)),b.enter().append("line").attr("class","ygrid"),b.attr("x1",h?D:0).attr("x2",h?D:q).attr("y1",h?0:D).attr("y2",h?r:D),b.exit().remove());c&&ic&&(c=l.select(".ygrid-lines"),c.selectAll("line").transition().duration(s).attr("x1",h?$a:0).attr("x2",h?$a:q).attr("y1",h?0:$a).attr("y2",h?r:$a),c.selectAll("text").attr("x",h?0:q).attr("y",$a));c=l.selectAll(".-bars").selectAll(".-bar").data(hd);c.enter().append("path").attr("d",A).style("stroke",
"none").style("opacity",0).style("fill",function(a){return I(a.id)}).attr("class",Sc);c.style("opacity",Ba).transition().duration(s).attr("d",A).style("opacity",1);c.exit().transition().duration(a).style("opacity",0).remove();c=l.selectAll(".-texts").selectAll(".-text").data(Ae);c.enter().append("text").attr("class",le).attr("text-anchor",function(a){return h?0>a.value?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return Yb(a.value)});c.style("fill-opacity",
se).transition().duration(s).attr("x",u).attr("y",v).style("fill-opacity",Uc);c.exit().transition().duration(a).style("fill-opacity",0).remove();l.selectAll(".-line").style("opacity",Ba).transition().duration(s).attr("d",We).style("opacity",1);l.selectAll(".-area").style("opacity",0).transition().duration(s).attr("d",Xe).style("opacity",Ad);a=l.selectAll(".-circles").selectAll(".-circle").data(ze);a.enter().append("circle").attr("class",qe).style("opacity",0).attr("r",ec);a.style("opacity",Ba).transition().duration(s).style("opacity",
te).attr("cx",h?Ga:Fa).attr("cy",h?Fa:Ga);a.exit().remove();l.selectAll(".chart-arc").select(".-arc").attr("transform",x?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(s).attrTween("d",function(a){a=na(a);if(!a)return function(){return"M 0 0"};var b=e.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return gd(a.data)||Tb(a.data)?mb(a,!0):"M 0 0"}}).attr("transform",x?"scale(1)":"").style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform",
eb).style("opacity",0).transition().duration(s).text(Cb).style("opacity",function(a){return gd(a.data)||Tb(a.data)?1:0});l.select(".chart-arcs-title").style("opacity",Z(f.data.targets,"donut")?1:0);Ha&&(null!==e.event&&"zoom"===e.event.type&&J.extent(m.orgDomain()).update(),k&&(G.select(".x.axis").style("opacity",w?0:1).transition().duration(h?s:0).call(Pb),J.empty()||J.extent(m.orgDomain()).update(),k=od(d,!0),d=G.selectAll(".-bars").selectAll(".-bar").data(hd),d.enter().append("path").attr("d",
k).style("stroke","none").style("fill",function(a){return I(a.id)}).attr("class",Sc),d.style("opacity",Ba).transition().duration(s).attr("d",k).style("opacity",1),d.exit().transition().duration(s).style("opacity",0).remove(),G.selectAll(".-line").style("opacity",Ba).transition().duration(s).attr("d",Ye).style("opacity",1)));l.selectAll(".selected-circles").filter(function(a){return va(a)}).selectAll("circle").remove();l.selectAll(".selected-circle").transition().duration(s).attr("cx",h?Ga:Fa).attr("cy",
h?Fa:Ga);ba?(k=l.select(".event-rects").selectAll(".event-rect").data([0]),Se(k.enter()),k.attr("x",0).attr("y",0).attr("width",q).attr("height",r)):(Wb?(p=function(a,b){var c=Nc(b),d=b<Aa()-1?f.data.targets[0].values[b+1].x:void 0;return(m(d?d:a.x+50)-m(c?c:a.x-50))/2},d=function(a,b){var c=Nc(b);return(m(a.x)+m(c?c:a.x-50))/2}):(p=Gd(),d=function(a){return m(a.x)-p/2}),k=ke(),l.select(".event-rects").datum(k?k.values:[]),k=l.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),
Re(k.enter()),k.attr("class",Tc).attr("x",h?0:d).attr("y",h?d:0).attr("width",h?q:p).attr("height",h?p:r),k.exit().remove());d=l.select(".regions").selectAll("rect.region").data(O);d.enter().append("rect").style("fill-opacity",0);d.attr("class",re).attr("x",h?0:Vb).attr("y",h?Vb:n).attr("width",h?q:Ic).attr("height",h?Ic:r).transition().duration(s).style("fill-opacity",function(a){return F(a.opacity)?a.opacity:0.1});d.exit().transition().duration(s).style("fill-opacity",0).remove();xb(f.data.targets,
{withTransition:t});Xa().forEach(function(a){Xb[a]=!0})}function Ze(){"mousemove"===e.event.sourceEvent.type&&E.altDomain?(m.domain(E.altDomain),E.scale(m).updateScaleExtent()):(ia&&m.orgDomain()[0]===$[0]&&m.domain([$[0]-1E-10,m.orgDomain()[1]]),V({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===e.event.sourceEvent.type&&(lc=!0))}function Qe(){function a(){b.forEach(function(a){a()})}var b=[];a.add=function(a){b.push(a)};return a}function W(a){var b;a=y(a)?a:{};b=y(a.withTransition)?a.withTransition:
!1;a=y(a.withTransform)?a.withTransform:!1;pa();P();J.scale(T);ea&&E.scale(m);p.attr("width",Oa).attr("height",qa);p.select("#"+gc).select("rect").attr("width",q).attr("height",r);p.select("#xaxis-clip").select("rect").attr("width",ha);p.select(".zoom-rect").attr("width",q).attr("height",r);l.attr("transform",K.main);l.select(".x.axis").attr("transform",K.x);l.select(".y2.axis").attr("transform",K.y2);l.select(".chart-arcs").attr("transform",K.arc);Ha&&(G.attr("transform",K.context),G.select(".x.axis").attr("transform",
K.subx));var c=!1!==b?250:0;sa&&Ia.transition().duration(c).attr("transform",K.legend);V({withTransition:b,withUpdateXDomain:!0,withTransform:a,durationForExit:0})}function ud(a){var b;l.select(".chart-texts").selectAll(".chart-text").data(a).enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none").append("g").attr("class",me).style("fill",function(a){return I(a.id)});l.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").append("g").attr("class",Rc).style("fill",function(a){return I(a.id)}).style("stroke","none").style("cursor",function(a){return la(a)?"pointer":null});b=l.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");b.append("path").attr("class",Qc).style("opacity",0).style("stroke",function(a){return I(a.id)});
b.append("path").attr("class",pe).style("opacity",function(){Ad=+e.select(this).style("opacity");return 0}).style("fill",function(a){return I(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",ne).style("fill",function(a){return I(a.id)}).style("cursor",function(a){return la(a)?"pointer":null});a.forEach(function(a){var b=yb(a.id);l.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});
b=l.select(".chart-arcs").selectAll(".chart-arc").data(Sb(a)).enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id});b.append("path").attr("class",oe).style("opacity",0).style("fill",function(a){return I(a.data.id)}).style("cursor",function(a){return la(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){wc(a.data.id);oc(a.data.id)}).on("mouseout",function(a){Ub(a.data.id);pc()});b.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor",
"middle").style("pointer-events","none");Ha&&(b=G.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),b.append("g").attr("class",Rc).style("fill",function(a){return I(a.id)}),b=G.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),b.append("path").attr("class",Qc).style("opacity",0).style("stroke",function(a){return I(a.id)}));
sa&&xb(a);p.selectAll(".target").transition().style("opacity",1)}function db(a,b){f.data.targets.forEach(function(b){for(var d=0;d<a.length;d++)if(b.id===a[d].id){b.values=a[d].values;a.splice(d,1);break}});f.data.targets=f.data.targets.concat(a);ud(f.data.targets);V({withUpdateOrgXDomain:!0,withUpdateXDomain:!0});b()}function oc(a){var b=p.selectAll(".legend-item"),c=function(b){return!a||b===a};b.filter(function(a){return!c(a)}).transition().duration(100).style("opacity",0.3);b.filter(c).transition().duration(100).style("opacity",
1)}function $e(a){var b=p.selectAll(".legend-item"),c=function(b){return!a||b===a};b.filter(function(a){return!c(a)}).transition().duration(100).style("opacity",1);b.filter(c).transition().duration(100).style("opacity",0.3)}function pc(){p.selectAll(".legend-item").transition().duration(100).style("opacity",1)}function xb(a,b){var c=Xa(a),d,e,h,l,m,n,p,q=0,r=0,s,u,t;b=w(b)?{}:b;t=y(b.withTransition)?b.withTransition:!0;x?(e=function(){return 0.2*Qa},m=function(a,b){return s+q*b}):(e=function(a,b){return s+
r*b},m=function(){return 0.2*ra});h=function(a,b){return e(a,b)+14};n=function(a,b){return m(a,b)+9};l=function(a,b){return e(a,b)-4};p=function(a,b){return m(a,b)-7};u=function(b,c){var d=10*Math.ceil((b+30)/10),g=10*Math.ceil((c+4)/10);d>r&&(r=d,x||(s=(Qa-r*Object.keys(a).length)/2));g>q&&(q=g,x&&(s=(ra-q*Object.keys(a).length)/2))};d=Ia.selectAll(".legend-item").data(c).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){af(a)}).on("mouseover",
function(a){oc(a);f.focus(a)}).on("mouseout",function(){pc();f.revert()});d.append("text").text(function(a){return y(Va[a])?Va[a]:a}).each(function(){u(this.offsetWidth,this.offsetHeight)}).style("pointer-events","none").attr("x",x?h:-200).attr("y",x?-200:m);d.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",x?l:-200).attr("y",x?-200:p).attr("width",r+14).attr("height",24);d.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",
function(a){return I(a)}).attr("x",x?h:-200).attr("y",x?-200:n).attr("width",10).attr("height",10);Ia.selectAll("text").data(c).each(function(){u(this.offsetWidth,this.offsetHeight)}).transition().duration(t?250:0).attr("x",h).attr("y",n);Ia.selectAll("rect.legend-item-event").data(c).transition().duration(t?250:0).attr("x",l).attr("y",p);Ia.selectAll("rect.legend-item-tile").data(c).transition().duration(t?250:0).attr("x",e).attr("y",m)}function yb(a){return a?"-"+a.replace(/\./g,"\\."):""}function ja(a){return".target"+
yb(a)}function qc(a){return Oc(a.id)}function rc(a){return"data"in a&&Oc(a.data.id)}var f={data:{}},rb={},da="_expanded_",ma="_selected_",nc="_included_",ya=d(["bindto"],"#chart"),Pa=d(["size","width"],null),Hb=d(["size","height"],null),gb=d(["padding","left"],null),zc=d(["padding","right"],null),ea=d(["zoom","enabled"],!1),Bd=d(["zoom","extent"],null),Oe=d(["zoom","privileged"],!1),Ie=d(["onenter"],function(){}),Je=d(["onleave"],function(){}),Ue=d(["transition","duration"],350);if(!("data"in fa))throw Error("data is required in config");
var ua=d(["data","x"],null),ba=d(["data","xs"],null),$b=d(["data","x_format"],"%Y-%m-%d"),je=d(["data","id_converter"],function(a){return a}),Va=d(["data","names"],{}),u=d(["data","groups"],[]),Dc=d(["data","axes"],{}),Mc=d(["data","type"],null),z=d(["data","types"],{}),Ca=d(["data","labels"],{}),Ea=d(["data","order"],null),Cd=d(["data","regions"],{}),bf=d(["data","colors"],{}),ka=d(["data","selection","enabled"],!1),wa=d(["data","selection","grouped"],!1),la=d(["data","selection","isselectable"],
function(){return!0}),Ha=d(["subchart","show"],!1),Eb=Ha?d(["subchart","size","height"],60):0,cf=d(["color","pattern"],null),sa=d(["legend","show"],!0),df=d(["legend","position"],"bottom"),af=d(["legend","item","onclick"],function(){}),h=d(["axis","rotated"],!1),sc=d(["axis","x","type"],"indexed"),Sa=d(["axis","x","categories"],[]),Pd=d(["axis","x","tick","centered"],!1),nb=d(["axis","x","tick","format"],null),Sd=d(["axis","x","tick","culling"],h||"categorized"===sc?!1:!0),Ec=d(["axis","x","tick",
"count"],10),wb=d(["axis","x","default"],null),Ke=d(["axis","x","label"],null),$d=d(["axis","y","max"],null),Yd=d(["axis","y","min"],null),be=d(["axis","y","center"],null),Le=d(["axis","y","label"],null),hb=d(["axis","y","inner"],!1),Rb=d(["axis","y","tick","format"],null),Ta=d(["axis","y","padding"],null),Ld=d(["axis","y","ticks"],10),fb=d(["axis","y2","show"],!1),Zd=d(["axis","y2","max"],null),Xd=d(["axis","y2","min"],null),ae=d(["axis","y2","center"],null),Ib=d(["axis","y2","inner"],!1),Nd=d(["axis",
"y2","tick","format"],null),Ua=d(["axis","y2","padding"],null),Od=d(["axis","y2","ticks"],10),sd=d(["grid","x","show"],!1),Ve=d(["grid","x","type"],"tick"),hc=d(["grid","x","lines"],null),td=d(["grid","y","show"],!1),ic=d(["grid","y","lines"],null),ec=d(["point","show"],!0)?d(["point","r"],2.5):0,Me=d(["point","focus","line","enabled"],!0),jc=d(["point","focus","expand","enabled"],!0),kc=d(["point","focus","expand","r"],jc?4:ec),ab=d(["point","focus","select","r"],8),Te=d(["point","onclick"],function(){}),
Ce=d(["point","onselected"],function(){}),De=d(["point","onunselected"],function(){}),Td=d(["arc","label","format"],function(a,b){return(100*b).toFixed(1)+"%"}),Ne=d(["arc","title"],""),O=d(["regions"],[]),bd=d(["tooltip","enabled"],!0),Dd=d(["tooltip","format","title"],null),Ed=d(["tooltip","format","value"],null),cd=d(["tooltip","contents"],function(a,b,c,d){b=Dd?Dd:b;c=Ed?Ed:c;var e,f,h,l;for(f=0;f<a.length;f++)a[f]&&(a[f].value||0===a[f].value)&&(e||(e=b?b(a[f].x):a[f].x,e="<table class='-tooltip'><tr><th colspan='2'>"+
e+"</th></tr>"),l=a[f].name,h=c(a[f].value),e+="<tr class='-tooltip-name-"+a[f].id+"'><td class='name'><span style='background-color:"+d(a[f].id)+"'></span>"+l+"</td><td class='value'>"+h+"</td></tr>");return e+"</table>"}),Pe=d(["tooltip","init","show"],!1),Ja=d(["tooltip","init","x"],0),vd=d(["tooltip","init","position"],{top:"0px",left:"50px"}),gc=ya.replace("#","")+"-clip",bb="url("+document.URL+"#"+gc+")",C="timeseries"===sc,ia="categorized"===sc,Wb=!C&&(ua||ba),mc=null,cb=!1,lc=!1,I=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]}}(bf,cf),Qd=function(){var a=[[e.time.format("%Y/%-m/%-d"),function(){return!0}],[e.time.format("%-m/%-d"),function(a){return a.getMonth()}],[e.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[e.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[e.time.format("%I %p"),
function(a){return a.getHours()}],[e.time.format("%I:%M"),function(a){return a.getMinutes()}],[e.time.format(":%S"),function(a){return a.getSeconds()}],[e.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)}}(),q,Fb,r,ib,Oa,qa,ra,Qa,Ra,jb,Gb,mb,Bc,Cc,Sb,Jb,Kb,Lb,Mb,Nb,Ob,m,D,aa,T,kb,lb,S,Qb,Ac,Pb,Id=h?"left":"bottom",Kd=h?hb?"top":"bottom":hb?"right":"left",Md=h?Ib?"bottom":"top":Ib?"left":"right",Jd=h?"left":
"bottom",K={main:function(){return"translate("+v+","+n+")"},context:function(){return"translate("+Ma+","+Ab+")"},legend:function(){return"translate("+zb+","+tc+")"},y2:function(){return"translate("+(h?0:q)+","+(h?1:0)+")"},x:function(){return"translate(0,"+r+")"},subx:function(){return"translate(0,"+(h?0:ib)+")"},arc:function(){return"translate("+q/2+","+r/2+")"}},x="right"===df,yc=40,xc=20;Sb=e.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var We=function(){var a=
e.svg.line().x(h?function(a){return t(a.id)(a.value)}:Da).y(h?Da:function(a){return t(a.id)(a.value)});return function(b){var c=bc(b.values),d;if(tb(b))return fd(b)?a.interpolate("cardinal"):a.interpolate("linear"),Cd[b.id]?He(c,m,t(b.id),Cd[b.id]):a(c);d=m(c[0].x);b=t(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),Xe=function(){var a;a=h?e.svg.area().x0(function(a){return t(a.id)(0)}).x1(function(a){return t(a.id)(a.value)}).y(Da):e.svg.area().x(Da).y0(function(a){return t(a.id)(0)}).y1(function(a){return t(a.id)(a.value)});
return function(b){var c=bc(b.values),d;if(Z([b],"area")||Z([b],"area-spline"))return fd(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=t(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),Ye=function(){var a=e.svg.line().x(h?function(a){return H(a.id)(a.value)}:Wc).y(h?Wc:function(a){return H(a.id)(a.value)});return function(b){var c=bc(b.values);return tb(b)?a(c):"M "+T(c[0].x)+" "+H(b.id)(c[0].value)}}(),J,E=function(){};J=e.svg.brush().on("brush",function(){V({withTransition:!1,
withY:!1,withSubchart:!1,withUpdateXDomain:!0})});J.update=function(){G&&G.select(".x.brush").call(this);return this};J.scale=function(a){return h?this.y(a):this.x(a)};ea&&(E=e.behavior.zoom().on("zoomstart",function(){E.altDomain=e.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",ea?Ze:null),E.scale=function(a){return h?this.y(a):this.x(a)},E.orgScaleExtent=function(){var a=Bd?Bd:[1,10];return[a[0],Math.max(Aa()/a[1],a[1])]},E.updateScaleExtent=function(){var a=za(m.orgDomain())/za($),b=this.orgScaleExtent();
this.scaleExtent([b[0]*a,b[1]*a]);return this});var p,vb,l,G,Ia,U,ub,$,Ad,Xb={};f.focus=function(a){var b=p.selectAll(ja(a)),c=b.filter(qc),b=b.filter(rc);f.revert();f.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);B(f.data.targets)&&wc(a,!0);oc(a)};f.defocus=function(a){var b=p.selectAll(ja(a)),c=b.filter(qc),b=b.filter(rc);f.revert();c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",
0.3);B(f.data.targets)&&Ub(a);$e(a)};f.revert=function(a){var b=p.selectAll(ja(a)),c=b.filter(qc),b=b.filter(rc);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);B(f.data.targets)&&Ub(a);pc()};f.show=function(a){p.selectAll(ja(a)).transition().style("opacity",1)};f.hide=function(a){p.selectAll(ja(a)).transition().style("opacity",0)};f.unzoom=function(){J.clear().update();V({withUpdateXDomain:!0})};f.load=function(a){"function"!==
typeof a.done&&(a.done=function(){});a.xs&&ie(a.xs);"categories"in a&&ia&&(Sa=a.categories,S.categories(Sa));if("cacheIds"in a&&ee(a.cacheIds))db(fe(a.cacheIds),a.done);else if("data"in a)db(Wa(a.data),a.done);else if("url"in a)e.csv(a.url,function(b,c){db(Wa(c),a.done)});else if("rows"in a)db(Wa(Kc(a.rows)),a.done);else if("columns"in a)db(Wa(Lc(a.columns)),a.done);else throw Error("url or rows or columns is required.");};f.unload=function(a){f.data.targets=f.data.targets.filter(function(b){return b.id!==
a});p.selectAll(ja(a)).transition().style("opacity",0).remove();sa&&(p.selectAll(".legend-item"+yb(a)).remove(),xb(f.data.targets));0<f.data.targets.length&&V({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})};f.selected=function(a){a=yb(a);return e.merge(l.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return e.select(this).classed(ma)}).map(function(a){return a.map(function(a){return a.__data__})}))};f.select=function(a,b,c){ka&&l.selectAll(".-shapes").selectAll(".-shape").each(function(d,
f){var h="circle"===this.nodeName?kd:Ee,l="circle"===this.nodeName?ac:md;0<=b.indexOf(f)?la(d)&&(wa||w(a)||0<=a.indexOf(d.id))&&h(e.select(this).classed(ma,!0),d,f):y(c)&&c&&l(e.select(this).classed(ma,!1),d,f)})};f.unselect=function(a,b){ka&&l.selectAll(".-shapes").selectAll(".-shape").each(function(c,d){var f="circle"===this.nodeName?ac:md;(w(b)||0<=b.indexOf(d))&&la(c)&&(wa||w(a)||0<=a.indexOf(c.id))&&f(e.select(this).classed(ma,!1),c,d)})};f.toLine=function(a){ca(a,"line");W({withTransition:!0})};
f.toSpline=function(a){ca(a,"spline");W({withTransition:!0})};f.toBar=function(a){ca(a,"bar");W({withTransition:!0})};f.toScatter=function(a){ca(a,"scatter");W({withTransition:!0})};f.toArea=function(a){ca(a,"area");W({withTransition:!0})};f.toAreaSpline=function(a){ca(a,"area-spline");W({withTransition:!0})};f.toPie=function(a){ca(a,"pie");W({withTransition:!0,withTransform:!0})};f.toDonut=function(a){ca(a,"donut");W({withTransition:!0,withTransform:!0})};f.groups=function(a){if(w(a))return u;u=
a;V();return u};f.regions=function(a){if(w(a))return O;O=a;V();return O};f.regions.add=function(a){if(w(a))return O;O=O.concat(a);V();return O};f.regions.remove=function(a,b){var c=[].concat(a);b=y(b)?b:{};c.forEach(function(a){var c=F(b.duration)?b.duration:0;p.selectAll("."+a).transition().duration(c).style("fill-opacity",0).remove();O=O.filter(function(b){return 0>b.classes.indexOf(a)})});return O};f.data.get=function(a){a=f.data.getAsTarget(a);return y(a)?a.values.map(function(a){return a.value}):
void 0};f.data.getAsTarget=function(a){var b=pb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};f.resize=function(a){Pa=a?a.width:null;Hb=a?a.height:null;W()};f.destroy=function(){f.data.targets=void 0;f.data.x={};ub.html("");N.onresize=null};if("url"in fa.data)e.csv(fa.data.url,function(a,b){fc(b)});else if("rows"in fa.data)fc(Kc(fa.data.rows));else if("columns"in fa.data)fc(Lc(fa.data.columns));else throw Error("url or rows or columns is required.");return f}})(window);

Loading…
Cancel
Save