diff --git a/c3.js b/c3.js index 87c29d5..330e407 100644 --- a/c3.js +++ b/c3.js @@ -209,7 +209,7 @@ // text when empty main.append("text") - .attr("class", CLASS[_text] + ' ' + CLASS[_empty]) + .attr("class", CLASS.text + ' ' + CLASS.empty) .attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers. .attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE. @@ -222,7 +222,7 @@ // Define g for chart area main.append('g') .attr("clip-path", $$.clipPath) - .attr('class', CLASS[_chart]); + .attr('class', CLASS.chart); // Cover whole with rects for events $$.initEventRect(); @@ -242,8 +242,8 @@ // if zoom privileged, insert rect to forefront // TODO: is this needed? - main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS[_regions]) - .attr('class', CLASS[_zoomRect]) + main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS.regions) + .attr('class', CLASS.zoomRect) .attr('width', $$.width) .attr('height', $$.height) .style('opacity', 0) @@ -399,7 +399,7 @@ /*-- Show --*/ // Fade-in each chart - $$.svg.selectAll('.' + CLASS[_target]).filter(function (d) { return $$.isTargetToShow(d.id); }) + $$.svg.selectAll('.' + CLASS.target).filter(function (d) { return $$.isTargetToShow(d.id); }) .transition().duration(config.transition_duration) .style("opacity", 1); }; @@ -475,14 +475,14 @@ break; } } - $$.svg.selectAll('.' + CLASS[_axisX] + ' .tick text').each(function (e) { + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function (e) { var index = tickValues.indexOf(e); if (index >= 0) { d3.select(this).style('display', index % intervalForCulling ? 'none' : 'block'); } }); } else { - $$.svg.selectAll('.' + CLASS[_axisX] + ' .tick text').style('display', 'block'); + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').style('display', 'block'); } } @@ -509,7 +509,7 @@ $$.updateXgridFocus(); // Data empty label positioning and text. - main.select("text." + CLASS[_text] + '.' + CLASS[_empty]) + main.select("text." + CLASS.text + '.' + CLASS.empty) .attr("x", $$.width / 2) .attr("y", $$.height / 2) .text(config.data_empty_label_text) @@ -544,7 +544,7 @@ } // circles for select - main.selectAll('.' + CLASS[_selectedCircles]) + main.selectAll('.' + CLASS.selectedCircles) .filter($$.isBarType.bind($$)) .selectAll('circle') .remove(); @@ -696,26 +696,26 @@ if (transitions && transitions.axisX) { xAxis = transitions.axisX; } else { - xAxis = $$.main.select('.' + CLASS[_axisX]); + xAxis = $$.main.select('.' + CLASS.axisX); if (withTransition) { xAxis = xAxis.transition(); } } if (transitions && transitions.axisY) { yAxis = transitions.axisY; } else { - yAxis = $$.main.select('.' + CLASS[_axisY]); + yAxis = $$.main.select('.' + CLASS.axisY); if (withTransition) { yAxis = yAxis.transition(); } } if (transitions && transitions.axisY2) { y2Axis = transitions.axisY2; } else { - y2Axis = $$.main.select('.' + CLASS[_axisY2]); + y2Axis = $$.main.select('.' + CLASS.axisY2); if (withTransition) { y2Axis = y2Axis.transition(); } } (withTransition ? $$.main.transition() : $$.main).attr("transform", $$.getTranslate('main')); xAxis.attr("transform", $$.getTranslate('x')); yAxis.attr("transform", $$.getTranslate('y')); y2Axis.attr("transform", $$.getTranslate('y2')); - $$.main.select('.' + CLASS[_chartArcs]).attr("transform", $$.getTranslate('arc')); + $$.main.select('.' + CLASS.chartArcs).attr("transform", $$.getTranslate('arc')); }; c3_chart_internal_fn.transformAll = function (withTransition, transitions) { var $$ = this; @@ -740,7 +740,7 @@ .attr('y', $$.getYAxisClipY.bind($$)) .attr('width', $$.getYAxisClipWidth.bind($$)) .attr('height', $$.getYAxisClipHeight.bind($$)); - $$.svg.select('.' + CLASS[_zoomRect]) + $$.svg.select('.' + CLASS.zoomRect) .attr('width', $$.width) .attr('height', $$.height); // MEMO: parent div's height will be bigger than svg when @@ -1935,7 +1935,7 @@ $$.withoutFadeIn[id] = false; // Remove target's elements if ($$.legend) { - $$.legend.selectAll('.' + CLASS[_legendItem] + $$.getTargetSelectorSuffix(id)).remove(); + $$.legend.selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)).remove(); } // Remove target $$.data.targets = $$.data.targets.filter(function (t) { @@ -1950,27 +1950,27 @@ }; c3_chart_internal_fn.initEventRect = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_eventRects]) + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.eventRects) .style('fill-opacity', 0); }; c3_chart_internal_fn.redrawEventRect = function () { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, eventRectUpdate, maxDataCountTarget, isMultipleX = $$.isMultipleX(); // rects for mouseover - var eventRects = $$.main.select('.' + CLASS[_eventRects]) + var eventRects = $$.main.select('.' + CLASS.eventRects) .style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null) - .classed(CLASS[_eventRectsMultiple], isMultipleX) - .classed(CLASS[_eventRectsSingle], !isMultipleX); + .classed(CLASS.eventRectsMultiple, isMultipleX) + .classed(CLASS.eventRectsSingle, !isMultipleX); // clear old rects - eventRects.selectAll('.' + CLASS[_eventRect]).remove(); + eventRects.selectAll('.' + CLASS.eventRect).remove(); // open as public variable - $$.eventRect = eventRects.selectAll('.' + CLASS[_eventRect]); + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); if (isMultipleX) { eventRectUpdate = $$.eventRect.data([0]); @@ -1984,7 +1984,7 @@ // Set data and update $$.eventRect maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets); eventRects.datum(maxDataCountTarget ? maxDataCountTarget.values : []); - $$.eventRect = eventRects.selectAll('.' + CLASS[_eventRect]); + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); eventRectUpdate = $$.eventRect.data(function (d) { return d; }); // enter $$.generateEventRectsForSingleX(eventRectUpdate.enter()); @@ -2071,7 +2071,7 @@ $$.expandBars(index); // Call event handler - $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { config.data_onmouseover.call($$, d); }); }) @@ -2084,13 +2084,13 @@ $$.unexpandCircles(index); $$.unexpandBars(); // Call event handler - $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { config.data_onmouseout.call($$, d); }); }) .on('mousemove', function (d) { var selectedData, index = d.index, - eventRect = $$.svg.select('.' + CLASS[_eventRect] + '-' + index); + eventRect = $$.svg.select('.' + CLASS.eventRect + '-' + index); if ($$.dragging) { return; } // do nothing when dragging if ($$.hasArcType()) { return; } @@ -2109,9 +2109,9 @@ return; } - $$.main.selectAll('.' + CLASS[_shape] + '-' + index) + $$.main.selectAll('.' + CLASS.shape + '-' + index) .each(function () { - d3.select(this).classed(CLASS[_EXPANDED], true); + d3.select(this).classed(CLASS.EXPANDED, true); if (config.data_selection_enabled) { eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); } @@ -2151,7 +2151,7 @@ $$.cancelClick = false; return; } - $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { $$.toggleShape(this, d, index); }); }) @@ -2171,7 +2171,7 @@ .attr('y', 0) .attr('width', $$.width) .attr('height', $$.height) - .attr('class', CLASS[_eventRect]) + .attr('class', CLASS.eventRect) .on('mouseout', function () { if ($$.hasArcType()) { return; } $$.hideXGridFocus(); @@ -2213,13 +2213,13 @@ // Show cursor as pointer if point is close to mouse position if ($$.dist(closest, mouse) < 100) { - $$.svg.select('.' + CLASS[_eventRect]).style('cursor', 'pointer'); + $$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer'); if (!$$.mouseover) { config.data_onmouseover.call($$, closest); $$.mouseover = true; } } else if ($$.mouseover) { - $$.svg.select('.' + CLASS[_eventRect]).style('cursor', null); + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); config.data_onmouseout.call($$, closest); $$.mouseover = false; } @@ -2237,7 +2237,7 @@ // select if selection enabled if ($$.dist(closest, mouse) < 100 && $$.toggleShape) { - $$.main.select('.' + CLASS[_circles] + $$.getTargetSelectorSuffix(closest.id)).select('.' + CLASS[_circle] + '-' + closest.index).each(function () { + $$.main.select('.' + CLASS.circles + $$.getTargetSelectorSuffix(closest.id)).select('.' + CLASS.circle + '-' + closest.index).each(function () { $$.toggleShape(this, closest, closest.index); }); } @@ -2312,7 +2312,7 @@ c3_chart_internal_fn.getSvgLeft = function () { var $$ = this, config = $$.config, - leftAxisClass = config.axis_rotated ? CLASS[_axisX] : CLASS[_axisY], + leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY, leftAxis = $$.main.select('.' + leftAxisClass).node(), svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0}, chartRect = $$.selectChart.node().getBoundingClientRect(), @@ -2408,18 +2408,18 @@ }; c3_chart_internal_fn.initLine = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartLines]); + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartLines); }; c3_chart_internal_fn.updateTargetsForLine = function (targets) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, mainLineUpdate, mainLineEnter, classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$), classCircles = $$.classCircles.bind($$); - mainLineUpdate = $$.main.select('.' + CLASS[_chartLines]).selectAll('.' + CLASS[_chartLine]) + mainLineUpdate = $$.main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) .data(targets) .attr('class', classChartLine); mainLineEnter = mainLineUpdate.enter().append('g') @@ -2434,13 +2434,13 @@ .attr('class', classAreas); // Circles for each data point on lines mainLineEnter.append('g') - .attr("class", function (d) { return $$.generateClass(CLASS[_selectedCircles], d.id); }); + .attr("class", function (d) { return $$.generateClass(CLASS.selectedCircles, d.id); }); mainLineEnter.append('g') .attr("class", classCircles) .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); // Update date for selected circles targets.forEach(function (t) { - $$.main.selectAll('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS[_selectedCircle]).each(function (d) { + $$.main.selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS.selectedCircle).each(function (d) { d.value = t.values[d.index].value; }); }); @@ -2448,8 +2448,8 @@ //mainLineUpdate.exit().remove(); }; c3_chart_internal_fn.redrawLine = function (durationForExit) { - var $$ = this, CLASS = $$.CLASS; - $$.mainLine = $$.main.selectAll('.' + CLASS[_lines]).selectAll('.' + CLASS[_line]) + var $$ = this; + $$.mainLine = $$.main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) .data($$.lineData.bind($$)); $$.mainLine.enter().append('path') .attr('class', $$.classLine.bind($$)) @@ -2603,8 +2603,8 @@ c3_chart_internal_fn.redrawArea = function (durationForExit) { - var $$ = this, CLASS = $$.CLASS, d3 = $$.d3; - $$.mainArea = $$.main.selectAll('.' + CLASS[_areas]).selectAll('.' + CLASS[_area]) + var $$ = this, d3 = $$.d3; + $$.mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) .data($$.lineData.bind($$)); $$.mainArea.enter().append('path') .attr("class", $$.classArea.bind($$)) @@ -2680,8 +2680,8 @@ c3_chart_internal_fn.redrawCircle = function () { - var $$ = this, CLASS = $$.CLASS; - $$.mainCircle = $$.main.selectAll('.' + CLASS[_circles]).selectAll('.' + CLASS[_circle]) + var $$ = this; + $$.mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle) .data($$.lineOrScatterData.bind($$)); $$.mainCircle.enter().append("circle") .attr("class", $$.classCircle.bind($$)) @@ -2698,7 +2698,7 @@ .style("fill", $$.color) .attr("cx", cx) .attr("cy", cy)); - transitions.push($$.main.selectAll('.' + CLASS[_selectedCircle]).transition() + transitions.push($$.main.selectAll('.' + CLASS.selectedCircle).transition() .attr("cx", cx) .attr("cy", cy)); }; @@ -2712,21 +2712,21 @@ }; c3_chart_internal_fn.getCircles = function (i, id) { var $$ = this; - return (id ? $$.main.selectAll('.' + CLASS[_circles] + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS[_circle] + (isValue(i) ? '-' + i : '')); + return (id ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); }; c3_chart_internal_fn.expandCircles = function (i, id) { var $$ = this, r = $$.pointExpandedR.bind($$); $$.getCircles(i, id) - .classed(CLASS[_EXPANDED], true) + .classed(CLASS.EXPANDED, true) .attr('r', r); }; c3_chart_internal_fn.unexpandCircles = function (i) { var $$ = this, r = $$.pointR.bind($$); $$.getCircles(i) - .filter(function () { return $$.d3.select(this).classed(CLASS[_EXPANDED]); }) - .classed(CLASS[_EXPANDED], false) + .filter(function () { return $$.d3.select(this).classed(CLASS.EXPANDED); }) + .classed(CLASS.EXPANDED, false) .attr('r', r); }; c3_chart_internal_fn.pointR = function (d) { @@ -2749,16 +2749,16 @@ }; c3_chart_internal_fn.initBar = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartBars]); + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartBars); }; c3_chart_internal_fn.updateTargetsForBar = function (targets) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, mainBarUpdate, mainBarEnter, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$); - mainBarUpdate = $$.main.select('.' + CLASS[_chartBars]).selectAll('.' + CLASS[_chartBar]) + mainBarUpdate = $$.main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) .data(targets) .attr('class', classChartBar); mainBarEnter = mainBarUpdate.enter().append('g') @@ -2772,12 +2772,12 @@ }; c3_chart_internal_fn.redrawBar = function (durationForExit) { - var $$ = this, CLASS = $$.CLASS, + var $$ = this, barData = $$.barData.bind($$), classBar = $$.classBar.bind($$), initialOpacity = $$.initialOpacity.bind($$), color = function (d) { return $$.color(d.id); }; - $$.mainBar = $$.main.selectAll('.' + CLASS[_bars]).selectAll('.' + CLASS[_bar]) + $$.mainBar = $$.main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) .data(barData); $$.mainBar.enter().append('path') .attr("class", classBar) @@ -2803,15 +2803,15 @@ }; c3_chart_internal_fn.getBars = function (i) { var $$ = this; - return $$.main.selectAll('.' + CLASS[_bar] + (isValue(i) ? '-' + i : '')); + return $$.main.selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); }; c3_chart_internal_fn.expandBars = function (i) { var $$ = this; - $$.getBars(i).classed(CLASS[_EXPANDED], true); + $$.getBars(i).classed(CLASS.EXPANDED, true); }; c3_chart_internal_fn.unexpandBars = function (i) { var $$ = this; - $$.getBars(i).classed(CLASS[_EXPANDED], false); + $$.getBars(i).classed(CLASS.EXPANDED, false); }; c3_chart_internal_fn.generateDrawBar = function (barIndices, isSub) { var $$ = this, config = $$.config, @@ -2868,16 +2868,16 @@ }; c3_chart_internal_fn.initText = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartTexts]); + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartTexts); $$.mainText = $$.d3.selectAll([]); }; c3_chart_internal_fn.updateTargetsForText = function (targets) { - var $$ = this, CLASS = $$.CLASS, mainTextUpdate, mainTextEnter, + var $$ = this, mainTextUpdate, mainTextEnter, classChartText = $$.classChartText.bind($$), classTexts = $$.classTexts.bind($$); - mainTextUpdate = $$.main.select('.' + CLASS[_chartTexts]).selectAll('.' + CLASS[_chartText]) + mainTextUpdate = $$.main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText) .data(targets) .attr('class', classChartText); mainTextEnter = mainTextUpdate.enter().append('g') @@ -2888,10 +2888,10 @@ .attr('class', classTexts); }; c3_chart_internal_fn.redrawText = function (durationForExit) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, barOrLineData = $$.barOrLineData.bind($$), classText = $$.classText.bind($$); - $$.mainText = $$.main.selectAll('.' + CLASS[_texts]).selectAll('.' + CLASS[_text]) + $$.mainText = $$.main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text) .data(barOrLineData); $$.mainText.enter().append('text') .attr("class", classText) @@ -3039,30 +3039,30 @@ }; c3_chart_internal_fn.initGrid = function () { - var $$ = this, config = $$.config, CLASS = $$.CLASS, d3 = $$.d3; + var $$ = this, config = $$.config, d3 = $$.d3; $$.grid = $$.main.append('g') .attr("clip-path", $$.clipPath) - .attr('class', CLASS[_grid]); + .attr('class', CLASS.grid); if (config.grid_x_show) { - $$.grid.append("g").attr("class", CLASS[_xgrids]); + $$.grid.append("g").attr("class", CLASS.xgrids); } if (config.grid_y_show) { - $$.grid.append('g').attr('class', CLASS[_ygrids]); + $$.grid.append('g').attr('class', CLASS.ygrids); } - $$.grid.append('g').attr("class", CLASS[_xgridLines]); - $$.grid.append('g').attr('class', CLASS[_ygridLines]); + $$.grid.append('g').attr("class", CLASS.xgridLines); + $$.grid.append('g').attr('class', CLASS.ygridLines); if (config.grid_focus_show) { $$.grid.append('g') - .attr("class", CLASS[_xgridFocus]) + .attr("class", CLASS.xgridFocus) .append('line') - .attr('class', CLASS[_xgridFocus]); + .attr('class', CLASS.xgridFocus); } $$.xgrid = d3.selectAll([]); $$.xgridLines = d3.selectAll([]); }; c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, d3 = $$.d3, + var $$ = this, config = $$.config, d3 = $$.d3, xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; @@ -3078,9 +3078,9 @@ 'y2': $$.height }; - $$.xgrid = $$.main.select('.' + CLASS[_xgrids]).selectAll('.' + CLASS[_xgrid]) + $$.xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid) .data(xgridData); - $$.xgrid.enter().append('line').attr("class", CLASS[_xgrid]); + $$.xgrid.enter().append('line').attr("class", CLASS.xgrid); if (!withoutUpdate) { $$.xgrid.attr($$.xgridAttr) .style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; }); @@ -3089,11 +3089,11 @@ }; c3_chart_internal_fn.updateYGrid = function () { - var $$ = this, config = $$.config, CLASS = $$.CLASS; - $$.ygrid = $$.main.select('.' + CLASS[_ygrids]).selectAll('.' + CLASS[_ygrid]) + var $$ = this, config = $$.config; + $$.ygrid = $$.main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid) .data($$.y.ticks(config.grid_y_ticks)); $$.ygrid.enter().append('line') - .attr('class', CLASS[_ygrid]); + .attr('class', CLASS.ygrid); $$.ygrid.attr("x1", config.axis_rotated ? $$.y : 0) .attr("x2", config.axis_rotated ? $$.y : $$.width) .attr("y1", config.axis_rotated ? 0 : $$.y) @@ -3104,17 +3104,17 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) { - var $$ = this, main = $$.main, config = $$.config, CLASS = $$.CLASS, + var $$ = this, main = $$.main, config = $$.config, xgridLine, ygridLine, yv; - main.select('line.' + CLASS[_xgridFocus]).style("visibility", "hidden"); + main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); if (config.grid_x_show) { $$.updateXGrid(); } - $$.xgridLines = main.select('.' + CLASS[_xgridLines]).selectAll('.' + CLASS[_xgridLine]) + $$.xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine) .data(config.grid_x_lines); // enter xgridLine = $$.xgridLines.enter().append('g') - .attr("class", function (d) { return CLASS[_xgridLine] + (d.class ? ' ' + d.class : ''); }); + .attr("class", function (d) { return CLASS.xgridLine + (d.class ? ' ' + d.class : ''); }); xgridLine.append('line') .style("opacity", 0); xgridLine.append('text') @@ -3135,11 +3135,11 @@ $$.updateYGrid(); } if (withY) { - $$.ygridLines = main.select('.' + CLASS[_ygridLines]).selectAll('.' + CLASS[_ygridLine]) + $$.ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine) .data(config.grid_y_lines); // enter ygridLine = $$.ygridLines.enter().append('g') - .attr("class", function (d) { return CLASS[_ygridLine] + (d.class ? ' ' + d.class : ''); }); + .attr("class", function (d) { return CLASS.ygridLine + (d.class ? ' ' + d.class : ''); }); ygridLine.append('line') .style("opacity", 0); ygridLine.append('text') @@ -3186,7 +3186,7 @@ c3_chart_internal_fn.showXGridFocus = function (selectedData) { var $$ = this, config = $$.config, dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }), - focusEl = $$.main.selectAll('line.' + CLASS[_xgridFocus]), + focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus), xx = $$.xx.bind($$); if (! config.tooltip_show) { return; } // Hide when scatter plot exists @@ -3199,11 +3199,11 @@ $$.smoothLines(focusEl, 'grid'); }; c3_chart_internal_fn.hideXGridFocus = function () { - this.main.select('line.' + CLASS[_xgridFocus]).style("visibility", "hidden"); + this.main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); }; c3_chart_internal_fn.updateXgridFocus = function () { var $$ = this, config = $$.config; - $$.main.select('line.' + CLASS[_xgridFocus]) + $$.main.select('line.' + CLASS.xgridFocus) .attr("x1", config.axis_rotated ? 0 : -10) .attr("x2", config.axis_rotated ? $$.width : -10) .attr("y1", config.axis_rotated ? -10 : 0) @@ -3212,7 +3212,7 @@ c3_chart_internal_fn.generateGridData = function (type, scale) { var $$ = this, gridData = [], xDomain, firstYear, lastYear, i, - tickNum = $$.main.select("." + CLASS[_axisX]).selectAll('.tick').size(); + tickNum = $$.main.select("." + CLASS.axisX).selectAll('.tick').size(); if (type === 'year') { xDomain = $$.getXDomain(); firstYear = xDomain[0].getFullYear(); @@ -3243,8 +3243,8 @@ var $$ = this, config = $$.config, toRemove = $$.getGridFilterToRemove(params), toShow = function (line) { return !toRemove(line); }, - classLines = forX ? CLASS[_xgridLines] : CLASS[_ygridLines], - classLine = forX ? CLASS[_xgridLine] : CLASS.ygridLine; + classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, + classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; $$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove) .transition().duration(config.transition_duration) .style('opacity', 0).remove(); @@ -3292,14 +3292,14 @@ if (! text) { title = titleFormat ? titleFormat(d[i].x) : d[i].x; - text = "" + (title || title === 0 ? "" : ""); + text = "
" + title + "
" + (title || title === 0 ? "" : ""); } name = nameFormat(d[i].name); value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index); bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); - text += ""; + text += ""; text += ""; text += ""; text += ""; @@ -3409,15 +3409,15 @@ }; c3_chart_internal_fn.opacityForLegend = function (legendItem) { var $$ = this; - return legendItem.classed(CLASS[_legendItemHidden]) ? $$.legendOpacityForHidden : 1; + return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 1; }; c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { var $$ = this; - return legendItem.classed(CLASS[_legendItemHidden]) ? $$.legendOpacityForHidden : 0.3; + return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 0.3; }; c3_chart_internal_fn.toggleFocusLegend = function (id, focus) { var $$ = this; - $$.legend.selectAll('.' + CLASS[_legendItem]) + $$.legend.selectAll('.' + CLASS.legendItem) .transition().duration(100) .style('opacity', function (_id) { var This = $$.d3.select(this); @@ -3430,7 +3430,7 @@ }; c3_chart_internal_fn.revertLegend = function () { var $$ = this, d3 = $$.d3; - $$.legend.selectAll('.' + CLASS[_legendItem]) + $$.legend.selectAll('.' + CLASS.legendItem) .transition().duration(100) .style('opacity', function () { return $$.opacityForLegend(d3.select(this)); }); }; @@ -3463,7 +3463,7 @@ var paddingTop = 4, paddingRight = 36, maxWidth = 0, maxHeight = 0, posMin = 10; var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; var withTransition, withTransitionForTransform; - var hasFocused = $$.legend.selectAll('.' + CLASS[_legendItemFocused]).size(); + var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size(); var texts, rects, tiles; options = options || {}; @@ -3471,7 +3471,7 @@ withTransitionForTransform = getOption(options, "withTransitionForTransform", true); function updatePositions(textElement, id, reset) { - var box = $$.getTextRect(textElement.textContent, CLASS[_legendItem]), + var box = $$.getTextRect(textElement.textContent, CLASS.legendItem), itemWidth = Math.ceil((box.width + paddingRight) / 10) * 10, itemHeight = Math.ceil((box.height + paddingTop) / 10) * 10, itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, @@ -3546,17 +3546,17 @@ yForLegendRect = function (id, i) { return yForLegend(id, i) - 7; }; // Define g for legend area - l = $$.legend.selectAll('.' + CLASS[_legendItem]) + l = $$.legend.selectAll('.' + CLASS.legendItem) .data(targetIds) .enter().append('g') - .attr('class', function (id) { return $$.generateClass(CLASS[_legendItem], id); }) + .attr('class', function (id) { return $$.generateClass(CLASS.legendItem, id); }) .style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; }) .style('cursor', 'pointer') .on('click', function (id) { config.legend_item_onclick ? config.legend_item_onclick.call($$, id) : $$.api.toggle(id); }) .on('mouseover', function (id) { - $$.d3.select(this).classed(CLASS[_legendItemFocused], true); + $$.d3.select(this).classed(CLASS.legendItemFocused, true); if (!$$.transiting) { $$.api.focus(id); } @@ -3565,7 +3565,7 @@ } }) .on('mouseout', function (id) { - $$.d3.select(this).classed(CLASS[_legendItemFocused], false); + $$.d3.select(this).classed(CLASS.legendItemFocused, false); if (!$$.transiting) { $$.api.revert(); } @@ -3580,12 +3580,12 @@ .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); l.append('rect') - .attr("class", CLASS[_legendItemEvent]) + .attr("class", CLASS.legendItemEvent) .style('fill-opacity', 0) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); l.append('rect') - .attr("class", CLASS[_legendItemTile]) + .attr("class", CLASS.legendItemTile) .style("pointer-events", "none") .style('fill', $$.color) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) @@ -3594,8 +3594,8 @@ .attr('height', 10); // Set background for inset legend if ($$.isLegendInset && maxWidth !== 0) { - $$.legend.insert('g', '.' + CLASS[_legendItem]) - .attr("class", CLASS[_legendBackground]) + $$.legend.insert('g', '.' + CLASS.legendItem) + .attr("class", CLASS.legendBackground) .append('rect') .attr('height', $$.getLegendHeight() - 10) .attr('width', maxWidth * (step + 1) + 10); @@ -3609,7 +3609,7 @@ .attr('x', xForLegendText) .attr('y', yForLegendText); - rects = $$.legend.selectAll('rect.' + CLASS[_legendItemEvent]) + rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent) .data(targetIds); (withTransition ? rects.transition() : rects) .attr('width', function (id) { return widths[id]; }) @@ -3617,7 +3617,7 @@ .attr('x', xForLegendRect) .attr('y', yForLegendRect); - tiles = $$.legend.selectAll('rect.' + CLASS[_legendItemTile]) + tiles = $$.legend.selectAll('rect.' + CLASS.legendItemTile) .data(targetIds); (withTransition ? tiles.transition() : tiles) .style('fill', $$.color) @@ -3625,13 +3625,13 @@ .attr('y', yForLegend); // toggle legend state - $$.legend.selectAll('.' + CLASS[_legendItem]) - .classed(CLASS[_legendItemHidden], function (id) { return !$$.isTargetToShow(id); }) + $$.legend.selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemHidden, function (id) { return !$$.isTargetToShow(id); }) .transition() .style('opacity', function (id) { var This = $$.d3.select(this); if ($$.isTargetToShow(id)) { - return !hasFocused || This.classed(CLASS[_legendItemFocused]) ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This); + return !hasFocused || This.classed(CLASS.legendItemFocused) ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This); } else { return $$.legendOpacityForHidden; } @@ -3650,34 +3650,34 @@ }; c3_chart_internal_fn.initAxis = function () { - var $$ = this, config = $$.config, main = $$.main, CLASS = $$.CLASS; + var $$ = this, config = $$.config, main = $$.main; $$.axes.x = main.append("g") - .attr("class", CLASS[_axis] + ' ' + CLASS[_axisX]) + .attr("class", CLASS.axis + ' ' + CLASS.axisX) .attr("clip-path", $$.clipPathForXAxis) .attr("transform", $$.getTranslate('x')) .style("visibility", config.axis_x_show ? 'visible' : 'hidden'); $$.axes.x.append("text") - .attr("class", CLASS[_axisXLabel]) + .attr("class", CLASS.axisXLabel) .attr("transform", config.axis_rotated ? "rotate(-90)" : "") .style("text-anchor", $$.textAnchorForXAxisLabel.bind($$)); $$.axes.y = main.append("g") - .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY]) + .attr("class", CLASS.axis + ' ' + CLASS.axisY) .attr("clip-path", $$.clipPathForYAxis) .attr("transform", $$.getTranslate('y')) .style("visibility", config.axis_y_show ? 'visible' : 'hidden'); $$.axes.y.append("text") - .attr("class", CLASS[_axisYLabel]) + .attr("class", CLASS.axisYLabel) .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForYAxisLabel.bind($$)); $$.axes.y2 = main.append("g") - .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY2]) + .attr("class", CLASS.axis + ' ' + CLASS.axisY2) // clip-path? .attr("transform", $$.getTranslate('y2')) .style("visibility", config.axis_y2_show ? 'visible' : 'hidden'); $$.axes.y2.append("text") - .attr("class", CLASS[_axisY2Label]) + .attr("class", CLASS.axisY2Label) .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForY2AxisLabel.bind($$)); }; @@ -3912,9 +3912,9 @@ c3_chart_internal_fn.updateAxisLabels = function (withTransition) { var $$ = this; - var axisXLabel = $$.main.select('.' + CLASS[_axisX] + ' .' + CLASS[_axisXLabel]), - axisYLabel = $$.main.select('.' + CLASS[_axisY] + ' .' + CLASS[_axisYLabel]), - axisY2Label = $$.main.select('.' + CLASS[_axisY2] + ' .' + CLASS[_axisY2Label]); + var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), + axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), + axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label); (withTransition ? axisXLabel.transition() : axisXLabel) .attr("x", $$.xForXAxisLabel.bind($$)) .attr("dx", $$.dxForXAxisLabel.bind($$)) @@ -4160,8 +4160,8 @@ c3_chart_internal_fn.expandArc = function (id, withoutFadeOut) { var $$ = this, - target = $$.svg.selectAll('.' + CLASS[_chartArc] + $$.selectorTarget(id)), - noneTargets = $$.svg.selectAll('.' + CLASS[_arc]).filter(function (data) { return data.data.id !== id; }); + target = $$.svg.selectAll('.' + CLASS.chartArc + $$.selectorTarget(id)), + noneTargets = $$.svg.selectAll('.' + CLASS.arc).filter(function (data) { return data.data.id !== id; }); if ($$.shouldExpand(id)) { target.selectAll('path') @@ -4182,11 +4182,11 @@ c3_chart_internal_fn.unexpandArc = function (id) { var $$ = this, - target = $$.svg.selectAll('.' + CLASS[_chartArc] + $$.selectorTarget(id)); - target.selectAll('path.' + CLASS[_arc]) + target = $$.svg.selectAll('.' + CLASS.chartArc + $$.selectorTarget(id)); + target.selectAll('path.' + CLASS.arc) .transition().duration(50) .attr("d", $$.svgArc); - $$.svg.selectAll('.' + CLASS[_arc]) + $$.svg.selectAll('.' + CLASS.arc) .style("opacity", 1); }; @@ -4237,7 +4237,7 @@ mainPieUpdate, mainPieEnter, classChartArc = $$.classChartArc.bind($$), classArcs = $$.classArcs.bind($$); - mainPieUpdate = main.select('.' + CLASS[_chartArcs]).selectAll('.' + CLASS[_chartArc]) + mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc) .data($$.pie(targets)) .attr("class", classChartArc); mainPieEnter = mainPieUpdate.enter().append("g") @@ -4255,11 +4255,11 @@ c3_chart_internal_fn.initArc = function () { var $$ = this; - $$.arcs = $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartArcs]) + $$.arcs = $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartArcs) .attr("transform", $$.getTranslate('arc')); $$.arcs.append('text') - .attr('class', CLASS[_chartArcsTitle]) + .attr('class', CLASS.chartArcsTitle) .style("text-anchor", "middle") .text($$.getArcTitle()); }; @@ -4267,7 +4267,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransform) { var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, mainArc; - mainArc = main.selectAll('.' + CLASS[_arcs]).selectAll('.' + CLASS[_arc]) + mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) .data($$.arcData.bind($$)); mainArc.enter().append('path') .attr("class", $$.classArc.bind($$)) @@ -4354,14 +4354,14 @@ mainArc.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); - main.selectAll('.' + CLASS[_chartArc]).select('text') + main.selectAll('.' + CLASS.chartArc).select('text') .style("opacity", 0) - .attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS[_gaugeValue] : ''; }) + .attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS.gaugeValue : ''; }) .text($$.textForArcLabel.bind($$)) .attr("transform", $$.transformForArcLabel.bind($$)) .transition().duration(duration) .style("opacity", function (d) { return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0; }); - main.select('.' + CLASS[_chartArcsTitle]) + main.select('.' + CLASS.chartArcsTitle) .style("opacity", $$.hasType('donut') || $$.hasType('gauge') ? 1 : 0); }; @@ -4369,7 +4369,7 @@ var $$ = this, config = $$.config, arcs = $$.arcs; if ($$.hasType('gauge')) { arcs.append('path') - .attr("class", CLASS[_chartArcsBackground]) + .attr("class", CLASS.chartArcsBackground) .attr("d", function () { var d = { data: [{value: config.gauge_max}], @@ -4380,21 +4380,21 @@ }); arcs.append("text") .attr("dy", ".75em") - .attr("class", CLASS[_chartArcsGaugeUnit]) + .attr("class", CLASS.chartArcsGaugeUnit) .style("text-anchor", "middle") .style("pointer-events", "none") .text(config.gauge_label_show ? config.gauge_units : ''); arcs.append("text") .attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / 2)) + "px") .attr("dy", "1.2em") - .attr("class", CLASS[_chartArcsGaugeMin]) + .attr("class", CLASS.chartArcsGaugeMin) .style("text-anchor", "middle") .style("pointer-events", "none") .text(config.gauge_label_show ? config.gauge_min : ''); arcs.append("text") .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px") .attr("dy", "1.2em") - .attr("class", CLASS[_chartArcsGaugeMax]) + .attr("class", CLASS.chartArcsGaugeMax) .style("text-anchor", "middle") .style("pointer-events", "none") .text(config.gauge_label_show ? config.gauge_max : ''); @@ -4402,14 +4402,14 @@ }; c3_chart_internal_fn.initRegion = function () { - var $$ = this, CLASS = $$.CLASS; + var $$ = this; $$.main.append('g') .attr("clip-path", $$.clipPath) - .attr("class", CLASS[_regions]); + .attr("class", CLASS.regions); }; c3_chart_internal_fn.redrawRegion = function (duration) { - var $$ = this, config = $$.config, CLASS = $$.CLASS; - $$.mainRegion = $$.main.select('.' + CLASS[_regions]).selectAll('.' + CLASS[_region]) + var $$ = this, config = $$.config; + $$.mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region) .data(config.regions); $$.mainRegion.enter().append('g') .attr('class', $$.classRegion.bind($$)) @@ -4494,26 +4494,26 @@ minY = (config.data_selection_grouped) ? $$.margin.top : Math.min(sy, my); maxY = (config.data_selection_grouped) ? $$.height : Math.max(sy, my); - main.select('.' + CLASS[_dragarea]) + main.select('.' + CLASS.dragarea) .attr('x', minX) .attr('y', minY) .attr('width', maxX - minX) .attr('height', maxY - minY); // TODO: binary search when multiple xs - main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]) + main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape) .filter(function (d) { return config.data_selection_isselectable(d); }) .each(function (d, i) { var shape = d3.select(this), - isSelected = shape.classed(CLASS[_SELECTED]), - isIncluded = shape.classed(CLASS[_INCLUDED]), + isSelected = shape.classed(CLASS.SELECTED), + isIncluded = shape.classed(CLASS.INCLUDED), _x, _y, _w, _h, toggle, isWithin = false, box; - if (shape.classed(CLASS[_circle])) { + if (shape.classed(CLASS.circle)) { _x = shape.attr("cx") * 1; _y = shape.attr("cy") * 1; toggle = $$.togglePoint; isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; } - else if (shape.classed(CLASS[_bar])) { + else if (shape.classed(CLASS.bar)) { box = getPathBox(this); _x = box.x; _y = box.y; @@ -4526,9 +4526,9 @@ return; } if (isWithin ^ isIncluded) { - shape.classed(CLASS[_INCLUDED], !isIncluded); + shape.classed(CLASS.INCLUDED, !isIncluded); // TODO: included/unincluded callback here - shape.classed(CLASS[_SELECTED], !isSelected); + shape.classed(CLASS.SELECTED, !isSelected); toggle.call($$, !isSelected, shape, d, i); } }); @@ -4539,8 +4539,8 @@ if ($$.hasArcType()) { return; } if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.dragStart = mouse; - $$.main.select('.' + CLASS[_chart]).append('rect') - .attr('class', CLASS[_dragarea]) + $$.main.select('.' + CLASS.chart).append('rect') + .attr('class', CLASS.dragarea) .style('opacity', 0.1); $$.dragging = true; $$.config.data_ondragstart(); @@ -4550,12 +4550,12 @@ var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } if (! config.data_selection_enabled) { return; } // do nothing if not selectable - $$.main.select('.' + CLASS[_dragarea]) + $$.main.select('.' + CLASS.dragarea) .transition().duration(100) .style('opacity', 0) .remove(); - $$.main.selectAll('.' + CLASS[_shape]) - .classed(CLASS[_INCLUDED], false); + $$.main.selectAll('.' + CLASS.shape) + .classed(CLASS.INCLUDED, false); $$.dragging = false; $$.config.data_ondragend(); }; @@ -4568,10 +4568,10 @@ r = $$.pointSelectR.bind($$); config.data_onselected.call($$.api, d, target.node()); // add selected-circle on low layer g - $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) + $$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) .data([d]) .enter().append('circle') - .attr("class", function () { return $$.generateClass(CLASS[_selectedCircle], i); }) + .attr("class", function () { return $$.generateClass(CLASS.selectedCircle, i); }) .attr("cx", cx) .attr("cy", cy) .attr("stroke", function () { return $$.color(d); }) @@ -4583,7 +4583,7 @@ var $$ = this; $$.config.data_onunselected(d, target.node()); // remove selected-circle from low layer g - $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) + $$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) .transition().duration(100).attr('r', 0) .remove(); }; @@ -4611,17 +4611,17 @@ c3_chart_internal_fn.getToggle = function (that) { var $$ = this; // path selection not supported yet - return that.nodeName === 'circle' ? $$.togglePoint : ($$.d3.select(that).classed(CLASS[_bar]) ? $$.toggleBar : $$.toggleArc); + return that.nodeName === 'circle' ? $$.togglePoint : ($$.d3.select(that).classed(CLASS.bar) ? $$.toggleBar : $$.toggleArc); }; c3_chart_internal_fn.toggleShape = function (that, d, i) { var $$ = this, d3 = $$.d3, config = $$.config, - shape = d3.select(that), isSelected = shape.classed(CLASS[_SELECTED]), isWithin, toggle; + shape = d3.select(that), isSelected = shape.classed(CLASS.SELECTED), isWithin, toggle; if (that.nodeName === 'circle') { isWithin = $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); toggle = $$.togglePoint; } else if (that.nodeName === 'path') { - if (shape.classed(CLASS[_bar])) { + if (shape.classed(CLASS.bar)) { isWithin = $$.isWithinBar(that); toggle = $$.toggleBar; } else { // would be arc @@ -4632,12 +4632,12 @@ if (config.data_selection_grouped || isWithin) { if (config.data_selection_enabled && config.data_selection_isselectable(d)) { if (!config.data_selection_multiple) { - $$.main.selectAll('.' + CLASS[_shapes] + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) { + $$.main.selectAll('.' + CLASS.shapes + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this); - if (shape.classed(CLASS[_SELECTED])) { toggle.call($$, false, shape.classed(CLASS[_SELECTED], false), d, i); } + if (shape.classed(CLASS.SELECTED)) { toggle.call($$, false, shape.classed(CLASS.SELECTED, false), d, i); } }); } - shape.classed(CLASS[_SELECTED], !isSelected); + shape.classed(CLASS.SELECTED, !isSelected); toggle.call($$, !isSelected, shape, d, i); } $$.config.data_onclick.call($$.api, d, that); @@ -4648,7 +4648,7 @@ var $$ = this, d3 = $$.d3; $$.brush = d3.svg.brush().on("brush", function () { $$.redrawForBrush(); }); $$.brush.update = function () { - if ($$.context) { $$.context.select('.' + $$.CLASS[_brush]).call(this); } + if ($$.context) { $$.context.select('.' + CLASS.brush).call(this); } return this; }; $$.brush.scale = function (scale) { @@ -4666,20 +4666,20 @@ // Define g for chart area context.append('g') .attr("clip-path", $$.clipPath) - .attr('class', CLASS[_chart]); + .attr('class', CLASS.chart); // Define g for bar chart area - context.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartBars]); + context.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartBars); // Define g for line chart area - context.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartLines]); + context.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartLines); // Add extent rect for Brush context.append("g") .attr("clip-path", $$.clipPath) - .attr("class", CLASS[_brush]) + .attr("class", CLASS.brush) .call($$.brush) .selectAll("rect") .attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? $$.width2 : $$.height2); @@ -4687,7 +4687,7 @@ // ATTENTION: This must be called AFTER chart added // Add Axis $$.axes.subx = context.append("g") - .attr("class", CLASS[_axisX]) + .attr("class", CLASS.axisX) .attr("transform", $$.getTranslate('subx')) .attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis); }; @@ -4701,7 +4701,7 @@ classAreas = $$.classAreas.bind($$); if (config.subchart_show) { - contextBarUpdate = context.select('.' + CLASS[_chartBars]).selectAll('.' + CLASS[_chartBar]) + contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) .data(targets) .attr('class', classChartBar); contextBarEnter = contextBarUpdate.enter().append('g') @@ -4712,7 +4712,7 @@ .attr("class", classBars); //-- Line --// - contextLineUpdate = context.select('.' + CLASS[_chartLines]).selectAll('.' + CLASS[_chartLine]) + contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) .data(targets) .attr('class', classChartLine); contextLineEnter = contextLineUpdate.enter().append('g') @@ -4759,7 +4759,7 @@ drawBarOnSub = $$.generateDrawBar(barIndices, true); drawLineOnSub = $$.generateDrawLine(lineIndices, true); // bars - contextBar = context.selectAll('.' + CLASS[_bars]).selectAll('.' + CLASS[_bar]) + contextBar = context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) .data(barData); contextBar.enter().append('path') .attr("class", classBar) @@ -4774,7 +4774,7 @@ .style('opacity', 0) .remove(); // lines - contextLine = context.selectAll('.' + CLASS[_lines]).selectAll('.' + CLASS[_line]) + contextLine = context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) .data(lineData); contextLine.enter().append('path') .attr('class', classLine) @@ -4788,7 +4788,7 @@ .style('opacity', 0) .remove(); // area - contextArea = context.selectAll('.' + CLASS[_areas]).selectAll('.' + CLASS[_area]) + contextArea = context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) .data(lineData); contextArea.enter().append('path') .attr("class", classArea) @@ -4821,7 +4821,7 @@ if (transitions && transitions.axisSubX) { subXAxis = transitions.axisSubX; } else { - subXAxis = $$.context.select('.' + CLASS[_axisX]); + subXAxis = $$.context.select('.' + CLASS.axisX); if (withTransition) { subXAxis = subXAxis.transition(); } } $$.context.attr("transform", $$.getTranslate('context')); @@ -4851,8 +4851,8 @@ }; c3_chart_internal_fn.updateZoom = function () { var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {}; - $$.main.select('.' + $$.CLASS[_zoomRect]).call(z); - $$.main.selectAll('.' + $$.CLASS[_eventRect]).call(z); + $$.main.select('.' + CLASS.zoomRect).call(z); + $$.main.selectAll('.' + CLASS.eventRect).call(z); }; c3_chart_internal_fn.redrawForZoom = function () { var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x, orgXDomain = $$.orgXDomain; @@ -4984,234 +4984,162 @@ return targets; }; - var _target = 'target', - _chart = 'chart ', - _chartLine = 'chartLine', - _chartLines = 'chartLines', - _chartBar = 'chartBar', - _chartBars = 'chartBars', - _chartText = 'chartText', - _chartTexts = 'chartTexts', - _chartArc = 'chartArc', - _chartArcs = 'chartArcs', - _chartArcsTitle = 'chartArcsTitle', - _chartArcsBackground = 'chartArcsBackground', - _chartArcsGaugeUnit = 'chartArcsGaugeUnit', - _chartArcsGaugeMax = 'chartArcsGaugeMax', - _chartArcsGaugeMin = 'chartArcsGaugeMin', - _selectedCircle = 'selectedCircle', - _selectedCircles = 'selectedCircles', - _eventRect = 'eventRect', - _eventRects = 'eventRects', - _eventRectsSingle = 'eventRectsSingle', - _eventRectsMultiple = 'eventRectsMultiple', - _zoomRect = 'zoomRect', - _brush = 'brush', - _focused = 'focused', - _region = 'region', - _regions = 'regions', - _tooltip = 'tooltip', - _tooltipName = 'tooltipName', - _shape = 'shape', - _shapes = 'shapes', - _line = 'line', - _lines = 'lines', - _bar = 'bar', - _bars = 'bars', - _circle = 'circle', - _circles = 'circles', - _arc = 'arc', - _arcs = 'arcs', - _area = 'area', - _areas = 'areas', - _empty = 'empty', - _text = 'text', - _texts = 'texts', - _gaugeValue = 'gaugeValue', - _grid = 'grid', - _xgrid = 'xgrid', - _xgrids = 'xgrids', - _xgridLine = 'xgridLine', - _xgridLines = 'xgridLines', - _xgridFocus = 'xgridFocus', - _ygrid = 'ygrid', - _ygrids = 'ygrids', - _ygridLine = 'ygridLine', - _ygridLines = 'ygridLines', - _axis = 'axis', - _axisX = 'axisX', - _axisXLabel = 'axisXLabel', - _axisY = 'axisY', - _axisYLabel = 'axisYLabel', - _axisY2 = 'axisY2', - _axisY2Label = 'axisY2Label', - _legendBackground = 'legendBackground', - _legendItem = 'legendItem', - _legendItemEvent = 'legendItemEvent', - _legendItemTile = 'legendItemTile', - _legendItemHidden = 'legendItemHidden', - _legendItemFocused = 'legendItemFocused', - _dragarea = 'dragarea', - _EXPANDED = 'EXPANDED', - _SELECTED = 'SELECTED', - _INCLUDED = 'INCLUDED'; - - var CLASS = c3_chart_internal_fn.CLASS = {}; - CLASS[_target] = 'c3-target'; - CLASS[_chart] = 'c3-chart'; - CLASS[_chartLine] = 'c3-chart-line'; - CLASS[_chartLines] = 'c3-chart-lines'; - CLASS[_chartBar] = 'c3-chart-bar'; - CLASS[_chartBars] = 'c3-chart-bars'; - CLASS[_chartText] = 'c3-chart-text'; - CLASS[_chartTexts] = 'c3-chart-texts'; - CLASS[_chartArc] = 'c3-chart-arc'; - CLASS[_chartArcs] = 'c3-chart-arcs'; - CLASS[_chartArcsTitle] = 'c3-chart-arcs-title'; - CLASS[_chartArcsBackground] = 'c3-chart-arcs-background'; - CLASS[_chartArcsGaugeUnit] = 'c3-chart-arcs-gauge-unit'; - CLASS[_chartArcsGaugeMax] = 'c3-chart-arcs-gauge-max'; - CLASS[_chartArcsGaugeMin] = 'c3-chart-arcs-gauge-min'; - CLASS[_selectedCircle] = 'c3-selected-circle'; - CLASS[_selectedCircles] = 'c3-selected-circles'; - CLASS[_eventRect] = 'c3-event-rect'; - CLASS[_eventRects] = 'c3-event-rects'; - CLASS[_eventRectsSingle] = 'c3-event-rects-single'; - CLASS[_eventRectsMultiple] = 'c3-event-rects-multiple'; - CLASS[_zoomRect] = 'c3-zoom-rect'; - CLASS[_brush] = 'c3-brush'; - CLASS[_focused] = 'c3-focused'; - CLASS[_region] = 'c3-region'; - CLASS[_regions] = 'c3-regions'; - CLASS[_tooltip] = 'c3-tooltip'; - CLASS[_tooltipName] = 'c3-tooltip-name'; - CLASS[_shape] = 'c3-shape'; - CLASS[_shapes] = 'c3-shapes'; - CLASS[_line] = 'c3-line'; - CLASS[_lines] = 'c3-lines'; - CLASS[_bar] = 'c3-bar'; - CLASS[_bars] = 'c3-bars'; - CLASS[_circle] = 'c3-circle'; - CLASS[_circles] = 'c3-circles'; - CLASS[_arc] = 'c3-arc'; - CLASS[_arcs] = 'c3-arcs'; - CLASS[_area] = 'c3-area'; - CLASS[_areas] = 'c3-areas'; - CLASS[_empty] = 'c3-empty'; - CLASS[_text] = 'c3-text'; - CLASS[_texts] = 'c3-texts'; - CLASS[_gaugeValue] = 'c3-gauge-value'; - CLASS[_grid] = 'c3-grid'; - CLASS[_xgrid] = 'c3-xgrid'; - CLASS[_xgrids] = 'c3-xgrids'; - CLASS[_xgridLine] = 'c3-xgrid-line'; - CLASS[_xgridLines] = 'c3-xgrid-lines'; - CLASS[_xgridFocus] = 'c3-xgrid-focus'; - CLASS[_ygrid] = 'c3-ygrid'; - CLASS[_ygrids] = 'c3-ygrids'; - CLASS[_ygridLine] = 'c3-ygrid-line'; - CLASS[_ygridLines] = 'c3-ygrid-lines'; - CLASS[_axis] = 'c3-axis'; - CLASS[_axisX] = 'c3-axis-x'; - CLASS[_axisXLabel] = 'c3-axis-x-label'; - CLASS[_axisY] = 'c3-axis-y'; - CLASS[_axisYLabel] = 'c3-axis-y-label'; - CLASS[_axisY2] = 'c3-axis-y2'; - CLASS[_axisY2Label] = 'c3-axis-y2-label'; - CLASS[_legendBackground] = 'c3-legend-background'; - CLASS[_legendItem] = 'c3-legend-item'; - CLASS[_legendItemEvent] = 'c3-legend-item-event'; - CLASS[_legendItemTile] = 'c3-legend-item-tile'; - CLASS[_legendItemHidden] = 'c3-legend-item-hidden'; - CLASS[_legendItemFocused] = 'c3-legend-item-focused'; - CLASS[_dragarea] = 'c3-dragarea'; - CLASS[_EXPANDED] = '_expanded_'; - CLASS[_SELECTED] = '_selected_'; - CLASS[_INCLUDED] = '_included_'; - + var CLASS = c3_chart_internal_fn.CLASS = { + target: 'c3-target', + chart: 'c3-chart', + chartLine: 'c3-chart-line', + chartLines: 'c3-chart-lines', + chartBar: 'c3-chart-bar', + chartBars: 'c3-chart-bars', + chartText: 'c3-chart-text', + chartTexts: 'c3-chart-texts', + chartArc: 'c3-chart-arc', + chartArcs: 'c3-chart-arcs', + chartArcsTitle: 'c3-chart-arcs-title', + chartArcsBackground: 'c3-chart-arcs-background', + chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', + chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', + chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', + selectedCircle: 'c3-selected-circle', + selectedCircles: 'c3-selected-circles', + eventRect: 'c3-event-rect', + eventRects: 'c3-event-rects', + eventRectsSingle: 'c3-event-rects-single', + eventRectsMultiple: 'c3-event-rects-multiple', + zoomRect: 'c3-zoom-rect', + brush: 'c3-brush', + focused: 'c3-focused', + region: 'c3-region', + regions: 'c3-regions', + tooltip: 'c3-tooltip', + tooltipName: 'c3-tooltip-name', + shape: 'c3-shape', + shapes: 'c3-shapes', + line: 'c3-line', + lines: 'c3-lines', + bar: 'c3-bar', + bars: 'c3-bars', + circle: 'c3-circle', + circles: 'c3-circles', + arc: 'c3-arc', + arcs: 'c3-arcs', + area: 'c3-area', + areas: 'c3-areas', + empty: 'c3-empty', + text: 'c3-text', + texts: 'c3-texts', + gaugeValue: 'c3-gauge-value', + grid: 'c3-grid', + xgrid: 'c3-xgrid', + xgrids: 'c3-xgrids', + xgridLine: 'c3-xgrid-line', + xgridLines: 'c3-xgrid-lines', + xgridFocus: 'c3-xgrid-focus', + ygrid: 'c3-ygrid', + ygrids: 'c3-ygrids', + ygridLine: 'c3-ygrid-line', + ygridLines: 'c3-ygrid-lines', + axis: 'c3-axis', + axisX: 'c3-axis-x', + axisXLabel: 'c3-axis-x-label', + axisY: 'c3-axis-y', + axisYLabel: 'c3-axis-y-label', + axisY2: 'c3-axis-y2', + axisY2Label: 'c3-axis-y2-label', + legendBackground: 'c3-legend-background', + legendItem: 'c3-legend-item', + legendItemEvent: 'c3-legend-item-event', + legendItemTile: 'c3-legend-item-tile', + legendItemHidden: 'c3-legend-item-hidden', + legendItemFocused: 'c3-legend-item-focused', + dragarea: 'c3-dragarea', + EXPANDED: '_expanded_', + SELECTED: '_selected_', + INCLUDED: '_included_' + }; c3_chart_internal_fn.generateClass = function (prefix, targetId) { return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(targetId); }; c3_chart_internal_fn.classText = function (d) { - return this.generateClass(CLASS[_text], d.index); + return this.generateClass(CLASS.text, d.index); }; c3_chart_internal_fn.classTexts = function (d) { - return this.generateClass(CLASS[_texts], d.id); + return this.generateClass(CLASS.texts, d.id); }; c3_chart_internal_fn.classShape = function (d) { - return this.generateClass(CLASS[_shape], d.index); + return this.generateClass(CLASS.shape, d.index); }; c3_chart_internal_fn.classShapes = function (d) { - return this.generateClass(CLASS[_shapes], d.id); + return this.generateClass(CLASS.shapes, d.id); }; c3_chart_internal_fn.classLine = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_line], d.id); + return this.classShape(d) + this.generateClass(CLASS.line, d.id); }; c3_chart_internal_fn.classLines = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_lines], d.id); + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); }; c3_chart_internal_fn.classCircle = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_circle], d.index); + return this.classShape(d) + this.generateClass(CLASS.circle, d.index); }; c3_chart_internal_fn.classCircles = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_circles], d.id); + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); }; c3_chart_internal_fn.classBar = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_bar], d.index); + return this.classShape(d) + this.generateClass(CLASS.bar, d.index); }; c3_chart_internal_fn.classBars = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_bars], d.id); + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); }; c3_chart_internal_fn.classArc = function (d) { - return this.classShape(d.data) + this.generateClass(CLASS[_arc], d.data.id); + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); }; c3_chart_internal_fn.classArcs = function (d) { - return this.classShapes(d.data) + this.generateClass(CLASS[_arcs], d.data.id); + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); }; c3_chart_internal_fn.classArea = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_area], d.id); + return this.classShape(d) + this.generateClass(CLASS.area, d.id); }; c3_chart_internal_fn.classAreas = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_areas], d.id); + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); }; c3_chart_internal_fn.classRegion = function (d, i) { - return this.generateClass(CLASS[_region], i) + ' ' + ('class' in d ? d.class : ''); + return this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d.class : ''); }; c3_chart_internal_fn.classEvent = function (d) { - return this.generateClass(CLASS[_eventRect], d.index); + return this.generateClass(CLASS.eventRect, d.index); }; c3_chart_internal_fn.classTarget = function (id) { var $$ = this; var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; if (additionalClassSuffix) { - additionalClass = ' ' + CLASS[_target] + '-' + additionalClassSuffix; + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; } - return $$.generateClass(CLASS[_target], id) + additionalClass; + return $$.generateClass(CLASS.target, id) + additionalClass; }; c3_chart_internal_fn.classChartText = function (d) { - return CLASS[_chartText] + this.classTarget(d.id); + return CLASS.chartText + this.classTarget(d.id); }; c3_chart_internal_fn.classChartLine = function (d) { - return CLASS[_chartLine] + this.classTarget(d.id); + return CLASS.chartLine + this.classTarget(d.id); }; c3_chart_internal_fn.classChartBar = function (d) { - return CLASS[_chartBar] + this.classTarget(d.id); + return CLASS.chartBar + this.classTarget(d.id); }; c3_chart_internal_fn.classChartArc = function (d) { - return CLASS[_chartArc] + this.classTarget(d.data.id); + return CLASS.chartArc + this.classTarget(d.data.id); }; c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { return targetId || targetId === 0 ? '-' + (targetId.replace ? targetId.replace(/([^a-zA-Z0-9-_])/g, '-') : targetId) : ''; }; c3_chart_internal_fn.selectorTarget = function (id) { - return '.' + CLASS[_target] + this.getTargetSelectorSuffix(id); + return '.' + CLASS.target + this.getTargetSelectorSuffix(id); }; c3_chart_internal_fn.selectorTargets = function (ids) { var $$ = this; return ids.length ? ids.map(function (id) { return $$.selectorTarget(id); }) : null; }; c3_chart_internal_fn.selectorLegend = function (id) { - return '.' + CLASS[_legendItem] + this.getTargetSelectorSuffix(id); + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); }; c3_chart_internal_fn.selectorLegends = function (ids) { var $$ = this; @@ -5275,7 +5203,7 @@ } this.revert(); this.defocus(); - focus(candidatesForNoneArc.classed(CLASS[_focused], true)); + focus(candidatesForNoneArc.classed(CLASS.focused, true)); focus(candidatesForArc); if ($$.hasArcType()) { $$.expandArc(targetId, true); @@ -5292,7 +5220,7 @@ $$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 0.3); } this.revert(); - defocus(candidatesForNoneArc.classed(CLASS[_focused], false)); + defocus(candidatesForNoneArc.classed(CLASS.focused, false)); defocus(candidatesForArc); if ($$.hasArcType()) { $$.unexpandArc(targetId); @@ -5308,7 +5236,7 @@ function revert(targets) { $$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 1); } - revert(candidatesForNoneArc.classed(CLASS[_focused], false)); + revert(candidatesForNoneArc.classed(CLASS.focused, false)); revert(candidatesForArc); if ($$.hasArcType()) { $$.unexpandArc(targetId); @@ -5553,7 +5481,7 @@ }; c3_chart_internal_fn.generateFlow = function (args) { - var $$ = this, config = $$.config, d3 = $$.d3, CLASS = $$.CLASS; + var $$ = this, config = $$.config, d3 = $$.d3; return function () { var targets = args.targets, @@ -5639,14 +5567,14 @@ // remove flowed elements if (flowLength) { for (i = 0; i < flowLength; i++) { - shapes.push('.' + CLASS[_shape] + '-' + (flowIndex + i)); - texts.push('.' + CLASS[_text] + '-' + (flowIndex + i)); - eventRects.push('.' + CLASS[_eventRect] + '-' + (flowIndex + i)); + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + eventRects.push('.' + CLASS.eventRect + '-' + (flowIndex + i)); } - $$.svg.selectAll('.' + CLASS[_shapes]).selectAll(shapes).remove(); - $$.svg.selectAll('.' + CLASS[_texts]).selectAll(texts).remove(); - $$.svg.selectAll('.' + CLASS[_eventRects]).selectAll(eventRects).remove(); - $$.svg.select('.' + CLASS[_xgrid]).remove(); + $$.svg.selectAll('.' + CLASS.shapes).selectAll(shapes).remove(); + $$.svg.selectAll('.' + CLASS.texts).selectAll(texts).remove(); + $$.svg.selectAll('.' + CLASS.eventRects).selectAll(eventRects).remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); } // draw again for removing flowed elements and reverting attr @@ -5695,30 +5623,30 @@ c3_chart_fn.selected = function (targetId) { var $$ = this.internal, d3 = $$.d3; return d3.merge( - $$.main.selectAll('.' + CLASS[_shapes] + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS[_shape]) - .filter(function () { return d3.select(this).classed(CLASS[_SELECTED]); }) + $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS.shape) + .filter(function () { return d3.select(this).classed(CLASS.SELECTED); }) .map(function (d) { return d.map(function (d) { var data = d.__data__; return data.data ? data.data : data; }); }) ); }; c3_chart_fn.select = function (ids, indices, resetOther) { var $$ = this.internal, d3 = $$.d3, config = $$.config; if (! config.data_selection_enabled) { return; } - $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { + $$.main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, - isSelected = shape.classed(CLASS[_SELECTED]); + isSelected = shape.classed(CLASS.SELECTED); // line/area selection not supported yet - if (shape.classed(CLASS[_line]) || shape.classed(CLASS[_area])) { + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { return; } if (isTargetId && isTargetIndex) { if (config.data_selection_isselectable(d) && !isSelected) { - toggle(true, shape.classed(CLASS[_SELECTED], true), d, i); + toggle(true, shape.classed(CLASS.SELECTED, true), d, i); } } else if (isDefined(resetOther) && resetOther) { if (isSelected) { - toggle(false, shape.classed(CLASS[_SELECTED], false), d, i); + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } } }); @@ -5726,19 +5654,19 @@ c3_chart_fn.unselect = function (ids, indices) { var $$ = this.internal, d3 = $$.d3, config = $$.config; if (! config.data_selection_enabled) { return; } - $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { + $$.main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, - isSelected = shape.classed(CLASS[_SELECTED]); + isSelected = shape.classed(CLASS.SELECTED); // line/area selection not supported yet - if (shape.classed(CLASS[_line]) || shape.classed(CLASS[_area])) { + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { return; } if (isTargetId && isTargetIndex) { if (config.data_selection_isselectable(d)) { if (isSelected) { - toggle(false, shape.classed(CLASS[_SELECTED], false), d, i); + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } } } @@ -5821,9 +5749,9 @@ options = options || {}; duration = $$.getOption(options, "duration", config.transition_duration); - classes = $$.getOption(options, "classes", [CLASS[_region]]); + classes = $$.getOption(options, "classes", [CLASS.region]); - regions = $$.main.select('.' + CLASS[_regions]).selectAll(classes.map(function (c) { return '.' + c; })); + regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { return '.' + c; })); (duration ? regions.transition().duration(duration) : regions) .style('opacity', 0) .remove(); diff --git a/c3.min.js b/c3.min.js index 95a879e..4872573 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,4 +1,4 @@ -!function(a){"use strict";function b(a){var b=this.internal=new c(this);b.loadConfig(a),b.init(),function d(a,b,c){for(var e in a)b[e]=a[e].bind(c),Object.keys(a[e]).length>0&&d(a[e],b[e],c)}(e,this,this)}function c(b){var c=this;c.d3=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,c.api=b,c.config=c.getDefaultConfig(),c.data={},c.cache={},c.axes={}}function d(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,k);for(c=a.domain(),b=Math.ceil(c[0]);b0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=m.copy();return b&&(a=m.domain(),c.domain([a[0],a[1]-1])),c}function h(a){return j?j(a):a}function i(i){i.each(function(){function i(a){var b=m(a)+s;return B[0]=0&&B.select(this).style("display",b%y?"none":"block")})}else z.svg.selectAll("."+yb[ib]+" .tick text").style("display","block");!C.axis_rotated&&C.axis_x_tick_rotate&&z.rotateTickText(z.axes.x,b.axisX,C.axis_x_tick_rotate),l=z.generateDrawArea?z.generateDrawArea(D,!1):void 0,m=z.generateDrawBar?z.generateDrawBar(E):void 0,n=z.generateDrawLine?z.generateDrawLine(F,!1):void 0,o=z.generateXYForText(E,!0),p=z.generateXYForText(E,!1),z.subY.domain(z.y.domain()),z.subY2.domain(z.y2.domain()),z.tooltip.style("display","none"),z.updateXgridFocus(),A.select("text."+yb[W]+"."+yb[V]).attr("x",z.width/2).attr("y",z.height/2).text(C.data_empty_label_text).transition().style("opacity",H.length?0:1),z.redrawGrid(q,c),z.redrawRegion(q),z.redrawBar(r),z.redrawLine(r),z.redrawArea(r),C.point_show&&z.redrawCircle(),z.hasDataLabel()&&z.redrawText(r),z.redrawArc&&z.redrawArc(q,r,h),z.redrawSubchart&&z.redrawSubchart(d,b,q,r,D,E,F),A.selectAll("."+yb[x]).filter(z.isBarType.bind(z)).selectAll("circle").remove(),C.interaction_enabled&&z.redrawEventRect(),B.transition().duration(q).each(function(){var b=[];z.addTransitionForBar(b,m),z.addTransitionForLine(b,n),z.addTransitionForArea(b,l),z.addTransitionForCircle(b,J,K),z.addTransitionForText(b,o,p,a.flow),z.addTransitionForRegion(b),z.addTransitionForGrid(b),a.flow&&(t=z.generateWait(),b.forEach(function(a){t.add(a)}),u=z.generateFlow({targets:H,flow:a.flow,duration:q,drawBar:m,drawLine:n,drawArea:l,cx:J,cy:K,xv:I,xForText:o,yForText:p}))}).call(t||function(){},u||function(){}),z.mapToIds(z.data.targets).forEach(function(a){z.withoutFadeIn[a]=!0}),z.updateZoom&&z.updateZoom()},f.updateAndRedraw=function(a){var b,c=this,d=c.config;a=a||{},a.withTransition=Jb(a,"withTransition",!0),a.withTransform=Jb(a,"withTransform",!1),a.withLegend=Jb(a,"withLegend",!1),a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,a.withTransitionForTransform=Jb(a,"withTransitionForTransform",a.withTransition),c.updateSizes(),a.withLegend&&d.legend_show||(b=c.generateAxisTransitions(a.withTransitionForAxis?d.transition_duration:0),c.updateScales(),c.updateSvgSize(),c.transformAll(a.withTransitionForTransform,b)),c.redraw(a,b)},f.isTimeSeries=function(){return"timeseries"===this.config.axis_x_type},f.isCategorized=function(){return this.config.axis_x_type.indexOf("categor")>=0},f.isCustomX=function(){var a=this,b=a.config;return!a.isTimeSeries()&&(b.data_x||Ib(b.data_xs))},f.getTranslate=function(a){var b,c,d=this,e=d.config;return"main"===a?(b=Fb(d.margin.left),c=Fb(d.margin.top)):"context"===a?(b=Fb(d.margin2.left),c=Fb(d.margin2.top)):"legend"===a?(b=d.margin3.left,c=d.margin3.top):"x"===a?(b=0,c=e.axis_rotated?0:d.height):"y"===a?(b=0,c=e.axis_rotated?d.height:0):"y2"===a?(b=e.axis_rotated?0:d.width,c=e.axis_rotated?1:0):"subx"===a?(b=0,c=e.axis_rotated?0:d.height2):"arc"===a&&(b=d.arcWidth/2,c=d.arcHeight/2),"translate("+b+","+c+")"},f.initialOpacity=function(a){return null!==a.value&&this.withoutFadeIn[a.id]?1:0},f.opacityForCircle=function(a){var b=this;return zb(a.value)?b.isScatterType(a)?.5:1:0},f.opacityForText=function(){return this.hasDataLabel()?1:0},f.xx=function(a){return a?this.x(a.x):null},f.xv=function(a){var b=this;return Math.ceil(b.x(b.isTimeSeries()?b.parseDate(a.value):a.value))},f.yv=function(a){var b=this,c=a.axis&&"y2"===a.axis?b.y2:b.y;return Math.ceil(c(a.value))},f.subxx=function(a){return a?this.subX(a.x):null},f.transformMain=function(a,b){var c,d,e,f=this;b&&b.axisX?c=b.axisX:(c=f.main.select("."+yb[ib]),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=f.main.select("."+yb[kb]),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=f.main.select("."+yb[mb]),a&&(e=e.transition())),(a?f.main.transition():f.main).attr("transform",f.getTranslate("main")),c.attr("transform",f.getTranslate("x")),d.attr("transform",f.getTranslate("y")),e.attr("transform",f.getTranslate("y2")),f.main.select("."+yb[q]).attr("transform",f.getTranslate("arc"))},f.transformAll=function(a,b){var c=this;c.transformMain(a,b),c.config.subchart_show&&c.transformContext(a,b),c.legend&&c.transformLegend(a)},f.updateSvgSize=function(){var a=this;a.svg.attr("width",a.currentWidth).attr("height",a.currentHeight),a.svg.select("#"+a.clipId).select("rect").attr("width",a.width).attr("height",a.height),a.svg.select("#"+a.clipIdForXAxis).select("rect").attr("x",a.getXAxisClipX.bind(a)).attr("y",a.getXAxisClipY.bind(a)).attr("width",a.getXAxisClipWidth.bind(a)).attr("height",a.getXAxisClipHeight.bind(a)),a.svg.select("#"+a.clipIdForYAxis).select("rect").attr("x",a.getYAxisClipX.bind(a)).attr("y",a.getYAxisClipY.bind(a)).attr("width",a.getYAxisClipWidth.bind(a)).attr("height",a.getYAxisClipHeight.bind(a)),a.svg.select("."+yb[C]).attr("width",a.width).attr("height",a.height),a.selectChart.style("max-height",a.currentHeight+"px")},f.updateDimension=function(){var a=this;a.config.axis_rotated?(a.axes.x.call(a.xAxis),a.axes.subx.call(a.subXAxis)):(a.axes.y.call(a.yAxis),a.axes.y2.call(a.y2Axis)),a.updateSizes(),a.updateScales(),a.updateSvgSize(),a.transformAll(!1)},f.observeInserted=function(b){var c=this,d=new MutationObserver(function(e){e.forEach(function(e){if("childList"===e.type&&e.previousSibling){d.disconnect();var f=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(f),c.updateDimension(),c.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),b.transition().style("opacity",1))},10)}})});d.observe(b.node(),{attributes:!0,childList:!0,characterData:!0})},f.generateResize=function(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a},f.endall=function(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})},f.generateWait=function(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0;a.forEach(function(a){if(a.empty())return void(b+=1);try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b},f.parseDate=function(b){var c,d=this;return c=b instanceof Date?b:"number"==typeof b?new Date(b):d.dataTimeFormat(d.config.data_xFormat).parse(b),(!c||isNaN(+c))&&a.console.error("Failed to parse x '"+b+"' to Date object"),c},f.getDefaultConfig=function(){var a={bindto:"#chart",size_width:void 0,size_height:void 0,padding_left:void 0,padding_right:void 0,padding_top:void 0,padding_bottom:void 0,zoom_enabled:!1,zoom_extent:void 0,zoom_privileged:!1,zoom_onzoom:function(){},interaction_enabled:!0,onmouseover:function(){},onmouseout:function(){},onresize:function(){},onresized:function(){},transition_duration:350,data_x:void 0,data_xs:{},data_xFormat:"%Y-%m-%d",data_xLocaltime:!0,data_idConverter:function(a){return a},data_names:{},data_classes:{},data_groups:[],data_axes:{},data_type:void 0,data_types:{},data_labels:{},data_order:"desc",data_regions:{},data_color:void 0,data_colors:{},data_hide:!1,data_filter:void 0,data_selection_enabled:!1,data_selection_grouped:!1,data_selection_isselectable:function(){return!0},data_selection_multiple:!0,data_onclick:function(){},data_onmouseover:function(){},data_onmouseout:function(){},data_onselected:function(){},data_onunselected:function(){},data_ondragstart:function(){},data_ondragend:function(){},data_url:void 0,data_json:void 0,data_rows:void 0,data_columns:void 0,data_mimeType:void 0,data_keys:void 0,data_empty_label_text:"",subchart_show:!1,subchart_size_height:60,subchart_onbrush:function(){},color_pattern:[],color_threshold:{},legend_show:!0,legend_position:"bottom",legend_inset_anchor:"top-left",legend_inset_x:10,legend_inset_y:0,legend_inset_step:void 0,legend_item_onclick:void 0,legend_item_onmouseover:void 0,legend_item_onmouseout:void 0,legend_equally:!1,axis_rotated:!1,axis_x_show:!0,axis_x_type:"indexed",axis_x_localtime:!0,axis_x_categories:[],axis_x_tick_centered:!1,axis_x_tick_format:void 0,axis_x_tick_culling:{},axis_x_tick_culling_max:10,axis_x_tick_count:void 0,axis_x_tick_fit:!0,axis_x_tick_values:null,axis_x_tick_rotate:void 0,axis_x_tick_outer:!0,axis_x_max:null,axis_x_min:null,axis_x_padding:{},axis_x_height:void 0,axis_x_default:void 0,axis_x_label:{},axis_y_show:!0,axis_y_max:void 0,axis_y_min:void 0,axis_y_center:void 0,axis_y_label:{},axis_y_tick_format:void 0,axis_y_tick_outer:!0,axis_y_padding:void 0,axis_y_ticks:10,axis_y2_show:!1,axis_y2_max:void 0,axis_y2_min:void 0,axis_y2_center:void 0,axis_y2_label:{},axis_y2_tick_format:void 0,axis_y2_tick_outer:!0,axis_y2_padding:void 0,axis_y2_ticks:10,grid_x_show:!1,grid_x_type:"tick",grid_x_lines:[],grid_y_show:!1,grid_y_lines:[],grid_y_ticks:10,grid_focus_show:!0,point_show:!0,point_r:2.5,point_focus_expand_enabled:!0,point_focus_expand_r:void 0,point_select_r:void 0,line_connect_null:!1,bar_width:void 0,bar_width_ratio:.6,bar_width_max:void 0,bar_zerobased:!0,area_zerobased:!0,pie_label_show:!0,pie_label_format:void 0,pie_label_threshold:.05,pie_sort:!0,pie_expand:!0,gauge_label_show:!0,gauge_label_format:void 0,gauge_expand:!0,gauge_min:0,gauge_max:100,gauge_units:void 0,gauge_width:void 0,donut_label_show:!0,donut_label_format:void 0,donut_label_threshold:.05,donut_width:void 0,donut_sort:!0,donut_expand:!0,donut_title:"",regions:[],tooltip_show:!0,tooltip_grouped:!0,tooltip_format_title:void 0,tooltip_format_name:void 0,tooltip_format_value:void 0,tooltip_contents:function(a,b,c,d){return this.getTooltipContent?this.getTooltipContent(a,b,c,d):""},tooltip_init_show:!1,tooltip_init_x:0,tooltip_init_position:{top:"0px",left:"50px"}};return Object.keys(this.additionalConfig).forEach(function(b){a[b]=this.additionalConfig[b]},this),a},f.additionalConfig={},f.loadConfig=function(a){function b(){var a=d.shift();return a&&c&&"object"==typeof c&&a in c?(c=c[a],b()):a?void 0:c}var c,d,e,f=this.config;Object.keys(f).forEach(function(g){c=a,d=g.split("_"),e=b(),Db(e)&&(f[g]=e)})},f.getScale=function(a,b,c){return(c?this.d3.time.scale():this.d3.scale.linear()).range([a,b])},f.getX=function(a,b,c,d){var e,f=this,g=f.getScale(a,b,f.isTimeSeries()),h=c?g.domain(c):g;f.isCategorized()?(d=d||function(){return 0},g=function(a,b){var c=h(a)+d(a);return b?c:Math.ceil(c)}):g=function(a,b){var c=h(a);return b?c:Math.ceil(c)};for(e in h)g[e]=h[e];return g.orgDomain=function(){return h.domain()},f.isCategorized()&&(g.domain=function(a){return arguments.length?(h.domain(a),g):(a=this.orgDomain(),[a[0],a[1]+1])}),g},f.getY=function(a,b,c){var d=this.getScale(a,b);return c&&d.domain(c),d},f.getYScale=function(a){return"y2"===this.getAxisId(a)?this.y2:this.y},f.getSubYScale=function(a){return"y2"===this.getAxisId(a)?this.subY2:this.subY},f.updateScales=function(){var a=this,b=a.config,c=!a.x;a.xMin=b.axis_rotated?1:0,a.xMax=b.axis_rotated?a.height:a.width,a.yMin=b.axis_rotated?0:a.height,a.yMax=b.axis_rotated?a.width:1,a.subXMin=a.xMin,a.subXMax=a.xMax,a.subYMin=b.axis_rotated?0:a.height2,a.subYMax=b.axis_rotated?a.width2:1,a.x=a.getX(a.xMin,a.xMax,c?void 0:a.x.orgDomain(),function(){return a.xAxis.tickOffset()}),a.y=a.getY(a.yMin,a.yMax,c?void 0:a.y.domain()),a.y2=a.getY(a.yMin,a.yMax,c?void 0:a.y2.domain()),a.subX=a.getX(a.xMin,a.xMax,a.orgXDomain,function(b){return b%1?0:a.subXAxis.tickOffset()}),a.subY=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY.domain()),a.subY2=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY2.domain()),a.xAxisTickFormat=a.getXAxisTickFormat(),a.xAxisTickValues=b.axis_x_tick_values?b.axis_x_tick_values:c?void 0:a.xAxis.tickValues(),a.xAxis=a.getXAxis(a.x,a.xOrient,a.xAxisTickFormat,a.xAxisTickValues),a.subXAxis=a.getXAxis(a.subX,a.subXOrient,a.xAxisTickFormat,a.xAxisTickValues),a.yAxis=a.getYAxis(a.y,a.yOrient,b.axis_y_tick_format,b.axis_y_ticks),a.y2Axis=a.getYAxis(a.y2,a.y2Orient,b.axis_y2_tick_format,b.axis_y2_ticks),c||(a.brush&&a.brush.scale(a.subX),b.zoom_enabled&&a.zoom.scale(a.x)),a.updateArc&&a.updateArc()},f.getYDomainMin=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasNegativeValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=0>a?a:0}),c=1;c0||(k[d][b]+=+a)});return h.d3.min(Object.keys(k).map(function(a){return h.d3.min(k[a])}))},f.getYDomainMax=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasPositiveValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=a>0?a:0}),c=1;c+a||(k[d][b]+=+a)});return h.d3.max(Object.keys(k).map(function(a){return h.d3.max(k[a])}))},f.getYDomain=function(a,b){var c,d,e,f,g,h,i,j,k,l,m=this,n=m.config,o=a.filter(function(a){return m.getAxisId(a.id)===b}),p="y2"===b?n.axis_y2_min:n.axis_y_min,q="y2"===b?n.axis_y2_max:n.axis_y_max,r=zb(p)?p:m.getYDomainMin(o),s=zb(q)?q:m.getYDomainMax(o),t="y2"===b?n.axis_y2_center:n.axis_y_center,u=m.hasType("bar",o)&&n.bar_zerobased||m.hasType("area",o)&&n.area_zerobased,v=m.hasDataLabel()&&n.axis_rotated,w=m.hasDataLabel()&&!n.axis_rotated;return 0===o.length?"y2"===b?m.y2.domain():m.y.domain():(r===s&&(0>r?s=0:r=0),k=r>=0&&s>=0,l=0>=r&&0>=s,u&&(k&&(r=0),l&&(s=0)),c=Math.abs(s-r),d=e=f=.1*c,t&&(g=Math.max(Math.abs(r),Math.abs(s)),s=g-t,r=t-g),v?(h=m.getDataLabelLength(r,s,b,"width"),i=Gb(m.y.range()),j=[h[0]/i,h[1]/i],e+=c*(j[1]/(1-j[0]-j[1])),f+=c*(j[0]/(1-j[0]-j[1]))):w&&(h=m.getDataLabelLength(r,s,b,"height"),e+=h[1],f+=h[0]),"y"===b&&n.axis_y_padding&&(e=m.getAxisPadding(n.axis_y_padding,"top",d,c),f=m.getAxisPadding(n.axis_y_padding,"bottom",d,c)),"y2"===b&&n.axis_y2_padding&&(e=m.getAxisPadding(n.axis_y2_padding,"top",d,c),f=m.getAxisPadding(n.axis_y2_padding,"bottom",d,c)),u&&(k&&(f=r),l&&(e=-s)),[r-f,s+e])},f.getXDomainMin=function(a){var b=this,c=b.config;return c.axis_x_min?b.isTimeSeries()?this.parseDate(c.axis_x_min):c.axis_x_min:b.d3.min(a,function(a){return b.d3.min(a.values,function(a){return a.x})})},f.getXDomainMax=function(a){var b=this,c=b.config;return c.axis_x_max?b.isTimeSeries()?this.parseDate(c.axis_x_max):c.axis_x_max:b.d3.max(a,function(a){return b.d3.max(a.values,function(a){return a.x})})},f.getXDomainPadding=function(a){var b,c,d,e,f=this,g=f.config,h=this.getEdgeX(a),i=h[1]-h[0];return f.isCategorized()?c=0:f.hasType("bar",a)?(b=f.getMaxDataCount(),c=b>1?i/(b-1)/2:.5):c=.01*i,"object"==typeof g.axis_x_padding&&Ib(g.axis_x_padding)?(d=zb(g.axis_x_padding.left)?g.axis_x_padding.left:c,e=zb(g.axis_x_padding.right)?g.axis_x_padding.right:c):d=e="number"==typeof g.axis_x_padding?g.axis_x_padding:c,{left:d,right:e}},f.getXDomain=function(a){var b=this,c=[b.getXDomainMin(a),b.getXDomainMax(a)],d=c[0],e=c[1],f=b.getXDomainPadding(a),g=0,h=0;return d-e!==0||b.isCategorized()||(d=b.isTimeSeries()?new Date(.5*d.getTime()):-.5,e=b.isTimeSeries()?new Date(1.5*e.getTime()):.5),(d||0===d)&&(g=b.isTimeSeries()?new Date(d.getTime()-f.left):d-f.left),(e||0===e)&&(h=b.isTimeSeries()?new Date(e.getTime()+f.right):e+f.right),[g,h]},f.updateXDomain=function(a,b,c,d){var e=this,f=e.config;return c&&(e.x.domain(d?d:e.d3.extent(e.getXDomain(a))),e.orgXDomain=e.x.domain(),f.zoom_enabled&&e.zoom.scale(e.x).updateScaleExtent(),e.subX.domain(e.x.domain()),e.brush&&e.brush.scale(e.subX)),b&&(e.x.domain(d?d:!e.brush||e.brush.empty()?e.orgXDomain:e.brush.extent()),f.zoom_enabled&&e.zoom.scale(e.x).updateScaleExtent()),e.x.domain()},f.isX=function(a){var b=this,c=b.config;return c.data_x&&a===c.data_x||Ib(c.data_xs)&&Kb(c.data_xs,a)},f.isNotX=function(a){return!this.isX(a)},f.getXKey=function(a){var b=this,c=b.config;return c.data_x?c.data_x:Ib(c.data_xs)?c.data_xs[a]:null},f.getXValuesOfXKey=function(a,b){var c,d=this,e=b&&Ib(b)?d.mapToIds(b):[];return e.forEach(function(b){d.getXKey(b)===a&&(c=d.data.xs[b])}),c},f.getXValue=function(a,b){var c=this;return a in c.data.xs&&c.data.xs[a]&&zb(c.data.xs[a][b])?c.data.xs[a][b]:b},f.getOtherTargetXs=function(){var a=this,b=Object.keys(a.data.xs);return b.length?a.data.xs[b[0]]:null},f.getOtherTargetX=function(a){var b=this.getOtherTargetXs();return b&&a1},f.isMultipleX=function(){var a=this,b=a.config;return Ib(b.data_xs)&&a.hasMultipleX(b.data_xs)},f.addName=function(a){var b,c=this;return a&&(b=c.config.data_names[a.id],a.name=b?b:a.id),a},f.getValueOnIndex=function(a,b){var c=a.filter(function(a){return a.index===b});return c.length?c[0]:null},f.updateTargetX=function(a,b){var c=this;a.forEach(function(a){a.values.forEach(function(d,e){d.x=c.generateTargetX(b[e],a.id,e)}),c.data.xs[a.id]=b})},f.updateTargetXs=function(a,b){var c=this;a.forEach(function(a){b[a.id]&&c.updateTargetX([a],b[a.id])})},f.generateTargetX=function(a,b,c){var d,e=this;return d=e.isTimeSeries()?e.parseDate(a?a:e.getXValue(b,c)):e.isCustomX()&&!e.isCategorized()?zb(a)?+a:e.getXValue(b,c):c},f.cloneTarget=function(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}})}},f.getPrevX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a-1);return c?c.x:null},f.getNextX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a+1);return c?c.x:null},f.getMaxDataCount=function(){var a=this;return a.d3.max(a.data.targets,function(a){return a.values.length})},f.getMaxDataCountTarget=function(a){var b,c=a.length,d=0;return c>1?a.forEach(function(a){a.values.length>d&&(b=a,d=a.values.length)}):b=c?a[0]:null,b},f.getEdgeX=function(a){var b,c,d=this.getMaxDataCountTarget(a);return d?(b=d.values[0],c=d.values[d.values.length-1],[b.x,c.x]):[0,0]},f.mapToIds=function(a){return a.map(function(a){return a.id})},f.mapToTargetIds=function(a){var b=this;return a?Bb(a)?[a]:a:b.mapToIds(b.data.targets)},f.hasTarget=function(a,b){var c,d=this.mapToIds(a);for(c=0;ca})},f.hasPositiveValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return a>0})},f.isOrderDesc=function(){var a=this.config;return a.data_order&&"desc"===a.data_order.toLowerCase()},f.isOrderAsc=function(){var a=this.config;return a.data_order&&"asc"===a.data_order.toLowerCase()},f.orderTargets=function(a){var b=this,c=b.config,d=b.isOrderAsc(),e=b.isOrderDesc();return d||e?a.sort(function(a,b){var c=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(c,0),f=b.values.reduce(c,0);return d?f-e:e-f}):Ab(c.data_order)&&a.sort(c.data_order),a},f.filterSameX=function(a,b){return this.d3.merge(a.map(function(a){return a.values -})).filter(function(a){return a.x-b===0})},f.filterRemoveNull=function(a){return a.filter(function(a){return zb(a.value)})},f.hasDataLabel=function(){var a=this.config;return"boolean"==typeof a.data_labels&&a.data_labels?!0:"object"==typeof a.data_labels&&Ib(a.data_labels)?!0:!1},f.getDataLabelLength=function(a,b,c,d){var e=this,f=[0,0],g=1.3;return e.selectChart.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return e.formatByAxisId(c)(a)}).each(function(a,b){f[b]=this.getBoundingClientRect()[d]*g}).remove(),f},f.isNoneArc=function(a){return this.hasTarget(this.data.targets,a.id)},f.isArc=function(a){return"data"in a&&this.hasTarget(this.data.targets,a.data.id)},f.findSameXOfValues=function(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?h=i:g=i,h-g===1||0===g&&0===h?(e=[],(a[g].x||0===a[g].x)&&(e=e.concat(f.findSameXOfValues(a,g))),(a[h].x||0===a[h].x)&&(e=e.concat(f.findSameXOfValues(a,h))),f.findClosest(e,b)):f.findClosestOfValues(a,b,g,h)},f.findClosestFromTargets=function(a,b){var c,d=this;return c=a.map(function(a){return d.findClosestOfValues(a.values,b)}),d.findClosest(c,b)},f.findClosest=function(a,b){var c,d,e=this;return a.forEach(function(a){var f=e.dist(a,b);(c>f||!c)&&(c=f,d=a)}),d},f.dist=function(a,b){var c=this,d=c.config,e="y"===c.getAxisId(a.id)?c.y:c.y2,f=d.axis_rotated?1:0,g=d.axis_rotated?0:1;return Math.pow(c.x(a.x)-b[f],2)+Math.pow(e(a.value)-b[g],2)},f.convertUrlToData=function(a,b,c,d){var e=this,f=b?b:"csv";e.d3.xhr(a,function(a,b){var g;g="json"===f?e.convertJsonToData(JSON.parse(b.response),c):e.convertCsvToData(b.response),d.call(e,g)})},f.convertCsvToData=function(a){var b,c=this.d3,d=c.csv.parseRows(a);return 1===d.length?(b=[{}],d[0].forEach(function(a){b[0][a]=null})):b=c.csv.parse(a),b},f.convertJsonToData=function(a,b){var c,d,e=this,f=[];return b?(c=b.value,b.x&&(c.push(b.x),e.config.data_x=b.x),f.push(c),a.forEach(function(a){var b=[];c.forEach(function(c){var d=Cb(a[c])?null:a[c];b.push(d)}),f.push(b)}),d=e.convertRowsToData(f)):(Object.keys(a).forEach(function(b){f.push([b].concat(a[b]))}),d=e.convertColumnsToData(f)),d},f.convertRowsToData=function(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?d.data.xs[c]=(b&&d.data.xs[c]?d.data.xs[c]:[]).concat(a.map(function(a){return a[f]}).filter(zb).map(function(a,b){return d.generateTargetX(a,c,b)})):e.data_x?d.data.xs[c]=d.getOtherTargetXs():Ib(e.data_xs)&&(d.data.xs[c]=d.getXValuesOfXKey(f,d.data.targets)):d.data.xs[c]=a.map(function(a,b){return b})}),f.forEach(function(a){if(!d.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),c=f.map(function(b,c){var f=e.data_idConverter(b);return{id:f,id_org:b,values:a.map(function(a,g){var h=d.getXKey(b),i=a[h],j=d.generateTargetX(i,b,g);return d.isCustomX()&&d.isCategorized()&&0===c&&i&&(0===g&&(e.axis_x_categories=[]),e.axis_x_categories.push(i)),(Cb(a[b])||d.data.xs[b].length<=g)&&(j=void 0),{x:j,value:null===a[b]||isNaN(a[b])?null:+a[b],id:f}}).filter(function(a){return Db(a.x)})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++}),d.data.xs[a.id].sort(function(a,b){return a-b})}),e.data_type&&d.setTargetType(d.mapToIds(c).filter(function(a){return!(a in e.data_types)}),e.data_type),c.forEach(function(a){d.addCache(a.id_org,a)}),c},f.load=function(a,b){var c=this;a&&(b.filter&&(a=a.filter(b.filter)),(b.type||b.types)&&a.forEach(function(a){c.setTargetType(a.id,b.types?b.types[a.id]:b.type)}),c.data.targets.forEach(function(b){for(var c=0;ce?0:e},g=function(a){var b=h.getPrevX(a.index),c=h.data.xs[a.id][a.index];return(h.x(c)+h.x(b?b:c))/2}),b=i.axis_rotated?0:g,c=i.axis_rotated?g:0,d=i.axis_rotated?h.width:f,e=i.axis_rotated?f:h.height),a.attr("class",h.classEvent.bind(h)).attr("x",b).attr("y",c).attr("width",d).attr("height",e)},f.generateEventRectsForSingleX=function(a){var b=this,c=b.d3,d=b.config;a.append("rect").attr("class",b.classEvent.bind(b)).style("cursor",d.data_selection_enabled&&d.data_selection_grouped?"pointer":null).on("mouseover",function(a){var c,e,f=a.index;b.dragging||b.hasArcType()||(c=b.data.targets.map(function(a){return b.addName(b.getValueOnIndex(a.values,f))}),e=[],Object.keys(d.data_names).forEach(function(a){for(var b=0;b0?c:320},f.getCurrentPaddingTop=function(){var a=this.config;return zb(a.padding_top)?a.padding_top:0},f.getCurrentPaddingBottom=function(){var a=this.config;return zb(a.padding_bottom)?a.padding_bottom:0},f.getCurrentPaddingLeft=function(){var a=this,b=a.config;return zb(b.padding_left)?b.padding_left:b.axis_rotated?b.axis_x_show?Math.max(Eb(a.getAxisWidthByAxisId("x")),40):1:b.axis_y_show?Eb(a.getAxisWidthByAxisId("y")):1},f.getCurrentPaddingRight=function(){var a=this,b=a.config,c=10,d=a.isLegendRight?a.getLegendWidth()+20:0;return zb(b.padding_right)?b.padding_right+1:b.axis_rotated?c+d:(b.axis_y2_show?Eb(a.getAxisWidthByAxisId("y2")):c)+d},f.getParentRectValue=function(a){for(var b,c=this.selectChart.node();c&&"BODY"!==c.tagName&&!(b=c.getBoundingClientRect()[a]);)c=c.parentNode;return b},f.getParentWidth=function(){return this.getParentRectValue("width")},f.getParentHeight=function(){var a=this.selectChart.style("height");return a.indexOf("px")>0?+a.replace("px",""):0},f.getSvgLeft=function(){var a=this,b=a.config,c=b.axis_rotated?yb[ib]:yb[kb],d=a.main.select("."+c).node(),e=d?d.getBoundingClientRect():{right:0},f=a.selectChart.node().getBoundingClientRect(),g=a.hasArcType(),h=e.right-f.left-(g?0:a.getCurrentPaddingLeft());return h>0?h:0},f.getAxisWidthByAxisId=function(a){var b=this,c=b.getAxisLabelPositionById(a);return c.isInner?20+b.getMaxTickWidth(a):40+b.getMaxTickWidth(a)},f.getHorizontalAxisHeight=function(a){var b=this,c=b.config;return"x"!==a||c.axis_x_show?"x"===a&&c.axis_x_height?c.axis_x_height:"y"!==a||c.axis_y_show?"y2"!==a||c.axis_y2_show?(b.getAxisLabelPositionById(a).isInner?30:40)+("y2"===a?-10:0):b.rotated_padding_top:!c.legend_show||b.isLegendRight||b.isLegendInset?1:10:0},f.getEventRectWidth=function(){var a,b,c,d,e,f,g=this,h=g.getMaxDataCountTarget(g.data.targets);return h?(a=h.values[0],b=h.values[h.values.length-1],c=g.x(b.x)-g.x(a.x),0===c?g.config.axis_rotated?g.height:g.width:(d=g.getMaxDataCount(),e=g.hasType("bar")?(d-(g.isCategorized()?.25:1))/d:1,f=d>1?c*e/(d-1):c,1>f?1:f)):0},f.getShapeIndices=function(a){var b,c,d=this,e=d.config,f={},g=0;return d.filterTargetsToShow(d.data.targets.filter(a,d)).forEach(function(a){for(b=0;b=0&&(j+=h(c.values[g].value)-i)}),j}},f.getInterpolate=function(a){var b=this;return b.isSplineType(a)?"cardinal":b.isStepType(a)?"step-after":"linear"},f.initLine=function(){var a=this,b=a.CLASS;a.main.select("."+b[i]).append("g").attr("class",b[k])},f.updateTargetsForLine=function(a){var b,c,d=this,e=d.config,f=d.CLASS,g=d.classChartLine.bind(d),h=d.classLines.bind(d),i=d.classAreas.bind(d),l=d.classCircles.bind(d);b=d.main.select("."+f[k]).selectAll("."+f[j]).data(a).attr("class",g),c=b.enter().append("g").attr("class",g).style("opacity",0).style("pointer-events","none"),c.append("g").attr("class",h),c.append("g").attr("class",i),c.append("g").attr("class",function(a){return d.generateClass(f[x],a.id)}),c.append("g").attr("class",l).style("cursor",function(a){return e.data_selection_isselectable(a)?"pointer":null}),a.forEach(function(a){d.main.selectAll("."+f[x]+d.getTargetSelectorSuffix(a.id)).selectAll("."+f[w]).each(function(b){b.value=a.values[b.index].value})})},f.redrawLine=function(a){var b=this,c=b.CLASS;b.mainLine=b.main.selectAll("."+c[M]).selectAll("."+c[L]).data(b.lineData.bind(b)),b.mainLine.enter().append("path").attr("class",b.classLine.bind(b)).style("stroke",b.color),b.mainLine.style("opacity",b.initialOpacity.bind(b)).attr("transform",null),b.mainLine.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForLine=function(a,b){var c=this;a.push(c.mainLine.transition().attr("d",b).style("stroke",c.color).style("opacity",1))},f.generateDrawLine=function(a,b){var c=this,d=c.config,e=c.d3.svg.line(),f=c.generateGetLinePoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x(i).y(h):e.x(h).y(i),d.line_connect_null||(e=e.defined(function(a){return null!=a.value})),function(a){var f,h=d.line_connect_null?c.filterRemoveNull(a.values):a.values,i=b?c.x:c.subX,j=g.call(c,a.id),k=0,l=0;return c.isLineType(a)?f=d.data_regions[a.id]?c.lineWithRegions(h,i,j,d.data_regions[a.id]):e.interpolate(c.getInterpolate(a))(h):(h[0]&&(k=i(h[0].x),l=j(h[0].value)),f=d.axis_rotated?"M "+l+" "+k:"M "+k+" "+l),f?f:"M 0 0"}},f.generateGetLinePoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isLineType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0l||a.value<0&&l>e)&&(l=e),[[k,l-(e-j)]]}},f.lineWithRegions=function(a,b,c,d){function e(a,b){var c;for(c=0;c=g;g+=o)u+=h(a[f-1],a[f],g,n);t=a[f].x}return u},f.redrawArea=function(a){var b=this,c=b.CLASS,d=b.d3;b.mainArea=b.main.selectAll("."+c[U]).selectAll("."+c[T]).data(b.lineData.bind(b)),b.mainArea.enter().append("path").attr("class",b.classArea.bind(b)).style("fill",b.color).style("opacity",function(){return b.orgAreaOpacity=+d.select(this).style("opacity"),0}),b.mainArea.style("opacity",b.orgAreaOpacity),b.mainArea.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForArea=function(a,b){var c=this;a.push(c.mainArea.transition().attr("d",b).style("fill",c.color).style("opacity",c.orgAreaOpacity))},f.generateDrawArea=function(a,b){var c=this,d=c.config,e=c.d3.svg.area(),f=c.generateGetAreaPoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(0)},j=function(a,b){return d.data_groups.length>0?f(a,b)[1][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x0(i).x1(j).y(h):e.x(h).y0(i).y1(j),d.line_connect_null||(e=e.defined(function(a){return null!==a.value})),function(a){var b,f=d.line_connect_null?c.filterRemoveNull(a.values):a.values,g=0,h=0;return c.isAreaType(a)?b=e.interpolate(c.getInterpolate(a))(f):(f[0]&&(g=c.x(f[0].x),h=c.getYScale(a.id)(f[0].value)),b=d.axis_rotated?"M "+h+" "+g:"M "+g+" "+h),b?b:"M 0 0"}},f.generateGetAreaPoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isAreaType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0l||a.value<0&&l>e)&&(l=e),[[k,j],[k,l-(e-j)]]}},f.redrawCircle=function(){var a=this,b=a.CLASS;a.mainCircle=a.main.selectAll("."+b[Q]).selectAll("."+b[P]).data(a.lineOrScatterData.bind(a)),a.mainCircle.enter().append("circle").attr("class",a.classCircle.bind(a)).attr("r",a.pointR.bind(a)).style("fill",a.color),a.mainCircle.style("opacity",a.initialOpacity.bind(a)),a.mainCircle.exit().remove()},f.addTransitionForCircle=function(a,b,c){var d=this;a.push(d.mainCircle.transition().style("opacity",d.opacityForCircle.bind(d)).style("fill",d.color).attr("cx",b).attr("cy",c)),a.push(d.main.selectAll("."+yb[w]).transition().attr("cx",b).attr("cy",c))},f.circleX=function(a){return a.x||0===a.x?this.x(a.x):null},f.circleY=function(a,b){var c=this,d=c.getShapeIndices(c.isLineType),e=c.generateGetLinePoint(d);return c.config.data_groups.length>0?e(a,b)[0][1]:c.getYScale(a.id)(a.value)},f.getCircles=function(a,b){var c=this;return(b?c.main.selectAll("."+yb[Q]+c.getTargetSelectorSuffix(b)):c.main).selectAll("."+yb[P]+(zb(a)?"-"+a:""))},f.expandCircles=function(a,b){var c=this,d=c.pointExpandedR.bind(c);c.getCircles(a,b).classed(yb[vb],!0).attr("r",d)},f.unexpandCircles=function(a){var b=this,c=b.pointR.bind(b);b.getCircles(a).filter(function(){return b.d3.select(this).classed(yb[vb])}).classed(yb[vb],!1).attr("r",c)},f.pointR=function(a){var b=this,c=b.config;return c.point_show&&!b.isStepType(a)?Ab(c.point_r)?c.point_r(a):c.point_r:0},f.pointExpandedR=function(a){var b=this,c=b.config;return c.point_focus_expand_enabled?c.point_focus_expand_r?c.point_focus_expand_r:1.75*b.pointR(a):b.pointR(a)},f.pointSelectR=function(a){var b=this,c=b.config;return c.point_select_r?c.point_select_r:4*b.pointR(a)},f.isWithinCircle=function(a,b){var c=this.d3,d=c.mouse(a),e=c.select(a),f=1*e.attr("cx"),g=1*e.attr("cy");return Math.sqrt(Math.pow(f-d[0],2)+Math.pow(g-d[1],2))d.bar_width_max?d.bar_width_max:e},f.getBars=function(a){var b=this;return b.main.selectAll("."+yb[N]+(zb(a)?"-"+a:""))},f.expandBars=function(a){var b=this;b.getBars(a).classed(yb[vb],!0)},f.unexpandBars=function(a){var b=this;b.getBars(a).classed(yb[vb],!1)},f.generateDrawBar=function(a,b){var c=this,d=c.config,e=c.generateGetBarPoints(a,b);return function(a,b){var c=e(a,b),f=d.axis_rotated?1:0,g=d.axis_rotated?0:1,h="M "+c[0][f]+","+c[0][g]+" L"+c[1][f]+","+c[1][g]+" L"+c[2][f]+","+c[2][g]+" L"+c[3][f]+","+c[3][g]+" z";return h}},f.generateGetBarPoints=function(a,b){var c=this,d=a.__max__+1,e=c.getBarW(c.xAxis,d),f=c.getShapeX(e,d,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isBarType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var d=i.call(c,a.id)(0),j=h(a,b)||d,k=f(a),l=g(a);return c.config.axis_rotated&&(0l||a.value<0&&l>d)&&(l=d),[[k,j],[k,l-(d-j)],[k+e,l-(d-j)],[k+e,j]]}},f.isWithinBar=function(a){var b=this.d3,c=b.mouse(a),d=a.getBoundingClientRect(),e=a.pathSegList.getItem(0),f=a.pathSegList.getItem(1),g=e.x,h=Math.min(e.y,f.y),i=d.width,j=d.height,k=2,l=g-k,m=g+i+k,n=h+j+k,o=h-k;return lf.width?f.width-g.width:d},f.getYForText=function(a,b,c){var d,e=this,f=c.getBoundingClientRect();return d=e.config.axis_rotated?(a[0][0]+a[2][0]+.6*f.height)/2:a[2][1]+(b.value<0?f.height:e.isBarType(b)?-3:-6),d=0||!(b.id in d)&&"line"===a)&&(e=!0)}),e},f.hasArcType=function(a){return this.hasType("pie",a)||this.hasType("donut",a)||this.hasType("gauge",a)},f.isLineType=function(a){var b=this.config,c=Bb(a)?a:a.id;return!b.data_types[c]||["line","spline","area","area-spline","step","area-step"].indexOf(b.data_types[c])>=0},f.isStepType=function(a){var b=Bb(a)?a:a.id;return["step","area-step"].indexOf(this.config.data_types[b])>=0},f.isSplineType=function(a){var b=Bb(a)?a:a.id;return["spline","area-spline"].indexOf(this.config.data_types[b])>=0},f.isAreaType=function(a){var b=Bb(a)?a:a.id;return["area","area-spline","area-step"].indexOf(this.config.data_types[b])>=0},f.isBarType=function(a){var b=Bb(a)?a:a.id;return"bar"===this.config.data_types[b]},f.isScatterType=function(a){var b=Bb(a)?a:a.id;return"scatter"===this.config.data_types[b]},f.isPieType=function(a){var b=Bb(a)?a:a.id;return"pie"===this.config.data_types[b]},f.isGaugeType=function(a){var b=Bb(a)?a:a.id;return"gauge"===this.config.data_types[b]},f.isDonutType=function(a){var b=Bb(a)?a:a.id;return"donut"===this.config.data_types[b]},f.isArcType=function(a){return this.isPieType(a)||this.isDonutType(a)||this.isGaugeType(a)},f.lineData=function(a){return this.isLineType(a)?[a]:[]},f.arcData=function(a){return this.isArcType(a.data)?[a]:[]},f.barData=function(a){return this.isBarType(a)?a.values:[]},f.lineOrScatterData=function(a){return this.isLineType(a)||this.isScatterType(a)?a.values:[]},f.barOrLineData=function(a){return this.isBarType(a)||this.isLineType(a)?a.values:[]},f.initGrid=function(){var a=this,b=a.config,c=a.CLASS,d=a.d3;a.grid=a.main.append("g").attr("clip-path",a.clipPath).attr("class",c[Z]),b.grid_x_show&&a.grid.append("g").attr("class",c[_]),b.grid_y_show&&a.grid.append("g").attr("class",c[eb]),a.grid.append("g").attr("class",c[bb]),a.grid.append("g").attr("class",c[gb]),b.grid_focus_show&&a.grid.append("g").attr("class",c[cb]).append("line").attr("class",c[cb]),a.xgrid=d.selectAll([]),a.xgridLines=d.selectAll([])},f.updateXGrid=function(a){var b=this,c=b.config,d=b.CLASS,e=b.d3,f=b.generateGridData(c.grid_x_type,b.x),g=b.isCategorized()?b.xAxis.tickOffset():0;b.xgridAttr=c.axis_rotated?{x1:0,x2:b.width,y1:function(a){return b.x(a)-g},y2:function(a){return b.x(a)-g}}:{x1:function(a){return b.x(a)+g},x2:function(a){return b.x(a)+g},y1:0,y2:b.height},b.xgrid=b.main.select("."+d[_]).selectAll("."+d[$]).data(f),b.xgrid.enter().append("line").attr("class",d[$]),a||b.xgrid.attr(b.xgridAttr).style("opacity",function(){return+e.select(this).attr(c.axis_rotated?"y1":"x1")===(c.axis_rotated?b.height:0)?0:1}),b.xgrid.exit().remove()},f.updateYGrid=function(){var a=this,b=a.config,c=a.CLASS;a.ygrid=a.main.select("."+c[eb]).selectAll("."+c[db]).data(a.y.ticks(b.grid_y_ticks)),a.ygrid.enter().append("line").attr("class",c[db]),a.ygrid.attr("x1",b.axis_rotated?a.y:0).attr("x2",b.axis_rotated?a.y:a.width).attr("y1",b.axis_rotated?0:a.y).attr("y2",b.axis_rotated?a.height:a.y),a.ygrid.exit().remove(),a.smoothLines(a.ygrid,"grid")},f.redrawGrid=function(a,b){var c,d,e,f=this,g=f.main,h=f.config,i=f.CLASS;g.select("line."+i[cb]).style("visibility","hidden"),h.grid_x_show&&f.updateXGrid(),f.xgridLines=g.select("."+i[bb]).selectAll("."+i[ab]).data(h.grid_x_lines),c=f.xgridLines.enter().append("g").attr("class",function(a){return i[ab]+(a.class?" "+a.class:"")}),c.append("line").style("opacity",0),c.append("text").attr("text-anchor","end").attr("transform",h.axis_rotated?"":"rotate(-90)").attr("dx",h.axis_rotated?0:-f.margin.top).attr("dy",-5).style("opacity",0),f.xgridLines.exit().transition().duration(a).style("opacity",0).remove(),b&&h.grid_y_show&&f.updateYGrid(),b&&(f.ygridLines=g.select("."+i[gb]).selectAll("."+i[fb]).data(h.grid_y_lines),d=f.ygridLines.enter().append("g").attr("class",function(a){return i[fb]+(a.class?" "+a.class:"")}),d.append("line").style("opacity",0),d.append("text").attr("text-anchor","end").attr("transform",h.axis_rotated?"rotate(-90)":"").attr("dx",h.axis_rotated?0:-f.margin.top).attr("dy",-5).style("opacity",0),e=f.yv.bind(f),f.ygridLines.select("line").transition().duration(a).attr("x1",h.axis_rotated?e:0).attr("x2",h.axis_rotated?e:f.width).attr("y1",h.axis_rotated?0:e).attr("y2",h.axis_rotated?f.height:e).style("opacity",1),f.ygridLines.select("text").transition().duration(a).attr("x",h.axis_rotated?0:f.width).attr("y",e).text(function(a){return a.text}).style("opacity",1),f.ygridLines.exit().transition().duration(a).style("opacity",0).remove())},f.addTransitionForGrid=function(a){var b=this,c=b.config,d=b.xv.bind(b);a.push(b.xgridLines.select("line").transition().attr("x1",c.axis_rotated?0:d).attr("x2",c.axis_rotated?b.width:d).attr("y1",c.axis_rotated?d:b.margin.top).attr("y2",c.axis_rotated?d:b.height).style("opacity",1)),a.push(b.xgridLines.select("text").transition().attr("x",c.axis_rotated?b.width:0).attr("y",d).text(function(a){return a.text}).style("opacity",1))},f.showXGridFocus=function(a){var b=this,c=b.config,d=a.filter(function(a){return a&&zb(a.value)}),e=b.main.selectAll("line."+yb[cb]),f=b.xx.bind(b);c.tooltip_show&&(b.hasType("scatter")||b.hasArcType()||(e.style("visibility","visible").data([d[0]]).attr(c.axis_rotated?"y1":"x1",f).attr(c.axis_rotated?"y2":"x2",f),b.smoothLines(e,"grid")))},f.hideXGridFocus=function(){this.main.select("line."+yb[cb]).style("visibility","hidden")},f.updateXgridFocus=function(){var a=this,b=a.config;a.main.select("line."+yb[cb]).attr("x1",b.axis_rotated?0:-10).attr("x2",b.axis_rotated?a.width:-10).attr("y1",b.axis_rotated?-10:0).attr("y2",b.axis_rotated?-10:a.height)},f.generateGridData=function(a,b){var c,d,e,f,g=this,h=[],i=g.main.select("."+yb[ib]).selectAll(".tick").size();if("year"===a)for(c=g.getXDomain(),d=c[0].getFullYear(),e=c[1].getFullYear(),f=d;e>=f;f++)h.push(new Date(f+"-01-01 00:00:00"));else h=b.ticks(10),h.length>i&&(h=h.filter(function(a){return(""+a).indexOf(".")<0}));return h},f.getGridFilterToRemove=function(a){return a?function(b){var c=!1;return[].concat(a).forEach(function(d){("value"in d&&b.value===a.value||"class"in d&&b.class===a.class)&&(c=!0) -}),c}:function(){return!0}},f.removeGridLines=function(a,b){var c=this,d=c.config,e=c.getGridFilterToRemove(a),f=function(a){return!e(a)},g=b?yb[bb]:yb[gb],h=b?yb[ab]:yb.ygridLine;c.main.select("."+g).selectAll("."+h).filter(e).transition().duration(d.transition_duration).style("opacity",0).remove(),b?d.grid_x_lines=d.grid_x_lines.filter(f):d.grid_y_lines=d.grid_y_lines.filter(f)},f.initTooltip=function(){var a,b=this,c=b.config;if(b.tooltip=b.selectChart.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),c.tooltip_init_show){if(b.isTimeSeries()&&Bb(c.tooltip_init_x)){for(c.tooltip_init_x=b.parseDate(c.tooltip_init_x),a=0;a"+(g||0===g?"":"")),i=n(a[f].name),h=o(a[f].value,a[f].ratio,a[f].id,a[f].index),j=k.levelColor?k.levelColor(a[f].value):d(a[f].id),e+="",e+="",e+="",e+="");return e+"
" + title + "
" + name + "" + value + "
"+g+"
"+i+""+h+"
"},f.showTooltip=function(a,b){var c,d,e,f,g,h,i,j=this,k=j.config,l=j.hasArcType(),m=a.filter(function(a){return a&&zb(a.value)});0!==m.length&&k.tooltip_show&&(j.tooltip.html(k.tooltip_contents.call(j,a,j.getXAxisTickFormat(),j.getYFormat(l),j.color)).style("display","block"),c=j.tooltip.property("offsetWidth"),d=j.tooltip.property("offsetHeight"),l?(f=j.width/2+b[0],h=j.height/2+b[1]+20):(k.axis_rotated?(e=j.getSvgLeft(),f=e+b[0]+100,g=f+c,i=j.getCurrentWidth()-j.getCurrentPaddingRight(),h=j.x(m[0].x)+20):(e=j.getSvgLeft(),f=e+j.getCurrentPaddingLeft()+j.x(m[0].x)+20,g=f+c,i=e+j.getCurrentWidth()-j.getCurrentPaddingRight(),h=b[1]+15),g>i&&(f-=g-i),h+d>j.getCurrentHeight()&&h>d+30&&(h-=d+30)),j.tooltip.style("top",h+"px").style("left",f+"px"))},f.hideTooltip=function(){this.tooltip.style("display","none")},f.initLegend=function(){var a=this;a.legend=a.svg.append("g").attr("transform",a.getTranslate("legend")),a.config.legend_show||(a.legend.style("visibility","hidden"),a.hiddenLegendIds=a.mapToIds(a.data.targets)),a.updateLegend(a.mapToIds(a.data.targets),{withTransform:!1,withTransitionForTransform:!1,withTransition:!1})},f.updateSizeForLegend=function(a,b){var c=this,d=c.config,e={top:c.isLegendTop?c.getCurrentPaddingTop()+d.legend_inset_y+5.5:c.currentHeight-a-c.getCurrentPaddingBottom()-d.legend_inset_y,left:c.isLegendLeft?c.getCurrentPaddingLeft()+d.legend_inset_x+.5:c.currentWidth-b-c.getCurrentPaddingRight()-d.legend_inset_x+.5};c.margin3={top:c.isLegendRight?0:c.isLegendInset?e.top:c.currentHeight-a,right:0/0,bottom:0,left:c.isLegendRight?c.currentWidth-b:c.isLegendInset?e.left:0}},f.transformLegend=function(a){var b=this;(a?b.legend.transition():b.legend).attr("transform",b.getTranslate("legend"))},f.updateLegendStep=function(a){this.legendStep=a},f.updateLegendItemWidth=function(a){this.legendItemWidth=a},f.updateLegendItemHeight=function(a){this.legendItemHeight=a},f.getLegendWidth=function(){var a=this;return a.config.legend_show?a.isLegendRight||a.isLegendInset?a.legendItemWidth*(a.legendStep+1):a.currentWidth:0},f.getLegendHeight=function(){var a=this,b=a.config,c=0;return b.legend_show&&(c=a.isLegendRight?a.currentHeight:a.isLegendInset?b.legend_inset_step?Math.max(20,a.legendItemHeight)*(b.legend_inset_step+1):a.height:Math.max(20,a.legendItemHeight)*(a.legendStep+1)),c},f.opacityForLegend=function(a){var b=this;return a.classed(yb[sb])?b.legendOpacityForHidden:1},f.opacityForUnfocusedLegend=function(a){var b=this;return a.classed(yb[sb])?b.legendOpacityForHidden:.3},f.toggleFocusLegend=function(a,b){var c=this;c.legend.selectAll("."+yb[pb]).transition().duration(100).style("opacity",function(d){var e=c.d3.select(this);return a&&d!==a?b?c.opacityForUnfocusedLegend(e):c.opacityForLegend(e):b?c.opacityForLegend(e):c.opacityForUnfocusedLegend(e)})},f.revertLegend=function(){var a=this,b=a.d3;a.legend.selectAll("."+yb[pb]).transition().duration(100).style("opacity",function(){return a.opacityForLegend(b.select(this))})},f.showLegend=function(a){var b=this,c=b.config;c.legend_show||(c.legend_show=!0,b.legend.style("visibility","visible")),b.removeHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("visibility","visible").transition().style("opacity",function(){return b.opacityForLegend(b.d3.select(this))})},f.hideLegend=function(a){var b=this,c=b.config;c.legend_show&&Hb(a)&&(c.legend_show=!1,b.legend.style("visibility","hidden")),b.addHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("opacity",0).style("visibility","hidden")},f.updateLegend=function(a,b,c){function d(b,c,d){function e(a,b){b||(f=(l-x-k)/2,w>f&&(f=(l-k)/2,x=0,D++)),C[a]=D,B[D]=q.isLegendInset?10:f,y[a]=x,x+=k}var f,g,h=q.getTextRect(b.textContent,yb[pb]),i=10*Math.ceil((h.width+t)/10),j=10*Math.ceil((h.height+s)/10),k=q.isLegendRight||q.isLegendInset?j:i,l=q.isLegendRight||q.isLegendInset?q.getLegendHeight():q.getLegendWidth();return d&&(x=0,D=0,u=0,v=0),r.legend_show&&!q.isLegendToShow(c)?void(z[c]=A[c]=C[c]=y[c]=0):(z[c]=i,A[c]=j,(!u||i>=u)&&(u=i),(!v||j>=v)&&(v=j),g=q.isLegendRight||q.isLegendInset?v:u,void(r.legend_equally?(Object.keys(z).forEach(function(a){z[a]=u}),Object.keys(A).forEach(function(a){A[a]=v}),f=(l-g*a.length)/2,w>f?(x=0,D=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c)))}var e,f,g,h,i,j,k,l,m,n,o,p,q=this,r=q.config,s=4,t=36,u=0,v=0,w=10,x=0,y={},z={},A={},B=[0],C={},D=0,E=q.legend.selectAll("."+yb[tb]).size();b=b||{},l=Jb(b,"withTransition",!0),m=Jb(b,"withTransitionForTransform",!0),q.isLegendRight?(e=function(a){return u*C[a]},h=function(a){return B[C[a]]+y[a]}):q.isLegendInset?(e=function(a){return u*C[a]+10},h=function(a){return B[C[a]]+y[a]}):(e=function(a){return B[C[a]]+y[a]},h=function(a){return v*C[a]}),f=function(a,b){return e(a,b)+14},i=function(a,b){return h(a,b)+9},g=function(a,b){return e(a,b)-4},j=function(a,b){return h(a,b)-7},k=q.legend.selectAll("."+yb[pb]).data(a).enter().append("g").attr("class",function(a){return q.generateClass(yb[pb],a)}).style("visibility",function(a){return q.isLegendToShow(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){r.legend_item_onclick?r.legend_item_onclick.call(q,a):q.api.toggle(a)}).on("mouseover",function(a){q.d3.select(this).classed(yb[tb],!0),q.transiting||q.api.focus(a),r.legend_item_onmouseover&&r.legend_item_onmouseover.call(q,a)}).on("mouseout",function(a){q.d3.select(this).classed(yb[tb],!1),q.transiting||q.api.revert(),r.legend_item_onmouseout&&r.legend_item_onmouseout.call(q,a)}),k.append("text").text(function(a){return Db(r.data_names[a])?r.data_names[a]:a}).each(function(a,b){d(this,a,0===b)}).style("pointer-events","none").attr("x",q.isLegendRight||q.isLegendInset?f:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:i),k.append("rect").attr("class",yb[qb]).style("fill-opacity",0).attr("x",q.isLegendRight||q.isLegendInset?g:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:j),k.append("rect").attr("class",yb[rb]).style("pointer-events","none").style("fill",q.color).attr("x",q.isLegendRight||q.isLegendInset?f:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:h).attr("width",10).attr("height",10),q.isLegendInset&&0!==u&&q.legend.insert("g","."+yb[pb]).attr("class",yb[ob]).append("rect").attr("height",q.getLegendHeight()-10).attr("width",u*(D+1)+10),n=q.legend.selectAll("text").data(a).text(function(a){return Db(r.data_names[a])?r.data_names[a]:a}).each(function(a,b){d(this,a,0===b)}),(l?n.transition():n).attr("x",f).attr("y",i),o=q.legend.selectAll("rect."+yb[qb]).data(a),(l?o.transition():o).attr("width",function(a){return z[a]}).attr("height",function(a){return A[a]}).attr("x",g).attr("y",j),p=q.legend.selectAll("rect."+yb[rb]).data(a),(l?p.transition():p).style("fill",q.color).attr("x",e).attr("y",h),q.legend.selectAll("."+yb[pb]).classed(yb[sb],function(a){return!q.isTargetToShow(a)}).transition().style("opacity",function(a){var b=q.d3.select(this);return q.isTargetToShow(a)?!E||b.classed(yb[tb])?q.opacityForLegend(b):q.opacityForUnfocusedLegend(b):q.legendOpacityForHidden}),q.updateLegendItemWidth(u),q.updateLegendItemHeight(v),q.updateLegendStep(D),q.updateSizes(),q.updateScales(),q.updateSvgSize(),q.transformAll(m,c)},f.initAxis=function(){var a=this,b=a.config,c=a.main,d=a.CLASS;a.axes.x=c.append("g").attr("class",d[hb]+" "+d[ib]).attr("clip-path",a.clipPathForXAxis).attr("transform",a.getTranslate("x")).style("visibility",b.axis_x_show?"visible":"hidden"),a.axes.x.append("text").attr("class",d[jb]).attr("transform",b.axis_rotated?"rotate(-90)":"").style("text-anchor",a.textAnchorForXAxisLabel.bind(a)),a.axes.y=c.append("g").attr("class",d[hb]+" "+d[kb]).attr("clip-path",a.clipPathForYAxis).attr("transform",a.getTranslate("y")).style("visibility",b.axis_y_show?"visible":"hidden"),a.axes.y.append("text").attr("class",d[lb]).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForYAxisLabel.bind(a)),a.axes.y2=c.append("g").attr("class",d[hb]+" "+d[mb]).attr("transform",a.getTranslate("y2")).style("visibility",b.axis_y2_show?"visible":"hidden"),a.axes.y2.append("text").attr("class",d[nb]).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForY2AxisLabel.bind(a))},f.getXAxis=function(a,b,c,e){var f=this,g=f.config,h=d(f.d3,f.isCategorized()).scale(a).orient(b);return h.tickFormat(c).tickValues(e),f.isCategorized()?(h.tickCentered(g.axis_x_tick_centered),Hb(g.axis_x_tick_culling)&&(g.axis_x_tick_culling=!1)):h.tickOffset=function(){var a=f.getEdgeX(f.data.targets),b=f.x(a[1])-f.x(a[0]),c=b?b:g.axis_rotated?f.height:f.width;return c/f.getMaxDataCount()/2},h},f.getYAxis=function(a,b,c,e){return d(this.d3).scale(a).orient(b).tickFormat(c).ticks(e)},f.getAxisId=function(a){var b=this.config;return a in b.data_axes?b.data_axes[a]:"y"},f.getXAxisTickFormat=function(){var a=this,b=a.config,c=a.isTimeSeries()?a.defaultAxisTimeFormat:a.isCategorized()?a.categoryName:function(a){return 0>a?a.toFixed(0):a};return b.axis_x_tick_format&&(Ab(b.axis_x_tick_format)?c=b.axis_x_tick_format:a.isTimeSeries()&&(c=function(c){return c?a.axisTimeFormat(b.axis_x_tick_format)(c):""})),Ab(c)?function(b){return c.call(a,b)}:c},f.getAxisLabelOptionByAxisId=function(a){var b,c=this,d=c.config;return"y"===a?b=d.axis_y_label:"y2"===a?b=d.axis_y2_label:"x"===a&&(b=d.axis_x_label),b},f.getAxisLabelText=function(a){var b=this.getAxisLabelOptionByAxisId(a);return Bb(b)?b:b?b.text:null},f.setAxisLabelText=function(a,b){var c=this,d=c.config,e=c.getAxisLabelOptionByAxisId(a);Bb(e)?"y"===a?d.axis_y_label=b:"y2"===a?d.axis_y2_label=b:"x"===a&&(d.axis_x_label=b):e&&(e.text=b)},f.getAxisLabelPosition=function(a,b){var c=this.getAxisLabelOptionByAxisId(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}},f.getXAxisLabelPosition=function(){return this.getAxisLabelPosition("x",this.config.axis_rotated?"inner-top":"inner-right")},f.getYAxisLabelPosition=function(){return this.getAxisLabelPosition("y",this.config.axis_rotated?"inner-right":"inner-top")},f.getY2AxisLabelPosition=function(){return this.getAxisLabelPosition("y2",this.config.axis_rotated?"inner-right":"inner-top")},f.getAxisLabelPositionById=function(a){return"y2"===a?this.getY2AxisLabelPosition():"y"===a?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},f.textForXAxisLabel=function(){return this.getAxisLabelText("x")},f.textForYAxisLabel=function(){return this.getAxisLabelText("y")},f.textForY2AxisLabel=function(){return this.getAxisLabelText("y2")},f.xForAxisLabel=function(a,b){var c=this;return a?b.isLeft?0:b.isCenter?c.width/2:c.width:b.isBottom?-c.height:b.isMiddle?-c.height/2:0},f.dxForAxisLabel=function(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"},f.textAnchorForAxisLabel=function(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"},f.xForXAxisLabel=function(){return this.xForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},f.xForYAxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},f.xForY2AxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},f.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},f.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},f.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},f.dyForXAxisLabel=function(){var a=this,b=a.config,c=a.getXAxisLabelPosition();return b.axis_rotated?c.isInner?"1.2em":-25-a.getMaxTickWidth("x"):c.isInner?"-0.5em":b.axis_x_height?b.axis_x_height-10:"3em"},f.dyForYAxisLabel=function(){var a=this,b=a.getYAxisLabelPosition();return a.config.axis_rotated?b.isInner?"-0.5em":"3em":b.isInner?"1.2em":-20-a.getMaxTickWidth("y")},f.dyForY2AxisLabel=function(){var a=this,b=a.getY2AxisLabelPosition();return a.config.axis_rotated?b.isInner?"1.2em":"-2.2em":b.isInner?"-0.5em":30+this.getMaxTickWidth("y2")},f.textAnchorForXAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(!a.config.axis_rotated,a.getXAxisLabelPosition())},f.textAnchorForYAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getYAxisLabelPosition())},f.textAnchorForY2AxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getY2AxisLabelPosition())},f.xForRotatedTickText=function(a){return 10*Math.sin(Math.PI*(a/180))},f.yForRotatedTickText=function(a){return 11.5-2.5*(a/15)},f.rotateTickText=function(a,b,c){a.selectAll(".tick text").style("text-anchor","start"),b.selectAll(".tick text").attr("y",this.yForRotatedTickText(c)).attr("x",this.xForRotatedTickText(c)).attr("transform","rotate("+c+")")},f.getMaxTickWidth=function(a){var b,c,d,e=this,f=e.config,g=0;return e.svg&&(b=e.filterTargetsToShow(e.data.targets),"y"===a?(c=e.y.copy().domain(e.getYDomain(b,"y")),d=e.getYAxis(c,e.yOrient,f.axis_y_tick_format,f.axis_y_ticks)):"y2"===a?(c=e.y2.copy().domain(e.getYDomain(b,"y2")),d=e.getYAxis(c,e.y2Orient,f.axis_y2_tick_format,f.axis_y2_ticks)):(c=e.x.copy().domain(e.getXDomain(b)),d=e.getXAxis(c,e.xOrient,e.getXAxisTickFormat(),f.axis_x_tick_values?f.axis_x_tick_values:e.xAxis.tickValues())),e.main.append("g").call(d).each(function(){e.d3.select(this).selectAll("text").each(function(){var a=this.getBoundingClientRect();g=g?e.currentMaxTickWidth:g,e.currentMaxTickWidth},f.updateAxisLabels=function(a){var b=this,c=b.main.select("."+yb[ib]+" ."+yb[jb]),d=b.main.select("."+yb[kb]+" ."+yb[lb]),e=b.main.select("."+yb[mb]+" ."+yb[nb]);(a?c.transition():c).attr("x",b.xForXAxisLabel.bind(b)).attr("dx",b.dxForXAxisLabel.bind(b)).attr("dy",b.dyForXAxisLabel.bind(b)).text(b.textForXAxisLabel.bind(b)),(a?d.transition():d).attr("x",b.xForYAxisLabel.bind(b)).attr("dx",b.dxForYAxisLabel.bind(b)).attr("dy",b.dyForYAxisLabel.bind(b)).text(b.textForYAxisLabel.bind(b)),(a?e.transition():e).attr("x",b.xForY2AxisLabel.bind(b)).attr("dx",b.dxForY2AxisLabel.bind(b)).attr("dy",b.dyForY2AxisLabel.bind(b)).text(b.textForY2AxisLabel.bind(b))},f.getAxisPadding=function(a,b,c,d){var e="ratio"===a.unit?d:1;return zb(a[b])?a[b]*e:c},f.generateTickValues=function(a,b){var c,d,e,f,g,h,i,j=this,k=a;if(b)if(c=Ab(b)?b():b,1===c)k=[a[0]];else if(2===c)k=[a[0],a[a.length-1]];else if(c>2){for(f=c-2,d=a[0],e=a[a.length-1],g=(e-d)/(f+1),k=[d],h=0;f>h;h++)i=+d+g*(h+1),k.push(j.isTimeSeries()?new Date(i):i);k.push(e)}return j.isTimeSeries()||(k=k.sort(function(a,b){return a-b})),k},f.generateAxisTransitions=function(a){var b=this,c=b.axes;return{axisX:a?c.x.transition().duration(a):c.x,axisY:a?c.y.transition().duration(a):c.y,axisY2:a?c.y2.transition().duration(a):c.y2,axisSubX:a?c.subx.transition().duration(a):c.subx}},f.redrawAxis=function(a,b){var c=this;c.axes.x.style("opacity",b?0:1),c.axes.y.style("opacity",b?0:1),c.axes.y2.style("opacity",b?0:1),c.axes.subx.style("opacity",b?0:1),a.axisX.call(c.xAxis),a.axisY.call(c.yAxis),a.axisY2.call(c.y2Axis),a.axisSubX.call(c.subXAxis)},f.getClipPath=function(b){var c=a.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"},f.getAxisClipX=function(a){return a?-31:-(this.margin.left-1)},f.getAxisClipY=function(a){return a?-20:-4},f.getXAxisClipX=function(){var a=this;return a.getAxisClipX(!a.config.axis_rotated)},f.getXAxisClipY=function(){var a=this;return a.getAxisClipY(!a.config.axis_rotated)},f.getYAxisClipX=function(){var a=this;return a.getAxisClipX(a.config.axis_rotated)},f.getYAxisClipY=function(){var a=this;return a.getAxisClipY(a.config.axis_rotated)},f.getAxisClipWidth=function(a){var b=this;return a?b.width+2+30+30:b.margin.left+20},f.getAxisClipHeight=function(a){var b=this,c=b.config;return a?(c.axis_x_height?c.axis_x_height:0)+80:b.height+8},f.getXAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(!a.config.axis_rotated)},f.getXAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(!a.config.axis_rotated)},f.getYAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(a.config.axis_rotated)},f.getYAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(a.config.axis_rotated)},f.initPie=function(){var a=this,b=a.d3,c=a.config;a.pie=b.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)}),c.data_order&&c.pie_sort&&c.donut_sort||a.pie.sort(null)},f.updateRadius=function(){var a=this,b=a.config,c=b.gauge_width||b.donut_width;a.radiusExpanded=Math.min(a.arcWidth,a.arcHeight)/2,a.radius=.95*a.radiusExpanded,a.innerRadiusRatio=c?(a.radius-c)/a.radius:.6,a.innerRadius=a.hasType("donut")||a.hasType("gauge")?a.radius*a.innerRadiusRatio:0},f.updateArc=function(){var a=this;a.svgArc=a.getSvgArc(),a.svgArcExpanded=a.getSvgArcExpanded(),a.svgArcExpandedSub=a.getSvgArcExpanded(.98)},f.updateAngle=function(a){var b=this,c=b.config,d=!1,e=0;if(b.pie(b.filterTargetsToShow(b.data.targets)).sort(b.descByStartAngle).forEach(function(b){d||b.data.id!==a.data.id||(d=!0,a=b,a.index=e),e++}),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),b.isGaugeType(a.data)){var f=c.gauge_min,g=c.gauge_max,h=Math.abs(f)+g,i=Math.PI/h;a.startAngle=-1*(Math.PI/2)+i*Math.abs(f),a.endAngle=a.startAngle+i*(a.value>g?g:a.value)}return d?a:null},f.getSvgArc=function(){var a=this,b=a.d3.svg.arc().outerRadius(a.radius).innerRadius(a.innerRadius),c=function(c,d){var e;return d?b(c):(e=a.updateAngle(c),e?b(e):"M 0 0")};return c.centroid=b.centroid,c},f.getSvgArcExpanded=function(a){var b=this,c=b.d3.svg.arc().outerRadius(b.radiusExpanded*(a?a:1)).innerRadius(b.innerRadius);return function(a){var d=b.updateAngle(a);return d?c(d):"M 0 0"}},f.getArc=function(a,b,c){return c||this.isArcType(a.data)?this.svgArc(a,b):"M 0 0"},f.transformForArcLabel=function(a){var b,c,d,e,f,g=this,h=g.updateAngle(a),i="";return h&&!g.hasType("gauge")&&(b=this.svgArc.centroid(h),c=isNaN(b[0])?0:b[0],d=isNaN(b[1])?0:b[1],e=Math.sqrt(c*c+d*d),f=g.radius&&e?(36/g.radius>.375?1.175-36/g.radius:.8)*g.radius/e:0,i="translate("+c*f+","+d*f+")"),i},f.getArcRatio=function(a){var b=this,c=b.hasType("gauge")?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/c:null},f.convertToArcData=function(a){return this.addName({id:a.data.id,value:a.value,ratio:this.getArcRatio(a),index:a.index})},f.textForArcLabel=function(a){var b,c,d,e,f=this;return f.shouldShowArcLabel()?(b=f.updateAngle(a),c=b?b.value:null,d=f.getArcRatio(b),f.hasType("gauge")||f.meetsArcLabelThreshold(d)?(e=f.getArcLabelFormat(),e?e(c,d):f.defaultArcValueFormat(c,d)):""):""},f.expandArc=function(a,b){var c=this,d=c.svg.selectAll("."+yb[p]+c.selectorTarget(a)),e=c.svg.selectAll("."+yb[R]).filter(function(b){return b.data.id!==a});c.shouldExpand(a)&&d.selectAll("path").transition().duration(50).attr("d",c.svgArcExpanded).transition().duration(100).attr("d",c.svgArcExpandedSub).each(function(a){c.isDonutType(a.data)}),b||e.style("opacity",.3)},f.unexpandArc=function(a){var b=this,c=b.svg.selectAll("."+yb[p]+b.selectorTarget(a));c.selectAll("path."+yb[R]).transition().duration(50).attr("d",b.svgArc),b.svg.selectAll("."+yb[R]).style("opacity",1)},f.shouldExpand=function(a){var b=this,c=b.config;return b.isDonutType(a)&&c.donut_expand||b.isGaugeType(a)&&c.gauge_expand||b.isPieType(a)&&c.pie_expand},f.shouldShowArcLabel=function(){var a=this,b=a.config,c=!0;return a.hasType("donut")?c=b.donut_label_show:a.hasType("pie")&&(c=b.pie_label_show),c},f.meetsArcLabelThreshold=function(a){var b=this,c=b.config,d=b.hasType("donut")?c.donut_label_threshold:c.pie_label_threshold;return a>=d},f.getArcLabelFormat=function(){var a=this,b=a.config,c=b.pie_label_format;return a.hasType("gauge")?c=b.gauge_label_format:a.hasType("donut")&&(c=b.donut_label_format),c},f.getArcTitle=function(){var a=this;return a.hasType("donut")?a.config.donut_title:""},f.descByStartAngle=function(a,b){return a.startAngle-b.startAngle},f.updateTargetsForArc=function(a){var b,c,d=this,e=d.main,f=d.classChartArc.bind(d),g=d.classArcs.bind(d);b=e.select("."+yb[q]).selectAll("."+yb[p]).data(d.pie(a)).attr("class",f),c=b.enter().append("g").attr("class",f),c.append("g").attr("class",g),c.append("text").attr("dy",d.hasType("gauge")?"-0.35em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},f.initArc=function(){var a=this;a.arcs=a.main.select("."+yb[i]).append("g").attr("class",yb[q]).attr("transform",a.getTranslate("arc")),a.arcs.append("text").attr("class",yb[r]).style("text-anchor","middle").text(a.getArcTitle())},f.redrawArc=function(a,b,c){var d,e=this,f=e.d3,g=e.config,h=e.main;d=h.selectAll("."+yb[S]).selectAll("."+yb[R]).data(e.arcData.bind(e)),d.enter().append("path").attr("class",e.classArc.bind(e)).style("fill",function(a){return e.color(a.data)}).style("cursor",function(a){return g.data_selection_isselectable(a)?"pointer":null}).style("opacity",0).each(function(a){e.isGaugeType(a.data)&&(a.startAngle=a.endAngle=-1*(Math.PI/2)),this._current=a}).on("mouseover",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.expandArc(b.data.id),e.toggleFocusLegend(b.data.id,!0),e.config.data_onmouseover(c,this))}).on("mousemove",function(a){var b=e.updateAngle(a),c=e.convertToArcData(b),d=[c];e.showTooltip(d,f.mouse(this))}).on("mouseout",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.unexpandArc(b.data.id),e.revertLegend(),e.hideTooltip(),e.config.data_onmouseout(c,this))}).on("click",function(a,b){var c,d;e.toggleShape&&(c=e.updateAngle(a),d=e.convertToArcData(c),e.toggleShape(this,d,b))}),d.attr("transform",function(a){return!e.isGaugeType(a.data)&&c?"scale(0)":""}).style("opacity",function(a){return a===this._current?0:1}).each(function(){e.transiting=!0}).transition().duration(a).attrTween("d",function(a){var b,c=e.updateAngle(a);return c?(isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),b=f.interpolate(this._current,c),this._current=b(0),function(a){return e.getArc(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",c?"scale(1)":"").style("fill",function(a){return e.levelColor?e.levelColor(a.data.values[0].value):e.color(a.data.id)}).style("opacity",1).call(e.endall,function(){e.transiting=!1}),d.exit().transition().duration(b).style("opacity",0).remove(),h.selectAll("."+yb[p]).select("text").style("opacity",0).attr("class",function(a){return e.isGaugeType(a.data)?yb[Y]:""}).text(e.textForArcLabel.bind(e)).attr("transform",e.transformForArcLabel.bind(e)).transition().duration(a).style("opacity",function(a){return e.isTargetToShow(a.data.id)&&e.isArcType(a.data)?1:0}),h.select("."+yb[r]).style("opacity",e.hasType("donut")||e.hasType("gauge")?1:0)},f.initGauge=function(){var a=this,b=a.config,c=a.arcs;a.hasType("gauge")&&(c.append("path").attr("class",yb[s]).attr("d",function(){var c={data:[{value:b.gauge_max}],startAngle:-1*(Math.PI/2),endAngle:Math.PI/2};return a.getArc(c,!0,!0)}),c.append("text").attr("dy",".75em").attr("class",yb[t]).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_units:""),c.append("text").attr("dx",-1*(a.innerRadius+(a.radius-a.innerRadius)/2)+"px").attr("dy","1.2em").attr("class",yb[v]).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_min:""),c.append("text").attr("dx",a.innerRadius+(a.radius-a.innerRadius)/2+"px").attr("dy","1.2em").attr("class",yb[u]).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_max:""))},f.initRegion=function(){var a=this,b=a.CLASS;a.main.append("g").attr("clip-path",a.clipPath).attr("class",b[G])},f.redrawRegion=function(a){var b=this,c=b.config,d=b.CLASS;b.mainRegion=b.main.select("."+d[G]).selectAll("."+d[F]).data(c.regions),b.mainRegion.enter().append("g").attr("class",b.classRegion.bind(b)).append("rect").style("fill-opacity",0),b.mainRegion.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForRegion=function(a){var b=this,c=b.regionX.bind(b),d=b.regionY.bind(b),e=b.regionWidth.bind(b),f=b.regionHeight.bind(b);a.push(b.mainRegion.selectAll("rect").transition().attr("x",c).attr("y",d).attr("width",e).attr("height",f).style("fill-opacity",function(a){return zb(a.opacity)?a.opacity:.1}))},f.regionX=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?"start"in a?e(a.start):0:0:d.axis_rotated?0:"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0},f.regionY=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?0:"end"in a?e(a.end):0:d.axis_rotated?"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0:0},f.regionWidth=function(a){var b,c=this,d=c.config,e=c.regionX(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?"end"in a?f(a.end):c.width:c.width:d.axis_rotated?c.width:"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.width,e>b?0:b-e},f.regionHeight=function(a){var b,c=this,d=c.config,e=this.regionY(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?c.height:"start"in a?f(a.start):c.height:d.axis_rotated?"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.height:c.height,e>b?0:b-e},f.isRegionOnX=function(a){return!a.axis||"x"===a.axis},f.drag=function(a){var b,c,d,e,f,g,h,i,j=this,k=j.config,l=j.main,m=j.d3;j.hasArcType()||k.data_selection_enabled&&(!k.zoom_enabled||j.zoom.altDomain)&&k.data_selection_multiple&&(b=j.dragStart[0],c=j.dragStart[1],d=a[0],e=a[1],f=Math.min(b,d),g=Math.max(b,d),h=k.data_selection_grouped?j.margin.top:Math.min(c,e),i=k.data_selection_grouped?j.height:Math.max(c,e),l.select("."+yb[ub]).attr("x",f).attr("y",h).attr("width",g-f).attr("height",i-h),l.selectAll("."+yb[K]).selectAll("."+yb[J]).filter(function(a){return k.data_selection_isselectable(a)}).each(function(a,b){var c,d,e,k,l,n,o=m.select(this),p=o.classed(yb[wb]),q=o.classed(yb[xb]),r=!1;if(o.classed(yb[P]))c=1*o.attr("cx"),d=1*o.attr("cy"),l=j.togglePoint,r=c>f&&g>c&&d>h&&i>d;else{if(!o.classed(yb[N]))return;n=Lb(this),c=n.x,d=n.y,e=n.width,k=n.height,l=j.toggleBar,r=!(c>g||f>c+e||d>i||h>d+k)}r^q&&(o.classed(yb[xb],!q),o.classed(yb[wb],!p),l.call(j,!p,o,a,b))}))},f.dragstart=function(a){var b=this,c=b.config;b.hasArcType()||c.data_selection_enabled&&(b.dragStart=a,b.main.select("."+yb[i]).append("rect").attr("class",yb[ub]).style("opacity",.1),b.dragging=!0,b.config.data_ondragstart())},f.dragend=function(){var a=this,b=a.config;a.hasArcType()||b.data_selection_enabled&&(a.main.select("."+yb[ub]).transition().duration(100).style("opacity",0).remove(),a.main.selectAll("."+yb[J]).classed(yb[xb],!1),a.dragging=!1,a.config.data_ondragend())},f.selectPoint=function(a,b,c){var d=this,e=d.config,f=(e.axis_rotated?d.circleY:d.circleX).bind(d),g=(e.axis_rotated?d.circleX:d.circleY).bind(d),h=d.pointSelectR.bind(d);e.data_onselected.call(d.api,b,a.node()),d.main.select("."+yb[x]+d.getTargetSelectorSuffix(b.id)).selectAll("."+yb[w]+"-"+c).data([b]).enter().append("circle").attr("class",function(){return d.generateClass(yb[w],c)}).attr("cx",f).attr("cy",g).attr("stroke",function(){return d.color(b)}).attr("r",function(a){return 1.4*d.pointSelectR(a)}).transition().duration(100).attr("r",h)},f.unselectPoint=function(a,b,c){var d=this;d.config.data_onunselected(b,a.node()),d.main.select("."+yb[x]+d.getTargetSelectorSuffix(b.id)).selectAll("."+yb[w]+"-"+c).transition().duration(100).attr("r",0).remove()},f.togglePoint=function(a,b,c,d){a?this.selectPoint(b,c,d):this.unselectPoint(b,c,d)},f.selectBar=function(a,b){var c=this;c.config.data_onselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.d3.rgb(c.color(b)).brighter(.75)})},f.unselectBar=function(a,b){var c=this;c.config.data_onunselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.color(b)})},f.toggleBar=function(a,b,c,d){a?this.selectBar(b,c,d):this.unselectBar(b,c,d)},f.toggleArc=function(a,b,c,d){this.toggleBar(a,b,c.data,d)},f.getToggle=function(a){var b=this;return"circle"===a.nodeName?b.togglePoint:b.d3.select(a).classed(yb[N])?b.toggleBar:b.toggleArc},f.toggleShape=function(a,b,c){var d,e,f=this,g=f.d3,h=f.config,i=g.select(a),j=i.classed(yb[wb]);"circle"===a.nodeName?(d=f.isWithinCircle(a,1.5*f.pointSelectR(b)),e=f.togglePoint):"path"===a.nodeName&&(i.classed(yb[N])?(d=f.isWithinBar(a),e=f.toggleBar):(d=!0,e=f.toggleArc)),(h.data_selection_grouped||d)&&(h.data_selection_enabled&&h.data_selection_isselectable(b)&&(h.data_selection_multiple||f.main.selectAll("."+yb[K]+(h.data_selection_grouped?f.getTargetSelectorSuffix(b.id):"")).selectAll("."+yb[J]).each(function(a,b){var c=g.select(this);c.classed(yb[wb])&&e.call(f,!1,c.classed(yb[wb],!1),a,b)}),i.classed(yb[wb],!j),e.call(f,!j,i,b,c)),f.config.data_onclick.call(f.api,b,a))},f.initBrush=function(){var a=this,b=a.d3;a.brush=b.svg.brush().on("brush",function(){a.redrawForBrush()}),a.brush.update=function(){return a.context&&a.context.select("."+a.CLASS[D]).call(this),this},a.brush.scale=function(b){return a.config.axis_rotated?this.y(b):this.x(b)}},f.initSubchart=function(){var a=this,b=a.config,c=a.context=a.svg.append("g").attr("transform",a.getTranslate("context"));b.subchart_show||c.style("visibility","hidden"),c.append("g").attr("clip-path",a.clipPath).attr("class",yb[i]),c.select("."+yb[i]).append("g").attr("class",yb[m]),c.select("."+yb[i]).append("g").attr("class",yb[k]),c.append("g").attr("clip-path",a.clipPath).attr("class",yb[D]).call(a.brush).selectAll("rect").attr(b.axis_rotated?"width":"height",b.axis_rotated?a.width2:a.height2),a.axes.subx=c.append("g").attr("class",yb[ib]).attr("transform",a.getTranslate("subx")).attr("clip-path",b.axis_rotated?"":a.clipPathForXAxis)},f.updateTargetsForSubchart=function(a){var b,c,d,e,f=this,g=f.context,h=f.config,i=f.classChartBar.bind(f),n=f.classBars.bind(f),o=f.classChartLine.bind(f),p=f.classLines.bind(f),q=f.classAreas.bind(f); -h.subchart_show&&(e=g.select("."+yb[m]).selectAll("."+yb[l]).data(a).attr("class",i),d=e.enter().append("g").style("opacity",0).attr("class",i),d.append("g").attr("class",n),c=g.select("."+yb[k]).selectAll("."+yb[j]).data(a).attr("class",o),b=c.enter().append("g").style("opacity",0).attr("class",o),b.append("g").attr("class",p),b.append("g").attr("class",q))},f.redrawSubchart=function(a,b,c,d,e,f,g){var h,i,j,k,l,m,n=this,o=n.d3,p=n.context,q=n.config,r=n.barData.bind(n),s=n.lineData.bind(n),t=n.classBar.bind(n),u=n.classLine.bind(n),v=n.classArea.bind(n),w=n.initialOpacity.bind(n);q.subchart_show&&(o.event&&"zoom"===o.event.type&&n.brush.extent(n.x.orgDomain()).update(),a&&(!q.axis_rotated&&q.axis_x_tick_rotate&&n.rotateTickText(n.axes.subx,b.axisSubX,q.axis_x_tick_rotate),n.brush.empty()||n.brush.extent(n.x.orgDomain()).update(),k=n.generateDrawArea(e,!0),l=n.generateDrawBar(f,!0),m=n.generateDrawLine(g,!0),j=p.selectAll("."+yb[O]).selectAll("."+yb[N]).data(r),j.enter().append("path").attr("class",t).style("stroke","none").style("fill",n.color),j.style("opacity",w).transition().duration(c).attr("d",l).style("opacity",1),j.exit().transition().duration(c).style("opacity",0).remove(),h=p.selectAll("."+yb[M]).selectAll("."+yb[L]).data(s),h.enter().append("path").attr("class",u).style("stroke",n.color),h.style("opacity",w).transition().duration(c).attr("d",m).style("opacity",1),h.exit().transition().duration(c).style("opacity",0).remove(),i=p.selectAll("."+yb[U]).selectAll("."+yb[T]).data(s),i.enter().append("path").attr("class",v).style("fill",n.color).style("opacity",function(){return n.orgAreaOpacity=+o.select(this).style("opacity"),0}),i.style("opacity",0).transition().duration(c).attr("d",k).style("fill",n.color).style("opacity",n.orgAreaOpacity),i.exit().transition().duration(d).style("opacity",0).remove()))},f.redrawForBrush=function(){var a=this,b=a.x;a.redraw({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0}),a.config.subchart_onbrush.call(a.api,b.orgDomain())},f.transformContext=function(a,b){var c,d=this;b&&b.axisSubX?c=b.axisSubX:(c=d.context.select("."+yb[ib]),a&&(c=c.transition())),d.context.attr("transform",d.getTranslate("context")),c.attr("transform",d.getTranslate("subx"))},f.initZoom=function(){var a=this,b=a.d3,c=a.config;a.zoom=b.behavior.zoom().on("zoomstart",function(){a.zoom.altDomain=b.event.sourceEvent.altKey?a.x.orgDomain():null}).on("zoom",function(){a.redrawForZoom.call(a)}),a.zoom.scale=function(a){return c.axis_rotated?this.y(a):this.x(a)},a.zoom.orgScaleExtent=function(){var b=c.zoom_extent?c.zoom_extent:[1,10];return[b[0],Math.max(a.getMaxDataCount()/b[1],b[1])]},a.zoom.updateScaleExtent=function(){var b=Gb(a.x.orgDomain())/Gb(a.orgXDomain),c=this.orgScaleExtent();return this.scaleExtent([c[0]*b,c[1]*b]),this}},f.updateZoom=function(){var a=this,b=a.config.zoom_enabled?a.zoom:function(){};a.main.select("."+a.CLASS[C]).call(b),a.main.selectAll("."+a.CLASS[y]).call(b)},f.redrawForZoom=function(){var a=this,b=a.d3,c=a.config,d=a.zoom,e=a.x,f=a.orgXDomain;if(c.zoom_enabled&&0!==a.filterTargetsToShow(a.data.targets).length){if("mousemove"===b.event.sourceEvent.type&&d.altDomain)return e.domain(d.altDomain),void d.scale(e).updateScaleExtent();a.isCategorized()&&e.orgDomain()[0]===f[0]&&e.domain([f[0]-1e-10,e.orgDomain()[1]]),a.redraw({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===b.event.sourceEvent.type&&(a.cancelClick=!0),c.zoom_onzoom.call(a.api,e.orgDomain())}},f.generateColor=function(){var a=this,b=a.config,c=a.d3,d=b.data_colors,e=Ib(b.color_pattern)?b.color_pattern:c.scale.category10().range(),f=b.data_color,g=[];return function(a){var b,c=a.id||a;return d[c]instanceof Function?b=d[c](a):d[c]?b=d[c]:(g.indexOf(c)<0&&g.push(c),b=e[g.indexOf(c)%e.length],d[c]=b),f instanceof Function?f(b,a):b}},f.generateLevelColor=function(){var a=this,b=a.config,c=b.color_pattern,d=b.color_threshold,e="value"===d.unit,f=d.values&&d.values.length?d.values:[],g=d.max||100;return Ib(b.color_threshold)?function(a){var b,d,h=c[c.length-1];for(b=0;b0},Jb=f.getOption=function(a,b,c){return Db(a[b])?a[b]:c},Kb=f.hasValue=function(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c},Lb=f.getPathBox=function(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}};e.focus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),this.defocus(),b(e.classed(yb[E],!0)),b(f),c.hasArcType()&&c.expandArc(a,!0),c.toggleFocusLegend(a,!0)},e.defocus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",.3)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),b(e.classed(yb[E],!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.toggleFocusLegend(a,!1)},e.revert=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));b(e.classed(yb[E],!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.revertLegend()},e.show=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.removeHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",1),b.withLegend&&c.showLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.hide=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.addHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",0),b.withLegend&&c.hideLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.toggle=function(a){var b=this.internal;b.isTargetToShow(a)?this.hide(a):this.show(a)},e.zoom=function(){},e.zoom.enable=function(a){var b=this.internal;b.config.zoom_enabled=a,b.updateAndRedraw()},e.unzoom=function(){var a=this.internal;a.brush.clear().update(),a.redraw({withUpdateXDomain:!0})},e.load=function(a){var b=this.internal,c=b.config;return a.xs&&b.addXs(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){c.data_classes[b]=a.classes[b]}),"categories"in a&&b.isCategorized()&&(c.axis_x_categories=a.categories),"cacheIds"in a&&b.hasCaches(a.cacheIds)?void b.load(b.getCaches(a.cacheIds),a.done):void("unload"in a?b.unload(b.mapToTargetIds("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){b.loadFromArgs(a)}):b.loadFromArgs(a))},e.unload=function(a){var b=this.internal;a=a||{},b.unload(b.mapToTargetIds(a.ids),function(){b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),a.done&&a.done()})},e.flow=function(a){var b,c,d,e,f,g,h,i,j=this.internal,k=[],l=j.getMaxDataCount(),m=0,n=0;if(a.json)c=j.convertJsonToData(a.json,a.keys);else if(a.rows)c=j.convertRowsToData(a.rows);else{if(!a.columns)return;c=j.convertColumnsToData(a.columns)}b=j.convertDataToTargets(c,!0),j.data.targets.forEach(function(a){var c,d,e=!1;for(c=0;cd;d++)b[c].values[d].index=n+d,j.isTimeSeries()||(b[c].values[d].x=n+d);a.values=a.values.concat(b[c].values),b.splice(c,1);break}e||k.push(a.id)}),j.data.targets.forEach(function(a){var b,c;for(b=0;bc;c++)a.values.push({id:a.id,index:n+c,x:j.isTimeSeries()?j.getOtherTargetX(n+c):n+c,value:null})}),j.data.targets.length&&b.forEach(function(a){var b,c=[];for(b=j.data.targets[0].values[0].index;n>b;b++)c.push({id:a.id,index:b,x:j.isTimeSeries()?j.getOtherTargetX(b):b,value:null});a.values.forEach(function(a){a.index+=n,j.isTimeSeries()||(a.x+=n)}),a.values=c.concat(a.values)}),j.data.targets=j.data.targets.concat(b),d=j.getMaxDataCount(),f=j.data.targets[0],g=f.values[0],Db(a.to)?(m=0,i=j.isTimeSeries()?j.parseDate(a.to):a.to,f.values.forEach(function(a){a.x1?f.values[f.values.length-1].x-g.x:g.x-j.getXDomain(j.data.targets)[0]:1,e=[g.x-h,g.x],j.updateXDomain(null,!0,!0,e)),j.updateTargets(j.data.targets),j.redraw({flow:{index:g.index,length:m,duration:zb(a.duration)?a.duration:j.config.transition_duration,done:a.done,orgDataCount:l},withLegend:!0,withTransition:l>1})},f.generateFlow=function(a){var b=this,c=b.config,d=b.d3,e=b.CLASS;return function(){var f,g,h,i=a.targets,j=a.flow,k=a.drawBar,l=a.drawLine,m=a.drawArea,n=a.cx,o=a.cy,p=a.xv,q=a.xForText,r=a.yForText,s=a.duration,t=1,u=j.index,v=j.length,w=b.getValueOnIndex(b.data.targets[0].values,u),x=b.getValueOnIndex(b.data.targets[0].values,u+v),A=b.x.domain(),B=j.duration||s,C=j.done||function(){},D=b.generateWait(),E=b.xgrid||d.selectAll([]),F=b.xgridLines||d.selectAll([]),G=b.mainRegion||d.selectAll([]),H=b.mainText||d.selectAll([]),I=b.mainBar||d.selectAll([]),L=b.mainLine||d.selectAll([]),M=b.mainArea||d.selectAll([]),N=b.mainCircle||d.selectAll([]);b.data.targets.forEach(function(a){a.values.splice(0,v)}),h=b.updateXDomain(i,!0,!0),b.updateXGrid&&b.updateXGrid(!0),j.orgDataCount?f=1===j.orgDataCount||w.x===x.x?b.x(A[0])-b.x(h[0]):b.isTimeSeries()?b.x(A[0])-b.x(h[0]):b.x(w.x)-b.x(x.x):1!==b.data.targets[0].values.length?f=b.x(A[0])-b.x(h[0]):b.isTimeSeries()?(w=b.getValueOnIndex(b.data.targets[0].values,0),x=b.getValueOnIndex(b.data.targets[0].values,b.data.targets[0].values.length-1),f=b.x(w.x)-b.x(x.x)):f=Gb(h)/2,t=Gb(A)/Gb(h),g="translate("+f+",0) scale("+t+",1)",d.transition().ease("linear").duration(B).each(function(){D.add(b.axes.x.transition().call(b.xAxis)),D.add(I.transition().attr("transform",g)),D.add(L.transition().attr("transform",g)),D.add(M.transition().attr("transform",g)),D.add(N.transition().attr("transform",g)),D.add(H.transition().attr("transform",g)),D.add(G.filter(b.isRegionOnX).transition().attr("transform",g)),D.add(E.transition().attr("transform",g)),D.add(F.transition().attr("transform",g))}).call(D,function(){var a,d=[],f=[],g=[];if(v){for(a=0;v>a;a++)d.push("."+e[J]+"-"+(u+a)),f.push("."+e[W]+"-"+(u+a)),g.push("."+e[y]+"-"+(u+a));b.svg.selectAll("."+e[K]).selectAll(d).remove(),b.svg.selectAll("."+e[X]).selectAll(f).remove(),b.svg.selectAll("."+e[z]).selectAll(g).remove(),b.svg.select("."+e[$]).remove()}E.attr("transform",null).attr(b.xgridAttr),F.attr("transform",null),F.select("line").attr("x1",c.axis_rotated?0:p).attr("x2",c.axis_rotated?b.width:p),F.select("text").attr("x",c.axis_rotated?b.width:0).attr("y",p),I.attr("transform",null).attr("d",k),L.attr("transform",null).attr("d",l),M.attr("transform",null).attr("d",m),N.attr("transform",null).attr("cx",n).attr("cy",o),H.attr("transform",null).attr("x",q).attr("y",r).style("fill-opacity",b.opacityForText.bind(b)),G.attr("transform",null),G.select("rect").filter(b.isRegionOnX).attr("x",b.regionX.bind(b)).attr("width",b.regionWidth.bind(b)),b.updateEventRect(),C()})}},e.selected=function(a){var b=this.internal,c=b.d3;return c.merge(b.main.selectAll("."+yb[K]+b.getTargetSelectorSuffix(a)).selectAll("."+yb[J]).filter(function(){return c.select(this).classed(yb[wb])}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},e.select=function(a,b,c){var d=this.internal,e=d.d3,f=d.config;f.data_selection_enabled&&d.main.selectAll("."+yb[K]).selectAll("."+yb[J]).each(function(g,h){var i=e.select(this),j=g.data?g.data.id:g.id,k=d.getToggle(this),l=f.data_selection_grouped||!a||a.indexOf(j)>=0,m=!b||b.indexOf(h)>=0,n=i.classed(yb[wb]);i.classed(yb[L])||i.classed(yb[T])||(l&&m?f.data_selection_isselectable(g)&&!n&&k(!0,i.classed(yb[wb],!0),g,h):Db(c)&&c&&n&&k(!1,i.classed(yb[wb],!1),g,h))})},e.unselect=function(a,b){var c=this.internal,d=c.d3,e=c.config;e.data_selection_enabled&&c.main.selectAll("."+yb[K]).selectAll("."+yb[J]).each(function(f,g){var h=d.select(this),i=f.data?f.data.id:f.id,j=c.getToggle(this),k=e.data_selection_grouped||!a||a.indexOf(i)>=0,l=!b||b.indexOf(g)>=0,m=h.classed(yb[wb]);h.classed(yb[L])||h.classed(yb[T])||k&&l&&e.data_selection_isselectable(f)&&m&&j(!1,h.classed(yb[wb],!1),f,g)})},e.transform=function(a,b){var c=this.internal,d=["pie","donut"].indexOf(a)>=0?{withTransform:!0}:null;c.transformTo(b,a,d)},f.transformTo=function(a,b,c){var d=this,e=!d.hasArcType(),f=c||{withTransitionForAxis:e};f.withTransitionForTransform=!1,d.transiting=!1,d.setTargetType(a,b),d.updateAndRedraw(f)},e.groups=function(a){var b=this.internal,c=b.config;return Cb(a)?c.data_groups:(c.data_groups=a,b.redraw(),c.data_groups)},e.xgrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_x_lines=a,b.redraw(),c.grid_x_lines):c.grid_x_lines},e.xgrids.add=function(a){var b=this.internal;return this.xgrids(b.config.grid_x_lines.concat(a?a:[]))},e.xgrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!0)},e.ygrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_y_lines=a,b.redraw(),c.grid_y_lines):c.grid_y_lines},e.ygrids.add=function(a){var b=this.internal;return this.ygrids(b.config.grid_y_lines.concat(a?a:[]))},e.ygrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!1)},e.regions=function(a){var b=this.internal,c=b.config;return a?(c.regions=a,b.redraw(),c.regions):c.regions},e.regions.add=function(a){var b=this.internal,c=b.config;return a?(c.regions=c.regions.concat(a),b.redraw(),c.regions):c.regions},e.regions.remove=function(a){var b,c,d,e=this.internal,f=e.config;return a=a||{},b=e.getOption(a,"duration",f.transition_duration),c=e.getOption(a,"classes",[yb[F]]),d=e.main.select("."+yb[G]).selectAll(c.map(function(a){return"."+a})),(b?d.transition().duration(b):d).style("opacity",0).remove(),f.regions=f.regions.filter(function(a){var b=!1;return a.class?(a.class.split(" ").forEach(function(a){c.indexOf(a)>=0&&(b=!0)}),!b):!0}),f.regions},e.data=function(){},e.data.get=function(a){var b=this.data.getAsTarget(a);return Db(b)?b.values.map(function(a){return a.value}):void 0},e.data.getAsTarget=function(a){var b=this.data.targets.filter(function(b){return b.id===a});return b.length>0?b[0]:void 0},e.data.names=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_names[b]=a[b]}),b.redraw({withLegend:!0}),c.data_names):c.data_names},e.data.colors=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_colors[b]=a[b]}),b.redraw({withLegend:!0}),c.data_colors):c.data_colors},e.category=function(a,b){var c=this.internal,d=c.config;return arguments.length>1&&(d.axis_x_categories[a]=b,c.redraw()),d.axis_x_categories[a]},e.categories=function(a){var b=this.internal,c=b.config;return arguments.length?(c.axis_x_categories=a,b.redraw(),c.axis_x_categories):c.axis_x_categories},e.color=function(a){var b=this.internal;return b.color(a)},e.x=function(a){var b=this.internal;return arguments.length&&(b.updateTargetX(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.xs=function(a){var b=this.internal;return arguments.length&&(b.updateTargetXs(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.axis=function(){},e.axis.labels=function(a){var b=this.internal;arguments.length&&(Object.keys(a).forEach(function(c){b.setAxisLabelText(c,a[c])}),b.updateAxisLabels())},e.axis.max=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(zb(a.x)&&(c.axis_x_max=a.x),zb(a.y)&&(c.axis_y_max=a.y),zb(a.y2)&&(c.axis_y2_max=a.y2)):c.axis_y_max=c.axis_y2_max=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.min=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(zb(a.x)&&(c.axis_x_min=a.x),zb(a.y)&&(c.axis_y_min=a.y),zb(a.y2)&&(c.axis_y2_min=a.y2)):c.axis_y_min=c.axis_y2_min=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.range=function(a){arguments.length&&(Db(a.max)&&this.axis.max(a.max),Db(a.min)&&this.axis.min(a.min))},e.legend=function(){},e.legend.show=function(a){var b=this.internal;b.showLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.legend.hide=function(a){var b=this.internal;b.hideLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.resize=function(a){var b=this.internal,c=b.config;c.size_width=a?a.width:null,c.size_height=a?a.height:null,this.flush()},e.flush=function(){var a=this.internal;a.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},e.destroy=function(){var b=this.internal;b.data.targets=void 0,b.data.xs={},b.selectChart.classed("c3",!1).html(""),a.onresize=null},"function"==typeof define&&define.amd?define("c3",["d3"],g):"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=g:a.c3=g}(window); \ No newline at end of file +!function(a){"use strict";function b(a){var b=this.internal=new c(this);b.loadConfig(a),b.init(),function d(a,b,c){for(var e in a)b[e]=a[e].bind(c),Object.keys(a[e]).length>0&&d(a[e],b[e],c)}(e,this,this)}function c(b){var c=this;c.d3=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,c.api=b,c.config=c.getDefaultConfig(),c.data={},c.cache={},c.axes={}}function d(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,k);for(c=a.domain(),b=Math.ceil(c[0]);b0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=m.copy();return b&&(a=m.domain(),c.domain([a[0],a[1]-1])),c}function h(a){return j?j(a):a}function i(i){i.each(function(){function i(a){var b=m(a)+s;return B[0]=0&&C.select(this).style("display",b%z?"none":"block")})}else A.svg.selectAll("."+h.axisX+" .tick text").style("display","block");!D.axis_rotated&&D.axis_x_tick_rotate&&A.rotateTickText(A.axes.x,b.axisX,D.axis_x_tick_rotate),m=A.generateDrawArea?A.generateDrawArea(E,!1):void 0,n=A.generateDrawBar?A.generateDrawBar(F):void 0,o=A.generateDrawLine?A.generateDrawLine(G,!1):void 0,p=A.generateXYForText(F,!0),q=A.generateXYForText(F,!1),A.subY.domain(A.y.domain()),A.subY2.domain(A.y2.domain()),A.tooltip.style("display","none"),A.updateXgridFocus(),B.select("text."+h.text+"."+h.empty).attr("x",A.width/2).attr("y",A.height/2).text(D.data_empty_label_text).transition().style("opacity",I.length?0:1),A.redrawGrid(r,c),A.redrawRegion(r),A.redrawBar(t),A.redrawLine(t),A.redrawArea(t),D.point_show&&A.redrawCircle(),A.hasDataLabel()&&A.redrawText(t),A.redrawArc&&A.redrawArc(r,t,i),A.redrawSubchart&&A.redrawSubchart(d,b,r,t,E,F,G),B.selectAll("."+h.selectedCircles).filter(A.isBarType.bind(A)).selectAll("circle").remove(),D.interaction_enabled&&A.redrawEventRect(),C.transition().duration(r).each(function(){var b=[];A.addTransitionForBar(b,n),A.addTransitionForLine(b,o),A.addTransitionForArea(b,m),A.addTransitionForCircle(b,K,L),A.addTransitionForText(b,p,q,a.flow),A.addTransitionForRegion(b),A.addTransitionForGrid(b),a.flow&&(v=A.generateWait(),b.forEach(function(a){v.add(a)}),w=A.generateFlow({targets:I,flow:a.flow,duration:r,drawBar:n,drawLine:o,drawArea:m,cx:K,cy:L,xv:J,xForText:p,yForText:q}))}).call(v||function(){},w||function(){}),A.mapToIds(A.data.targets).forEach(function(a){A.withoutFadeIn[a]=!0}),A.updateZoom&&A.updateZoom()},f.updateAndRedraw=function(a){var b,c=this,d=c.config;a=a||{},a.withTransition=s(a,"withTransition",!0),a.withTransform=s(a,"withTransform",!1),a.withLegend=s(a,"withLegend",!1),a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,a.withTransitionForTransform=s(a,"withTransitionForTransform",a.withTransition),c.updateSizes(),a.withLegend&&d.legend_show||(b=c.generateAxisTransitions(a.withTransitionForAxis?d.transition_duration:0),c.updateScales(),c.updateSvgSize(),c.transformAll(a.withTransitionForTransform,b)),c.redraw(a,b)},f.isTimeSeries=function(){return"timeseries"===this.config.axis_x_type},f.isCategorized=function(){return this.config.axis_x_type.indexOf("categor")>=0},f.isCustomX=function(){var a=this,b=a.config;return!a.isTimeSeries()&&(b.data_x||r(b.data_xs))},f.getTranslate=function(a){var b,c,d=this,e=d.config;return"main"===a?(b=o(d.margin.left),c=o(d.margin.top)):"context"===a?(b=o(d.margin2.left),c=o(d.margin2.top)):"legend"===a?(b=d.margin3.left,c=d.margin3.top):"x"===a?(b=0,c=e.axis_rotated?0:d.height):"y"===a?(b=0,c=e.axis_rotated?d.height:0):"y2"===a?(b=e.axis_rotated?0:d.width,c=e.axis_rotated?1:0):"subx"===a?(b=0,c=e.axis_rotated?0:d.height2):"arc"===a&&(b=d.arcWidth/2,c=d.arcHeight/2),"translate("+b+","+c+")"},f.initialOpacity=function(a){return null!==a.value&&this.withoutFadeIn[a.id]?1:0},f.opacityForCircle=function(a){var b=this;return i(a.value)?b.isScatterType(a)?.5:1:0},f.opacityForText=function(){return this.hasDataLabel()?1:0},f.xx=function(a){return a?this.x(a.x):null},f.xv=function(a){var b=this;return Math.ceil(b.x(b.isTimeSeries()?b.parseDate(a.value):a.value))},f.yv=function(a){var b=this,c=a.axis&&"y2"===a.axis?b.y2:b.y;return Math.ceil(c(a.value))},f.subxx=function(a){return a?this.subX(a.x):null},f.transformMain=function(a,b){var c,d,e,f=this;b&&b.axisX?c=b.axisX:(c=f.main.select("."+h.axisX),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=f.main.select("."+h.axisY),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=f.main.select("."+h.axisY2),a&&(e=e.transition())),(a?f.main.transition():f.main).attr("transform",f.getTranslate("main")),c.attr("transform",f.getTranslate("x")),d.attr("transform",f.getTranslate("y")),e.attr("transform",f.getTranslate("y2")),f.main.select("."+h.chartArcs).attr("transform",f.getTranslate("arc"))},f.transformAll=function(a,b){var c=this;c.transformMain(a,b),c.config.subchart_show&&c.transformContext(a,b),c.legend&&c.transformLegend(a)},f.updateSvgSize=function(){var a=this;a.svg.attr("width",a.currentWidth).attr("height",a.currentHeight),a.svg.select("#"+a.clipId).select("rect").attr("width",a.width).attr("height",a.height),a.svg.select("#"+a.clipIdForXAxis).select("rect").attr("x",a.getXAxisClipX.bind(a)).attr("y",a.getXAxisClipY.bind(a)).attr("width",a.getXAxisClipWidth.bind(a)).attr("height",a.getXAxisClipHeight.bind(a)),a.svg.select("#"+a.clipIdForYAxis).select("rect").attr("x",a.getYAxisClipX.bind(a)).attr("y",a.getYAxisClipY.bind(a)).attr("width",a.getYAxisClipWidth.bind(a)).attr("height",a.getYAxisClipHeight.bind(a)),a.svg.select("."+h.zoomRect).attr("width",a.width).attr("height",a.height),a.selectChart.style("max-height",a.currentHeight+"px")},f.updateDimension=function(){var a=this;a.config.axis_rotated?(a.axes.x.call(a.xAxis),a.axes.subx.call(a.subXAxis)):(a.axes.y.call(a.yAxis),a.axes.y2.call(a.y2Axis)),a.updateSizes(),a.updateScales(),a.updateSvgSize(),a.transformAll(!1)},f.observeInserted=function(b){var c=this,d=new MutationObserver(function(e){e.forEach(function(e){if("childList"===e.type&&e.previousSibling){d.disconnect();var f=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(f),c.updateDimension(),c.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),b.transition().style("opacity",1))},10)}})});d.observe(b.node(),{attributes:!0,childList:!0,characterData:!0})},f.generateResize=function(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a},f.endall=function(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})},f.generateWait=function(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0;a.forEach(function(a){if(a.empty())return void(b+=1);try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b},f.parseDate=function(b){var c,d=this;return c=b instanceof Date?b:"number"==typeof b?new Date(b):d.dataTimeFormat(d.config.data_xFormat).parse(b),(!c||isNaN(+c))&&a.console.error("Failed to parse x '"+b+"' to Date object"),c},f.getDefaultConfig=function(){var a={bindto:"#chart",size_width:void 0,size_height:void 0,padding_left:void 0,padding_right:void 0,padding_top:void 0,padding_bottom:void 0,zoom_enabled:!1,zoom_extent:void 0,zoom_privileged:!1,zoom_onzoom:function(){},interaction_enabled:!0,onmouseover:function(){},onmouseout:function(){},onresize:function(){},onresized:function(){},transition_duration:350,data_x:void 0,data_xs:{},data_xFormat:"%Y-%m-%d",data_xLocaltime:!0,data_idConverter:function(a){return a},data_names:{},data_classes:{},data_groups:[],data_axes:{},data_type:void 0,data_types:{},data_labels:{},data_order:"desc",data_regions:{},data_color:void 0,data_colors:{},data_hide:!1,data_filter:void 0,data_selection_enabled:!1,data_selection_grouped:!1,data_selection_isselectable:function(){return!0},data_selection_multiple:!0,data_onclick:function(){},data_onmouseover:function(){},data_onmouseout:function(){},data_onselected:function(){},data_onunselected:function(){},data_ondragstart:function(){},data_ondragend:function(){},data_url:void 0,data_json:void 0,data_rows:void 0,data_columns:void 0,data_mimeType:void 0,data_keys:void 0,data_empty_label_text:"",subchart_show:!1,subchart_size_height:60,subchart_onbrush:function(){},color_pattern:[],color_threshold:{},legend_show:!0,legend_position:"bottom",legend_inset_anchor:"top-left",legend_inset_x:10,legend_inset_y:0,legend_inset_step:void 0,legend_item_onclick:void 0,legend_item_onmouseover:void 0,legend_item_onmouseout:void 0,legend_equally:!1,axis_rotated:!1,axis_x_show:!0,axis_x_type:"indexed",axis_x_localtime:!0,axis_x_categories:[],axis_x_tick_centered:!1,axis_x_tick_format:void 0,axis_x_tick_culling:{},axis_x_tick_culling_max:10,axis_x_tick_count:void 0,axis_x_tick_fit:!0,axis_x_tick_values:null,axis_x_tick_rotate:void 0,axis_x_tick_outer:!0,axis_x_max:null,axis_x_min:null,axis_x_padding:{},axis_x_height:void 0,axis_x_default:void 0,axis_x_label:{},axis_y_show:!0,axis_y_max:void 0,axis_y_min:void 0,axis_y_center:void 0,axis_y_label:{},axis_y_tick_format:void 0,axis_y_tick_outer:!0,axis_y_padding:void 0,axis_y_ticks:10,axis_y2_show:!1,axis_y2_max:void 0,axis_y2_min:void 0,axis_y2_center:void 0,axis_y2_label:{},axis_y2_tick_format:void 0,axis_y2_tick_outer:!0,axis_y2_padding:void 0,axis_y2_ticks:10,grid_x_show:!1,grid_x_type:"tick",grid_x_lines:[],grid_y_show:!1,grid_y_lines:[],grid_y_ticks:10,grid_focus_show:!0,point_show:!0,point_r:2.5,point_focus_expand_enabled:!0,point_focus_expand_r:void 0,point_select_r:void 0,line_connect_null:!1,bar_width:void 0,bar_width_ratio:.6,bar_width_max:void 0,bar_zerobased:!0,area_zerobased:!0,pie_label_show:!0,pie_label_format:void 0,pie_label_threshold:.05,pie_sort:!0,pie_expand:!0,gauge_label_show:!0,gauge_label_format:void 0,gauge_expand:!0,gauge_min:0,gauge_max:100,gauge_units:void 0,gauge_width:void 0,donut_label_show:!0,donut_label_format:void 0,donut_label_threshold:.05,donut_width:void 0,donut_sort:!0,donut_expand:!0,donut_title:"",regions:[],tooltip_show:!0,tooltip_grouped:!0,tooltip_format_title:void 0,tooltip_format_name:void 0,tooltip_format_value:void 0,tooltip_contents:function(a,b,c,d){return this.getTooltipContent?this.getTooltipContent(a,b,c,d):""},tooltip_init_show:!1,tooltip_init_x:0,tooltip_init_position:{top:"0px",left:"50px"}};return Object.keys(this.additionalConfig).forEach(function(b){a[b]=this.additionalConfig[b]},this),a},f.additionalConfig={},f.loadConfig=function(a){function b(){var a=d.shift();return a&&c&&"object"==typeof c&&a in c?(c=c[a],b()):a?void 0:c}var c,d,e,f=this.config;Object.keys(f).forEach(function(g){c=a,d=g.split("_"),e=b(),m(e)&&(f[g]=e)})},f.getScale=function(a,b,c){return(c?this.d3.time.scale():this.d3.scale.linear()).range([a,b])},f.getX=function(a,b,c,d){var e,f=this,g=f.getScale(a,b,f.isTimeSeries()),h=c?g.domain(c):g;f.isCategorized()?(d=d||function(){return 0},g=function(a,b){var c=h(a)+d(a);return b?c:Math.ceil(c)}):g=function(a,b){var c=h(a);return b?c:Math.ceil(c)};for(e in h)g[e]=h[e];return g.orgDomain=function(){return h.domain()},f.isCategorized()&&(g.domain=function(a){return arguments.length?(h.domain(a),g):(a=this.orgDomain(),[a[0],a[1]+1])}),g},f.getY=function(a,b,c){var d=this.getScale(a,b);return c&&d.domain(c),d},f.getYScale=function(a){return"y2"===this.getAxisId(a)?this.y2:this.y},f.getSubYScale=function(a){return"y2"===this.getAxisId(a)?this.subY2:this.subY},f.updateScales=function(){var a=this,b=a.config,c=!a.x;a.xMin=b.axis_rotated?1:0,a.xMax=b.axis_rotated?a.height:a.width,a.yMin=b.axis_rotated?0:a.height,a.yMax=b.axis_rotated?a.width:1,a.subXMin=a.xMin,a.subXMax=a.xMax,a.subYMin=b.axis_rotated?0:a.height2,a.subYMax=b.axis_rotated?a.width2:1,a.x=a.getX(a.xMin,a.xMax,c?void 0:a.x.orgDomain(),function(){return a.xAxis.tickOffset()}),a.y=a.getY(a.yMin,a.yMax,c?void 0:a.y.domain()),a.y2=a.getY(a.yMin,a.yMax,c?void 0:a.y2.domain()),a.subX=a.getX(a.xMin,a.xMax,a.orgXDomain,function(b){return b%1?0:a.subXAxis.tickOffset()}),a.subY=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY.domain()),a.subY2=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY2.domain()),a.xAxisTickFormat=a.getXAxisTickFormat(),a.xAxisTickValues=b.axis_x_tick_values?b.axis_x_tick_values:c?void 0:a.xAxis.tickValues(),a.xAxis=a.getXAxis(a.x,a.xOrient,a.xAxisTickFormat,a.xAxisTickValues),a.subXAxis=a.getXAxis(a.subX,a.subXOrient,a.xAxisTickFormat,a.xAxisTickValues),a.yAxis=a.getYAxis(a.y,a.yOrient,b.axis_y_tick_format,b.axis_y_ticks),a.y2Axis=a.getYAxis(a.y2,a.y2Orient,b.axis_y2_tick_format,b.axis_y2_ticks),c||(a.brush&&a.brush.scale(a.subX),b.zoom_enabled&&a.zoom.scale(a.x)),a.updateArc&&a.updateArc()},f.getYDomainMin=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasNegativeValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=0>a?a:0}),c=1;c0||(k[d][b]+=+a)});return h.d3.min(Object.keys(k).map(function(a){return h.d3.min(k[a])}))},f.getYDomainMax=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasPositiveValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=a>0?a:0}),c=1;c+a||(k[d][b]+=+a)});return h.d3.max(Object.keys(k).map(function(a){return h.d3.max(k[a])}))},f.getYDomain=function(a,b){var c,d,e,f,g,h,j,k,l,m,n=this,o=n.config,q=a.filter(function(a){return n.getAxisId(a.id)===b}),r="y2"===b?o.axis_y2_min:o.axis_y_min,s="y2"===b?o.axis_y2_max:o.axis_y_max,t=i(r)?r:n.getYDomainMin(q),u=i(s)?s:n.getYDomainMax(q),v="y2"===b?o.axis_y2_center:o.axis_y_center,w=n.hasType("bar",q)&&o.bar_zerobased||n.hasType("area",q)&&o.area_zerobased,x=n.hasDataLabel()&&o.axis_rotated,y=n.hasDataLabel()&&!o.axis_rotated;return 0===q.length?"y2"===b?n.y2.domain():n.y.domain():(t===u&&(0>t?u=0:t=0),l=t>=0&&u>=0,m=0>=t&&0>=u,w&&(l&&(t=0),m&&(u=0)),c=Math.abs(u-t),d=e=f=.1*c,v&&(g=Math.max(Math.abs(t),Math.abs(u)),u=g-v,t=v-g),x?(h=n.getDataLabelLength(t,u,b,"width"),j=p(n.y.range()),k=[h[0]/j,h[1]/j],e+=c*(k[1]/(1-k[0]-k[1])),f+=c*(k[0]/(1-k[0]-k[1]))):y&&(h=n.getDataLabelLength(t,u,b,"height"),e+=h[1],f+=h[0]),"y"===b&&o.axis_y_padding&&(e=n.getAxisPadding(o.axis_y_padding,"top",d,c),f=n.getAxisPadding(o.axis_y_padding,"bottom",d,c)),"y2"===b&&o.axis_y2_padding&&(e=n.getAxisPadding(o.axis_y2_padding,"top",d,c),f=n.getAxisPadding(o.axis_y2_padding,"bottom",d,c)),w&&(l&&(f=t),m&&(e=-u)),[t-f,u+e])},f.getXDomainMin=function(a){var b=this,c=b.config;return c.axis_x_min?b.isTimeSeries()?this.parseDate(c.axis_x_min):c.axis_x_min:b.d3.min(a,function(a){return b.d3.min(a.values,function(a){return a.x})})},f.getXDomainMax=function(a){var b=this,c=b.config;return c.axis_x_max?b.isTimeSeries()?this.parseDate(c.axis_x_max):c.axis_x_max:b.d3.max(a,function(a){return b.d3.max(a.values,function(a){return a.x})})},f.getXDomainPadding=function(a){var b,c,d,e,f=this,g=f.config,h=this.getEdgeX(a),j=h[1]-h[0];return f.isCategorized()?c=0:f.hasType("bar",a)?(b=f.getMaxDataCount(),c=b>1?j/(b-1)/2:.5):c=.01*j,"object"==typeof g.axis_x_padding&&r(g.axis_x_padding)?(d=i(g.axis_x_padding.left)?g.axis_x_padding.left:c,e=i(g.axis_x_padding.right)?g.axis_x_padding.right:c):d=e="number"==typeof g.axis_x_padding?g.axis_x_padding:c,{left:d,right:e}},f.getXDomain=function(a){var b=this,c=[b.getXDomainMin(a),b.getXDomainMax(a)],d=c[0],e=c[1],f=b.getXDomainPadding(a),g=0,h=0;return d-e!==0||b.isCategorized()||(d=b.isTimeSeries()?new Date(.5*d.getTime()):-.5,e=b.isTimeSeries()?new Date(1.5*e.getTime()):.5),(d||0===d)&&(g=b.isTimeSeries()?new Date(d.getTime()-f.left):d-f.left),(e||0===e)&&(h=b.isTimeSeries()?new Date(e.getTime()+f.right):e+f.right),[g,h]},f.updateXDomain=function(a,b,c,d){var e=this,f=e.config;return c&&(e.x.domain(d?d:e.d3.extent(e.getXDomain(a))),e.orgXDomain=e.x.domain(),f.zoom_enabled&&e.zoom.scale(e.x).updateScaleExtent(),e.subX.domain(e.x.domain()),e.brush&&e.brush.scale(e.subX)),b&&(e.x.domain(d?d:!e.brush||e.brush.empty()?e.orgXDomain:e.brush.extent()),f.zoom_enabled&&e.zoom.scale(e.x).updateScaleExtent()),e.x.domain()},f.isX=function(a){var b=this,c=b.config;return c.data_x&&a===c.data_x||r(c.data_xs)&&t(c.data_xs,a)},f.isNotX=function(a){return!this.isX(a)},f.getXKey=function(a){var b=this,c=b.config;return c.data_x?c.data_x:r(c.data_xs)?c.data_xs[a]:null},f.getXValuesOfXKey=function(a,b){var c,d=this,e=b&&r(b)?d.mapToIds(b):[];return e.forEach(function(b){d.getXKey(b)===a&&(c=d.data.xs[b])}),c},f.getXValue=function(a,b){var c=this;return a in c.data.xs&&c.data.xs[a]&&i(c.data.xs[a][b])?c.data.xs[a][b]:b},f.getOtherTargetXs=function(){var a=this,b=Object.keys(a.data.xs);return b.length?a.data.xs[b[0]]:null},f.getOtherTargetX=function(a){var b=this.getOtherTargetXs();return b&&a1},f.isMultipleX=function(){var a=this,b=a.config;return r(b.data_xs)&&a.hasMultipleX(b.data_xs)},f.addName=function(a){var b,c=this;return a&&(b=c.config.data_names[a.id],a.name=b?b:a.id),a},f.getValueOnIndex=function(a,b){var c=a.filter(function(a){return a.index===b});return c.length?c[0]:null},f.updateTargetX=function(a,b){var c=this;a.forEach(function(a){a.values.forEach(function(d,e){d.x=c.generateTargetX(b[e],a.id,e)}),c.data.xs[a.id]=b})},f.updateTargetXs=function(a,b){var c=this;a.forEach(function(a){b[a.id]&&c.updateTargetX([a],b[a.id])})},f.generateTargetX=function(a,b,c){var d,e=this;return d=e.isTimeSeries()?e.parseDate(a?a:e.getXValue(b,c)):e.isCustomX()&&!e.isCategorized()?i(a)?+a:e.getXValue(b,c):c},f.cloneTarget=function(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}})}},f.getPrevX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a-1);return c?c.x:null},f.getNextX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a+1);return c?c.x:null},f.getMaxDataCount=function(){var a=this;return a.d3.max(a.data.targets,function(a){return a.values.length})},f.getMaxDataCountTarget=function(a){var b,c=a.length,d=0;return c>1?a.forEach(function(a){a.values.length>d&&(b=a,d=a.values.length)}):b=c?a[0]:null,b},f.getEdgeX=function(a){var b,c,d=this.getMaxDataCountTarget(a);return d?(b=d.values[0],c=d.values[d.values.length-1],[b.x,c.x]):[0,0]},f.mapToIds=function(a){return a.map(function(a){return a.id})},f.mapToTargetIds=function(a){var b=this;return a?k(a)?[a]:a:b.mapToIds(b.data.targets)},f.hasTarget=function(a,b){var c,d=this.mapToIds(a);for(c=0;ca})},f.hasPositiveValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return a>0})},f.isOrderDesc=function(){var a=this.config;return a.data_order&&"desc"===a.data_order.toLowerCase()},f.isOrderAsc=function(){var a=this.config;return a.data_order&&"asc"===a.data_order.toLowerCase()},f.orderTargets=function(a){var b=this,c=b.config,d=b.isOrderAsc(),e=b.isOrderDesc();return d||e?a.sort(function(a,b){var c=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(c,0),f=b.values.reduce(c,0);return d?f-e:e-f}):j(c.data_order)&&a.sort(c.data_order),a},f.filterSameX=function(a,b){return this.d3.merge(a.map(function(a){return a.values +})).filter(function(a){return a.x-b===0})},f.filterRemoveNull=function(a){return a.filter(function(a){return i(a.value)})},f.hasDataLabel=function(){var a=this.config;return"boolean"==typeof a.data_labels&&a.data_labels?!0:"object"==typeof a.data_labels&&r(a.data_labels)?!0:!1},f.getDataLabelLength=function(a,b,c,d){var e=this,f=[0,0],g=1.3;return e.selectChart.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return e.formatByAxisId(c)(a)}).each(function(a,b){f[b]=this.getBoundingClientRect()[d]*g}).remove(),f},f.isNoneArc=function(a){return this.hasTarget(this.data.targets,a.id)},f.isArc=function(a){return"data"in a&&this.hasTarget(this.data.targets,a.data.id)},f.findSameXOfValues=function(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?h=i:g=i,h-g===1||0===g&&0===h?(e=[],(a[g].x||0===a[g].x)&&(e=e.concat(f.findSameXOfValues(a,g))),(a[h].x||0===a[h].x)&&(e=e.concat(f.findSameXOfValues(a,h))),f.findClosest(e,b)):f.findClosestOfValues(a,b,g,h)},f.findClosestFromTargets=function(a,b){var c,d=this;return c=a.map(function(a){return d.findClosestOfValues(a.values,b)}),d.findClosest(c,b)},f.findClosest=function(a,b){var c,d,e=this;return a.forEach(function(a){var f=e.dist(a,b);(c>f||!c)&&(c=f,d=a)}),d},f.dist=function(a,b){var c=this,d=c.config,e="y"===c.getAxisId(a.id)?c.y:c.y2,f=d.axis_rotated?1:0,g=d.axis_rotated?0:1;return Math.pow(c.x(a.x)-b[f],2)+Math.pow(e(a.value)-b[g],2)},f.convertUrlToData=function(a,b,c,d){var e=this,f=b?b:"csv";e.d3.xhr(a,function(a,b){var g;g="json"===f?e.convertJsonToData(JSON.parse(b.response),c):e.convertCsvToData(b.response),d.call(e,g)})},f.convertCsvToData=function(a){var b,c=this.d3,d=c.csv.parseRows(a);return 1===d.length?(b=[{}],d[0].forEach(function(a){b[0][a]=null})):b=c.csv.parse(a),b},f.convertJsonToData=function(a,b){var c,d,e=this,f=[];return b?(c=b.value,b.x&&(c.push(b.x),e.config.data_x=b.x),f.push(c),a.forEach(function(a){var b=[];c.forEach(function(c){var d=l(a[c])?null:a[c];b.push(d)}),f.push(b)}),d=e.convertRowsToData(f)):(Object.keys(a).forEach(function(b){f.push([b].concat(a[b]))}),d=e.convertColumnsToData(f)),d},f.convertRowsToData=function(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?d.data.xs[c]=(b&&d.data.xs[c]?d.data.xs[c]:[]).concat(a.map(function(a){return a[f]}).filter(i).map(function(a,b){return d.generateTargetX(a,c,b)})):e.data_x?d.data.xs[c]=d.getOtherTargetXs():r(e.data_xs)&&(d.data.xs[c]=d.getXValuesOfXKey(f,d.data.targets)):d.data.xs[c]=a.map(function(a,b){return b})}),f.forEach(function(a){if(!d.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),c=f.map(function(b,c){var f=e.data_idConverter(b);return{id:f,id_org:b,values:a.map(function(a,g){var h=d.getXKey(b),i=a[h],j=d.generateTargetX(i,b,g);return d.isCustomX()&&d.isCategorized()&&0===c&&i&&(0===g&&(e.axis_x_categories=[]),e.axis_x_categories.push(i)),(l(a[b])||d.data.xs[b].length<=g)&&(j=void 0),{x:j,value:null===a[b]||isNaN(a[b])?null:+a[b],id:f}}).filter(function(a){return m(a.x)})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++}),d.data.xs[a.id].sort(function(a,b){return a-b})}),e.data_type&&d.setTargetType(d.mapToIds(c).filter(function(a){return!(a in e.data_types)}),e.data_type),c.forEach(function(a){d.addCache(a.id_org,a)}),c},f.load=function(a,b){var c=this;a&&(b.filter&&(a=a.filter(b.filter)),(b.type||b.types)&&a.forEach(function(a){c.setTargetType(a.id,b.types?b.types[a.id]:b.type)}),c.data.targets.forEach(function(b){for(var c=0;ce?0:e},g=function(a){var b=h.getPrevX(a.index),c=h.data.xs[a.id][a.index];return(h.x(c)+h.x(b?b:c))/2}),b=i.axis_rotated?0:g,c=i.axis_rotated?g:0,d=i.axis_rotated?h.width:f,e=i.axis_rotated?f:h.height),a.attr("class",h.classEvent.bind(h)).attr("x",b).attr("y",c).attr("width",d).attr("height",e)},f.generateEventRectsForSingleX=function(a){var b=this,c=b.d3,d=b.config;a.append("rect").attr("class",b.classEvent.bind(b)).style("cursor",d.data_selection_enabled&&d.data_selection_grouped?"pointer":null).on("mouseover",function(a){var c,e,f=a.index;b.dragging||b.hasArcType()||(c=b.data.targets.map(function(a){return b.addName(b.getValueOnIndex(a.values,f))}),e=[],Object.keys(d.data_names).forEach(function(a){for(var b=0;b0?c:320},f.getCurrentPaddingTop=function(){var a=this.config;return i(a.padding_top)?a.padding_top:0},f.getCurrentPaddingBottom=function(){var a=this.config;return i(a.padding_bottom)?a.padding_bottom:0},f.getCurrentPaddingLeft=function(){var a=this,b=a.config;return i(b.padding_left)?b.padding_left:b.axis_rotated?b.axis_x_show?Math.max(n(a.getAxisWidthByAxisId("x")),40):1:b.axis_y_show?n(a.getAxisWidthByAxisId("y")):1},f.getCurrentPaddingRight=function(){var a=this,b=a.config,c=10,d=a.isLegendRight?a.getLegendWidth()+20:0;return i(b.padding_right)?b.padding_right+1:b.axis_rotated?c+d:(b.axis_y2_show?n(a.getAxisWidthByAxisId("y2")):c)+d},f.getParentRectValue=function(a){for(var b,c=this.selectChart.node();c&&"BODY"!==c.tagName&&!(b=c.getBoundingClientRect()[a]);)c=c.parentNode;return b},f.getParentWidth=function(){return this.getParentRectValue("width")},f.getParentHeight=function(){var a=this.selectChart.style("height");return a.indexOf("px")>0?+a.replace("px",""):0},f.getSvgLeft=function(){var a=this,b=a.config,c=b.axis_rotated?h.axisX:h.axisY,d=a.main.select("."+c).node(),e=d?d.getBoundingClientRect():{right:0},f=a.selectChart.node().getBoundingClientRect(),g=a.hasArcType(),i=e.right-f.left-(g?0:a.getCurrentPaddingLeft());return i>0?i:0},f.getAxisWidthByAxisId=function(a){var b=this,c=b.getAxisLabelPositionById(a);return c.isInner?20+b.getMaxTickWidth(a):40+b.getMaxTickWidth(a)},f.getHorizontalAxisHeight=function(a){var b=this,c=b.config;return"x"!==a||c.axis_x_show?"x"===a&&c.axis_x_height?c.axis_x_height:"y"!==a||c.axis_y_show?"y2"!==a||c.axis_y2_show?(b.getAxisLabelPositionById(a).isInner?30:40)+("y2"===a?-10:0):b.rotated_padding_top:!c.legend_show||b.isLegendRight||b.isLegendInset?1:10:0},f.getEventRectWidth=function(){var a,b,c,d,e,f,g=this,h=g.getMaxDataCountTarget(g.data.targets);return h?(a=h.values[0],b=h.values[h.values.length-1],c=g.x(b.x)-g.x(a.x),0===c?g.config.axis_rotated?g.height:g.width:(d=g.getMaxDataCount(),e=g.hasType("bar")?(d-(g.isCategorized()?.25:1))/d:1,f=d>1?c*e/(d-1):c,1>f?1:f)):0},f.getShapeIndices=function(a){var b,c,d=this,e=d.config,f={},g=0;return d.filterTargetsToShow(d.data.targets.filter(a,d)).forEach(function(a){for(b=0;b=0&&(j+=h(c.values[g].value)-i)}),j}},f.getInterpolate=function(a){var b=this;return b.isSplineType(a)?"cardinal":b.isStepType(a)?"step-after":"linear"},f.initLine=function(){var a=this;a.main.select("."+h.chart).append("g").attr("class",h.chartLines)},f.updateTargetsForLine=function(a){var b,c,d=this,e=d.config,f=d.classChartLine.bind(d),g=d.classLines.bind(d),i=d.classAreas.bind(d),j=d.classCircles.bind(d);b=d.main.select("."+h.chartLines).selectAll("."+h.chartLine).data(a).attr("class",f),c=b.enter().append("g").attr("class",f).style("opacity",0).style("pointer-events","none"),c.append("g").attr("class",g),c.append("g").attr("class",i),c.append("g").attr("class",function(a){return d.generateClass(h.selectedCircles,a.id)}),c.append("g").attr("class",j).style("cursor",function(a){return e.data_selection_isselectable(a)?"pointer":null}),a.forEach(function(a){d.main.selectAll("."+h.selectedCircles+d.getTargetSelectorSuffix(a.id)).selectAll("."+h.selectedCircle).each(function(b){b.value=a.values[b.index].value})})},f.redrawLine=function(a){var b=this;b.mainLine=b.main.selectAll("."+h.lines).selectAll("."+h.line).data(b.lineData.bind(b)),b.mainLine.enter().append("path").attr("class",b.classLine.bind(b)).style("stroke",b.color),b.mainLine.style("opacity",b.initialOpacity.bind(b)).attr("transform",null),b.mainLine.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForLine=function(a,b){var c=this;a.push(c.mainLine.transition().attr("d",b).style("stroke",c.color).style("opacity",1))},f.generateDrawLine=function(a,b){var c=this,d=c.config,e=c.d3.svg.line(),f=c.generateGetLinePoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x(i).y(h):e.x(h).y(i),d.line_connect_null||(e=e.defined(function(a){return null!=a.value})),function(a){var f,h=d.line_connect_null?c.filterRemoveNull(a.values):a.values,i=b?c.x:c.subX,j=g.call(c,a.id),k=0,l=0;return c.isLineType(a)?f=d.data_regions[a.id]?c.lineWithRegions(h,i,j,d.data_regions[a.id]):e.interpolate(c.getInterpolate(a))(h):(h[0]&&(k=i(h[0].x),l=j(h[0].value)),f=d.axis_rotated?"M "+l+" "+k:"M "+k+" "+l),f?f:"M 0 0"}},f.generateGetLinePoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isLineType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0l||a.value<0&&l>e)&&(l=e),[[k,l-(e-j)]]}},f.lineWithRegions=function(a,b,c,d){function e(a,b){var c;for(c=0;c=g;g+=q)w+=h(a[f-1],a[f],g,p);v=a[f].x}return w},f.redrawArea=function(a){var b=this,c=b.d3;b.mainArea=b.main.selectAll("."+h.areas).selectAll("."+h.area).data(b.lineData.bind(b)),b.mainArea.enter().append("path").attr("class",b.classArea.bind(b)).style("fill",b.color).style("opacity",function(){return b.orgAreaOpacity=+c.select(this).style("opacity"),0}),b.mainArea.style("opacity",b.orgAreaOpacity),b.mainArea.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForArea=function(a,b){var c=this;a.push(c.mainArea.transition().attr("d",b).style("fill",c.color).style("opacity",c.orgAreaOpacity))},f.generateDrawArea=function(a,b){var c=this,d=c.config,e=c.d3.svg.area(),f=c.generateGetAreaPoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(0)},j=function(a,b){return d.data_groups.length>0?f(a,b)[1][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x0(i).x1(j).y(h):e.x(h).y0(i).y1(j),d.line_connect_null||(e=e.defined(function(a){return null!==a.value})),function(a){var b,f=d.line_connect_null?c.filterRemoveNull(a.values):a.values,g=0,h=0;return c.isAreaType(a)?b=e.interpolate(c.getInterpolate(a))(f):(f[0]&&(g=c.x(f[0].x),h=c.getYScale(a.id)(f[0].value)),b=d.axis_rotated?"M "+h+" "+g:"M "+g+" "+h),b?b:"M 0 0"}},f.generateGetAreaPoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isAreaType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0l||a.value<0&&l>e)&&(l=e),[[k,j],[k,l-(e-j)]]}},f.redrawCircle=function(){var a=this;a.mainCircle=a.main.selectAll("."+h.circles).selectAll("."+h.circle).data(a.lineOrScatterData.bind(a)),a.mainCircle.enter().append("circle").attr("class",a.classCircle.bind(a)).attr("r",a.pointR.bind(a)).style("fill",a.color),a.mainCircle.style("opacity",a.initialOpacity.bind(a)),a.mainCircle.exit().remove()},f.addTransitionForCircle=function(a,b,c){var d=this;a.push(d.mainCircle.transition().style("opacity",d.opacityForCircle.bind(d)).style("fill",d.color).attr("cx",b).attr("cy",c)),a.push(d.main.selectAll("."+h.selectedCircle).transition().attr("cx",b).attr("cy",c))},f.circleX=function(a){return a.x||0===a.x?this.x(a.x):null},f.circleY=function(a,b){var c=this,d=c.getShapeIndices(c.isLineType),e=c.generateGetLinePoint(d);return c.config.data_groups.length>0?e(a,b)[0][1]:c.getYScale(a.id)(a.value)},f.getCircles=function(a,b){var c=this;return(b?c.main.selectAll("."+h.circles+c.getTargetSelectorSuffix(b)):c.main).selectAll("."+h.circle+(i(a)?"-"+a:""))},f.expandCircles=function(a,b){var c=this,d=c.pointExpandedR.bind(c);c.getCircles(a,b).classed(h.EXPANDED,!0).attr("r",d)},f.unexpandCircles=function(a){var b=this,c=b.pointR.bind(b);b.getCircles(a).filter(function(){return b.d3.select(this).classed(h.EXPANDED)}).classed(h.EXPANDED,!1).attr("r",c)},f.pointR=function(a){var b=this,c=b.config;return c.point_show&&!b.isStepType(a)?j(c.point_r)?c.point_r(a):c.point_r:0},f.pointExpandedR=function(a){var b=this,c=b.config;return c.point_focus_expand_enabled?c.point_focus_expand_r?c.point_focus_expand_r:1.75*b.pointR(a):b.pointR(a)},f.pointSelectR=function(a){var b=this,c=b.config;return c.point_select_r?c.point_select_r:4*b.pointR(a)},f.isWithinCircle=function(a,b){var c=this.d3,d=c.mouse(a),e=c.select(a),f=1*e.attr("cx"),g=1*e.attr("cy");return Math.sqrt(Math.pow(f-d[0],2)+Math.pow(g-d[1],2))d.bar_width_max?d.bar_width_max:e},f.getBars=function(a){var b=this;return b.main.selectAll("."+h.bar+(i(a)?"-"+a:""))},f.expandBars=function(a){var b=this;b.getBars(a).classed(h.EXPANDED,!0)},f.unexpandBars=function(a){var b=this;b.getBars(a).classed(h.EXPANDED,!1)},f.generateDrawBar=function(a,b){var c=this,d=c.config,e=c.generateGetBarPoints(a,b);return function(a,b){var c=e(a,b),f=d.axis_rotated?1:0,g=d.axis_rotated?0:1,h="M "+c[0][f]+","+c[0][g]+" L"+c[1][f]+","+c[1][g]+" L"+c[2][f]+","+c[2][g]+" L"+c[3][f]+","+c[3][g]+" z";return h}},f.generateGetBarPoints=function(a,b){var c=this,d=a.__max__+1,e=c.getBarW(c.xAxis,d),f=c.getShapeX(e,d,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isBarType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var d=i.call(c,a.id)(0),j=h(a,b)||d,k=f(a),l=g(a);return c.config.axis_rotated&&(0l||a.value<0&&l>d)&&(l=d),[[k,j],[k,l-(d-j)],[k+e,l-(d-j)],[k+e,j]]}},f.isWithinBar=function(a){var b=this.d3,c=b.mouse(a),d=a.getBoundingClientRect(),e=a.pathSegList.getItem(0),f=a.pathSegList.getItem(1),g=e.x,h=Math.min(e.y,f.y),i=d.width,j=d.height,k=2,l=g-k,m=g+i+k,n=h+j+k,o=h-k;return lf.width?f.width-g.width:d},f.getYForText=function(a,b,c){var d,e=this,f=c.getBoundingClientRect();return d=e.config.axis_rotated?(a[0][0]+a[2][0]+.6*f.height)/2:a[2][1]+(b.value<0?f.height:e.isBarType(b)?-3:-6),d=0||!(b.id in d)&&"line"===a)&&(e=!0)}),e},f.hasArcType=function(a){return this.hasType("pie",a)||this.hasType("donut",a)||this.hasType("gauge",a)},f.isLineType=function(a){var b=this.config,c=k(a)?a:a.id;return!b.data_types[c]||["line","spline","area","area-spline","step","area-step"].indexOf(b.data_types[c])>=0},f.isStepType=function(a){var b=k(a)?a:a.id;return["step","area-step"].indexOf(this.config.data_types[b])>=0},f.isSplineType=function(a){var b=k(a)?a:a.id;return["spline","area-spline"].indexOf(this.config.data_types[b])>=0},f.isAreaType=function(a){var b=k(a)?a:a.id;return["area","area-spline","area-step"].indexOf(this.config.data_types[b])>=0},f.isBarType=function(a){var b=k(a)?a:a.id;return"bar"===this.config.data_types[b]},f.isScatterType=function(a){var b=k(a)?a:a.id;return"scatter"===this.config.data_types[b]},f.isPieType=function(a){var b=k(a)?a:a.id;return"pie"===this.config.data_types[b]},f.isGaugeType=function(a){var b=k(a)?a:a.id;return"gauge"===this.config.data_types[b]},f.isDonutType=function(a){var b=k(a)?a:a.id;return"donut"===this.config.data_types[b]},f.isArcType=function(a){return this.isPieType(a)||this.isDonutType(a)||this.isGaugeType(a)},f.lineData=function(a){return this.isLineType(a)?[a]:[]},f.arcData=function(a){return this.isArcType(a.data)?[a]:[]},f.barData=function(a){return this.isBarType(a)?a.values:[]},f.lineOrScatterData=function(a){return this.isLineType(a)||this.isScatterType(a)?a.values:[]},f.barOrLineData=function(a){return this.isBarType(a)||this.isLineType(a)?a.values:[]},f.initGrid=function(){var a=this,b=a.config,c=a.d3;a.grid=a.main.append("g").attr("clip-path",a.clipPath).attr("class",h.grid),b.grid_x_show&&a.grid.append("g").attr("class",h.xgrids),b.grid_y_show&&a.grid.append("g").attr("class",h.ygrids),a.grid.append("g").attr("class",h.xgridLines),a.grid.append("g").attr("class",h.ygridLines),b.grid_focus_show&&a.grid.append("g").attr("class",h.xgridFocus).append("line").attr("class",h.xgridFocus),a.xgrid=c.selectAll([]),a.xgridLines=c.selectAll([])},f.updateXGrid=function(a){var b=this,c=b.config,d=b.d3,e=b.generateGridData(c.grid_x_type,b.x),f=b.isCategorized()?b.xAxis.tickOffset():0;b.xgridAttr=c.axis_rotated?{x1:0,x2:b.width,y1:function(a){return b.x(a)-f},y2:function(a){return b.x(a)-f}}:{x1:function(a){return b.x(a)+f},x2:function(a){return b.x(a)+f},y1:0,y2:b.height},b.xgrid=b.main.select("."+h.xgrids).selectAll("."+h.xgrid).data(e),b.xgrid.enter().append("line").attr("class",h.xgrid),a||b.xgrid.attr(b.xgridAttr).style("opacity",function(){return+d.select(this).attr(c.axis_rotated?"y1":"x1")===(c.axis_rotated?b.height:0)?0:1}),b.xgrid.exit().remove()},f.updateYGrid=function(){var a=this,b=a.config;a.ygrid=a.main.select("."+h.ygrids).selectAll("."+h.ygrid).data(a.y.ticks(b.grid_y_ticks)),a.ygrid.enter().append("line").attr("class",h.ygrid),a.ygrid.attr("x1",b.axis_rotated?a.y:0).attr("x2",b.axis_rotated?a.y:a.width).attr("y1",b.axis_rotated?0:a.y).attr("y2",b.axis_rotated?a.height:a.y),a.ygrid.exit().remove(),a.smoothLines(a.ygrid,"grid")},f.redrawGrid=function(a,b){var c,d,e,f=this,g=f.main,i=f.config;g.select("line."+h.xgridFocus).style("visibility","hidden"),i.grid_x_show&&f.updateXGrid(),f.xgridLines=g.select("."+h.xgridLines).selectAll("."+h.xgridLine).data(i.grid_x_lines),c=f.xgridLines.enter().append("g").attr("class",function(a){return h.xgridLine+(a.class?" "+a.class:"")}),c.append("line").style("opacity",0),c.append("text").attr("text-anchor","end").attr("transform",i.axis_rotated?"":"rotate(-90)").attr("dx",i.axis_rotated?0:-f.margin.top).attr("dy",-5).style("opacity",0),f.xgridLines.exit().transition().duration(a).style("opacity",0).remove(),b&&i.grid_y_show&&f.updateYGrid(),b&&(f.ygridLines=g.select("."+h.ygridLines).selectAll("."+h.ygridLine).data(i.grid_y_lines),d=f.ygridLines.enter().append("g").attr("class",function(a){return h.ygridLine+(a.class?" "+a.class:"")}),d.append("line").style("opacity",0),d.append("text").attr("text-anchor","end").attr("transform",i.axis_rotated?"rotate(-90)":"").attr("dx",i.axis_rotated?0:-f.margin.top).attr("dy",-5).style("opacity",0),e=f.yv.bind(f),f.ygridLines.select("line").transition().duration(a).attr("x1",i.axis_rotated?e:0).attr("x2",i.axis_rotated?e:f.width).attr("y1",i.axis_rotated?0:e).attr("y2",i.axis_rotated?f.height:e).style("opacity",1),f.ygridLines.select("text").transition().duration(a).attr("x",i.axis_rotated?0:f.width).attr("y",e).text(function(a){return a.text}).style("opacity",1),f.ygridLines.exit().transition().duration(a).style("opacity",0).remove())},f.addTransitionForGrid=function(a){var b=this,c=b.config,d=b.xv.bind(b);a.push(b.xgridLines.select("line").transition().attr("x1",c.axis_rotated?0:d).attr("x2",c.axis_rotated?b.width:d).attr("y1",c.axis_rotated?d:b.margin.top).attr("y2",c.axis_rotated?d:b.height).style("opacity",1)),a.push(b.xgridLines.select("text").transition().attr("x",c.axis_rotated?b.width:0).attr("y",d).text(function(a){return a.text}).style("opacity",1))},f.showXGridFocus=function(a){var b=this,c=b.config,d=a.filter(function(a){return a&&i(a.value)}),e=b.main.selectAll("line."+h.xgridFocus),f=b.xx.bind(b);c.tooltip_show&&(b.hasType("scatter")||b.hasArcType()||(e.style("visibility","visible").data([d[0]]).attr(c.axis_rotated?"y1":"x1",f).attr(c.axis_rotated?"y2":"x2",f),b.smoothLines(e,"grid")))},f.hideXGridFocus=function(){this.main.select("line."+h.xgridFocus).style("visibility","hidden")},f.updateXgridFocus=function(){var a=this,b=a.config;a.main.select("line."+h.xgridFocus).attr("x1",b.axis_rotated?0:-10).attr("x2",b.axis_rotated?a.width:-10).attr("y1",b.axis_rotated?-10:0).attr("y2",b.axis_rotated?-10:a.height)},f.generateGridData=function(a,b){var c,d,e,f,g=this,i=[],j=g.main.select("."+h.axisX).selectAll(".tick").size();if("year"===a)for(c=g.getXDomain(),d=c[0].getFullYear(),e=c[1].getFullYear(),f=d;e>=f;f++)i.push(new Date(f+"-01-01 00:00:00")); +else i=b.ticks(10),i.length>j&&(i=i.filter(function(a){return(""+a).indexOf(".")<0}));return i},f.getGridFilterToRemove=function(a){return a?function(b){var c=!1;return[].concat(a).forEach(function(d){("value"in d&&b.value===a.value||"class"in d&&b.class===a.class)&&(c=!0)}),c}:function(){return!0}},f.removeGridLines=function(a,b){var c=this,d=c.config,e=c.getGridFilterToRemove(a),f=function(a){return!e(a)},g=b?h.xgridLines:h.ygridLines,i=b?h.xgridLine:h.ygridLine;c.main.select("."+g).selectAll("."+i).filter(e).transition().duration(d.transition_duration).style("opacity",0).remove(),b?d.grid_x_lines=d.grid_x_lines.filter(f):d.grid_y_lines=d.grid_y_lines.filter(f)},f.initTooltip=function(){var a,b=this,c=b.config;if(b.tooltip=b.selectChart.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),c.tooltip_init_show){if(b.isTimeSeries()&&k(c.tooltip_init_x)){for(c.tooltip_init_x=b.parseDate(c.tooltip_init_x),a=0;a"+(g||0===g?""+g+"":"")),j=o(a[f].name),i=p(a[f].value,a[f].ratio,a[f].id,a[f].index),k=l.levelColor?l.levelColor(a[f].value):d(a[f].id),e+="",e+=""+j+"",e+=""+i+"",e+="");return e+""},f.showTooltip=function(a,b){var c,d,e,f,g,h,j,k=this,l=k.config,m=k.hasArcType(),n=a.filter(function(a){return a&&i(a.value)});0!==n.length&&l.tooltip_show&&(k.tooltip.html(l.tooltip_contents.call(k,a,k.getXAxisTickFormat(),k.getYFormat(m),k.color)).style("display","block"),c=k.tooltip.property("offsetWidth"),d=k.tooltip.property("offsetHeight"),m?(f=k.width/2+b[0],h=k.height/2+b[1]+20):(l.axis_rotated?(e=k.getSvgLeft(),f=e+b[0]+100,g=f+c,j=k.getCurrentWidth()-k.getCurrentPaddingRight(),h=k.x(n[0].x)+20):(e=k.getSvgLeft(),f=e+k.getCurrentPaddingLeft()+k.x(n[0].x)+20,g=f+c,j=e+k.getCurrentWidth()-k.getCurrentPaddingRight(),h=b[1]+15),g>j&&(f-=g-j),h+d>k.getCurrentHeight()&&h>d+30&&(h-=d+30)),k.tooltip.style("top",h+"px").style("left",f+"px"))},f.hideTooltip=function(){this.tooltip.style("display","none")},f.initLegend=function(){var a=this;a.legend=a.svg.append("g").attr("transform",a.getTranslate("legend")),a.config.legend_show||(a.legend.style("visibility","hidden"),a.hiddenLegendIds=a.mapToIds(a.data.targets)),a.updateLegend(a.mapToIds(a.data.targets),{withTransform:!1,withTransitionForTransform:!1,withTransition:!1})},f.updateSizeForLegend=function(a,b){var c=this,d=c.config,e={top:c.isLegendTop?c.getCurrentPaddingTop()+d.legend_inset_y+5.5:c.currentHeight-a-c.getCurrentPaddingBottom()-d.legend_inset_y,left:c.isLegendLeft?c.getCurrentPaddingLeft()+d.legend_inset_x+.5:c.currentWidth-b-c.getCurrentPaddingRight()-d.legend_inset_x+.5};c.margin3={top:c.isLegendRight?0:c.isLegendInset?e.top:c.currentHeight-a,right:0/0,bottom:0,left:c.isLegendRight?c.currentWidth-b:c.isLegendInset?e.left:0}},f.transformLegend=function(a){var b=this;(a?b.legend.transition():b.legend).attr("transform",b.getTranslate("legend"))},f.updateLegendStep=function(a){this.legendStep=a},f.updateLegendItemWidth=function(a){this.legendItemWidth=a},f.updateLegendItemHeight=function(a){this.legendItemHeight=a},f.getLegendWidth=function(){var a=this;return a.config.legend_show?a.isLegendRight||a.isLegendInset?a.legendItemWidth*(a.legendStep+1):a.currentWidth:0},f.getLegendHeight=function(){var a=this,b=a.config,c=0;return b.legend_show&&(c=a.isLegendRight?a.currentHeight:a.isLegendInset?b.legend_inset_step?Math.max(20,a.legendItemHeight)*(b.legend_inset_step+1):a.height:Math.max(20,a.legendItemHeight)*(a.legendStep+1)),c},f.opacityForLegend=function(a){var b=this;return a.classed(h.legendItemHidden)?b.legendOpacityForHidden:1},f.opacityForUnfocusedLegend=function(a){var b=this;return a.classed(h.legendItemHidden)?b.legendOpacityForHidden:.3},f.toggleFocusLegend=function(a,b){var c=this;c.legend.selectAll("."+h.legendItem).transition().duration(100).style("opacity",function(d){var e=c.d3.select(this);return a&&d!==a?b?c.opacityForUnfocusedLegend(e):c.opacityForLegend(e):b?c.opacityForLegend(e):c.opacityForUnfocusedLegend(e)})},f.revertLegend=function(){var a=this,b=a.d3;a.legend.selectAll("."+h.legendItem).transition().duration(100).style("opacity",function(){return a.opacityForLegend(b.select(this))})},f.showLegend=function(a){var b=this,c=b.config;c.legend_show||(c.legend_show=!0,b.legend.style("visibility","visible")),b.removeHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("visibility","visible").transition().style("opacity",function(){return b.opacityForLegend(b.d3.select(this))})},f.hideLegend=function(a){var b=this,c=b.config;c.legend_show&&q(a)&&(c.legend_show=!1,b.legend.style("visibility","hidden")),b.addHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("opacity",0).style("visibility","hidden")},f.updateLegend=function(a,b,c){function d(b,c,d){function e(a,b){b||(f=(m-A-l)/2,z>f&&(f=(m-l)/2,A=0,G++)),F[a]=G,E[G]=t.isLegendInset?10:f,B[a]=A,A+=l}var f,g,i=t.getTextRect(b.textContent,h.legendItem),j=10*Math.ceil((i.width+w)/10),k=10*Math.ceil((i.height+v)/10),l=t.isLegendRight||t.isLegendInset?k:j,m=t.isLegendRight||t.isLegendInset?t.getLegendHeight():t.getLegendWidth();return d&&(A=0,G=0,x=0,y=0),u.legend_show&&!t.isLegendToShow(c)?void(C[c]=D[c]=F[c]=B[c]=0):(C[c]=j,D[c]=k,(!x||j>=x)&&(x=j),(!y||k>=y)&&(y=k),g=t.isLegendRight||t.isLegendInset?y:x,void(u.legend_equally?(Object.keys(C).forEach(function(a){C[a]=x}),Object.keys(D).forEach(function(a){D[a]=y}),f=(m-g*a.length)/2,z>f?(A=0,G=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c)))}var e,f,g,i,j,k,l,n,o,p,q,r,t=this,u=t.config,v=4,w=36,x=0,y=0,z=10,A=0,B={},C={},D={},E=[0],F={},G=0,H=t.legend.selectAll("."+h.legendItemFocused).size();b=b||{},n=s(b,"withTransition",!0),o=s(b,"withTransitionForTransform",!0),t.isLegendRight?(e=function(a){return x*F[a]},i=function(a){return E[F[a]]+B[a]}):t.isLegendInset?(e=function(a){return x*F[a]+10},i=function(a){return E[F[a]]+B[a]}):(e=function(a){return E[F[a]]+B[a]},i=function(a){return y*F[a]}),f=function(a,b){return e(a,b)+14},j=function(a,b){return i(a,b)+9},g=function(a,b){return e(a,b)-4},k=function(a,b){return i(a,b)-7},l=t.legend.selectAll("."+h.legendItem).data(a).enter().append("g").attr("class",function(a){return t.generateClass(h.legendItem,a)}).style("visibility",function(a){return t.isLegendToShow(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){u.legend_item_onclick?u.legend_item_onclick.call(t,a):t.api.toggle(a)}).on("mouseover",function(a){t.d3.select(this).classed(h.legendItemFocused,!0),t.transiting||t.api.focus(a),u.legend_item_onmouseover&&u.legend_item_onmouseover.call(t,a)}).on("mouseout",function(a){t.d3.select(this).classed(h.legendItemFocused,!1),t.transiting||t.api.revert(),u.legend_item_onmouseout&&u.legend_item_onmouseout.call(t,a)}),l.append("text").text(function(a){return m(u.data_names[a])?u.data_names[a]:a}).each(function(a,b){d(this,a,0===b)}).style("pointer-events","none").attr("x",t.isLegendRight||t.isLegendInset?f:-200).attr("y",t.isLegendRight||t.isLegendInset?-200:j),l.append("rect").attr("class",h.legendItemEvent).style("fill-opacity",0).attr("x",t.isLegendRight||t.isLegendInset?g:-200).attr("y",t.isLegendRight||t.isLegendInset?-200:k),l.append("rect").attr("class",h.legendItemTile).style("pointer-events","none").style("fill",t.color).attr("x",t.isLegendRight||t.isLegendInset?f:-200).attr("y",t.isLegendRight||t.isLegendInset?-200:i).attr("width",10).attr("height",10),t.isLegendInset&&0!==x&&t.legend.insert("g","."+h.legendItem).attr("class",h.legendBackground).append("rect").attr("height",t.getLegendHeight()-10).attr("width",x*(G+1)+10),p=t.legend.selectAll("text").data(a).text(function(a){return m(u.data_names[a])?u.data_names[a]:a}).each(function(a,b){d(this,a,0===b)}),(n?p.transition():p).attr("x",f).attr("y",j),q=t.legend.selectAll("rect."+h.legendItemEvent).data(a),(n?q.transition():q).attr("width",function(a){return C[a]}).attr("height",function(a){return D[a]}).attr("x",g).attr("y",k),r=t.legend.selectAll("rect."+h.legendItemTile).data(a),(n?r.transition():r).style("fill",t.color).attr("x",e).attr("y",i),t.legend.selectAll("."+h.legendItem).classed(h.legendItemHidden,function(a){return!t.isTargetToShow(a)}).transition().style("opacity",function(a){var b=t.d3.select(this);return t.isTargetToShow(a)?!H||b.classed(h.legendItemFocused)?t.opacityForLegend(b):t.opacityForUnfocusedLegend(b):t.legendOpacityForHidden}),t.updateLegendItemWidth(x),t.updateLegendItemHeight(y),t.updateLegendStep(G),t.updateSizes(),t.updateScales(),t.updateSvgSize(),t.transformAll(o,c)},f.initAxis=function(){var a=this,b=a.config,c=a.main;a.axes.x=c.append("g").attr("class",h.axis+" "+h.axisX).attr("clip-path",a.clipPathForXAxis).attr("transform",a.getTranslate("x")).style("visibility",b.axis_x_show?"visible":"hidden"),a.axes.x.append("text").attr("class",h.axisXLabel).attr("transform",b.axis_rotated?"rotate(-90)":"").style("text-anchor",a.textAnchorForXAxisLabel.bind(a)),a.axes.y=c.append("g").attr("class",h.axis+" "+h.axisY).attr("clip-path",a.clipPathForYAxis).attr("transform",a.getTranslate("y")).style("visibility",b.axis_y_show?"visible":"hidden"),a.axes.y.append("text").attr("class",h.axisYLabel).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForYAxisLabel.bind(a)),a.axes.y2=c.append("g").attr("class",h.axis+" "+h.axisY2).attr("transform",a.getTranslate("y2")).style("visibility",b.axis_y2_show?"visible":"hidden"),a.axes.y2.append("text").attr("class",h.axisY2Label).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForY2AxisLabel.bind(a))},f.getXAxis=function(a,b,c,e){var f=this,g=f.config,h=d(f.d3,f.isCategorized()).scale(a).orient(b);return h.tickFormat(c).tickValues(e),f.isCategorized()?(h.tickCentered(g.axis_x_tick_centered),q(g.axis_x_tick_culling)&&(g.axis_x_tick_culling=!1)):h.tickOffset=function(){var a=f.getEdgeX(f.data.targets),b=f.x(a[1])-f.x(a[0]),c=b?b:g.axis_rotated?f.height:f.width;return c/f.getMaxDataCount()/2},h},f.getYAxis=function(a,b,c,e){return d(this.d3).scale(a).orient(b).tickFormat(c).ticks(e)},f.getAxisId=function(a){var b=this.config;return a in b.data_axes?b.data_axes[a]:"y"},f.getXAxisTickFormat=function(){var a=this,b=a.config,c=a.isTimeSeries()?a.defaultAxisTimeFormat:a.isCategorized()?a.categoryName:function(a){return 0>a?a.toFixed(0):a};return b.axis_x_tick_format&&(j(b.axis_x_tick_format)?c=b.axis_x_tick_format:a.isTimeSeries()&&(c=function(c){return c?a.axisTimeFormat(b.axis_x_tick_format)(c):""})),j(c)?function(b){return c.call(a,b)}:c},f.getAxisLabelOptionByAxisId=function(a){var b,c=this,d=c.config;return"y"===a?b=d.axis_y_label:"y2"===a?b=d.axis_y2_label:"x"===a&&(b=d.axis_x_label),b},f.getAxisLabelText=function(a){var b=this.getAxisLabelOptionByAxisId(a);return k(b)?b:b?b.text:null},f.setAxisLabelText=function(a,b){var c=this,d=c.config,e=c.getAxisLabelOptionByAxisId(a);k(e)?"y"===a?d.axis_y_label=b:"y2"===a?d.axis_y2_label=b:"x"===a&&(d.axis_x_label=b):e&&(e.text=b)},f.getAxisLabelPosition=function(a,b){var c=this.getAxisLabelOptionByAxisId(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}},f.getXAxisLabelPosition=function(){return this.getAxisLabelPosition("x",this.config.axis_rotated?"inner-top":"inner-right")},f.getYAxisLabelPosition=function(){return this.getAxisLabelPosition("y",this.config.axis_rotated?"inner-right":"inner-top")},f.getY2AxisLabelPosition=function(){return this.getAxisLabelPosition("y2",this.config.axis_rotated?"inner-right":"inner-top")},f.getAxisLabelPositionById=function(a){return"y2"===a?this.getY2AxisLabelPosition():"y"===a?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},f.textForXAxisLabel=function(){return this.getAxisLabelText("x")},f.textForYAxisLabel=function(){return this.getAxisLabelText("y")},f.textForY2AxisLabel=function(){return this.getAxisLabelText("y2")},f.xForAxisLabel=function(a,b){var c=this;return a?b.isLeft?0:b.isCenter?c.width/2:c.width:b.isBottom?-c.height:b.isMiddle?-c.height/2:0},f.dxForAxisLabel=function(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"},f.textAnchorForAxisLabel=function(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"},f.xForXAxisLabel=function(){return this.xForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},f.xForYAxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},f.xForY2AxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},f.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},f.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},f.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},f.dyForXAxisLabel=function(){var a=this,b=a.config,c=a.getXAxisLabelPosition();return b.axis_rotated?c.isInner?"1.2em":-25-a.getMaxTickWidth("x"):c.isInner?"-0.5em":b.axis_x_height?b.axis_x_height-10:"3em"},f.dyForYAxisLabel=function(){var a=this,b=a.getYAxisLabelPosition();return a.config.axis_rotated?b.isInner?"-0.5em":"3em":b.isInner?"1.2em":-20-a.getMaxTickWidth("y")},f.dyForY2AxisLabel=function(){var a=this,b=a.getY2AxisLabelPosition();return a.config.axis_rotated?b.isInner?"1.2em":"-2.2em":b.isInner?"-0.5em":30+this.getMaxTickWidth("y2")},f.textAnchorForXAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(!a.config.axis_rotated,a.getXAxisLabelPosition())},f.textAnchorForYAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getYAxisLabelPosition())},f.textAnchorForY2AxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getY2AxisLabelPosition())},f.xForRotatedTickText=function(a){return 10*Math.sin(Math.PI*(a/180))},f.yForRotatedTickText=function(a){return 11.5-2.5*(a/15)},f.rotateTickText=function(a,b,c){a.selectAll(".tick text").style("text-anchor","start"),b.selectAll(".tick text").attr("y",this.yForRotatedTickText(c)).attr("x",this.xForRotatedTickText(c)).attr("transform","rotate("+c+")")},f.getMaxTickWidth=function(a){var b,c,d,e=this,f=e.config,g=0;return e.svg&&(b=e.filterTargetsToShow(e.data.targets),"y"===a?(c=e.y.copy().domain(e.getYDomain(b,"y")),d=e.getYAxis(c,e.yOrient,f.axis_y_tick_format,f.axis_y_ticks)):"y2"===a?(c=e.y2.copy().domain(e.getYDomain(b,"y2")),d=e.getYAxis(c,e.y2Orient,f.axis_y2_tick_format,f.axis_y2_ticks)):(c=e.x.copy().domain(e.getXDomain(b)),d=e.getXAxis(c,e.xOrient,e.getXAxisTickFormat(),f.axis_x_tick_values?f.axis_x_tick_values:e.xAxis.tickValues())),e.main.append("g").call(d).each(function(){e.d3.select(this).selectAll("text").each(function(){var a=this.getBoundingClientRect();g=g?e.currentMaxTickWidth:g,e.currentMaxTickWidth},f.updateAxisLabels=function(a){var b=this,c=b.main.select("."+h.axisX+" ."+h.axisXLabel),d=b.main.select("."+h.axisY+" ."+h.axisYLabel),e=b.main.select("."+h.axisY2+" ."+h.axisY2Label);(a?c.transition():c).attr("x",b.xForXAxisLabel.bind(b)).attr("dx",b.dxForXAxisLabel.bind(b)).attr("dy",b.dyForXAxisLabel.bind(b)).text(b.textForXAxisLabel.bind(b)),(a?d.transition():d).attr("x",b.xForYAxisLabel.bind(b)).attr("dx",b.dxForYAxisLabel.bind(b)).attr("dy",b.dyForYAxisLabel.bind(b)).text(b.textForYAxisLabel.bind(b)),(a?e.transition():e).attr("x",b.xForY2AxisLabel.bind(b)).attr("dx",b.dxForY2AxisLabel.bind(b)).attr("dy",b.dyForY2AxisLabel.bind(b)).text(b.textForY2AxisLabel.bind(b))},f.getAxisPadding=function(a,b,c,d){var e="ratio"===a.unit?d:1;return i(a[b])?a[b]*e:c},f.generateTickValues=function(a,b){var c,d,e,f,g,h,i,k=this,l=a;if(b)if(c=j(b)?b():b,1===c)l=[a[0]];else if(2===c)l=[a[0],a[a.length-1]];else if(c>2){for(f=c-2,d=a[0],e=a[a.length-1],g=(e-d)/(f+1),l=[d],h=0;f>h;h++)i=+d+g*(h+1),l.push(k.isTimeSeries()?new Date(i):i);l.push(e)}return k.isTimeSeries()||(l=l.sort(function(a,b){return a-b})),l},f.generateAxisTransitions=function(a){var b=this,c=b.axes;return{axisX:a?c.x.transition().duration(a):c.x,axisY:a?c.y.transition().duration(a):c.y,axisY2:a?c.y2.transition().duration(a):c.y2,axisSubX:a?c.subx.transition().duration(a):c.subx}},f.redrawAxis=function(a,b){var c=this;c.axes.x.style("opacity",b?0:1),c.axes.y.style("opacity",b?0:1),c.axes.y2.style("opacity",b?0:1),c.axes.subx.style("opacity",b?0:1),a.axisX.call(c.xAxis),a.axisY.call(c.yAxis),a.axisY2.call(c.y2Axis),a.axisSubX.call(c.subXAxis)},f.getClipPath=function(b){var c=a.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"},f.getAxisClipX=function(a){return a?-31:-(this.margin.left-1)},f.getAxisClipY=function(a){return a?-20:-4},f.getXAxisClipX=function(){var a=this;return a.getAxisClipX(!a.config.axis_rotated)},f.getXAxisClipY=function(){var a=this;return a.getAxisClipY(!a.config.axis_rotated)},f.getYAxisClipX=function(){var a=this;return a.getAxisClipX(a.config.axis_rotated)},f.getYAxisClipY=function(){var a=this;return a.getAxisClipY(a.config.axis_rotated)},f.getAxisClipWidth=function(a){var b=this;return a?b.width+2+30+30:b.margin.left+20},f.getAxisClipHeight=function(a){var b=this,c=b.config;return a?(c.axis_x_height?c.axis_x_height:0)+80:b.height+8},f.getXAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(!a.config.axis_rotated)},f.getXAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(!a.config.axis_rotated)},f.getYAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(a.config.axis_rotated)},f.getYAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(a.config.axis_rotated)},f.initPie=function(){var a=this,b=a.d3,c=a.config;a.pie=b.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)}),c.data_order&&c.pie_sort&&c.donut_sort||a.pie.sort(null)},f.updateRadius=function(){var a=this,b=a.config,c=b.gauge_width||b.donut_width;a.radiusExpanded=Math.min(a.arcWidth,a.arcHeight)/2,a.radius=.95*a.radiusExpanded,a.innerRadiusRatio=c?(a.radius-c)/a.radius:.6,a.innerRadius=a.hasType("donut")||a.hasType("gauge")?a.radius*a.innerRadiusRatio:0},f.updateArc=function(){var a=this;a.svgArc=a.getSvgArc(),a.svgArcExpanded=a.getSvgArcExpanded(),a.svgArcExpandedSub=a.getSvgArcExpanded(.98)},f.updateAngle=function(a){var b=this,c=b.config,d=!1,e=0;if(b.pie(b.filterTargetsToShow(b.data.targets)).sort(b.descByStartAngle).forEach(function(b){d||b.data.id!==a.data.id||(d=!0,a=b,a.index=e),e++}),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),b.isGaugeType(a.data)){var f=c.gauge_min,g=c.gauge_max,h=Math.abs(f)+g,i=Math.PI/h;a.startAngle=-1*(Math.PI/2)+i*Math.abs(f),a.endAngle=a.startAngle+i*(a.value>g?g:a.value)}return d?a:null},f.getSvgArc=function(){var a=this,b=a.d3.svg.arc().outerRadius(a.radius).innerRadius(a.innerRadius),c=function(c,d){var e;return d?b(c):(e=a.updateAngle(c),e?b(e):"M 0 0")};return c.centroid=b.centroid,c},f.getSvgArcExpanded=function(a){var b=this,c=b.d3.svg.arc().outerRadius(b.radiusExpanded*(a?a:1)).innerRadius(b.innerRadius);return function(a){var d=b.updateAngle(a);return d?c(d):"M 0 0"}},f.getArc=function(a,b,c){return c||this.isArcType(a.data)?this.svgArc(a,b):"M 0 0"},f.transformForArcLabel=function(a){var b,c,d,e,f,g=this,h=g.updateAngle(a),i="";return h&&!g.hasType("gauge")&&(b=this.svgArc.centroid(h),c=isNaN(b[0])?0:b[0],d=isNaN(b[1])?0:b[1],e=Math.sqrt(c*c+d*d),f=g.radius&&e?(36/g.radius>.375?1.175-36/g.radius:.8)*g.radius/e:0,i="translate("+c*f+","+d*f+")"),i},f.getArcRatio=function(a){var b=this,c=b.hasType("gauge")?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/c:null},f.convertToArcData=function(a){return this.addName({id:a.data.id,value:a.value,ratio:this.getArcRatio(a),index:a.index})},f.textForArcLabel=function(a){var b,c,d,e,f=this;return f.shouldShowArcLabel()?(b=f.updateAngle(a),c=b?b.value:null,d=f.getArcRatio(b),f.hasType("gauge")||f.meetsArcLabelThreshold(d)?(e=f.getArcLabelFormat(),e?e(c,d):f.defaultArcValueFormat(c,d)):""):""},f.expandArc=function(a,b){var c=this,d=c.svg.selectAll("."+h.chartArc+c.selectorTarget(a)),e=c.svg.selectAll("."+h.arc).filter(function(b){return b.data.id!==a});c.shouldExpand(a)&&d.selectAll("path").transition().duration(50).attr("d",c.svgArcExpanded).transition().duration(100).attr("d",c.svgArcExpandedSub).each(function(a){c.isDonutType(a.data)}),b||e.style("opacity",.3)},f.unexpandArc=function(a){var b=this,c=b.svg.selectAll("."+h.chartArc+b.selectorTarget(a));c.selectAll("path."+h.arc).transition().duration(50).attr("d",b.svgArc),b.svg.selectAll("."+h.arc).style("opacity",1)},f.shouldExpand=function(a){var b=this,c=b.config;return b.isDonutType(a)&&c.donut_expand||b.isGaugeType(a)&&c.gauge_expand||b.isPieType(a)&&c.pie_expand},f.shouldShowArcLabel=function(){var a=this,b=a.config,c=!0;return a.hasType("donut")?c=b.donut_label_show:a.hasType("pie")&&(c=b.pie_label_show),c},f.meetsArcLabelThreshold=function(a){var b=this,c=b.config,d=b.hasType("donut")?c.donut_label_threshold:c.pie_label_threshold;return a>=d},f.getArcLabelFormat=function(){var a=this,b=a.config,c=b.pie_label_format;return a.hasType("gauge")?c=b.gauge_label_format:a.hasType("donut")&&(c=b.donut_label_format),c},f.getArcTitle=function(){var a=this;return a.hasType("donut")?a.config.donut_title:""},f.descByStartAngle=function(a,b){return a.startAngle-b.startAngle},f.updateTargetsForArc=function(a){var b,c,d=this,e=d.main,f=d.classChartArc.bind(d),g=d.classArcs.bind(d);b=e.select("."+h.chartArcs).selectAll("."+h.chartArc).data(d.pie(a)).attr("class",f),c=b.enter().append("g").attr("class",f),c.append("g").attr("class",g),c.append("text").attr("dy",d.hasType("gauge")?"-0.35em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},f.initArc=function(){var a=this;a.arcs=a.main.select("."+h.chart).append("g").attr("class",h.chartArcs).attr("transform",a.getTranslate("arc")),a.arcs.append("text").attr("class",h.chartArcsTitle).style("text-anchor","middle").text(a.getArcTitle())},f.redrawArc=function(a,b,c){var d,e=this,f=e.d3,g=e.config,i=e.main;d=i.selectAll("."+h.arcs).selectAll("."+h.arc).data(e.arcData.bind(e)),d.enter().append("path").attr("class",e.classArc.bind(e)).style("fill",function(a){return e.color(a.data)}).style("cursor",function(a){return g.data_selection_isselectable(a)?"pointer":null}).style("opacity",0).each(function(a){e.isGaugeType(a.data)&&(a.startAngle=a.endAngle=-1*(Math.PI/2)),this._current=a}).on("mouseover",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.expandArc(b.data.id),e.toggleFocusLegend(b.data.id,!0),e.config.data_onmouseover(c,this))}).on("mousemove",function(a){var b=e.updateAngle(a),c=e.convertToArcData(b),d=[c];e.showTooltip(d,f.mouse(this))}).on("mouseout",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.unexpandArc(b.data.id),e.revertLegend(),e.hideTooltip(),e.config.data_onmouseout(c,this))}).on("click",function(a,b){var c,d;e.toggleShape&&(c=e.updateAngle(a),d=e.convertToArcData(c),e.toggleShape(this,d,b))}),d.attr("transform",function(a){return!e.isGaugeType(a.data)&&c?"scale(0)":""}).style("opacity",function(a){return a===this._current?0:1}).each(function(){e.transiting=!0}).transition().duration(a).attrTween("d",function(a){var b,c=e.updateAngle(a);return c?(isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),b=f.interpolate(this._current,c),this._current=b(0),function(a){return e.getArc(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",c?"scale(1)":"").style("fill",function(a){return e.levelColor?e.levelColor(a.data.values[0].value):e.color(a.data.id)}).style("opacity",1).call(e.endall,function(){e.transiting=!1}),d.exit().transition().duration(b).style("opacity",0).remove(),i.selectAll("."+h.chartArc).select("text").style("opacity",0).attr("class",function(a){return e.isGaugeType(a.data)?h.gaugeValue:""}).text(e.textForArcLabel.bind(e)).attr("transform",e.transformForArcLabel.bind(e)).transition().duration(a).style("opacity",function(a){return e.isTargetToShow(a.data.id)&&e.isArcType(a.data)?1:0}),i.select("."+h.chartArcsTitle).style("opacity",e.hasType("donut")||e.hasType("gauge")?1:0)},f.initGauge=function(){var a=this,b=a.config,c=a.arcs;a.hasType("gauge")&&(c.append("path").attr("class",h.chartArcsBackground).attr("d",function(){var c={data:[{value:b.gauge_max}],startAngle:-1*(Math.PI/2),endAngle:Math.PI/2};return a.getArc(c,!0,!0)}),c.append("text").attr("dy",".75em").attr("class",h.chartArcsGaugeUnit).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_units:""),c.append("text").attr("dx",-1*(a.innerRadius+(a.radius-a.innerRadius)/2)+"px").attr("dy","1.2em").attr("class",h.chartArcsGaugeMin).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_min:""),c.append("text").attr("dx",a.innerRadius+(a.radius-a.innerRadius)/2+"px").attr("dy","1.2em").attr("class",h.chartArcsGaugeMax).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_max:""))},f.initRegion=function(){var a=this;a.main.append("g").attr("clip-path",a.clipPath).attr("class",h.regions)},f.redrawRegion=function(a){var b=this,c=b.config;b.mainRegion=b.main.select("."+h.regions).selectAll("."+h.region).data(c.regions),b.mainRegion.enter().append("g").attr("class",b.classRegion.bind(b)).append("rect").style("fill-opacity",0),b.mainRegion.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForRegion=function(a){var b=this,c=b.regionX.bind(b),d=b.regionY.bind(b),e=b.regionWidth.bind(b),f=b.regionHeight.bind(b);a.push(b.mainRegion.selectAll("rect").transition().attr("x",c).attr("y",d).attr("width",e).attr("height",f).style("fill-opacity",function(a){return i(a.opacity)?a.opacity:.1}))},f.regionX=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?"start"in a?e(a.start):0:0:d.axis_rotated?0:"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0},f.regionY=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?0:"end"in a?e(a.end):0:d.axis_rotated?"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0:0},f.regionWidth=function(a){var b,c=this,d=c.config,e=c.regionX(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?"end"in a?f(a.end):c.width:c.width:d.axis_rotated?c.width:"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.width,e>b?0:b-e},f.regionHeight=function(a){var b,c=this,d=c.config,e=this.regionY(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?c.height:"start"in a?f(a.start):c.height:d.axis_rotated?"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.height:c.height,e>b?0:b-e},f.isRegionOnX=function(a){return!a.axis||"x"===a.axis},f.drag=function(a){var b,c,d,e,f,g,i,j,k=this,l=k.config,m=k.main,n=k.d3;k.hasArcType()||l.data_selection_enabled&&(!l.zoom_enabled||k.zoom.altDomain)&&l.data_selection_multiple&&(b=k.dragStart[0],c=k.dragStart[1],d=a[0],e=a[1],f=Math.min(b,d),g=Math.max(b,d),i=l.data_selection_grouped?k.margin.top:Math.min(c,e),j=l.data_selection_grouped?k.height:Math.max(c,e),m.select("."+h.dragarea).attr("x",f).attr("y",i).attr("width",g-f).attr("height",j-i),m.selectAll("."+h.shapes).selectAll("."+h.shape).filter(function(a){return l.data_selection_isselectable(a)}).each(function(a,b){var c,d,e,l,m,o,p=n.select(this),q=p.classed(h.SELECTED),r=p.classed(h.INCLUDED),s=!1;if(p.classed(h.circle))c=1*p.attr("cx"),d=1*p.attr("cy"),m=k.togglePoint,s=c>f&&g>c&&d>i&&j>d;else{if(!p.classed(h.bar))return;o=u(this),c=o.x,d=o.y,e=o.width,l=o.height,m=k.toggleBar,s=!(c>g||f>c+e||d>j||i>d+l)}s^r&&(p.classed(h.INCLUDED,!r),p.classed(h.SELECTED,!q),m.call(k,!q,p,a,b))}))},f.dragstart=function(a){var b=this,c=b.config;b.hasArcType()||c.data_selection_enabled&&(b.dragStart=a,b.main.select("."+h.chart).append("rect").attr("class",h.dragarea).style("opacity",.1),b.dragging=!0,b.config.data_ondragstart())},f.dragend=function(){var a=this,b=a.config;a.hasArcType()||b.data_selection_enabled&&(a.main.select("."+h.dragarea).transition().duration(100).style("opacity",0).remove(),a.main.selectAll("."+h.shape).classed(h.INCLUDED,!1),a.dragging=!1,a.config.data_ondragend())},f.selectPoint=function(a,b,c){var d=this,e=d.config,f=(e.axis_rotated?d.circleY:d.circleX).bind(d),g=(e.axis_rotated?d.circleX:d.circleY).bind(d),i=d.pointSelectR.bind(d);e.data_onselected.call(d.api,b,a.node()),d.main.select("."+h.selectedCircles+d.getTargetSelectorSuffix(b.id)).selectAll("."+h.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return d.generateClass(h.selectedCircle,c)}).attr("cx",f).attr("cy",g).attr("stroke",function(){return d.color(b)}).attr("r",function(a){return 1.4*d.pointSelectR(a)}).transition().duration(100).attr("r",i)},f.unselectPoint=function(a,b,c){var d=this;d.config.data_onunselected(b,a.node()),d.main.select("."+h.selectedCircles+d.getTargetSelectorSuffix(b.id)).selectAll("."+h.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()},f.togglePoint=function(a,b,c,d){a?this.selectPoint(b,c,d):this.unselectPoint(b,c,d)},f.selectBar=function(a,b){var c=this;c.config.data_onselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.d3.rgb(c.color(b)).brighter(.75)})},f.unselectBar=function(a,b){var c=this;c.config.data_onunselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.color(b)})},f.toggleBar=function(a,b,c,d){a?this.selectBar(b,c,d):this.unselectBar(b,c,d)},f.toggleArc=function(a,b,c,d){this.toggleBar(a,b,c.data,d)},f.getToggle=function(a){var b=this;return"circle"===a.nodeName?b.togglePoint:b.d3.select(a).classed(h.bar)?b.toggleBar:b.toggleArc},f.toggleShape=function(a,b,c){var d,e,f=this,g=f.d3,i=f.config,j=g.select(a),k=j.classed(h.SELECTED);"circle"===a.nodeName?(d=f.isWithinCircle(a,1.5*f.pointSelectR(b)),e=f.togglePoint):"path"===a.nodeName&&(j.classed(h.bar)?(d=f.isWithinBar(a),e=f.toggleBar):(d=!0,e=f.toggleArc)),(i.data_selection_grouped||d)&&(i.data_selection_enabled&&i.data_selection_isselectable(b)&&(i.data_selection_multiple||f.main.selectAll("."+h.shapes+(i.data_selection_grouped?f.getTargetSelectorSuffix(b.id):"")).selectAll("."+h.shape).each(function(a,b){var c=g.select(this);c.classed(h.SELECTED)&&e.call(f,!1,c.classed(h.SELECTED,!1),a,b)}),j.classed(h.SELECTED,!k),e.call(f,!k,j,b,c)),f.config.data_onclick.call(f.api,b,a))},f.initBrush=function(){var a=this,b=a.d3;a.brush=b.svg.brush().on("brush",function(){a.redrawForBrush()}),a.brush.update=function(){return a.context&&a.context.select("."+h.brush).call(this),this +},a.brush.scale=function(b){return a.config.axis_rotated?this.y(b):this.x(b)}},f.initSubchart=function(){var a=this,b=a.config,c=a.context=a.svg.append("g").attr("transform",a.getTranslate("context"));b.subchart_show||c.style("visibility","hidden"),c.append("g").attr("clip-path",a.clipPath).attr("class",h.chart),c.select("."+h.chart).append("g").attr("class",h.chartBars),c.select("."+h.chart).append("g").attr("class",h.chartLines),c.append("g").attr("clip-path",a.clipPath).attr("class",h.brush).call(a.brush).selectAll("rect").attr(b.axis_rotated?"width":"height",b.axis_rotated?a.width2:a.height2),a.axes.subx=c.append("g").attr("class",h.axisX).attr("transform",a.getTranslate("subx")).attr("clip-path",b.axis_rotated?"":a.clipPathForXAxis)},f.updateTargetsForSubchart=function(a){var b,c,d,e,f=this,g=f.context,i=f.config,j=f.classChartBar.bind(f),k=f.classBars.bind(f),l=f.classChartLine.bind(f),m=f.classLines.bind(f),n=f.classAreas.bind(f);i.subchart_show&&(e=g.select("."+h.chartBars).selectAll("."+h.chartBar).data(a).attr("class",j),d=e.enter().append("g").style("opacity",0).attr("class",j),d.append("g").attr("class",k),c=g.select("."+h.chartLines).selectAll("."+h.chartLine).data(a).attr("class",l),b=c.enter().append("g").style("opacity",0).attr("class",l),b.append("g").attr("class",m),b.append("g").attr("class",n))},f.redrawSubchart=function(a,b,c,d,e,f,g){var i,j,k,l,m,n,o=this,p=o.d3,q=o.context,r=o.config,s=o.barData.bind(o),t=o.lineData.bind(o),u=o.classBar.bind(o),v=o.classLine.bind(o),w=o.classArea.bind(o),x=o.initialOpacity.bind(o);r.subchart_show&&(p.event&&"zoom"===p.event.type&&o.brush.extent(o.x.orgDomain()).update(),a&&(!r.axis_rotated&&r.axis_x_tick_rotate&&o.rotateTickText(o.axes.subx,b.axisSubX,r.axis_x_tick_rotate),o.brush.empty()||o.brush.extent(o.x.orgDomain()).update(),l=o.generateDrawArea(e,!0),m=o.generateDrawBar(f,!0),n=o.generateDrawLine(g,!0),k=q.selectAll("."+h.bars).selectAll("."+h.bar).data(s),k.enter().append("path").attr("class",u).style("stroke","none").style("fill",o.color),k.style("opacity",x).transition().duration(c).attr("d",m).style("opacity",1),k.exit().transition().duration(c).style("opacity",0).remove(),i=q.selectAll("."+h.lines).selectAll("."+h.line).data(t),i.enter().append("path").attr("class",v).style("stroke",o.color),i.style("opacity",x).transition().duration(c).attr("d",n).style("opacity",1),i.exit().transition().duration(c).style("opacity",0).remove(),j=q.selectAll("."+h.areas).selectAll("."+h.area).data(t),j.enter().append("path").attr("class",w).style("fill",o.color).style("opacity",function(){return o.orgAreaOpacity=+p.select(this).style("opacity"),0}),j.style("opacity",0).transition().duration(c).attr("d",l).style("fill",o.color).style("opacity",o.orgAreaOpacity),j.exit().transition().duration(d).style("opacity",0).remove()))},f.redrawForBrush=function(){var a=this,b=a.x;a.redraw({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0}),a.config.subchart_onbrush.call(a.api,b.orgDomain())},f.transformContext=function(a,b){var c,d=this;b&&b.axisSubX?c=b.axisSubX:(c=d.context.select("."+h.axisX),a&&(c=c.transition())),d.context.attr("transform",d.getTranslate("context")),c.attr("transform",d.getTranslate("subx"))},f.initZoom=function(){var a=this,b=a.d3,c=a.config;a.zoom=b.behavior.zoom().on("zoomstart",function(){a.zoom.altDomain=b.event.sourceEvent.altKey?a.x.orgDomain():null}).on("zoom",function(){a.redrawForZoom.call(a)}),a.zoom.scale=function(a){return c.axis_rotated?this.y(a):this.x(a)},a.zoom.orgScaleExtent=function(){var b=c.zoom_extent?c.zoom_extent:[1,10];return[b[0],Math.max(a.getMaxDataCount()/b[1],b[1])]},a.zoom.updateScaleExtent=function(){var b=p(a.x.orgDomain())/p(a.orgXDomain),c=this.orgScaleExtent();return this.scaleExtent([c[0]*b,c[1]*b]),this}},f.updateZoom=function(){var a=this,b=a.config.zoom_enabled?a.zoom:function(){};a.main.select("."+h.zoomRect).call(b),a.main.selectAll("."+h.eventRect).call(b)},f.redrawForZoom=function(){var a=this,b=a.d3,c=a.config,d=a.zoom,e=a.x,f=a.orgXDomain;if(c.zoom_enabled&&0!==a.filterTargetsToShow(a.data.targets).length){if("mousemove"===b.event.sourceEvent.type&&d.altDomain)return e.domain(d.altDomain),void d.scale(e).updateScaleExtent();a.isCategorized()&&e.orgDomain()[0]===f[0]&&e.domain([f[0]-1e-10,e.orgDomain()[1]]),a.redraw({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===b.event.sourceEvent.type&&(a.cancelClick=!0),c.zoom_onzoom.call(a.api,e.orgDomain())}},f.generateColor=function(){var a=this,b=a.config,c=a.d3,d=b.data_colors,e=r(b.color_pattern)?b.color_pattern:c.scale.category10().range(),f=b.data_color,g=[];return function(a){var b,c=a.id||a;return d[c]instanceof Function?b=d[c](a):d[c]?b=d[c]:(g.indexOf(c)<0&&g.push(c),b=e[g.indexOf(c)%e.length],d[c]=b),f instanceof Function?f(b,a):b}},f.generateLevelColor=function(){var a=this,b=a.config,c=b.color_pattern,d=b.color_threshold,e="value"===d.unit,f=d.values&&d.values.length?d.values:[],g=d.max||100;return r(b.color_threshold)?function(a){var b,d,h=c[c.length-1];for(b=0;b0},s=f.getOption=function(a,b,c){return m(a[b])?a[b]:c},t=f.hasValue=function(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c},u=f.getPathBox=function(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}};e.focus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),this.defocus(),b(e.classed(h.focused,!0)),b(f),c.hasArcType()&&c.expandArc(a,!0),c.toggleFocusLegend(a,!0)},e.defocus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",.3)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),b(e.classed(h.focused,!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.toggleFocusLegend(a,!1)},e.revert=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));b(e.classed(h.focused,!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.revertLegend()},e.show=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.removeHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",1),b.withLegend&&c.showLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.hide=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.addHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",0),b.withLegend&&c.hideLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.toggle=function(a){var b=this.internal;b.isTargetToShow(a)?this.hide(a):this.show(a)},e.zoom=function(){},e.zoom.enable=function(a){var b=this.internal;b.config.zoom_enabled=a,b.updateAndRedraw()},e.unzoom=function(){var a=this.internal;a.brush.clear().update(),a.redraw({withUpdateXDomain:!0})},e.load=function(a){var b=this.internal,c=b.config;return a.xs&&b.addXs(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){c.data_classes[b]=a.classes[b]}),"categories"in a&&b.isCategorized()&&(c.axis_x_categories=a.categories),"cacheIds"in a&&b.hasCaches(a.cacheIds)?void b.load(b.getCaches(a.cacheIds),a.done):void("unload"in a?b.unload(b.mapToTargetIds("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){b.loadFromArgs(a)}):b.loadFromArgs(a))},e.unload=function(a){var b=this.internal;a=a||{},b.unload(b.mapToTargetIds(a.ids),function(){b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),a.done&&a.done()})},e.flow=function(a){var b,c,d,e,f,g,h,j,k=this.internal,l=[],n=k.getMaxDataCount(),o=0,p=0;if(a.json)c=k.convertJsonToData(a.json,a.keys);else if(a.rows)c=k.convertRowsToData(a.rows);else{if(!a.columns)return;c=k.convertColumnsToData(a.columns)}b=k.convertDataToTargets(c,!0),k.data.targets.forEach(function(a){var c,d,e=!1;for(c=0;cd;d++)b[c].values[d].index=p+d,k.isTimeSeries()||(b[c].values[d].x=p+d);a.values=a.values.concat(b[c].values),b.splice(c,1);break}e||l.push(a.id)}),k.data.targets.forEach(function(a){var b,c;for(b=0;bc;c++)a.values.push({id:a.id,index:p+c,x:k.isTimeSeries()?k.getOtherTargetX(p+c):p+c,value:null})}),k.data.targets.length&&b.forEach(function(a){var b,c=[];for(b=k.data.targets[0].values[0].index;p>b;b++)c.push({id:a.id,index:b,x:k.isTimeSeries()?k.getOtherTargetX(b):b,value:null});a.values.forEach(function(a){a.index+=p,k.isTimeSeries()||(a.x+=p)}),a.values=c.concat(a.values)}),k.data.targets=k.data.targets.concat(b),d=k.getMaxDataCount(),f=k.data.targets[0],g=f.values[0],m(a.to)?(o=0,j=k.isTimeSeries()?k.parseDate(a.to):a.to,f.values.forEach(function(a){a.x1?f.values[f.values.length-1].x-g.x:g.x-k.getXDomain(k.data.targets)[0]:1,e=[g.x-h,g.x],k.updateXDomain(null,!0,!0,e)),k.updateTargets(k.data.targets),k.redraw({flow:{index:g.index,length:o,duration:i(a.duration)?a.duration:k.config.transition_duration,done:a.done,orgDataCount:n},withLegend:!0,withTransition:n>1})},f.generateFlow=function(a){var b=this,c=b.config,d=b.d3;return function(){var e,f,g,i=a.targets,j=a.flow,k=a.drawBar,l=a.drawLine,m=a.drawArea,n=a.cx,o=a.cy,q=a.xv,r=a.xForText,s=a.yForText,t=a.duration,u=1,v=j.index,w=j.length,x=b.getValueOnIndex(b.data.targets[0].values,v),y=b.getValueOnIndex(b.data.targets[0].values,v+w),z=b.x.domain(),A=j.duration||t,B=j.done||function(){},C=b.generateWait(),D=b.xgrid||d.selectAll([]),E=b.xgridLines||d.selectAll([]),F=b.mainRegion||d.selectAll([]),G=b.mainText||d.selectAll([]),H=b.mainBar||d.selectAll([]),I=b.mainLine||d.selectAll([]),J=b.mainArea||d.selectAll([]),K=b.mainCircle||d.selectAll([]);b.data.targets.forEach(function(a){a.values.splice(0,w)}),g=b.updateXDomain(i,!0,!0),b.updateXGrid&&b.updateXGrid(!0),j.orgDataCount?e=1===j.orgDataCount||x.x===y.x?b.x(z[0])-b.x(g[0]):b.isTimeSeries()?b.x(z[0])-b.x(g[0]):b.x(x.x)-b.x(y.x):1!==b.data.targets[0].values.length?e=b.x(z[0])-b.x(g[0]):b.isTimeSeries()?(x=b.getValueOnIndex(b.data.targets[0].values,0),y=b.getValueOnIndex(b.data.targets[0].values,b.data.targets[0].values.length-1),e=b.x(x.x)-b.x(y.x)):e=p(g)/2,u=p(z)/p(g),f="translate("+e+",0) scale("+u+",1)",d.transition().ease("linear").duration(A).each(function(){C.add(b.axes.x.transition().call(b.xAxis)),C.add(H.transition().attr("transform",f)),C.add(I.transition().attr("transform",f)),C.add(J.transition().attr("transform",f)),C.add(K.transition().attr("transform",f)),C.add(G.transition().attr("transform",f)),C.add(F.filter(b.isRegionOnX).transition().attr("transform",f)),C.add(D.transition().attr("transform",f)),C.add(E.transition().attr("transform",f))}).call(C,function(){var a,d=[],e=[],f=[];if(w){for(a=0;w>a;a++)d.push("."+h.shape+"-"+(v+a)),e.push("."+h.text+"-"+(v+a)),f.push("."+h.eventRect+"-"+(v+a));b.svg.selectAll("."+h.shapes).selectAll(d).remove(),b.svg.selectAll("."+h.texts).selectAll(e).remove(),b.svg.selectAll("."+h.eventRects).selectAll(f).remove(),b.svg.select("."+h.xgrid).remove()}D.attr("transform",null).attr(b.xgridAttr),E.attr("transform",null),E.select("line").attr("x1",c.axis_rotated?0:q).attr("x2",c.axis_rotated?b.width:q),E.select("text").attr("x",c.axis_rotated?b.width:0).attr("y",q),H.attr("transform",null).attr("d",k),I.attr("transform",null).attr("d",l),J.attr("transform",null).attr("d",m),K.attr("transform",null).attr("cx",n).attr("cy",o),G.attr("transform",null).attr("x",r).attr("y",s).style("fill-opacity",b.opacityForText.bind(b)),F.attr("transform",null),F.select("rect").filter(b.isRegionOnX).attr("x",b.regionX.bind(b)).attr("width",b.regionWidth.bind(b)),b.updateEventRect(),B()})}},e.selected=function(a){var b=this.internal,c=b.d3;return c.merge(b.main.selectAll("."+h.shapes+b.getTargetSelectorSuffix(a)).selectAll("."+h.shape).filter(function(){return c.select(this).classed(h.SELECTED)}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},e.select=function(a,b,c){var d=this.internal,e=d.d3,f=d.config;f.data_selection_enabled&&d.main.selectAll("."+h.shapes).selectAll("."+h.shape).each(function(g,i){var j=e.select(this),k=g.data?g.data.id:g.id,l=d.getToggle(this),n=f.data_selection_grouped||!a||a.indexOf(k)>=0,o=!b||b.indexOf(i)>=0,p=j.classed(h.SELECTED);j.classed(h.line)||j.classed(h.area)||(n&&o?f.data_selection_isselectable(g)&&!p&&l(!0,j.classed(h.SELECTED,!0),g,i):m(c)&&c&&p&&l(!1,j.classed(h.SELECTED,!1),g,i))})},e.unselect=function(a,b){var c=this.internal,d=c.d3,e=c.config;e.data_selection_enabled&&c.main.selectAll("."+h.shapes).selectAll("."+h.shape).each(function(f,g){var i=d.select(this),j=f.data?f.data.id:f.id,k=c.getToggle(this),l=e.data_selection_grouped||!a||a.indexOf(j)>=0,m=!b||b.indexOf(g)>=0,n=i.classed(h.SELECTED);i.classed(h.line)||i.classed(h.area)||l&&m&&e.data_selection_isselectable(f)&&n&&k(!1,i.classed(h.SELECTED,!1),f,g)})},e.transform=function(a,b){var c=this.internal,d=["pie","donut"].indexOf(a)>=0?{withTransform:!0}:null;c.transformTo(b,a,d)},f.transformTo=function(a,b,c){var d=this,e=!d.hasArcType(),f=c||{withTransitionForAxis:e};f.withTransitionForTransform=!1,d.transiting=!1,d.setTargetType(a,b),d.updateAndRedraw(f)},e.groups=function(a){var b=this.internal,c=b.config;return l(a)?c.data_groups:(c.data_groups=a,b.redraw(),c.data_groups)},e.xgrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_x_lines=a,b.redraw(),c.grid_x_lines):c.grid_x_lines},e.xgrids.add=function(a){var b=this.internal;return this.xgrids(b.config.grid_x_lines.concat(a?a:[]))},e.xgrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!0)},e.ygrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_y_lines=a,b.redraw(),c.grid_y_lines):c.grid_y_lines},e.ygrids.add=function(a){var b=this.internal;return this.ygrids(b.config.grid_y_lines.concat(a?a:[]))},e.ygrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!1)},e.regions=function(a){var b=this.internal,c=b.config;return a?(c.regions=a,b.redraw(),c.regions):c.regions},e.regions.add=function(a){var b=this.internal,c=b.config;return a?(c.regions=c.regions.concat(a),b.redraw(),c.regions):c.regions},e.regions.remove=function(a){var b,c,d,e=this.internal,f=e.config;return a=a||{},b=e.getOption(a,"duration",f.transition_duration),c=e.getOption(a,"classes",[h.region]),d=e.main.select("."+h.regions).selectAll(c.map(function(a){return"."+a})),(b?d.transition().duration(b):d).style("opacity",0).remove(),f.regions=f.regions.filter(function(a){var b=!1;return a.class?(a.class.split(" ").forEach(function(a){c.indexOf(a)>=0&&(b=!0)}),!b):!0}),f.regions},e.data=function(){},e.data.get=function(a){var b=this.data.getAsTarget(a);return m(b)?b.values.map(function(a){return a.value}):void 0},e.data.getAsTarget=function(a){var b=this.data.targets.filter(function(b){return b.id===a});return b.length>0?b[0]:void 0},e.data.names=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_names[b]=a[b]}),b.redraw({withLegend:!0}),c.data_names):c.data_names},e.data.colors=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_colors[b]=a[b]}),b.redraw({withLegend:!0}),c.data_colors):c.data_colors},e.category=function(a,b){var c=this.internal,d=c.config;return arguments.length>1&&(d.axis_x_categories[a]=b,c.redraw()),d.axis_x_categories[a]},e.categories=function(a){var b=this.internal,c=b.config;return arguments.length?(c.axis_x_categories=a,b.redraw(),c.axis_x_categories):c.axis_x_categories},e.color=function(a){var b=this.internal;return b.color(a)},e.x=function(a){var b=this.internal;return arguments.length&&(b.updateTargetX(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.xs=function(a){var b=this.internal;return arguments.length&&(b.updateTargetXs(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.axis=function(){},e.axis.labels=function(a){var b=this.internal;arguments.length&&(Object.keys(a).forEach(function(c){b.setAxisLabelText(c,a[c])}),b.updateAxisLabels())},e.axis.max=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(i(a.x)&&(c.axis_x_max=a.x),i(a.y)&&(c.axis_y_max=a.y),i(a.y2)&&(c.axis_y2_max=a.y2)):c.axis_y_max=c.axis_y2_max=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.min=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(i(a.x)&&(c.axis_x_min=a.x),i(a.y)&&(c.axis_y_min=a.y),i(a.y2)&&(c.axis_y2_min=a.y2)):c.axis_y_min=c.axis_y2_min=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.range=function(a){arguments.length&&(m(a.max)&&this.axis.max(a.max),m(a.min)&&this.axis.min(a.min))},e.legend=function(){},e.legend.show=function(a){var b=this.internal;b.showLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.legend.hide=function(a){var b=this.internal;b.hideLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.resize=function(a){var b=this.internal,c=b.config;c.size_width=a?a.width:null,c.size_height=a?a.height:null,this.flush()},e.flush=function(){var a=this.internal;a.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},e.destroy=function(){var b=this.internal;b.data.targets=void 0,b.data.xs={},b.selectChart.classed("c3",!1).html(""),a.onresize=null},"function"==typeof define&&define.amd?define("c3",["d3"],g):"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=g:a.c3=g}(window); \ No newline at end of file diff --git a/src/api.flow.js b/src/api.flow.js index 861b678..b311b77 100644 --- a/src/api.flow.js +++ b/src/api.flow.js @@ -140,7 +140,7 @@ c3_chart_fn.flow = function (args) { }; c3_chart_internal_fn.generateFlow = function (args) { - var $$ = this, config = $$.config, d3 = $$.d3, CLASS = $$.CLASS; + var $$ = this, config = $$.config, d3 = $$.d3; return function () { var targets = args.targets, @@ -226,14 +226,14 @@ c3_chart_internal_fn.generateFlow = function (args) { // remove flowed elements if (flowLength) { for (i = 0; i < flowLength; i++) { - shapes.push('.' + CLASS[_shape] + '-' + (flowIndex + i)); - texts.push('.' + CLASS[_text] + '-' + (flowIndex + i)); - eventRects.push('.' + CLASS[_eventRect] + '-' + (flowIndex + i)); + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + eventRects.push('.' + CLASS.eventRect + '-' + (flowIndex + i)); } - $$.svg.selectAll('.' + CLASS[_shapes]).selectAll(shapes).remove(); - $$.svg.selectAll('.' + CLASS[_texts]).selectAll(texts).remove(); - $$.svg.selectAll('.' + CLASS[_eventRects]).selectAll(eventRects).remove(); - $$.svg.select('.' + CLASS[_xgrid]).remove(); + $$.svg.selectAll('.' + CLASS.shapes).selectAll(shapes).remove(); + $$.svg.selectAll('.' + CLASS.texts).selectAll(texts).remove(); + $$.svg.selectAll('.' + CLASS.eventRects).selectAll(eventRects).remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); } // draw again for removing flowed elements and reverting attr diff --git a/src/api.focus.js b/src/api.focus.js index 4710d77..f3a4eb7 100644 --- a/src/api.focus.js +++ b/src/api.focus.js @@ -8,7 +8,7 @@ c3_chart_fn.focus = function (targetId) { } this.revert(); this.defocus(); - focus(candidatesForNoneArc.classed(CLASS[_focused], true)); + focus(candidatesForNoneArc.classed(CLASS.focused, true)); focus(candidatesForArc); if ($$.hasArcType()) { $$.expandArc(targetId, true); @@ -25,7 +25,7 @@ c3_chart_fn.defocus = function (targetId) { $$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 0.3); } this.revert(); - defocus(candidatesForNoneArc.classed(CLASS[_focused], false)); + defocus(candidatesForNoneArc.classed(CLASS.focused, false)); defocus(candidatesForArc); if ($$.hasArcType()) { $$.unexpandArc(targetId); @@ -41,7 +41,7 @@ c3_chart_fn.revert = function (targetId) { function revert(targets) { $$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 1); } - revert(candidatesForNoneArc.classed(CLASS[_focused], false)); + revert(candidatesForNoneArc.classed(CLASS.focused, false)); revert(candidatesForArc); if ($$.hasArcType()) { $$.unexpandArc(targetId); diff --git a/src/api.region.js b/src/api.region.js index 9316e1f..640427f 100644 --- a/src/api.region.js +++ b/src/api.region.js @@ -18,9 +18,9 @@ c3_chart_fn.regions.remove = function (options) { options = options || {}; duration = $$.getOption(options, "duration", config.transition_duration); - classes = $$.getOption(options, "classes", [CLASS[_region]]); + classes = $$.getOption(options, "classes", [CLASS.region]); - regions = $$.main.select('.' + CLASS[_regions]).selectAll(classes.map(function (c) { return '.' + c; })); + regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { return '.' + c; })); (duration ? regions.transition().duration(duration) : regions) .style('opacity', 0) .remove(); diff --git a/src/api.selection.js b/src/api.selection.js index cbfc5ba..87c631b 100644 --- a/src/api.selection.js +++ b/src/api.selection.js @@ -1,30 +1,30 @@ c3_chart_fn.selected = function (targetId) { var $$ = this.internal, d3 = $$.d3; return d3.merge( - $$.main.selectAll('.' + CLASS[_shapes] + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS[_shape]) - .filter(function () { return d3.select(this).classed(CLASS[_SELECTED]); }) + $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS.shape) + .filter(function () { return d3.select(this).classed(CLASS.SELECTED); }) .map(function (d) { return d.map(function (d) { var data = d.__data__; return data.data ? data.data : data; }); }) ); }; c3_chart_fn.select = function (ids, indices, resetOther) { var $$ = this.internal, d3 = $$.d3, config = $$.config; if (! config.data_selection_enabled) { return; } - $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { + $$.main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, - isSelected = shape.classed(CLASS[_SELECTED]); + isSelected = shape.classed(CLASS.SELECTED); // line/area selection not supported yet - if (shape.classed(CLASS[_line]) || shape.classed(CLASS[_area])) { + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { return; } if (isTargetId && isTargetIndex) { if (config.data_selection_isselectable(d) && !isSelected) { - toggle(true, shape.classed(CLASS[_SELECTED], true), d, i); + toggle(true, shape.classed(CLASS.SELECTED, true), d, i); } } else if (isDefined(resetOther) && resetOther) { if (isSelected) { - toggle(false, shape.classed(CLASS[_SELECTED], false), d, i); + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } } }); @@ -32,19 +32,19 @@ c3_chart_fn.select = function (ids, indices, resetOther) { c3_chart_fn.unselect = function (ids, indices) { var $$ = this.internal, d3 = $$.d3, config = $$.config; if (! config.data_selection_enabled) { return; } - $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { + $$.main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, - isSelected = shape.classed(CLASS[_SELECTED]); + isSelected = shape.classed(CLASS.SELECTED); // line/area selection not supported yet - if (shape.classed(CLASS[_line]) || shape.classed(CLASS[_area])) { + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { return; } if (isTargetId && isTargetIndex) { if (config.data_selection_isselectable(d)) { if (isSelected) { - toggle(false, shape.classed(CLASS[_SELECTED], false), d, i); + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } } } diff --git a/src/arc.js b/src/arc.js index 007ef63..be2f735 100644 --- a/src/arc.js +++ b/src/arc.js @@ -120,8 +120,8 @@ c3_chart_internal_fn.textForArcLabel = function (d) { c3_chart_internal_fn.expandArc = function (id, withoutFadeOut) { var $$ = this, - target = $$.svg.selectAll('.' + CLASS[_chartArc] + $$.selectorTarget(id)), - noneTargets = $$.svg.selectAll('.' + CLASS[_arc]).filter(function (data) { return data.data.id !== id; }); + target = $$.svg.selectAll('.' + CLASS.chartArc + $$.selectorTarget(id)), + noneTargets = $$.svg.selectAll('.' + CLASS.arc).filter(function (data) { return data.data.id !== id; }); if ($$.shouldExpand(id)) { target.selectAll('path') @@ -142,11 +142,11 @@ c3_chart_internal_fn.expandArc = function (id, withoutFadeOut) { c3_chart_internal_fn.unexpandArc = function (id) { var $$ = this, - target = $$.svg.selectAll('.' + CLASS[_chartArc] + $$.selectorTarget(id)); - target.selectAll('path.' + CLASS[_arc]) + target = $$.svg.selectAll('.' + CLASS.chartArc + $$.selectorTarget(id)); + target.selectAll('path.' + CLASS.arc) .transition().duration(50) .attr("d", $$.svgArc); - $$.svg.selectAll('.' + CLASS[_arc]) + $$.svg.selectAll('.' + CLASS.arc) .style("opacity", 1); }; @@ -197,7 +197,7 @@ c3_chart_internal_fn.updateTargetsForArc = function (targets) { mainPieUpdate, mainPieEnter, classChartArc = $$.classChartArc.bind($$), classArcs = $$.classArcs.bind($$); - mainPieUpdate = main.select('.' + CLASS[_chartArcs]).selectAll('.' + CLASS[_chartArc]) + mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc) .data($$.pie(targets)) .attr("class", classChartArc); mainPieEnter = mainPieUpdate.enter().append("g") @@ -215,11 +215,11 @@ c3_chart_internal_fn.updateTargetsForArc = function (targets) { c3_chart_internal_fn.initArc = function () { var $$ = this; - $$.arcs = $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartArcs]) + $$.arcs = $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartArcs) .attr("transform", $$.getTranslate('arc')); $$.arcs.append('text') - .attr('class', CLASS[_chartArcsTitle]) + .attr('class', CLASS.chartArcsTitle) .style("text-anchor", "middle") .text($$.getArcTitle()); }; @@ -227,7 +227,7 @@ c3_chart_internal_fn.initArc = function () { c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransform) { var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, mainArc; - mainArc = main.selectAll('.' + CLASS[_arcs]).selectAll('.' + CLASS[_arc]) + mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) .data($$.arcData.bind($$)); mainArc.enter().append('path') .attr("class", $$.classArc.bind($$)) @@ -314,14 +314,14 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf mainArc.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); - main.selectAll('.' + CLASS[_chartArc]).select('text') + main.selectAll('.' + CLASS.chartArc).select('text') .style("opacity", 0) - .attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS[_gaugeValue] : ''; }) + .attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS.gaugeValue : ''; }) .text($$.textForArcLabel.bind($$)) .attr("transform", $$.transformForArcLabel.bind($$)) .transition().duration(duration) .style("opacity", function (d) { return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0; }); - main.select('.' + CLASS[_chartArcsTitle]) + main.select('.' + CLASS.chartArcsTitle) .style("opacity", $$.hasType('donut') || $$.hasType('gauge') ? 1 : 0); }; @@ -329,7 +329,7 @@ c3_chart_internal_fn.initGauge = function () { var $$ = this, config = $$.config, arcs = $$.arcs; if ($$.hasType('gauge')) { arcs.append('path') - .attr("class", CLASS[_chartArcsBackground]) + .attr("class", CLASS.chartArcsBackground) .attr("d", function () { var d = { data: [{value: config.gauge_max}], @@ -340,21 +340,21 @@ c3_chart_internal_fn.initGauge = function () { }); arcs.append("text") .attr("dy", ".75em") - .attr("class", CLASS[_chartArcsGaugeUnit]) + .attr("class", CLASS.chartArcsGaugeUnit) .style("text-anchor", "middle") .style("pointer-events", "none") .text(config.gauge_label_show ? config.gauge_units : ''); arcs.append("text") .attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / 2)) + "px") .attr("dy", "1.2em") - .attr("class", CLASS[_chartArcsGaugeMin]) + .attr("class", CLASS.chartArcsGaugeMin) .style("text-anchor", "middle") .style("pointer-events", "none") .text(config.gauge_label_show ? config.gauge_min : ''); arcs.append("text") .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px") .attr("dy", "1.2em") - .attr("class", CLASS[_chartArcsGaugeMax]) + .attr("class", CLASS.chartArcsGaugeMax) .style("text-anchor", "middle") .style("pointer-events", "none") .text(config.gauge_label_show ? config.gauge_max : ''); diff --git a/src/axis.js b/src/axis.js index 7f28b91..447564d 100644 --- a/src/axis.js +++ b/src/axis.js @@ -1,32 +1,32 @@ c3_chart_internal_fn.initAxis = function () { - var $$ = this, config = $$.config, main = $$.main, CLASS = $$.CLASS; + var $$ = this, config = $$.config, main = $$.main; $$.axes.x = main.append("g") - .attr("class", CLASS[_axis] + ' ' + CLASS[_axisX]) + .attr("class", CLASS.axis + ' ' + CLASS.axisX) .attr("clip-path", $$.clipPathForXAxis) .attr("transform", $$.getTranslate('x')) .style("visibility", config.axis_x_show ? 'visible' : 'hidden'); $$.axes.x.append("text") - .attr("class", CLASS[_axisXLabel]) + .attr("class", CLASS.axisXLabel) .attr("transform", config.axis_rotated ? "rotate(-90)" : "") .style("text-anchor", $$.textAnchorForXAxisLabel.bind($$)); $$.axes.y = main.append("g") - .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY]) + .attr("class", CLASS.axis + ' ' + CLASS.axisY) .attr("clip-path", $$.clipPathForYAxis) .attr("transform", $$.getTranslate('y')) .style("visibility", config.axis_y_show ? 'visible' : 'hidden'); $$.axes.y.append("text") - .attr("class", CLASS[_axisYLabel]) + .attr("class", CLASS.axisYLabel) .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForYAxisLabel.bind($$)); $$.axes.y2 = main.append("g") - .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY2]) + .attr("class", CLASS.axis + ' ' + CLASS.axisY2) // clip-path? .attr("transform", $$.getTranslate('y2')) .style("visibility", config.axis_y2_show ? 'visible' : 'hidden'); $$.axes.y2.append("text") - .attr("class", CLASS[_axisY2Label]) + .attr("class", CLASS.axisY2Label) .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForY2AxisLabel.bind($$)); }; @@ -261,9 +261,9 @@ c3_chart_internal_fn.getMaxTickWidth = function (id) { c3_chart_internal_fn.updateAxisLabels = function (withTransition) { var $$ = this; - var axisXLabel = $$.main.select('.' + CLASS[_axisX] + ' .' + CLASS[_axisXLabel]), - axisYLabel = $$.main.select('.' + CLASS[_axisY] + ' .' + CLASS[_axisYLabel]), - axisY2Label = $$.main.select('.' + CLASS[_axisY2] + ' .' + CLASS[_axisY2Label]); + var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), + axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), + axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label); (withTransition ? axisXLabel.transition() : axisXLabel) .attr("x", $$.xForXAxisLabel.bind($$)) .attr("dx", $$.dxForXAxisLabel.bind($$)) diff --git a/src/class.js b/src/class.js index 10d9f17..4e487ce 100644 --- a/src/class.js +++ b/src/class.js @@ -1,231 +1,159 @@ -var _target = 'target', - _chart = 'chart ', - _chartLine = 'chartLine', - _chartLines = 'chartLines', - _chartBar = 'chartBar', - _chartBars = 'chartBars', - _chartText = 'chartText', - _chartTexts = 'chartTexts', - _chartArc = 'chartArc', - _chartArcs = 'chartArcs', - _chartArcsTitle = 'chartArcsTitle', - _chartArcsBackground = 'chartArcsBackground', - _chartArcsGaugeUnit = 'chartArcsGaugeUnit', - _chartArcsGaugeMax = 'chartArcsGaugeMax', - _chartArcsGaugeMin = 'chartArcsGaugeMin', - _selectedCircle = 'selectedCircle', - _selectedCircles = 'selectedCircles', - _eventRect = 'eventRect', - _eventRects = 'eventRects', - _eventRectsSingle = 'eventRectsSingle', - _eventRectsMultiple = 'eventRectsMultiple', - _zoomRect = 'zoomRect', - _brush = 'brush', - _focused = 'focused', - _region = 'region', - _regions = 'regions', - _tooltip = 'tooltip', - _tooltipName = 'tooltipName', - _shape = 'shape', - _shapes = 'shapes', - _line = 'line', - _lines = 'lines', - _bar = 'bar', - _bars = 'bars', - _circle = 'circle', - _circles = 'circles', - _arc = 'arc', - _arcs = 'arcs', - _area = 'area', - _areas = 'areas', - _empty = 'empty', - _text = 'text', - _texts = 'texts', - _gaugeValue = 'gaugeValue', - _grid = 'grid', - _xgrid = 'xgrid', - _xgrids = 'xgrids', - _xgridLine = 'xgridLine', - _xgridLines = 'xgridLines', - _xgridFocus = 'xgridFocus', - _ygrid = 'ygrid', - _ygrids = 'ygrids', - _ygridLine = 'ygridLine', - _ygridLines = 'ygridLines', - _axis = 'axis', - _axisX = 'axisX', - _axisXLabel = 'axisXLabel', - _axisY = 'axisY', - _axisYLabel = 'axisYLabel', - _axisY2 = 'axisY2', - _axisY2Label = 'axisY2Label', - _legendBackground = 'legendBackground', - _legendItem = 'legendItem', - _legendItemEvent = 'legendItemEvent', - _legendItemTile = 'legendItemTile', - _legendItemHidden = 'legendItemHidden', - _legendItemFocused = 'legendItemFocused', - _dragarea = 'dragarea', - _EXPANDED = 'EXPANDED', - _SELECTED = 'SELECTED', - _INCLUDED = 'INCLUDED'; - -var CLASS = c3_chart_internal_fn.CLASS = {}; -CLASS[_target] = 'c3-target'; -CLASS[_chart] = 'c3-chart'; -CLASS[_chartLine] = 'c3-chart-line'; -CLASS[_chartLines] = 'c3-chart-lines'; -CLASS[_chartBar] = 'c3-chart-bar'; -CLASS[_chartBars] = 'c3-chart-bars'; -CLASS[_chartText] = 'c3-chart-text'; -CLASS[_chartTexts] = 'c3-chart-texts'; -CLASS[_chartArc] = 'c3-chart-arc'; -CLASS[_chartArcs] = 'c3-chart-arcs'; -CLASS[_chartArcsTitle] = 'c3-chart-arcs-title'; -CLASS[_chartArcsBackground] = 'c3-chart-arcs-background'; -CLASS[_chartArcsGaugeUnit] = 'c3-chart-arcs-gauge-unit'; -CLASS[_chartArcsGaugeMax] = 'c3-chart-arcs-gauge-max'; -CLASS[_chartArcsGaugeMin] = 'c3-chart-arcs-gauge-min'; -CLASS[_selectedCircle] = 'c3-selected-circle'; -CLASS[_selectedCircles] = 'c3-selected-circles'; -CLASS[_eventRect] = 'c3-event-rect'; -CLASS[_eventRects] = 'c3-event-rects'; -CLASS[_eventRectsSingle] = 'c3-event-rects-single'; -CLASS[_eventRectsMultiple] = 'c3-event-rects-multiple'; -CLASS[_zoomRect] = 'c3-zoom-rect'; -CLASS[_brush] = 'c3-brush'; -CLASS[_focused] = 'c3-focused'; -CLASS[_region] = 'c3-region'; -CLASS[_regions] = 'c3-regions'; -CLASS[_tooltip] = 'c3-tooltip'; -CLASS[_tooltipName] = 'c3-tooltip-name'; -CLASS[_shape] = 'c3-shape'; -CLASS[_shapes] = 'c3-shapes'; -CLASS[_line] = 'c3-line'; -CLASS[_lines] = 'c3-lines'; -CLASS[_bar] = 'c3-bar'; -CLASS[_bars] = 'c3-bars'; -CLASS[_circle] = 'c3-circle'; -CLASS[_circles] = 'c3-circles'; -CLASS[_arc] = 'c3-arc'; -CLASS[_arcs] = 'c3-arcs'; -CLASS[_area] = 'c3-area'; -CLASS[_areas] = 'c3-areas'; -CLASS[_empty] = 'c3-empty'; -CLASS[_text] = 'c3-text'; -CLASS[_texts] = 'c3-texts'; -CLASS[_gaugeValue] = 'c3-gauge-value'; -CLASS[_grid] = 'c3-grid'; -CLASS[_xgrid] = 'c3-xgrid'; -CLASS[_xgrids] = 'c3-xgrids'; -CLASS[_xgridLine] = 'c3-xgrid-line'; -CLASS[_xgridLines] = 'c3-xgrid-lines'; -CLASS[_xgridFocus] = 'c3-xgrid-focus'; -CLASS[_ygrid] = 'c3-ygrid'; -CLASS[_ygrids] = 'c3-ygrids'; -CLASS[_ygridLine] = 'c3-ygrid-line'; -CLASS[_ygridLines] = 'c3-ygrid-lines'; -CLASS[_axis] = 'c3-axis'; -CLASS[_axisX] = 'c3-axis-x'; -CLASS[_axisXLabel] = 'c3-axis-x-label'; -CLASS[_axisY] = 'c3-axis-y'; -CLASS[_axisYLabel] = 'c3-axis-y-label'; -CLASS[_axisY2] = 'c3-axis-y2'; -CLASS[_axisY2Label] = 'c3-axis-y2-label'; -CLASS[_legendBackground] = 'c3-legend-background'; -CLASS[_legendItem] = 'c3-legend-item'; -CLASS[_legendItemEvent] = 'c3-legend-item-event'; -CLASS[_legendItemTile] = 'c3-legend-item-tile'; -CLASS[_legendItemHidden] = 'c3-legend-item-hidden'; -CLASS[_legendItemFocused] = 'c3-legend-item-focused'; -CLASS[_dragarea] = 'c3-dragarea'; -CLASS[_EXPANDED] = '_expanded_'; -CLASS[_SELECTED] = '_selected_'; -CLASS[_INCLUDED] = '_included_'; - +var CLASS = c3_chart_internal_fn.CLASS = { + target: 'c3-target', + chart: 'c3-chart', + chartLine: 'c3-chart-line', + chartLines: 'c3-chart-lines', + chartBar: 'c3-chart-bar', + chartBars: 'c3-chart-bars', + chartText: 'c3-chart-text', + chartTexts: 'c3-chart-texts', + chartArc: 'c3-chart-arc', + chartArcs: 'c3-chart-arcs', + chartArcsTitle: 'c3-chart-arcs-title', + chartArcsBackground: 'c3-chart-arcs-background', + chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', + chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', + chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', + selectedCircle: 'c3-selected-circle', + selectedCircles: 'c3-selected-circles', + eventRect: 'c3-event-rect', + eventRects: 'c3-event-rects', + eventRectsSingle: 'c3-event-rects-single', + eventRectsMultiple: 'c3-event-rects-multiple', + zoomRect: 'c3-zoom-rect', + brush: 'c3-brush', + focused: 'c3-focused', + region: 'c3-region', + regions: 'c3-regions', + tooltip: 'c3-tooltip', + tooltipName: 'c3-tooltip-name', + shape: 'c3-shape', + shapes: 'c3-shapes', + line: 'c3-line', + lines: 'c3-lines', + bar: 'c3-bar', + bars: 'c3-bars', + circle: 'c3-circle', + circles: 'c3-circles', + arc: 'c3-arc', + arcs: 'c3-arcs', + area: 'c3-area', + areas: 'c3-areas', + empty: 'c3-empty', + text: 'c3-text', + texts: 'c3-texts', + gaugeValue: 'c3-gauge-value', + grid: 'c3-grid', + xgrid: 'c3-xgrid', + xgrids: 'c3-xgrids', + xgridLine: 'c3-xgrid-line', + xgridLines: 'c3-xgrid-lines', + xgridFocus: 'c3-xgrid-focus', + ygrid: 'c3-ygrid', + ygrids: 'c3-ygrids', + ygridLine: 'c3-ygrid-line', + ygridLines: 'c3-ygrid-lines', + axis: 'c3-axis', + axisX: 'c3-axis-x', + axisXLabel: 'c3-axis-x-label', + axisY: 'c3-axis-y', + axisYLabel: 'c3-axis-y-label', + axisY2: 'c3-axis-y2', + axisY2Label: 'c3-axis-y2-label', + legendBackground: 'c3-legend-background', + legendItem: 'c3-legend-item', + legendItemEvent: 'c3-legend-item-event', + legendItemTile: 'c3-legend-item-tile', + legendItemHidden: 'c3-legend-item-hidden', + legendItemFocused: 'c3-legend-item-focused', + dragarea: 'c3-dragarea', + EXPANDED: '_expanded_', + SELECTED: '_selected_', + INCLUDED: '_included_' +}; c3_chart_internal_fn.generateClass = function (prefix, targetId) { return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(targetId); }; c3_chart_internal_fn.classText = function (d) { - return this.generateClass(CLASS[_text], d.index); + return this.generateClass(CLASS.text, d.index); }; c3_chart_internal_fn.classTexts = function (d) { - return this.generateClass(CLASS[_texts], d.id); + return this.generateClass(CLASS.texts, d.id); }; c3_chart_internal_fn.classShape = function (d) { - return this.generateClass(CLASS[_shape], d.index); + return this.generateClass(CLASS.shape, d.index); }; c3_chart_internal_fn.classShapes = function (d) { - return this.generateClass(CLASS[_shapes], d.id); + return this.generateClass(CLASS.shapes, d.id); }; c3_chart_internal_fn.classLine = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_line], d.id); + return this.classShape(d) + this.generateClass(CLASS.line, d.id); }; c3_chart_internal_fn.classLines = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_lines], d.id); + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); }; c3_chart_internal_fn.classCircle = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_circle], d.index); + return this.classShape(d) + this.generateClass(CLASS.circle, d.index); }; c3_chart_internal_fn.classCircles = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_circles], d.id); + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); }; c3_chart_internal_fn.classBar = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_bar], d.index); + return this.classShape(d) + this.generateClass(CLASS.bar, d.index); }; c3_chart_internal_fn.classBars = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_bars], d.id); + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); }; c3_chart_internal_fn.classArc = function (d) { - return this.classShape(d.data) + this.generateClass(CLASS[_arc], d.data.id); + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); }; c3_chart_internal_fn.classArcs = function (d) { - return this.classShapes(d.data) + this.generateClass(CLASS[_arcs], d.data.id); + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); }; c3_chart_internal_fn.classArea = function (d) { - return this.classShape(d) + this.generateClass(CLASS[_area], d.id); + return this.classShape(d) + this.generateClass(CLASS.area, d.id); }; c3_chart_internal_fn.classAreas = function (d) { - return this.classShapes(d) + this.generateClass(CLASS[_areas], d.id); + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); }; c3_chart_internal_fn.classRegion = function (d, i) { - return this.generateClass(CLASS[_region], i) + ' ' + ('class' in d ? d.class : ''); + return this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d.class : ''); }; c3_chart_internal_fn.classEvent = function (d) { - return this.generateClass(CLASS[_eventRect], d.index); + return this.generateClass(CLASS.eventRect, d.index); }; c3_chart_internal_fn.classTarget = function (id) { var $$ = this; var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; if (additionalClassSuffix) { - additionalClass = ' ' + CLASS[_target] + '-' + additionalClassSuffix; + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; } - return $$.generateClass(CLASS[_target], id) + additionalClass; + return $$.generateClass(CLASS.target, id) + additionalClass; }; c3_chart_internal_fn.classChartText = function (d) { - return CLASS[_chartText] + this.classTarget(d.id); + return CLASS.chartText + this.classTarget(d.id); }; c3_chart_internal_fn.classChartLine = function (d) { - return CLASS[_chartLine] + this.classTarget(d.id); + return CLASS.chartLine + this.classTarget(d.id); }; c3_chart_internal_fn.classChartBar = function (d) { - return CLASS[_chartBar] + this.classTarget(d.id); + return CLASS.chartBar + this.classTarget(d.id); }; c3_chart_internal_fn.classChartArc = function (d) { - return CLASS[_chartArc] + this.classTarget(d.data.id); + return CLASS.chartArc + this.classTarget(d.data.id); }; c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { return targetId || targetId === 0 ? '-' + (targetId.replace ? targetId.replace(/([^a-zA-Z0-9-_])/g, '-') : targetId) : ''; }; c3_chart_internal_fn.selectorTarget = function (id) { - return '.' + CLASS[_target] + this.getTargetSelectorSuffix(id); + return '.' + CLASS.target + this.getTargetSelectorSuffix(id); }; c3_chart_internal_fn.selectorTargets = function (ids) { var $$ = this; return ids.length ? ids.map(function (id) { return $$.selectorTarget(id); }) : null; }; c3_chart_internal_fn.selectorLegend = function (id) { - return '.' + CLASS[_legendItem] + this.getTargetSelectorSuffix(id); + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); }; c3_chart_internal_fn.selectorLegends = function (ids) { var $$ = this; diff --git a/src/core.js b/src/core.js index e6e76ee..60a6542 100644 --- a/src/core.js +++ b/src/core.js @@ -204,7 +204,7 @@ c3_chart_internal_fn.initWithData = function (data) { // text when empty main.append("text") - .attr("class", CLASS[_text] + ' ' + CLASS[_empty]) + .attr("class", CLASS.text + ' ' + CLASS.empty) .attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers. .attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE. @@ -217,7 +217,7 @@ c3_chart_internal_fn.initWithData = function (data) { // Define g for chart area main.append('g') .attr("clip-path", $$.clipPath) - .attr('class', CLASS[_chart]); + .attr('class', CLASS.chart); // Cover whole with rects for events $$.initEventRect(); @@ -237,8 +237,8 @@ c3_chart_internal_fn.initWithData = function (data) { // if zoom privileged, insert rect to forefront // TODO: is this needed? - main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS[_regions]) - .attr('class', CLASS[_zoomRect]) + main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS.regions) + .attr('class', CLASS.zoomRect) .attr('width', $$.width) .attr('height', $$.height) .style('opacity', 0) @@ -394,7 +394,7 @@ c3_chart_internal_fn.updateTargets = function (targets) { /*-- Show --*/ // Fade-in each chart - $$.svg.selectAll('.' + CLASS[_target]).filter(function (d) { return $$.isTargetToShow(d.id); }) + $$.svg.selectAll('.' + CLASS.target).filter(function (d) { return $$.isTargetToShow(d.id); }) .transition().duration(config.transition_duration) .style("opacity", 1); }; @@ -470,14 +470,14 @@ c3_chart_internal_fn.redraw = function (options, transitions) { break; } } - $$.svg.selectAll('.' + CLASS[_axisX] + ' .tick text').each(function (e) { + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function (e) { var index = tickValues.indexOf(e); if (index >= 0) { d3.select(this).style('display', index % intervalForCulling ? 'none' : 'block'); } }); } else { - $$.svg.selectAll('.' + CLASS[_axisX] + ' .tick text').style('display', 'block'); + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').style('display', 'block'); } } @@ -504,7 +504,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { $$.updateXgridFocus(); // Data empty label positioning and text. - main.select("text." + CLASS[_text] + '.' + CLASS[_empty]) + main.select("text." + CLASS.text + '.' + CLASS.empty) .attr("x", $$.width / 2) .attr("y", $$.height / 2) .text(config.data_empty_label_text) @@ -539,7 +539,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { } // circles for select - main.selectAll('.' + CLASS[_selectedCircles]) + main.selectAll('.' + CLASS.selectedCircles) .filter($$.isBarType.bind($$)) .selectAll('circle') .remove(); @@ -691,26 +691,26 @@ c3_chart_internal_fn.transformMain = function (withTransition, transitions) { if (transitions && transitions.axisX) { xAxis = transitions.axisX; } else { - xAxis = $$.main.select('.' + CLASS[_axisX]); + xAxis = $$.main.select('.' + CLASS.axisX); if (withTransition) { xAxis = xAxis.transition(); } } if (transitions && transitions.axisY) { yAxis = transitions.axisY; } else { - yAxis = $$.main.select('.' + CLASS[_axisY]); + yAxis = $$.main.select('.' + CLASS.axisY); if (withTransition) { yAxis = yAxis.transition(); } } if (transitions && transitions.axisY2) { y2Axis = transitions.axisY2; } else { - y2Axis = $$.main.select('.' + CLASS[_axisY2]); + y2Axis = $$.main.select('.' + CLASS.axisY2); if (withTransition) { y2Axis = y2Axis.transition(); } } (withTransition ? $$.main.transition() : $$.main).attr("transform", $$.getTranslate('main')); xAxis.attr("transform", $$.getTranslate('x')); yAxis.attr("transform", $$.getTranslate('y')); y2Axis.attr("transform", $$.getTranslate('y2')); - $$.main.select('.' + CLASS[_chartArcs]).attr("transform", $$.getTranslate('arc')); + $$.main.select('.' + CLASS.chartArcs).attr("transform", $$.getTranslate('arc')); }; c3_chart_internal_fn.transformAll = function (withTransition, transitions) { var $$ = this; @@ -735,7 +735,7 @@ c3_chart_internal_fn.updateSvgSize = function () { .attr('y', $$.getYAxisClipY.bind($$)) .attr('width', $$.getYAxisClipWidth.bind($$)) .attr('height', $$.getYAxisClipHeight.bind($$)); - $$.svg.select('.' + CLASS[_zoomRect]) + $$.svg.select('.' + CLASS.zoomRect) .attr('width', $$.width) .attr('height', $$.height); // MEMO: parent div's height will be bigger than svg when diff --git a/src/data.load.js b/src/data.load.js index 0a5fc05..242bcdd 100644 --- a/src/data.load.js +++ b/src/data.load.js @@ -77,7 +77,7 @@ c3_chart_internal_fn.unload = function (targetIds, done) { $$.withoutFadeIn[id] = false; // Remove target's elements if ($$.legend) { - $$.legend.selectAll('.' + CLASS[_legendItem] + $$.getTargetSelectorSuffix(id)).remove(); + $$.legend.selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)).remove(); } // Remove target $$.data.targets = $$.data.targets.filter(function (t) { diff --git a/src/drag.js b/src/drag.js index bd2446a..3f21f3b 100644 --- a/src/drag.js +++ b/src/drag.js @@ -16,26 +16,26 @@ c3_chart_internal_fn.drag = function (mouse) { minY = (config.data_selection_grouped) ? $$.margin.top : Math.min(sy, my); maxY = (config.data_selection_grouped) ? $$.height : Math.max(sy, my); - main.select('.' + CLASS[_dragarea]) + main.select('.' + CLASS.dragarea) .attr('x', minX) .attr('y', minY) .attr('width', maxX - minX) .attr('height', maxY - minY); // TODO: binary search when multiple xs - main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]) + main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape) .filter(function (d) { return config.data_selection_isselectable(d); }) .each(function (d, i) { var shape = d3.select(this), - isSelected = shape.classed(CLASS[_SELECTED]), - isIncluded = shape.classed(CLASS[_INCLUDED]), + isSelected = shape.classed(CLASS.SELECTED), + isIncluded = shape.classed(CLASS.INCLUDED), _x, _y, _w, _h, toggle, isWithin = false, box; - if (shape.classed(CLASS[_circle])) { + if (shape.classed(CLASS.circle)) { _x = shape.attr("cx") * 1; _y = shape.attr("cy") * 1; toggle = $$.togglePoint; isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; } - else if (shape.classed(CLASS[_bar])) { + else if (shape.classed(CLASS.bar)) { box = getPathBox(this); _x = box.x; _y = box.y; @@ -48,9 +48,9 @@ c3_chart_internal_fn.drag = function (mouse) { return; } if (isWithin ^ isIncluded) { - shape.classed(CLASS[_INCLUDED], !isIncluded); + shape.classed(CLASS.INCLUDED, !isIncluded); // TODO: included/unincluded callback here - shape.classed(CLASS[_SELECTED], !isSelected); + shape.classed(CLASS.SELECTED, !isSelected); toggle.call($$, !isSelected, shape, d, i); } }); @@ -61,8 +61,8 @@ c3_chart_internal_fn.dragstart = function (mouse) { if ($$.hasArcType()) { return; } if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.dragStart = mouse; - $$.main.select('.' + CLASS[_chart]).append('rect') - .attr('class', CLASS[_dragarea]) + $$.main.select('.' + CLASS.chart).append('rect') + .attr('class', CLASS.dragarea) .style('opacity', 0.1); $$.dragging = true; $$.config.data_ondragstart(); @@ -72,12 +72,12 @@ c3_chart_internal_fn.dragend = function () { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } if (! config.data_selection_enabled) { return; } // do nothing if not selectable - $$.main.select('.' + CLASS[_dragarea]) + $$.main.select('.' + CLASS.dragarea) .transition().duration(100) .style('opacity', 0) .remove(); - $$.main.selectAll('.' + CLASS[_shape]) - .classed(CLASS[_INCLUDED], false); + $$.main.selectAll('.' + CLASS.shape) + .classed(CLASS.INCLUDED, false); $$.dragging = false; $$.config.data_ondragend(); }; diff --git a/src/grid.js b/src/grid.js index c76a8ac..31d8962 100644 --- a/src/grid.js +++ b/src/grid.js @@ -1,28 +1,28 @@ c3_chart_internal_fn.initGrid = function () { - var $$ = this, config = $$.config, CLASS = $$.CLASS, d3 = $$.d3; + var $$ = this, config = $$.config, d3 = $$.d3; $$.grid = $$.main.append('g') .attr("clip-path", $$.clipPath) - .attr('class', CLASS[_grid]); + .attr('class', CLASS.grid); if (config.grid_x_show) { - $$.grid.append("g").attr("class", CLASS[_xgrids]); + $$.grid.append("g").attr("class", CLASS.xgrids); } if (config.grid_y_show) { - $$.grid.append('g').attr('class', CLASS[_ygrids]); + $$.grid.append('g').attr('class', CLASS.ygrids); } - $$.grid.append('g').attr("class", CLASS[_xgridLines]); - $$.grid.append('g').attr('class', CLASS[_ygridLines]); + $$.grid.append('g').attr("class", CLASS.xgridLines); + $$.grid.append('g').attr('class', CLASS.ygridLines); if (config.grid_focus_show) { $$.grid.append('g') - .attr("class", CLASS[_xgridFocus]) + .attr("class", CLASS.xgridFocus) .append('line') - .attr('class', CLASS[_xgridFocus]); + .attr('class', CLASS.xgridFocus); } $$.xgrid = d3.selectAll([]); $$.xgridLines = d3.selectAll([]); }; c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, d3 = $$.d3, + var $$ = this, config = $$.config, d3 = $$.d3, xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; @@ -38,9 +38,9 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { 'y2': $$.height }; - $$.xgrid = $$.main.select('.' + CLASS[_xgrids]).selectAll('.' + CLASS[_xgrid]) + $$.xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid) .data(xgridData); - $$.xgrid.enter().append('line').attr("class", CLASS[_xgrid]); + $$.xgrid.enter().append('line').attr("class", CLASS.xgrid); if (!withoutUpdate) { $$.xgrid.attr($$.xgridAttr) .style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; }); @@ -49,11 +49,11 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { }; c3_chart_internal_fn.updateYGrid = function () { - var $$ = this, config = $$.config, CLASS = $$.CLASS; - $$.ygrid = $$.main.select('.' + CLASS[_ygrids]).selectAll('.' + CLASS[_ygrid]) + var $$ = this, config = $$.config; + $$.ygrid = $$.main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid) .data($$.y.ticks(config.grid_y_ticks)); $$.ygrid.enter().append('line') - .attr('class', CLASS[_ygrid]); + .attr('class', CLASS.ygrid); $$.ygrid.attr("x1", config.axis_rotated ? $$.y : 0) .attr("x2", config.axis_rotated ? $$.y : $$.width) .attr("y1", config.axis_rotated ? 0 : $$.y) @@ -64,17 +64,17 @@ c3_chart_internal_fn.updateYGrid = function () { c3_chart_internal_fn.redrawGrid = function (duration, withY) { - var $$ = this, main = $$.main, config = $$.config, CLASS = $$.CLASS, + var $$ = this, main = $$.main, config = $$.config, xgridLine, ygridLine, yv; - main.select('line.' + CLASS[_xgridFocus]).style("visibility", "hidden"); + main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); if (config.grid_x_show) { $$.updateXGrid(); } - $$.xgridLines = main.select('.' + CLASS[_xgridLines]).selectAll('.' + CLASS[_xgridLine]) + $$.xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine) .data(config.grid_x_lines); // enter xgridLine = $$.xgridLines.enter().append('g') - .attr("class", function (d) { return CLASS[_xgridLine] + (d.class ? ' ' + d.class : ''); }); + .attr("class", function (d) { return CLASS.xgridLine + (d.class ? ' ' + d.class : ''); }); xgridLine.append('line') .style("opacity", 0); xgridLine.append('text') @@ -95,11 +95,11 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) { $$.updateYGrid(); } if (withY) { - $$.ygridLines = main.select('.' + CLASS[_ygridLines]).selectAll('.' + CLASS[_ygridLine]) + $$.ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine) .data(config.grid_y_lines); // enter ygridLine = $$.ygridLines.enter().append('g') - .attr("class", function (d) { return CLASS[_ygridLine] + (d.class ? ' ' + d.class : ''); }); + .attr("class", function (d) { return CLASS.ygridLine + (d.class ? ' ' + d.class : ''); }); ygridLine.append('line') .style("opacity", 0); ygridLine.append('text') @@ -146,7 +146,7 @@ c3_chart_internal_fn.addTransitionForGrid = function (transitions) { c3_chart_internal_fn.showXGridFocus = function (selectedData) { var $$ = this, config = $$.config, dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }), - focusEl = $$.main.selectAll('line.' + CLASS[_xgridFocus]), + focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus), xx = $$.xx.bind($$); if (! config.tooltip_show) { return; } // Hide when scatter plot exists @@ -159,11 +159,11 @@ c3_chart_internal_fn.showXGridFocus = function (selectedData) { $$.smoothLines(focusEl, 'grid'); }; c3_chart_internal_fn.hideXGridFocus = function () { - this.main.select('line.' + CLASS[_xgridFocus]).style("visibility", "hidden"); + this.main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); }; c3_chart_internal_fn.updateXgridFocus = function () { var $$ = this, config = $$.config; - $$.main.select('line.' + CLASS[_xgridFocus]) + $$.main.select('line.' + CLASS.xgridFocus) .attr("x1", config.axis_rotated ? 0 : -10) .attr("x2", config.axis_rotated ? $$.width : -10) .attr("y1", config.axis_rotated ? -10 : 0) @@ -172,7 +172,7 @@ c3_chart_internal_fn.updateXgridFocus = function () { c3_chart_internal_fn.generateGridData = function (type, scale) { var $$ = this, gridData = [], xDomain, firstYear, lastYear, i, - tickNum = $$.main.select("." + CLASS[_axisX]).selectAll('.tick').size(); + tickNum = $$.main.select("." + CLASS.axisX).selectAll('.tick').size(); if (type === 'year') { xDomain = $$.getXDomain(); firstYear = xDomain[0].getFullYear(); @@ -203,8 +203,8 @@ c3_chart_internal_fn.removeGridLines = function (params, forX) { var $$ = this, config = $$.config, toRemove = $$.getGridFilterToRemove(params), toShow = function (line) { return !toRemove(line); }, - classLines = forX ? CLASS[_xgridLines] : CLASS[_ygridLines], - classLine = forX ? CLASS[_xgridLine] : CLASS.ygridLine; + classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, + classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; $$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove) .transition().duration(config.transition_duration) .style('opacity', 0).remove(); diff --git a/src/interaction.js b/src/interaction.js index 15fec7c..1cf09ce 100644 --- a/src/interaction.js +++ b/src/interaction.js @@ -1,25 +1,25 @@ c3_chart_internal_fn.initEventRect = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_eventRects]) + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.eventRects) .style('fill-opacity', 0); }; c3_chart_internal_fn.redrawEventRect = function () { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, eventRectUpdate, maxDataCountTarget, isMultipleX = $$.isMultipleX(); // rects for mouseover - var eventRects = $$.main.select('.' + CLASS[_eventRects]) + var eventRects = $$.main.select('.' + CLASS.eventRects) .style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null) - .classed(CLASS[_eventRectsMultiple], isMultipleX) - .classed(CLASS[_eventRectsSingle], !isMultipleX); + .classed(CLASS.eventRectsMultiple, isMultipleX) + .classed(CLASS.eventRectsSingle, !isMultipleX); // clear old rects - eventRects.selectAll('.' + CLASS[_eventRect]).remove(); + eventRects.selectAll('.' + CLASS.eventRect).remove(); // open as public variable - $$.eventRect = eventRects.selectAll('.' + CLASS[_eventRect]); + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); if (isMultipleX) { eventRectUpdate = $$.eventRect.data([0]); @@ -33,7 +33,7 @@ c3_chart_internal_fn.redrawEventRect = function () { // Set data and update $$.eventRect maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets); eventRects.datum(maxDataCountTarget ? maxDataCountTarget.values : []); - $$.eventRect = eventRects.selectAll('.' + CLASS[_eventRect]); + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); eventRectUpdate = $$.eventRect.data(function (d) { return d; }); // enter $$.generateEventRectsForSingleX(eventRectUpdate.enter()); @@ -120,7 +120,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { $$.expandBars(index); // Call event handler - $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { config.data_onmouseover.call($$, d); }); }) @@ -133,13 +133,13 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { $$.unexpandCircles(index); $$.unexpandBars(); // Call event handler - $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { config.data_onmouseout.call($$, d); }); }) .on('mousemove', function (d) { var selectedData, index = d.index, - eventRect = $$.svg.select('.' + CLASS[_eventRect] + '-' + index); + eventRect = $$.svg.select('.' + CLASS.eventRect + '-' + index); if ($$.dragging) { return; } // do nothing when dragging if ($$.hasArcType()) { return; } @@ -158,9 +158,9 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { return; } - $$.main.selectAll('.' + CLASS[_shape] + '-' + index) + $$.main.selectAll('.' + CLASS.shape + '-' + index) .each(function () { - d3.select(this).classed(CLASS[_EXPANDED], true); + d3.select(this).classed(CLASS.EXPANDED, true); if (config.data_selection_enabled) { eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); } @@ -200,7 +200,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { $$.cancelClick = false; return; } - $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { $$.toggleShape(this, d, index); }); }) @@ -220,7 +220,7 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) .attr('y', 0) .attr('width', $$.width) .attr('height', $$.height) - .attr('class', CLASS[_eventRect]) + .attr('class', CLASS.eventRect) .on('mouseout', function () { if ($$.hasArcType()) { return; } $$.hideXGridFocus(); @@ -262,13 +262,13 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) // Show cursor as pointer if point is close to mouse position if ($$.dist(closest, mouse) < 100) { - $$.svg.select('.' + CLASS[_eventRect]).style('cursor', 'pointer'); + $$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer'); if (!$$.mouseover) { config.data_onmouseover.call($$, closest); $$.mouseover = true; } } else if ($$.mouseover) { - $$.svg.select('.' + CLASS[_eventRect]).style('cursor', null); + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); config.data_onmouseout.call($$, closest); $$.mouseover = false; } @@ -286,7 +286,7 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) // select if selection enabled if ($$.dist(closest, mouse) < 100 && $$.toggleShape) { - $$.main.select('.' + CLASS[_circles] + $$.getTargetSelectorSuffix(closest.id)).select('.' + CLASS[_circle] + '-' + closest.index).each(function () { + $$.main.select('.' + CLASS.circles + $$.getTargetSelectorSuffix(closest.id)).select('.' + CLASS.circle + '-' + closest.index).each(function () { $$.toggleShape(this, closest, closest.index); }); } diff --git a/src/legend.js b/src/legend.js index 85f0288..b9e7b4c 100644 --- a/src/legend.js +++ b/src/legend.js @@ -53,15 +53,15 @@ c3_chart_internal_fn.getLegendHeight = function () { }; c3_chart_internal_fn.opacityForLegend = function (legendItem) { var $$ = this; - return legendItem.classed(CLASS[_legendItemHidden]) ? $$.legendOpacityForHidden : 1; + return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 1; }; c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { var $$ = this; - return legendItem.classed(CLASS[_legendItemHidden]) ? $$.legendOpacityForHidden : 0.3; + return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 0.3; }; c3_chart_internal_fn.toggleFocusLegend = function (id, focus) { var $$ = this; - $$.legend.selectAll('.' + CLASS[_legendItem]) + $$.legend.selectAll('.' + CLASS.legendItem) .transition().duration(100) .style('opacity', function (_id) { var This = $$.d3.select(this); @@ -74,7 +74,7 @@ c3_chart_internal_fn.toggleFocusLegend = function (id, focus) { }; c3_chart_internal_fn.revertLegend = function () { var $$ = this, d3 = $$.d3; - $$.legend.selectAll('.' + CLASS[_legendItem]) + $$.legend.selectAll('.' + CLASS.legendItem) .transition().duration(100) .style('opacity', function () { return $$.opacityForLegend(d3.select(this)); }); }; @@ -107,7 +107,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { var paddingTop = 4, paddingRight = 36, maxWidth = 0, maxHeight = 0, posMin = 10; var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; var withTransition, withTransitionForTransform; - var hasFocused = $$.legend.selectAll('.' + CLASS[_legendItemFocused]).size(); + var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size(); var texts, rects, tiles; options = options || {}; @@ -115,7 +115,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { withTransitionForTransform = getOption(options, "withTransitionForTransform", true); function updatePositions(textElement, id, reset) { - var box = $$.getTextRect(textElement.textContent, CLASS[_legendItem]), + var box = $$.getTextRect(textElement.textContent, CLASS.legendItem), itemWidth = Math.ceil((box.width + paddingRight) / 10) * 10, itemHeight = Math.ceil((box.height + paddingTop) / 10) * 10, itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, @@ -190,17 +190,17 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { yForLegendRect = function (id, i) { return yForLegend(id, i) - 7; }; // Define g for legend area - l = $$.legend.selectAll('.' + CLASS[_legendItem]) + l = $$.legend.selectAll('.' + CLASS.legendItem) .data(targetIds) .enter().append('g') - .attr('class', function (id) { return $$.generateClass(CLASS[_legendItem], id); }) + .attr('class', function (id) { return $$.generateClass(CLASS.legendItem, id); }) .style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; }) .style('cursor', 'pointer') .on('click', function (id) { config.legend_item_onclick ? config.legend_item_onclick.call($$, id) : $$.api.toggle(id); }) .on('mouseover', function (id) { - $$.d3.select(this).classed(CLASS[_legendItemFocused], true); + $$.d3.select(this).classed(CLASS.legendItemFocused, true); if (!$$.transiting) { $$.api.focus(id); } @@ -209,7 +209,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { } }) .on('mouseout', function (id) { - $$.d3.select(this).classed(CLASS[_legendItemFocused], false); + $$.d3.select(this).classed(CLASS.legendItemFocused, false); if (!$$.transiting) { $$.api.revert(); } @@ -224,12 +224,12 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); l.append('rect') - .attr("class", CLASS[_legendItemEvent]) + .attr("class", CLASS.legendItemEvent) .style('fill-opacity', 0) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); l.append('rect') - .attr("class", CLASS[_legendItemTile]) + .attr("class", CLASS.legendItemTile) .style("pointer-events", "none") .style('fill', $$.color) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) @@ -238,8 +238,8 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { .attr('height', 10); // Set background for inset legend if ($$.isLegendInset && maxWidth !== 0) { - $$.legend.insert('g', '.' + CLASS[_legendItem]) - .attr("class", CLASS[_legendBackground]) + $$.legend.insert('g', '.' + CLASS.legendItem) + .attr("class", CLASS.legendBackground) .append('rect') .attr('height', $$.getLegendHeight() - 10) .attr('width', maxWidth * (step + 1) + 10); @@ -253,7 +253,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { .attr('x', xForLegendText) .attr('y', yForLegendText); - rects = $$.legend.selectAll('rect.' + CLASS[_legendItemEvent]) + rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent) .data(targetIds); (withTransition ? rects.transition() : rects) .attr('width', function (id) { return widths[id]; }) @@ -261,7 +261,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { .attr('x', xForLegendRect) .attr('y', yForLegendRect); - tiles = $$.legend.selectAll('rect.' + CLASS[_legendItemTile]) + tiles = $$.legend.selectAll('rect.' + CLASS.legendItemTile) .data(targetIds); (withTransition ? tiles.transition() : tiles) .style('fill', $$.color) @@ -269,13 +269,13 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { .attr('y', yForLegend); // toggle legend state - $$.legend.selectAll('.' + CLASS[_legendItem]) - .classed(CLASS[_legendItemHidden], function (id) { return !$$.isTargetToShow(id); }) + $$.legend.selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemHidden, function (id) { return !$$.isTargetToShow(id); }) .transition() .style('opacity', function (id) { var This = $$.d3.select(this); if ($$.isTargetToShow(id)) { - return !hasFocused || This.classed(CLASS[_legendItemFocused]) ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This); + return !hasFocused || This.classed(CLASS.legendItemFocused) ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This); } else { return $$.legendOpacityForHidden; } diff --git a/src/region.js b/src/region.js index f6a9601..7bdb46b 100644 --- a/src/region.js +++ b/src/region.js @@ -1,12 +1,12 @@ c3_chart_internal_fn.initRegion = function () { - var $$ = this, CLASS = $$.CLASS; + var $$ = this; $$.main.append('g') .attr("clip-path", $$.clipPath) - .attr("class", CLASS[_regions]); + .attr("class", CLASS.regions); }; c3_chart_internal_fn.redrawRegion = function (duration) { - var $$ = this, config = $$.config, CLASS = $$.CLASS; - $$.mainRegion = $$.main.select('.' + CLASS[_regions]).selectAll('.' + CLASS[_region]) + var $$ = this, config = $$.config; + $$.mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region) .data(config.regions); $$.mainRegion.enter().append('g') .attr('class', $$.classRegion.bind($$)) diff --git a/src/selection.js b/src/selection.js index 6746087..b131bb0 100644 --- a/src/selection.js +++ b/src/selection.js @@ -5,10 +5,10 @@ c3_chart_internal_fn.selectPoint = function (target, d, i) { r = $$.pointSelectR.bind($$); config.data_onselected.call($$.api, d, target.node()); // add selected-circle on low layer g - $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) + $$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) .data([d]) .enter().append('circle') - .attr("class", function () { return $$.generateClass(CLASS[_selectedCircle], i); }) + .attr("class", function () { return $$.generateClass(CLASS.selectedCircle, i); }) .attr("cx", cx) .attr("cy", cy) .attr("stroke", function () { return $$.color(d); }) @@ -20,7 +20,7 @@ c3_chart_internal_fn.unselectPoint = function (target, d, i) { var $$ = this; $$.config.data_onunselected(d, target.node()); // remove selected-circle from low layer g - $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) + $$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) .transition().duration(100).attr('r', 0) .remove(); }; @@ -48,17 +48,17 @@ c3_chart_internal_fn.toggleArc = function (selected, target, d, i) { c3_chart_internal_fn.getToggle = function (that) { var $$ = this; // path selection not supported yet - return that.nodeName === 'circle' ? $$.togglePoint : ($$.d3.select(that).classed(CLASS[_bar]) ? $$.toggleBar : $$.toggleArc); + return that.nodeName === 'circle' ? $$.togglePoint : ($$.d3.select(that).classed(CLASS.bar) ? $$.toggleBar : $$.toggleArc); }; c3_chart_internal_fn.toggleShape = function (that, d, i) { var $$ = this, d3 = $$.d3, config = $$.config, - shape = d3.select(that), isSelected = shape.classed(CLASS[_SELECTED]), isWithin, toggle; + shape = d3.select(that), isSelected = shape.classed(CLASS.SELECTED), isWithin, toggle; if (that.nodeName === 'circle') { isWithin = $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); toggle = $$.togglePoint; } else if (that.nodeName === 'path') { - if (shape.classed(CLASS[_bar])) { + if (shape.classed(CLASS.bar)) { isWithin = $$.isWithinBar(that); toggle = $$.toggleBar; } else { // would be arc @@ -69,12 +69,12 @@ c3_chart_internal_fn.toggleShape = function (that, d, i) { if (config.data_selection_grouped || isWithin) { if (config.data_selection_enabled && config.data_selection_isselectable(d)) { if (!config.data_selection_multiple) { - $$.main.selectAll('.' + CLASS[_shapes] + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) { + $$.main.selectAll('.' + CLASS.shapes + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this); - if (shape.classed(CLASS[_SELECTED])) { toggle.call($$, false, shape.classed(CLASS[_SELECTED], false), d, i); } + if (shape.classed(CLASS.SELECTED)) { toggle.call($$, false, shape.classed(CLASS.SELECTED, false), d, i); } }); } - shape.classed(CLASS[_SELECTED], !isSelected); + shape.classed(CLASS.SELECTED, !isSelected); toggle.call($$, !isSelected, shape, d, i); } $$.config.data_onclick.call($$.api, d, that); diff --git a/src/shape.bar.js b/src/shape.bar.js index 195eeb2..4e8c0da 100644 --- a/src/shape.bar.js +++ b/src/shape.bar.js @@ -1,14 +1,14 @@ c3_chart_internal_fn.initBar = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartBars]); + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartBars); }; c3_chart_internal_fn.updateTargetsForBar = function (targets) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, mainBarUpdate, mainBarEnter, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$); - mainBarUpdate = $$.main.select('.' + CLASS[_chartBars]).selectAll('.' + CLASS[_chartBar]) + mainBarUpdate = $$.main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) .data(targets) .attr('class', classChartBar); mainBarEnter = mainBarUpdate.enter().append('g') @@ -22,12 +22,12 @@ c3_chart_internal_fn.updateTargetsForBar = function (targets) { }; c3_chart_internal_fn.redrawBar = function (durationForExit) { - var $$ = this, CLASS = $$.CLASS, + var $$ = this, barData = $$.barData.bind($$), classBar = $$.classBar.bind($$), initialOpacity = $$.initialOpacity.bind($$), color = function (d) { return $$.color(d.id); }; - $$.mainBar = $$.main.selectAll('.' + CLASS[_bars]).selectAll('.' + CLASS[_bar]) + $$.mainBar = $$.main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) .data(barData); $$.mainBar.enter().append('path') .attr("class", classBar) @@ -53,15 +53,15 @@ c3_chart_internal_fn.getBarW = function (axis, barTargetsNum) { }; c3_chart_internal_fn.getBars = function (i) { var $$ = this; - return $$.main.selectAll('.' + CLASS[_bar] + (isValue(i) ? '-' + i : '')); + return $$.main.selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); }; c3_chart_internal_fn.expandBars = function (i) { var $$ = this; - $$.getBars(i).classed(CLASS[_EXPANDED], true); + $$.getBars(i).classed(CLASS.EXPANDED, true); }; c3_chart_internal_fn.unexpandBars = function (i) { var $$ = this; - $$.getBars(i).classed(CLASS[_EXPANDED], false); + $$.getBars(i).classed(CLASS.EXPANDED, false); }; c3_chart_internal_fn.generateDrawBar = function (barIndices, isSub) { var $$ = this, config = $$.config, diff --git a/src/shape.line.js b/src/shape.line.js index 7b55175..27d0e3f 100644 --- a/src/shape.line.js +++ b/src/shape.line.js @@ -1,16 +1,16 @@ c3_chart_internal_fn.initLine = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartLines]); + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartLines); }; c3_chart_internal_fn.updateTargetsForLine = function (targets) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, mainLineUpdate, mainLineEnter, classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$), classCircles = $$.classCircles.bind($$); - mainLineUpdate = $$.main.select('.' + CLASS[_chartLines]).selectAll('.' + CLASS[_chartLine]) + mainLineUpdate = $$.main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) .data(targets) .attr('class', classChartLine); mainLineEnter = mainLineUpdate.enter().append('g') @@ -25,13 +25,13 @@ c3_chart_internal_fn.updateTargetsForLine = function (targets) { .attr('class', classAreas); // Circles for each data point on lines mainLineEnter.append('g') - .attr("class", function (d) { return $$.generateClass(CLASS[_selectedCircles], d.id); }); + .attr("class", function (d) { return $$.generateClass(CLASS.selectedCircles, d.id); }); mainLineEnter.append('g') .attr("class", classCircles) .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); // Update date for selected circles targets.forEach(function (t) { - $$.main.selectAll('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS[_selectedCircle]).each(function (d) { + $$.main.selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS.selectedCircle).each(function (d) { d.value = t.values[d.index].value; }); }); @@ -39,8 +39,8 @@ c3_chart_internal_fn.updateTargetsForLine = function (targets) { //mainLineUpdate.exit().remove(); }; c3_chart_internal_fn.redrawLine = function (durationForExit) { - var $$ = this, CLASS = $$.CLASS; - $$.mainLine = $$.main.selectAll('.' + CLASS[_lines]).selectAll('.' + CLASS[_line]) + var $$ = this; + $$.mainLine = $$.main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) .data($$.lineData.bind($$)); $$.mainLine.enter().append('path') .attr('class', $$.classLine.bind($$)) @@ -194,8 +194,8 @@ c3_chart_internal_fn.lineWithRegions = function (d, x, y, _regions) { c3_chart_internal_fn.redrawArea = function (durationForExit) { - var $$ = this, CLASS = $$.CLASS, d3 = $$.d3; - $$.mainArea = $$.main.selectAll('.' + CLASS[_areas]).selectAll('.' + CLASS[_area]) + var $$ = this, d3 = $$.d3; + $$.mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) .data($$.lineData.bind($$)); $$.mainArea.enter().append('path') .attr("class", $$.classArea.bind($$)) @@ -271,8 +271,8 @@ c3_chart_internal_fn.generateGetAreaPoint = function (areaIndices, isSub) { // p c3_chart_internal_fn.redrawCircle = function () { - var $$ = this, CLASS = $$.CLASS; - $$.mainCircle = $$.main.selectAll('.' + CLASS[_circles]).selectAll('.' + CLASS[_circle]) + var $$ = this; + $$.mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle) .data($$.lineOrScatterData.bind($$)); $$.mainCircle.enter().append("circle") .attr("class", $$.classCircle.bind($$)) @@ -289,7 +289,7 @@ c3_chart_internal_fn.addTransitionForCircle = function (transitions, cx, cy) { .style("fill", $$.color) .attr("cx", cx) .attr("cy", cy)); - transitions.push($$.main.selectAll('.' + CLASS[_selectedCircle]).transition() + transitions.push($$.main.selectAll('.' + CLASS.selectedCircle).transition() .attr("cx", cx) .attr("cy", cy)); }; @@ -303,21 +303,21 @@ c3_chart_internal_fn.circleY = function (d, i) { }; c3_chart_internal_fn.getCircles = function (i, id) { var $$ = this; - return (id ? $$.main.selectAll('.' + CLASS[_circles] + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS[_circle] + (isValue(i) ? '-' + i : '')); + return (id ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); }; c3_chart_internal_fn.expandCircles = function (i, id) { var $$ = this, r = $$.pointExpandedR.bind($$); $$.getCircles(i, id) - .classed(CLASS[_EXPANDED], true) + .classed(CLASS.EXPANDED, true) .attr('r', r); }; c3_chart_internal_fn.unexpandCircles = function (i) { var $$ = this, r = $$.pointR.bind($$); $$.getCircles(i) - .filter(function () { return $$.d3.select(this).classed(CLASS[_EXPANDED]); }) - .classed(CLASS[_EXPANDED], false) + .filter(function () { return $$.d3.select(this).classed(CLASS.EXPANDED); }) + .classed(CLASS.EXPANDED, false) .attr('r', r); }; c3_chart_internal_fn.pointR = function (d) { diff --git a/src/size.js b/src/size.js index 9c12c79..d29f7c8 100644 --- a/src/size.js +++ b/src/size.js @@ -59,7 +59,7 @@ c3_chart_internal_fn.getParentHeight = function () { c3_chart_internal_fn.getSvgLeft = function () { var $$ = this, config = $$.config, - leftAxisClass = config.axis_rotated ? CLASS[_axisX] : CLASS[_axisY], + leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY, leftAxis = $$.main.select('.' + leftAxisClass).node(), svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0}, chartRect = $$.selectChart.node().getBoundingClientRect(), diff --git a/src/subchart.js b/src/subchart.js index da089de..5602b0b 100644 --- a/src/subchart.js +++ b/src/subchart.js @@ -2,7 +2,7 @@ c3_chart_internal_fn.initBrush = function () { var $$ = this, d3 = $$.d3; $$.brush = d3.svg.brush().on("brush", function () { $$.redrawForBrush(); }); $$.brush.update = function () { - if ($$.context) { $$.context.select('.' + $$.CLASS[_brush]).call(this); } + if ($$.context) { $$.context.select('.' + CLASS.brush).call(this); } return this; }; $$.brush.scale = function (scale) { @@ -20,20 +20,20 @@ c3_chart_internal_fn.initSubchart = function () { // Define g for chart area context.append('g') .attr("clip-path", $$.clipPath) - .attr('class', CLASS[_chart]); + .attr('class', CLASS.chart); // Define g for bar chart area - context.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartBars]); + context.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartBars); // Define g for line chart area - context.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartLines]); + context.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartLines); // Add extent rect for Brush context.append("g") .attr("clip-path", $$.clipPath) - .attr("class", CLASS[_brush]) + .attr("class", CLASS.brush) .call($$.brush) .selectAll("rect") .attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? $$.width2 : $$.height2); @@ -41,7 +41,7 @@ c3_chart_internal_fn.initSubchart = function () { // ATTENTION: This must be called AFTER chart added // Add Axis $$.axes.subx = context.append("g") - .attr("class", CLASS[_axisX]) + .attr("class", CLASS.axisX) .attr("transform", $$.getTranslate('subx')) .attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis); }; @@ -55,7 +55,7 @@ c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { classAreas = $$.classAreas.bind($$); if (config.subchart_show) { - contextBarUpdate = context.select('.' + CLASS[_chartBars]).selectAll('.' + CLASS[_chartBar]) + contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) .data(targets) .attr('class', classChartBar); contextBarEnter = contextBarUpdate.enter().append('g') @@ -66,7 +66,7 @@ c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { .attr("class", classBars); //-- Line --// - contextLineUpdate = context.select('.' + CLASS[_chartLines]).selectAll('.' + CLASS[_chartLine]) + contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) .data(targets) .attr('class', classChartLine); contextLineEnter = contextLineUpdate.enter().append('g') @@ -113,7 +113,7 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat drawBarOnSub = $$.generateDrawBar(barIndices, true); drawLineOnSub = $$.generateDrawLine(lineIndices, true); // bars - contextBar = context.selectAll('.' + CLASS[_bars]).selectAll('.' + CLASS[_bar]) + contextBar = context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) .data(barData); contextBar.enter().append('path') .attr("class", classBar) @@ -128,7 +128,7 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat .style('opacity', 0) .remove(); // lines - contextLine = context.selectAll('.' + CLASS[_lines]).selectAll('.' + CLASS[_line]) + contextLine = context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) .data(lineData); contextLine.enter().append('path') .attr('class', classLine) @@ -142,7 +142,7 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat .style('opacity', 0) .remove(); // area - contextArea = context.selectAll('.' + CLASS[_areas]).selectAll('.' + CLASS[_area]) + contextArea = context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) .data(lineData); contextArea.enter().append('path') .attr("class", classArea) @@ -175,7 +175,7 @@ c3_chart_internal_fn.transformContext = function (withTransition, transitions) { if (transitions && transitions.axisSubX) { subXAxis = transitions.axisSubX; } else { - subXAxis = $$.context.select('.' + CLASS[_axisX]); + subXAxis = $$.context.select('.' + CLASS.axisX); if (withTransition) { subXAxis = subXAxis.transition(); } } $$.context.attr("transform", $$.getTranslate('context')); diff --git a/src/text.js b/src/text.js index 55a2615..351d027 100644 --- a/src/text.js +++ b/src/text.js @@ -1,14 +1,14 @@ c3_chart_internal_fn.initText = function () { - var $$ = this, CLASS = $$.CLASS; - $$.main.select('.' + CLASS[_chart]).append("g") - .attr("class", CLASS[_chartTexts]); + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartTexts); $$.mainText = $$.d3.selectAll([]); }; c3_chart_internal_fn.updateTargetsForText = function (targets) { - var $$ = this, CLASS = $$.CLASS, mainTextUpdate, mainTextEnter, + var $$ = this, mainTextUpdate, mainTextEnter, classChartText = $$.classChartText.bind($$), classTexts = $$.classTexts.bind($$); - mainTextUpdate = $$.main.select('.' + CLASS[_chartTexts]).selectAll('.' + CLASS[_chartText]) + mainTextUpdate = $$.main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText) .data(targets) .attr('class', classChartText); mainTextEnter = mainTextUpdate.enter().append('g') @@ -19,10 +19,10 @@ c3_chart_internal_fn.updateTargetsForText = function (targets) { .attr('class', classTexts); }; c3_chart_internal_fn.redrawText = function (durationForExit) { - var $$ = this, config = $$.config, CLASS = $$.CLASS, + var $$ = this, config = $$.config, barOrLineData = $$.barOrLineData.bind($$), classText = $$.classText.bind($$); - $$.mainText = $$.main.selectAll('.' + CLASS[_texts]).selectAll('.' + CLASS[_text]) + $$.mainText = $$.main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text) .data(barOrLineData); $$.mainText.enter().append('text') .attr("class", classText) diff --git a/src/tooltip.js b/src/tooltip.js index c960f8b..1603993 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -35,14 +35,14 @@ c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaul if (! text) { title = titleFormat ? titleFormat(d[i].x) : d[i].x; - text = "" + (title || title === 0 ? "" : ""); + text = "
" + title + "
" + (title || title === 0 ? "" : ""); } name = nameFormat(d[i].name); value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index); bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); - text += ""; + text += ""; text += ""; text += ""; text += ""; diff --git a/src/zoom.js b/src/zoom.js index 43ef248..dedc727 100644 --- a/src/zoom.js +++ b/src/zoom.js @@ -21,8 +21,8 @@ c3_chart_internal_fn.initZoom = function () { }; c3_chart_internal_fn.updateZoom = function () { var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {}; - $$.main.select('.' + $$.CLASS[_zoomRect]).call(z); - $$.main.selectAll('.' + $$.CLASS[_eventRect]).call(z); + $$.main.select('.' + CLASS.zoomRect).call(z); + $$.main.selectAll('.' + CLASS.eventRect).call(z); }; c3_chart_internal_fn.redrawForZoom = function () { var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x, orgXDomain = $$.orgXDomain;
" + title + "
" + name + "" + value + "