Browse Source

Implement pie chart - #9

pull/22/merge
Masayuki Tanaka 11 years ago
parent
commit
c40e305ca9
  1. 11
      c3.css
  2. 297
      c3.js
  3. 154
      c3.min.js

11
c3.css

@ -15,6 +15,15 @@ text {
user-select: none;
}
.chart-arc path {
stroke: #fff;
}
.chart-arc text {
fill: #fff;
font-size: 13px;
}
/*-- Grid --*/
.grid line {
@ -60,7 +69,7 @@ text {
/*-- Focus --*/
.target.focused path {
.target.focused path.-line {
stroke-width: 2px;
}

297
c3.js

@ -184,6 +184,7 @@
/*-- Set Chart Params --*/
var bottom, bottom2, right, left, top2, top3, margin, margin2, margin3, width, height, height2, height3, currentWidth, currentHeight;
var radius, radiusExpanded, svgArc, svgArcExpanded, svgArcExpandedSub, pie;
var xMin, xMax, yMin, yMax, x, y, y2, subX, subY, subY2, xAxis, yAxis, yAxis2, subXAxis;
var xOrient = __axis_rotated ? "left" : "bottom",
@ -197,7 +198,8 @@
legend : function () { return "translate(" + margin3.left + "," + margin3.top + ")"; },
y2 : function () { return "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 10 : 0) + ")"; },
x : function () { return "translate(0," + height + ")"; },
subx : function () { return "translate(0," + height2 + ")"; }
subx : function () { return "translate(0," + height2 + ")"; },
arc: function () { return "translate(" + width / 2 + "," + height / 2 + ")"; }
};
/*-- Define Functions --*/
@ -220,6 +222,8 @@
height = currentHeight - margin.top - margin.bottom;
height2 = currentHeight - margin2.top - margin2.bottom;
height3 = currentHeight - margin3.top - margin3.bottom;
radiusExpanded = height / 2;
radius = radiusExpanded * 0.95;
}
function getCurrentWidth() {
return __size_width === null ? getParentWidth() : __size_width;
@ -286,6 +290,10 @@
yAxis = getYAxis(y, yOrient);
yAxis2 = getYAxis(y2, y2Orient);
subXAxis = getXAxis(subX, subXOrient);
// update for arc
svgArc = getSvgArc();
svgArcExpanded = getSvgArcExpanded();
svgArcExpandedSub = getSvgArcExpanded(0.98);
}
function getX(min, max, domain, offset) {
@ -357,6 +365,80 @@
return tickFormat;
}
//-- Arc --//
pie = d3.layout.pie().value(function (d) {
return d.values.reduce(function (a, b) { return a + b.value; }, 0);
});
function updateAngle(d) {
var found = false;
pie(c3.data.targets).forEach(function (t) {
if (! found && t.data.id === d.data.id) {
found = true;
d = t;
return;
}
});
return found ? d : null;
}
function getSvgArc() {
var arc = d3.svg.arc().outerRadius(radius).innerRadius(0),
newArc = function (d, withoutUpdate) {
var updated;
if (withoutUpdate) { return arc(d); } // for interpolate
updated = updateAngle(d);
return updated ? arc(updated) : "M 0 0";
};
// TODO: extends all function
newArc.centroid = arc.centroid;
return newArc;
}
function getSvgArcExpanded(rate) {
var arc = d3.svg.arc().outerRadius(radiusExpanded * (rate ? rate : 1)).innerRadius(0);
return function (d) {
var updated = updateAngle(d);
return updated ? arc(updated) : "M 0 0";
};
}
function getArc(d, withoutUpdate) {
return isArcType(d.data) ? svgArc(d, withoutUpdate) : "M 0 0";
}
function transformForArcLable(d) {
var updated = updateAngle(d), c, x, y, h, translate = "";
if (updated) {
c = svgArc.centroid(updated);
x = c[0], y = c[1], h = Math.sqrt(x * x + y * y);
translate = "translate(" + ((x / h) * radius * 0.8) + ',' + ((y / h) * radius * 0.8) + ")";
}
return translate;
}
function textForArcLable(d) {
var ratio = 100 * (d.endAngle - d.startAngle) / (Math.PI * 2);
return ratio.toFixed(1) + "%";
}
function expandArc(targetId, withoutFadeOut) {
var target = d3.selectAll('.chart-arc.target' + (targetId ? '-' + targetId : '')),
noneTargets = d3.selectAll('.-arc').filter(function (data) { return data.data.id !== targetId; });
target.selectAll('path')
.transition().duration(50)
.attr("d", svgArcExpanded)
.transition().duration(100)
.attr("d", svgArcExpandedSub);
if (!withoutFadeOut) {
noneTargets.style("opacity", 0.3);
}
}
function unexpandArc(targetId) {
var target = d3.selectAll('.chart-arc.target' + (targetId ? '-' + targetId : ''));
target.selectAll('path')
.transition().duration(50)
.attr("d", svgArc);
d3.selectAll('.-arc')
.style("opacity", 1);
}
//-- Domain --//
function getYDomainMin(targets) {
@ -473,6 +555,9 @@
function getXKey(id) {
return __data_x ? __data_x : __data_xs ? __data_xs[id] : null;
}
function getXValue(id, i) {
return id in c3.data.x && c3.data.x[i] ? c3.data.x[i] : i;
}
function addName(data) {
var name = __data_names[data.id];
@ -536,7 +621,7 @@
x = parseDate(d[xKey]);
}
else if (isCustomX) {
x = d[xKey] ? d[xKey] : c3.data.x[id][i];
x = d[xKey] ? d[xKey] : getXValue(id, i);
}
else {
x = i;
@ -616,6 +701,7 @@
function classLine(d) { return classShapes(d) + " -line -line-" + d.id; }
function classCircles(d) { return classShapes(d) + " -circles -circles-" + d.id; }
function classBars(d) { return classShapes(d) + " -bars -bars-" + d.id; }
function classArc(d) { return classShapes(d.data) + " -arc -arc-" + d.data.id; }
function classShape(d, i) { return "-shape -shape-" + i; }
function classCircle(d, i) { return classShape(d, i) + " -circle -circle-" + i; }
function classBar(d, i) { return classShape(d, i) + " -bar -bar-" + i; }
@ -724,7 +810,7 @@
function showXGridFocus(data) {
// Hide when scatter plot exists
if (hasScatterType(c3.data.targets)) { return; }
if (hasScatterType(c3.data.targets) || hasArcType(c3.data.targets)) { return; }
main.selectAll('line.xgrid-focus')
.style("visibility", "visible")
.data([data])
@ -830,6 +916,9 @@
function hasScatterType(targets) {
return hasType(targets, 'scatter');
}
function hasArcType(targets) {
return hasType(targets, 'pie');
}
function isLineType(d) {
var id = (typeof d === 'string') ? d : d.id;
return !(id in __data_types) || __data_types[id] === 'line' || __data_types[id] === 'spline';
@ -846,6 +935,10 @@
var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'scatter';
}
function isArcType(d) {
var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'pie';
}
/* not used
function lineData(d) {
return isLineType(d) ? d.values : [];
@ -1132,11 +1225,6 @@
// TODO: set names if names not specified
// Set data type if data.type is specified
if (__data_type) {
setTargetType(getTargetIds().filter(function (id) { return ! (id in __data_types); }), __data_type);
}
// Init sizes and scales
updateSizes();
updateScales();
@ -1315,6 +1403,11 @@
main.select(".chart").append("g")
.attr("class", "chart-lines");
// Define g for arc chart area
main.select(".chart").append("g")
.attr("class", "chart-arcs")
.attr("transform", translate.arc);
if (__zoom_enabled) { // TODO: __zoom_privileged here?
// if zoom privileged, insert rect to forefront
main.insert('rect', __zoom_privileged ? null : 'g.grid')
@ -1405,6 +1498,7 @@
.style("cursor", __data_selection_enabled && __data_selection_grouped ? "pointer" : null)
.on('mouseover', function (d, i) {
if (dragging) { return; } // do nothing if dragging
if (hasArcType(c3.data.targets)) { return; }
var selectedData = c3.data.targets.map(function (d) { return addName(d.values[i]); });
var j, newData;
@ -1432,6 +1526,7 @@
showXGridFocus(selectedData[0]);
})
.on('mouseout', function (d, i) {
if (hasArcType(c3.data.targets)) { return; }
hideXGridFocus();
hideTooltip();
// Undo expanded shapes
@ -1442,6 +1537,7 @@
var selectedData;
if (dragging) { return; } // do nothing when dragging
if (hasArcType(c3.data.targets)) { return; }
// Show tooltip
selectedData = c3.data.targets.map(function (d) {
@ -1478,6 +1574,7 @@
});
})
.on('click', function (d, i) {
if (hasArcType(c3.data.targets)) { return; }
if (cancelClick) {
cancelClick = false;
return;
@ -1501,6 +1598,7 @@
.attr('height', height)
.attr('class', "event-rect")
.on('mouseout', function () {
if (hasArcType(c3.data.targets)) { return; }
hideXGridFocus();
hideTooltip();
unexpandCircles();
@ -1509,6 +1607,7 @@
var mouse, closest, selectedData;
if (dragging) { return; } // do nothing when dragging
if (hasArcType(c3.data.targets)) { return; }
mouse = d3.mouse(this);
closest = findClosestFromTargets(c3.data.targets, mouse);
@ -1534,8 +1633,12 @@
}
})
.on('click', function () {
var mouse = d3.mouse(this),
closest = findClosestFromTargets(c3.data.targets, mouse);
var mouse, closest;
if (hasArcType(c3.data.targets)) { return; }
mouse = d3.mouse(this);
closest = findClosestFromTargets(c3.data.targets, mouse);
// select if selection enabled
if (dist(closest, mouse) < 100) {
@ -1575,16 +1678,21 @@
}
function drag(mouse) {
var sx, sy, mx, my, minX, maxX, minY, maxY;
if (hasArcType(c3.data.targets)) { return; }
if (! __data_selection_enabled) { return; } // do nothing if not selectable
if (__zoom_enabled && ! zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior
var sx = dragStart[0], sy = dragStart[1],
mx = mouse[0],
my = mouse[1],
minX = Math.min(sx, mx),
maxX = Math.max(sx, mx),
minY = (__data_selection_grouped) ? margin.top : Math.min(sy, my),
maxY = (__data_selection_grouped) ? height : Math.max(sy, my);
sx = dragStart[0];
sy = dragStart[1];
mx = mouse[0];
my = mouse[1];
minX = Math.min(sx, mx);
maxX = Math.max(sx, mx);
minY = (__data_selection_grouped) ? margin.top : Math.min(sy, my);
maxY = (__data_selection_grouped) ? height : Math.max(sy, my);
main.select('.dragarea')
.attr('x', minX)
.attr('y', minY)
@ -1621,6 +1729,7 @@
}
function dragstart(mouse) {
if (hasArcType(c3.data.targets)) { return; }
if (! __data_selection_enabled) { return; } // do nothing if not selectable
dragStart = mouse;
main.select('.chart').append('rect')
@ -1631,6 +1740,7 @@
}
function dragend() {
if (hasArcType(c3.data.targets)) { return; }
if (! __data_selection_enabled) { return; } // do nothing if not selectable
main.select('.dragarea')
.transition().duration(100)
@ -1650,6 +1760,7 @@
var barX, barY, barW, barH;
var rectX, rectW;
var withY, withSubchart, withTransition, withUpdateXDomain;
var isPieChart;
var duration;
options = isDefined(options) ? options : {};
@ -1657,6 +1768,7 @@
withSubchart = isDefined(options.withSubchart) ? options.withSubchart : true;
withTransition = isDefined(options.withTransition) ? options.withTransition : true;
withUpdateXDomain = isDefined(options.withUpdateXDomain) ? options.withUpdateXDomain : false;
isPieChart = hasArcType(c3.data.targets);
duration = withTransition ? 250 : 0;
@ -1668,9 +1780,10 @@
y.domain(getYDomain('y'));
y2.domain(getYDomain('y2'));
main.select(".x.axis").transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : xAxis);
main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis);
main.select(".y2.axis").transition().call(yAxis2);
// axis
main.select(".x.axis").transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : xAxis).style("opacity", isPieChart ? 0 : 1);
main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis).style("opacity", isPieChart ? 0 : 1);
main.select(".y2.axis").transition().call(yAxis2).style("opacity", isPieChart ? 0 : 1);
// Update label position
main.select(".x.axis .-axis-x-label").attr("x", width);
@ -1763,7 +1876,7 @@
.remove();
// lines and cricles
main.selectAll('.-line')
main.selectAll('.chart-line').select('.-line')
.transition().duration(duration)
.attr("d", lineOnMain);
mainCircle = main.selectAll('.-circles').selectAll('.-circle')
@ -1780,6 +1893,35 @@
.attr("r", __point_r);
mainCircle.exit().remove();
// arc
main.selectAll('.chart-arc').select('.-arc')
.style("opacity", function (d) { return d === this._current ? 0 : 1; })
.transition().duration(duration)
.attrTween("d", function (d) {
var updated = updateAngle(d);
if (! updated) {
return function () { return "M 0 0"; };
}
/*
if (this._current === d) {
this._current = {
startAngle: Math.PI*2,
endAngle: Math.PI*2,
};
}
*/
var i = d3.interpolate(this._current, updated);
this._current = i(0);
return function (t) { return getArc(i(t), true); };
})
.style("opacity", 1);
main.selectAll('.chart-arc').select('text')
.attr("transform", transformForArcLable)
.attr("opacity", 0)
.transition().duration(duration)
.text(textForArcLable)
.attr("opacity", function (d) { return isArcType(d.data) ? 1 : 0; });
// subchart
if (__subchart_show) {
// reflect main chart to extent on subchart if zoomed
@ -1910,6 +2052,7 @@
// 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.select('.x.brush').selectAll('rect').attr('height', height2);
@ -1926,11 +2069,16 @@
}
function updateTargets(targets) {
var mainLineEnter, mainLineUpdate, mainBarEnter, mainBarUpdate;
var mainLineEnter, mainLineUpdate, mainBarEnter, mainBarUpdate, mainPieEnter, mainPieUpdate;
var contextLineEnter, contextLineUpdate, contextBarEnter, contextBarUpdate;
/*-- Main --*/
// Set data type if data.type is specified
if (__data_type) {
setTargetType(getTargetIds(targets).filter(function (id) { return ! (id in __data_types); }), __data_type);
}
//-- Bar --//
mainBarUpdate = main.select('.chart-bars')
.selectAll('.chart-bar')
@ -1972,6 +2120,36 @@
d.value = t.values[d.x].value;
});
});
// MEMO: can not keep same color...
//mainLineUpdate.exit().remove();
//-- Pie --//
mainPieUpdate = main.select('.chart-arcs')
.selectAll(".chart-arc")
.data(pie(targets));
mainPieEnter = mainPieUpdate.enter().append("g")
.attr("class", function (d) { return 'chart-arc target target-' + d.data.id; })
.style('opacity', 0);
mainPieEnter.append("path")
.attr("class", classArc)
.style("fill", function (d) { return color(d.data.id); })
.style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; })
.each(function (d) { this._current = d; })
.on('mouseover', function (d) {
expandArc(d.data.id);
focusLegend(d.data.id);
})
.on('mouseout', function (d) {
unexpandArc(d.data.id);
revertLegend();
});
mainPieEnter.append("text")
.attr("dy", ".35em")
.style("text-anchor", "middle")
.style("pointer-events", "none");
// MEMO: can not keep same color..., but not bad to update color in redraw
//mainPieUpdate.exit().remove();
/*-- Context --*/
@ -2039,6 +2217,17 @@
/*-- Draw Legend --*/
function focusLegend(id) {
d3.selectAll('.legend-item').filter(function (d) { return d !== id; })
.transition().duration(100)
.style('opacity', 0.3);
}
function revertLegend() {
d3.selectAll('.legend-item')
.transition().duration(100)
.style('opacity', 1);
}
function updateLegend(targets, options) {
var ids = getTargetIds(targets), l;
var padding = width / 2 - __legend_item_width * Object.keys(targets).length / 2;
@ -2058,15 +2247,11 @@
__legend_item_onclick(d);
})
.on('mouseover', function (d) {
d3.selectAll('.legend-item').filter(function (_d) { return _d !== d; })
.transition().duration(100)
.style('opacity', 0.3);
focusLegend(d);
c3.focus(d);
})
.on('mouseout', function () {
d3.selectAll('.legend-item')
.transition().duration(100)
.style('opacity', 1);
revertLegend();
c3.revert();
});
l.append('rect')
@ -2078,6 +2263,7 @@
.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; })
@ -2085,6 +2271,7 @@
.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; });
@ -2109,30 +2296,54 @@
function getTargetSelector(target) {
return isDefined(target) ? '.target-' + target : '.target';
}
function isNoneArc(d) {
return hasTarget(d.id);
}
function isArc(d) {
return 'data' in d && hasTarget(d.data.id);
}
c3.focus = function (target) {
var candidates = d3.selectAll(getTargetSelector(target)),
candidatesForNoneArc = candidates.filter(isNoneArc),
candidatesForArc = candidates.filter(isArc);
function focus(targets) {
targets.transition().duration(100).style('opacity', 1);
}
c3.defocus();
d3.selectAll(getTargetSelector(target))
.filter(function (d) { return hasTarget(d.id); })
.classed('focused', true)
.transition().duration(100)
.style('opacity', 1);
focus(candidatesForNoneArc.classed('focused', true));
focus(candidatesForArc);
if (hasArcType(c3.data.targets)) {
expandArc(target, true);
}
};
c3.defocus = function (target) {
d3.selectAll(getTargetSelector(target))
.filter(function (d) { return hasTarget(d.id); })
.classed('focused', false)
.transition().duration(100)
.style('opacity', 0.3);
var candidates = d3.selectAll(getTargetSelector(target)),
candidatesForNoneArc = candidates.filter(isNoneArc),
candidatesForArc = candidates.filter(isArc);
function defocus(targets) {
targets.transition().duration(100).style('opacity', 0.3);
}
defocus(candidatesForNoneArc.classed('focused', false));
defocus(candidatesForArc);
if (hasArcType(c3.data.targets)) {
unexpandArc(target);
}
};
c3.revert = function (target) {
d3.selectAll(getTargetSelector(target))
.filter(function (d) { return hasTarget(d.id); })
.classed('focused', false)
.transition().duration(100)
.style('opacity', 1);
var candidates = d3.selectAll(getTargetSelector(target)),
candidatesForNoneArc = candidates.filter(isNoneArc),
candidatesForArc = candidates.filter(isArc);
function revert(targets) {
targets.transition().duration(100).style('opacity', 1);
}
revert(candidatesForNoneArc.classed('focused', false));
revert(candidatesForArc);
if (hasArcType(c3.data.targets)) {
unexpandArc(target);
}
};
c3.show = function (target) {

154
c3.min.js vendored

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

Loading…
Cancel
Save