From f2b994f1e4c78e24d490e04d79720dd4587168a9 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Mon, 8 Jan 2018 22:13:32 +0900 Subject: [PATCH] Fix spec --- c3.js | 1281 ++++++++++++++++---------------------- c3.min.js | 2 +- spec/api.region-spec.js | 15 +- spec/arc-spec.js | 12 +- spec/axis-spec.js | 4 +- spec/c3-helper.js | 1 - spec/grid-spec.js | 6 +- spec/interaction-spec.js | 25 +- spec/shape.bar-spec.js | 22 +- spec/shape.line-spec.js | 4 +- spec/tooltip-spec.js | 170 +++-- spec/zoom-spec.js | 16 +- src/axis.js | 4 +- src/config.js | 2 +- src/data.js | 2 +- src/region.js | 3 +- src/shape.bar.js | 4 +- src/shape.js | 5 +- 18 files changed, 714 insertions(+), 864 deletions(-) diff --git a/c3.js b/c3.js index d607b17..51b43cb 100644 --- a/c3.js +++ b/c3.js @@ -213,7 +213,7 @@ function AxisInternal(component, params) { internal.params = params || {}; internal.d3 = component.d3; - internal.scale = internal.d3.scale.linear(); + internal.scale = internal.d3.scaleLinear(); internal.range; internal.orient = "bottom"; internal.innerTickSize = 6; @@ -310,20 +310,17 @@ c3_axis_internal_fn.updateTickTextCharSize = function (tick) { internal.tickTextCharSize = size; return size; }; -c3_axis_internal_fn.transitionise = function (selection) { - return this.params.withoutTransition ? selection : this.d3.transition(selection); -}; c3_axis_internal_fn.isVertical = function () { return this.orient === 'left' || this.orient === 'right'; }; -c3_axis_internal_fn.tspanData = function (d, i, ticks, scale) { +c3_axis_internal_fn.tspanData = function (d, i, scale) { var internal = this; - var splitted = internal.params.tickMultiline ? internal.splitTickText(d, ticks, scale) : [].concat(internal.textFormatted(d)); + var splitted = internal.params.tickMultiline ? internal.splitTickText(d, scale) : [].concat(internal.textFormatted(d)); return splitted.map(function (s) { return { index: i, splitted: s, length: splitted.length }; }); }; -c3_axis_internal_fn.splitTickText = function (d, ticks, scale) { +c3_axis_internal_fn.splitTickText = function (d, scale) { var internal = this, tickText = internal.textFormatted(d), maxWidth = internal.params.tickWidth, @@ -337,7 +334,7 @@ c3_axis_internal_fn.splitTickText = function (d, ticks, scale) { } if (!maxWidth || maxWidth <= 0) { - maxWidth = internal.isVertical() ? 95 : internal.params.isCategory ? Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12 : 110; + maxWidth = internal.isVertical() ? 95 : internal.params.isCategory ? Math.ceil(scale(1) - scale(0)) - 12 : 110; } function split(splitted, text) { @@ -404,20 +401,21 @@ c3_axis_internal_fn.generateAxis = function () { var internal = this, d3 = internal.d3, params = internal.params; - function axis(g) { + function axis(g, transition) { + var self; g.each(function () { var g = axis.g = d3.select(this); var scale0 = this.__chart__ || internal.scale, scale1 = this.__chart__ = internal.copyScale(); - var ticks = internal.tickValues ? internal.tickValues : internal.generateTicks(scale1), - tick = g.selectAll(".tick").data(ticks, scale1), - tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6), + var ticksValues = internal.tickValues ? internal.tickValues : internal.generateTicks(scale1), + ticks = g.selectAll(".tick").data(ticksValues, scale1), + tickEnter = ticks.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6), // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks. - tickExit = tick.exit().remove(), - tickUpdate = internal.transitionise(tick).style("opacity", 1), + tickExit = ticks.exit().remove(), + tickUpdate = ticks.merge(tickEnter), tickTransform, tickX, tickY; @@ -430,27 +428,24 @@ c3_axis_internal_fn.generateAxis = function () { internal.tickOffset = tickX = 0; } - tickEnter.append("line"); - tickEnter.append("text"); - internal.updateRange(); internal.updateTickLength(); internal.updateTickTextCharSize(g.select('.tick')); - var lineUpdate = tickUpdate.select("line"), - textUpdate = tickUpdate.select("text"), - tspanUpdate = tick.select("text").selectAll('tspan').data(function (d, i) { - return internal.tspanData(d, i, ticks, scale1); - }); + var lineUpdate = tickUpdate.select("line").merge(tickEnter.append("line")), + textUpdate = tickUpdate.select("text").merge(tickEnter.append("text")); - tspanUpdate.enter().append('tspan'); - tspanUpdate.exit().remove(); - tspanUpdate.text(function (d) { + var tspans = tickUpdate.selectAll('text').selectAll('tspan').data(function (d, i) { + return internal.tspanData(d, i, scale1); + }), + tspanEnter = tspans.enter().append('tspan'), + tspanUpdate = tspanEnter.merge(tspans).text(function (d) { return d.splitted; }); + tspans.exit().remove(); var path = g.selectAll(".domain").data([0]), - pathUpdate = (path.enter().append("path").attr("class", "domain"), internal.transitionise(path)); + pathUpdate = path.enter().append("path").merge(path).attr("class", "domain"); // TODO: each attr should be one function and change its behavior by internal.orient, probably switch (internal.orient) { @@ -520,8 +515,9 @@ c3_axis_internal_fn.generateAxis = function () { tickExit.call(tickTransform, scale1, internal.tickOffset); } tickEnter.call(tickTransform, scale0, internal.tickOffset); - tickUpdate.call(tickTransform, scale1, internal.tickOffset); + self = (transition ? tickUpdate.transition(transition) : tickUpdate).style('opacity', 1).call(tickTransform, scale1, internal.tickOffset); }); + return self; } axis.scale = function (x) { if (!arguments.length) { @@ -628,9 +624,9 @@ c3_axis_fn.init = function init() { $$.axes.y = main.append("g").attr("class", CLASS.axis + ' ' + CLASS.axisY).attr("clip-path", config.axis_y_inner ? "" : $$.clipPathForYAxis).attr("transform", $$.getTranslate('y')).style("visibility", config.axis_y_show ? 'visible' : 'hidden'); $$.axes.y.append("text").attr("class", CLASS.axisYLabel).attr("transform", config.axis_rotated ? "" : "rotate(-90)").style("text-anchor", this.textAnchorForYAxisLabel.bind(this)); - $$.axes.y2 = main.append("g").attr("class", CLASS.axis + ' ' + CLASS.axisY2 + $$.axes.y2 = main.append("g").attr("class", CLASS.axis + ' ' + CLASS.axisY2) // clip-path? - ).attr("transform", $$.getTranslate('y2')).style("visibility", config.axis_y2_show ? 'visible' : 'hidden'); + .attr("transform", $$.getTranslate('y2')).style("visibility", config.axis_y2_show ? 'visible' : 'hidden'); $$.axes.y2.append("text").attr("class", CLASS.axisY2Label).attr("transform", config.axis_rotated ? "" : "rotate(-90)").style("text-anchor", this.textAnchorForY2AxisLabel.bind(this)); }; c3_axis_fn.getXAxis = function getXAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { @@ -681,6 +677,7 @@ c3_axis_fn.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) c3_axis_fn.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { var $$ = this.owner, config = $$.config, + d3 = $$.d3, axisParams = { withOuterTick: withOuterTick, withoutTransition: withoutTransition, @@ -688,7 +685,7 @@ c3_axis_fn.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, w }, axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient).tickFormat(tickFormat); if ($$.isTimeSeriesY()) { - axis.ticks($$.d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval); + axis.ticks(config.axis_y_tick_time_type, config.axis_y_tick_time_interval); } else { axis.tickValues(tickValues); } @@ -989,16 +986,13 @@ c3_axis_fn.generateTransitions = function generateTransitions(duration) { axisSubX: duration ? axes.subx.transition().duration(duration) : axes.subx }; }; -c3_axis_fn.redraw = function redraw(transitions, isHidden) { - var $$ = this.owner; - $$.axes.x.style("opacity", isHidden ? 0 : 1); - $$.axes.y.style("opacity", isHidden ? 0 : 1); - $$.axes.y2.style("opacity", isHidden ? 0 : 1); - $$.axes.subx.style("opacity", isHidden ? 0 : 1); - transitions.axisX.call($$.xAxis); - transitions.axisY.call($$.yAxis); - transitions.axisY2.call($$.y2Axis); - transitions.axisSubX.call($$.subXAxis); +c3_axis_fn.redraw = function redraw(duration, isHidden) { + var $$ = this.owner, + transition = duration ? $$.d3.transition().duration(duration) : null; + $$.axes.x.style("opacity", isHidden ? 0 : 1).call($$.xAxis, transition); + $$.axes.y.style("opacity", isHidden ? 0 : 1).call($$.yAxis, transition); + $$.axes.y2.style("opacity", isHidden ? 0 : 1).call($$.y2Axis, transition); + $$.axes.subx.style("opacity", isHidden ? 0 : 1).call($$.subXAxis, transition); }; var c3$1 = { version: "0.4.18" }; @@ -1095,26 +1089,32 @@ c3_chart_internal_fn.initParams = function () { $$.color = $$.generateColor(); $$.levelColor = $$.generateLevelColor(); - $$.dataTimeFormat = config.data_xLocaltime ? d3.time.format : d3.time.format.utc; - $$.axisTimeFormat = config.axis_x_localtime ? d3.time.format : d3.time.format.utc; - $$.defaultAxisTimeFormat = $$.axisTimeFormat.multi([[".%L", function (d) { - return d.getMilliseconds(); - }], [":%S", function (d) { - return d.getSeconds(); - }], ["%I:%M", function (d) { - return d.getMinutes(); - }], ["%I %p", function (d) { - return d.getHours(); - }], ["%-m/%-d", function (d) { - return d.getDay() && d.getDate() !== 1; - }], ["%-m/%-d", function (d) { - return d.getDate() !== 1; - }], ["%-m/%-d", function (d) { - return d.getMonth(); - }], ["%Y/%-m/%-d", function () { - return true; - }]]); - + $$.dataTimeParse = (config.data_xLocaltime ? d3.timeParse : d3.utcParse)($$.config.data_xFormat); + $$.axisTimeFormat = config.axis_x_localtime ? d3.timeFormat : d3.utcFormat; + $$.defaultAxisTimeFormat = function (date) { + if (date.getMilliseconds()) { + return d3.timeFormat(".%L")(date); + } + if (date.getSeconds()) { + return d3.timeFormat(":%S")(date); + } + if (date.getMinutes()) { + return d3.timeFormat("%I:%M")(date); + } + if (date.getHours()) { + return d3.timeFormat("%I %p")(date); + } + if (date.getDay() && date.getDate() !== 1) { + return d3.timeFormat("%-m/%-d")(date); + } + if (date.getDate() !== 1) { + return d3.timeFormat("%-m/%-d")(date); + } + if (date.getMonth()) { + return d3.timeFormat("%-m/%-d")(date); + } + return d3.timeFormat("%Y/%-m/%-d")(date); + }; $$.hiddenTargetIds = []; $$.hiddenLegendIds = []; $$.focusedTargetIds = []; @@ -1178,16 +1178,6 @@ c3_chart_internal_fn.initWithData = function (data) { $$.axis = new Axis($$); - if ($$.initPie) { - $$.initPie(); - } - if ($$.initBrush) { - $$.initBrush(); - } - if ($$.initZoom) { - $$.initZoom(); - } - if (!config.bindto) { $$.selectChart = d3.selectAll([]); } else if (typeof config.bindto.node === 'function') { @@ -1238,14 +1228,6 @@ c3_chart_internal_fn.initWithData = function (data) { // Save original x domain for zoom update $$.orgXDomain = $$.x.domain(); - // Set initialized scales to brush and zoom - if ($$.brush) { - $$.brush.scale($$.subX); - } - if (config.zoom_enabled) { - $$.zoom.scale($$.x); - } - /*-- Basic Elements --*/ // Define svgs @@ -1271,6 +1253,9 @@ c3_chart_internal_fn.initWithData = function (data) { // Define regions main = $$.main = $$.svg.append("g").attr("transform", $$.getTranslate('main')); + if ($$.initPie) { + $$.initPie(); + } if ($$.initSubchart) { $$.initSubchart(); } @@ -1283,12 +1268,21 @@ c3_chart_internal_fn.initWithData = function (data) { if ($$.initTitle) { $$.initTitle(); } + if ($$.initZoom) { + $$.initZoom(); + } + + // Update selection based on size and scale + // TODO: currently this must be called after initLegend because of update of sizes, but it should be done in initSubchart. + if ($$.initSubchartBrush) { + $$.initSubchartBrush(); + } /*-- Main Region --*/ // text when empty - main.append("text").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. + main.append("text").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. // Regions $$.initRegion(); @@ -1304,27 +1298,23 @@ c3_chart_internal_fn.initWithData = function (data) { $$.initGridLines(); } - // Cover whole with rects for events - $$.initEventRect(); - // Define g for chart $$.initChartElements(); - // 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).attr('width', $$.width).attr('height', $$.height).style('opacity', 0).on("dblclick.zoom", null); - - // Set default extent if defined - if (config.axis_x_extent) { - $$.brush.extent($$.getDefaultExtent()); - } - // Add Axis $$.axis.init(); // Set targets $$.updateTargets($$.data.targets); + // Cover whole with rects for events + $$.initEventRect(); + + // Set default extent if defined + if (config.axis_x_selection) { + $$.brush.selectionAsValue($$.getDefaultSelection()); + } + // Draw with targets if (binding) { $$.updateDimension(); @@ -1494,7 +1484,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { var hideAxis = $$.hasArcType(); var drawArea, drawBar, drawLine, xForText, yForText; var duration, durationForExit, durationForAxis; - var waitForDraw, flow; + var transitionsToWait, waitForDraw, flow, transition; var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, @@ -1564,7 +1554,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { } // axes - $$.axis.redraw(transitions, hideAxis); + $$.axis.redraw(durationForAxis, hideAxis); // Update axis label $$.axis.updateLabels(withTransition); @@ -1596,6 +1586,12 @@ c3_chart_internal_fn.redraw = function (options, transitions) { xForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, true); yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false); + // update circleY based on updated parameters + $$.updateCircleY(); + // generate circle x/y functions depending on updated params + cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$); + cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); + // Update sub domain if (withY) { $$.subY.domain($$.getYDomain(targetsToShow, 'y')); @@ -1608,6 +1604,11 @@ c3_chart_internal_fn.redraw = function (options, transitions) { // Data empty label positioning and text. main.select("text." + CLASS.text + '.' + CLASS.empty).attr("x", $$.width / 2).attr("y", $$.height / 2).text(config.data_empty_label_text).transition().style('opacity', targetsToShow.length ? 0 : 1); + // event rect + if (withEventRect) { + $$.redrawEventRect(); + } + // grid $$.updateGrid(duration); @@ -1620,11 +1621,11 @@ c3_chart_internal_fn.redraw = function (options, transitions) { // lines, areas and cricles $$.updateLine(durationForExit); $$.updateArea(durationForExit); - $$.updateCircle(); + $$.updateCircle(cx, cy); // text if ($$.hasDataLabel()) { - $$.updateText(durationForExit); + $$.updateText(xForText, yForText, durationForExit); } // title @@ -1645,21 +1646,6 @@ c3_chart_internal_fn.redraw = function (options, transitions) { // circles for select main.selectAll('.' + CLASS.selectedCircles).filter($$.isBarType.bind($$)).selectAll('circle').remove(); - // event rects will redrawn when flow called - if (config.interaction_enabled && !options.flow && withEventRect) { - $$.redrawEventRect(); - if ($$.updateZoom) { - $$.updateZoom(); - } - } - - // update circleY based on updated parameters - $$.updateCircleY(); - - // generate circle x/y functions depending on updated params - cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$); - cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); - if (options.flow) { flow = $$.generateFlow({ targets: targetsToShow, @@ -1676,42 +1662,44 @@ c3_chart_internal_fn.redraw = function (options, transitions) { }); } - if ((duration || flow) && $$.isTabVisible()) { + if ($$.isTabVisible()) { // Only use transition if tab visible. See #938. - // transition should be derived from one transition - d3.transition().duration(duration).each(function () { - var transitionsToWait = []; - - // redraw and gather transitions - [$$.redrawBar(drawBar, true), $$.redrawLine(drawLine, true), $$.redrawArea(drawArea, true), $$.redrawCircle(cx, cy, true), $$.redrawText(xForText, yForText, options.flow, true), $$.redrawRegion(true), $$.redrawGrid(true)].forEach(function (transitions) { + if (duration) { + // transition should be derived from one transition + transition = d3.transition().duration(duration); + transitionsToWait = []; + [$$.redrawBar(drawBar, true, transition), $$.redrawLine(drawLine, true, transition), $$.redrawArea(drawArea, true, transition), $$.redrawCircle(cx, cy, true, transition), $$.redrawText(xForText, yForText, options.flow, true, transition), $$.redrawRegion(true, transition), $$.redrawGrid(true, transition)].forEach(function (transitions) { transitions.forEach(function (transition) { transitionsToWait.push(transition); }); }); - // Wait for end of transitions to call flow and onrendered callback waitForDraw = $$.generateWait(); transitionsToWait.forEach(function (t) { waitForDraw.add(t); }); - }).call(waitForDraw, function () { + waitForDraw(function () { + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + }); + } else { + $$.redrawBar(drawBar); + $$.redrawLine(drawLine); + $$.redrawArea(drawArea); + $$.redrawCircle(cx, cy); + $$.redrawText(xForText, yForText, options.flow); + $$.redrawRegion(); + $$.redrawGrid(); if (flow) { flow(); } if (config.onrendered) { config.onrendered.call($$); } - }); - } else { - $$.redrawBar(drawBar); - $$.redrawLine(drawLine); - $$.redrawArea(drawArea); - $$.redrawCircle(cx, cy); - $$.redrawText(xForText, yForText, options.flow); - $$.redrawRegion(); - $$.redrawGrid(); - if (config.onrendered) { - config.onrendered.call($$); } } @@ -1731,8 +1719,8 @@ c3_chart_internal_fn.updateAndRedraw = function (options) { options.withTransform = getOption(options, "withTransform", false); options.withLegend = getOption(options, "withLegend", false); // NOT same with redraw - options.withUpdateXDomain = true; - options.withUpdateOrgXDomain = true; + options.withUpdateXDomain = getOption(options, "withUpdateXDomain", true); + options.withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", true); options.withTransitionForExit = false; options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition); // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) @@ -1890,13 +1878,12 @@ c3_chart_internal_fn.transformAll = function (withTransition, transitions) { c3_chart_internal_fn.updateSvgSize = function () { var $$ = this, - brush = $$.svg.select(".c3-brush .background"); + brush = $$.svg.select(".c3-brush .overlay"); $$.svg.attr('width', $$.currentWidth).attr('height', $$.currentHeight); $$.svg.selectAll(['#' + $$.clipId, '#' + $$.clipIdForGrid]).select('rect').attr('width', $$.width).attr('height', $$.height); $$.svg.select('#' + $$.clipIdForXAxis).select('rect').attr('x', $$.getXAxisClipX.bind($$)).attr('y', $$.getXAxisClipY.bind($$)).attr('width', $$.getXAxisClipWidth.bind($$)).attr('height', $$.getXAxisClipHeight.bind($$)); $$.svg.select('#' + $$.clipIdForYAxis).select('rect').attr('x', $$.getYAxisClipX.bind($$)).attr('y', $$.getYAxisClipY.bind($$)).attr('width', $$.getYAxisClipWidth.bind($$)).attr('height', $$.getYAxisClipHeight.bind($$)); $$.svg.select('#' + $$.clipIdForSubchart).select('rect').attr('width', $$.width).attr('height', brush.size() ? brush.attr('height') : 0); - $$.svg.select('.' + CLASS.zoomRect).attr('width', $$.width).attr('height', $$.height); // MEMO: parent div's height will be bigger than svg when $$.selectChart.style('max-height', $$.currentHeight + "px"); }; @@ -1972,7 +1959,16 @@ c3_chart_internal_fn.bindResize = function () { } $$.resizeTimeout = window.setTimeout(function () { delete $$.resizeTimeout; - $$.api.flush(); + $$.updateAndRedraw({ + withUpdateXDomain: false, + withUpdateOrgXDomain: false, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + if ($$.brush) { + $$.brush.update(); + } }, 100); }); } @@ -1980,10 +1976,19 @@ c3_chart_internal_fn.bindResize = function () { config.onresized.call($$); }); + var resizeIfElementDisplayed = function resizeIfElementDisplayed() { + // if element not displayed skip it + if (!$$.api.element.offsetParent) { + return; + } + + $$.resizeFunction(); + }; + if (window.attachEvent) { - window.attachEvent('onresize', $$.resizeFunction); + window.attachEvent('onresize', resizeIfElementDisplayed); } else if (window.addEventListener) { - window.addEventListener('resize', $$.resizeFunction, false); + window.addEventListener('resize', resizeIfElementDisplayed, false); } else { // fallback to this, if this is a very old browser var wrapper = window.onresize; @@ -1997,7 +2002,14 @@ c3_chart_internal_fn.bindResize = function () { } // add this graph to the wrapper, we will be removed if the user calls destroy wrapper.add($$.resizeFunction); - window.onresize = wrapper; + window.onresize = function () { + // if element not displayed skip it + if (!$$.api.element.offsetParent) { + return; + } + + wrapper(); + }; } }; @@ -2026,7 +2038,7 @@ c3_chart_internal_fn.endall = function (transition, callback) { var n = 0; transition.each(function () { ++n; - }).each("end", function () { + }).on("end", function () { if (! --n) { callback.apply(this, arguments); } @@ -2034,7 +2046,7 @@ c3_chart_internal_fn.endall = function (transition, callback) { }; c3_chart_internal_fn.generateWait = function () { var transitionsToWait = [], - f = function f(transition, callback) { + f = function f(callback) { var timer = setInterval(function () { var done = 0; transitionsToWait.forEach(function (t) { @@ -2054,7 +2066,7 @@ c3_chart_internal_fn.generateWait = function () { callback(); } } - }, 10); + }, 50); }; f.add = function (transition) { transitionsToWait.push(transition); @@ -2068,7 +2080,7 @@ c3_chart_internal_fn.parseDate = function (date) { if (date instanceof Date) { parsedDate = date; } else if (typeof date === 'string') { - parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(date); + parsedDate = $$.dataTimeParse(date); } else if ((typeof date === 'undefined' ? 'undefined' : _typeof(date)) === 'object') { parsedDate = new Date(+date); } else if (typeof date === 'number' && !isNaN(date)) { @@ -2149,8 +2161,6 @@ if (!Function.prototype.bind) { // changes which were implemented in Firefox 43 and Chrome 46. (function () { - "use strict"; - if (!("SVGPathSeg" in window)) { // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg window.SVGPathSeg = function (type, typeAsLetter, owningPathSegList) { @@ -3718,14 +3728,7 @@ c3_chart_internal_fn.generateFlow = function (args) { done = flow.done || function () {}, wait = $$.generateWait(); - var xgrid = $$.xgrid || d3.selectAll([]), - xgridLines = $$.xgridLines || d3.selectAll([]), - mainRegion = $$.mainRegion || d3.selectAll([]), - mainText = $$.mainText || d3.selectAll([]), - mainBar = $$.mainBar || d3.selectAll([]), - mainLine = $$.mainLine || d3.selectAll([]), - mainArea = $$.mainArea || d3.selectAll([]), - mainCircle = $$.mainCircle || d3.selectAll([]); + var xgrid, xgridLines, mainRegion, mainText, mainBar, mainLine, mainArea, mainCircle; // set flag $$.flowing = true; @@ -3742,6 +3745,15 @@ c3_chart_internal_fn.generateFlow = function (args) { $$.updateXGrid(true); } + xgrid = $$.xgrid || d3.selectAll([]); // xgrid needs to be obtained after updateXGrid + xgridLines = $$.xgridLines || d3.selectAll([]); + mainRegion = $$.mainRegion || d3.selectAll([]); + mainText = $$.mainText || d3.selectAll([]); + mainBar = $$.mainBar || d3.selectAll([]); + mainLine = $$.mainLine || d3.selectAll([]); + mainArea = $$.mainArea || d3.selectAll([]); + mainCircle = $$.mainCircle || d3.selectAll([]); + // generate transform to flow if (!flow.orgDataCount) { // if empty @@ -3770,37 +3782,34 @@ c3_chart_internal_fn.generateFlow = function (args) { $$.hideXGridFocus(); - d3.transition().ease('linear').duration(durationForFlow).each(function () { - wait.add($$.axes.x.transition().call($$.xAxis)); - wait.add(mainBar.transition().attr('transform', transform)); - wait.add(mainLine.transition().attr('transform', transform)); - wait.add(mainArea.transition().attr('transform', transform)); - wait.add(mainCircle.transition().attr('transform', transform)); - wait.add(mainText.transition().attr('transform', transform)); - wait.add(mainRegion.filter($$.isRegionOnX).transition().attr('transform', transform)); - wait.add(xgrid.transition().attr('transform', transform)); - wait.add(xgridLines.transition().attr('transform', transform)); - }).call(wait, function () { + var flowTransition = d3.transition().ease(d3.easeLinear).duration(durationForFlow); + wait.add($$.xAxis($$.axes.x, flowTransition)); + wait.add(mainBar.transition(flowTransition).attr('transform', transform)); + wait.add(mainLine.transition(flowTransition).attr('transform', transform)); + wait.add(mainArea.transition(flowTransition).attr('transform', transform)); + wait.add(mainCircle.transition(flowTransition).attr('transform', transform)); + wait.add(mainText.transition(flowTransition).attr('transform', transform)); + wait.add(mainRegion.filter($$.isRegionOnX).transition(flowTransition).attr('transform', transform)); + wait.add(xgrid.transition(flowTransition).attr('transform', transform)); + wait.add(xgridLines.transition(flowTransition).attr('transform', transform)); + wait(function () { var i, shapes = [], - texts = [], - eventRects = []; + texts = []; // 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)); } $$.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 - xgrid.attr('transform', null).attr($$.xgridAttr); + xgrid.attr('transform', null).attr('x1', $$.xgridAttr.x1).attr('x2', $$.xgridAttr.x2).attr('y1', $$.xgridAttr.y1).attr('y2', $$.xgridAttr.y2).style("opacity", $$.xgridAttr.opacity); xgridLines.attr('transform', null); xgridLines.select('line').attr("x1", config.axis_rotated ? 0 : xv).attr("x2", config.axis_rotated ? $$.width : xv); xgridLines.select('text').attr("x", config.axis_rotated ? $$.width : 0).attr("y", xv); @@ -3810,11 +3819,7 @@ c3_chart_internal_fn.generateFlow = function (args) { mainCircle.attr('transform', null).attr("cx", cx).attr("cy", cy); mainText.attr('transform', null).attr('x', xForText).attr('y', yForText).style('fill-opacity', $$.opacityForText.bind($$)); mainRegion.attr('transform', null); - mainRegion.select('rect').filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$)); - - if (config.interaction_enabled) { - $$.redrawEventRect(); - } + mainRegion.filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$)); // callback for end of flow done(); @@ -4183,35 +4188,34 @@ c3_chart_fn.toggle = function (targetIds, options) { c3_chart_fn.tooltip = function () {}; c3_chart_fn.tooltip.show = function (args) { var $$ = this.internal, - index, - mouse; + targets, + data, + mouse = {}; // determine mouse position on the chart if (args.mouse) { mouse = args.mouse; - } - - // determine focus data - if (args.data) { - if ($$.isMultipleX()) { - // if multiple xs, target point will be determined by mouse - mouse = [$$.x(args.data.x), $$.getYScale(args.data.id)(args.data.value)]; - index = null; - } else { - // TODO: when tooltip_grouped = false - index = isValue(args.data.index) ? args.data.index : $$.getIndexByX(args.data.x); + } else { + // determine focus data + if (args.data) { + data = args.data; + } else if (typeof args.x !== 'undefined') { + if (args.id) { + targets = $$.data.targets.filter(function (t) { + return t.id === args.id; + }); + } else { + targets = $$.data.targets; + } + data = $$.filterByX(targets, args.x).slice(0, 1)[0]; } - } else if (typeof args.x !== 'undefined') { - index = $$.getIndexByX(args.x); - } else if (typeof args.index !== 'undefined') { - index = args.index; + mouse = data ? $$.getMousePosition(data) : null; } // emulate mouse events to show - $$.dispatchEvent('mouseover', index, mouse); - $$.dispatchEvent('mousemove', index, mouse); + $$.dispatchEvent('mousemove', mouse); - $$.config.tooltip_onshow.call($$, args.data); + $$.config.tooltip_onshow.call($$, data); }; c3_chart_fn.tooltip.hide = function () { // TODO: get target data by checking the state of focus @@ -4262,11 +4266,15 @@ c3_chart_fn.zoom = function (domain) { return $$.parseDate(x); }); } - $$.brush.extent(domain); - $$.redraw({ withUpdateXDomain: true, withY: $$.config.zoom_rescale }); + if ($$.config.subchart_show) { + $$.brush.selectionAsValue(domain); + } else { + $$.updateXDomain(null, true, false, false, domain); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); } - return $$.brush.extent(); + return domain; }; c3_chart_fn.zoom.enable = function (enabled) { var $$ = this.internal; @@ -4275,8 +4283,12 @@ c3_chart_fn.zoom.enable = function (enabled) { }; c3_chart_fn.unzoom = function () { var $$ = this.internal; - $$.brush.clear().update(); - $$.redraw({ withUpdateXDomain: true }); + if ($$.config.subchart_show) { + $$.brush.clear(); + } else { + $$.updateXDomain(null, true, false, false, $$.subX.domain()); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } }; c3_chart_fn.zoom.max = function (max) { @@ -4320,7 +4332,7 @@ c3_chart_fn.zoom.range = function (range) { c3_chart_internal_fn.initPie = function () { var $$ = this, d3 = $$.d3; - $$.pie = d3.layout.pie().value(function (d) { + $$.pie = d3.pie().value(function (d) { return d.values.reduce(function (a, b) { return a + b.value; }, 0); @@ -4386,7 +4398,7 @@ c3_chart_internal_fn.updateAngle = function (d) { c3_chart_internal_fn.getSvgArc = function () { var $$ = this, - arc = $$.d3.svg.arc().outerRadius($$.radius).innerRadius($$.innerRadius), + arc = $$.d3.arc().outerRadius($$.radius).innerRadius($$.innerRadius), newArc = function newArc(d, withoutUpdate) { var updated; if (withoutUpdate) { @@ -4402,7 +4414,7 @@ c3_chart_internal_fn.getSvgArc = function () { c3_chart_internal_fn.getSvgArcExpanded = function (rate) { var $$ = this, - arc = $$.d3.svg.arc().outerRadius($$.radiusExpanded * (rate ? rate : 1)).innerRadius($$.innerRadius); + arc = $$.d3.arc().outerRadius($$.radiusExpanded * (rate ? rate : 1)).innerRadius($$.innerRadius); return function (d) { var updated = $$.updateAngle(d); return updated ? arc(updated) : "M 0 0"; @@ -4597,15 +4609,15 @@ c3_chart_internal_fn.getArcTitle = function () { c3_chart_internal_fn.updateTargetsForArc = function (targets) { var $$ = this, main = $$.main, - mainPieUpdate, + mainPies, mainPieEnter, classChartArc = $$.classChartArc.bind($$), classArcs = $$.classArcs.bind($$), classFocus = $$.classFocus.bind($$); - mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc).data($$.pie(targets)).attr("class", function (d) { + mainPies = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc).data($$.pie(targets)).attr("class", function (d) { return classChartArc(d) + classFocus(d.data); }); - mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc); + mainPieEnter = mainPies.enter().append("g").attr("class", classChartArc); mainPieEnter.append('g').attr('class', classArcs); mainPieEnter.append("text").attr("dy", $$.hasType('gauge') ? "-.1em" : ".35em").style("opacity", 0).style("text-anchor", "middle").style("pointer-events", "none"); // MEMO: can not keep same color..., but not bad to update color in redraw @@ -4623,9 +4635,10 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf d3 = $$.d3, config = $$.config, main = $$.main, + arcs, mainArc; - mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc).data($$.arcData.bind($$)); - mainArc.enter().append('path').attr("class", $$.classArc.bind($$)).style("fill", function (d) { + arcs = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc).data($$.arcData.bind($$)); + mainArc = arcs.enter().append('path').attr("class", $$.classArc.bind($$)).style("fill", function (d) { return $$.color(d.data); }).style("cursor", function (d) { return config.interaction_enabled && config.data_selection_isselectable(d) ? "pointer" : null; @@ -4634,7 +4647,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf d.startAngle = d.endAngle = config.gauge_startingAngle; } this._current = d; - }); + }).merge(arcs); mainArc.attr("transform", function (d) { return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : ""; }).on('mouseover', config.interaction_enabled ? function (d) { @@ -4717,11 +4730,11 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf }; }).attr("transform", withTransform ? "scale(1)" : "").style("fill", function (d) { return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data.id); - } // Where gauge reading color would receive customization. - ).call($$.endall, function () { + }) // Where gauge reading color would receive customization. + .call($$.endall, function () { $$.transiting = false; }); - mainArc.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + arcs.exit().transition().duration(durationForExit).style('opacity', 0).remove(); main.selectAll('.' + CLASS.chartArc).select('text').style("opacity", 0).attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS.gaugeValue : ''; }).text($$.textForArcLabel.bind($$)).attr("transform", $$.transformForArcLabel.bind($$)).style('font-size', function (d) { @@ -4953,7 +4966,7 @@ c3_chart_internal_fn.generateColor = function () { config = $$.config, d3 = $$.d3, colors = config.data_colors, - pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(), + pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.schemeCategory10, callback = config.data_color, ids = []; @@ -5015,7 +5028,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { padding_bottom: undefined, resize_auto: true, zoom_enabled: false, - zoom_extent: undefined, + zoom_initialRange: undefined, zoom_privileged: false, zoom_rescale: false, zoom_onzoom: function zoom_onzoom() {}, @@ -5118,7 +5131,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { axis_x_min: undefined, axis_x_padding: {}, axis_x_height: undefined, - axis_x_extent: undefined, + axis_x_selection: undefined, axis_x_label: {}, axis_y_show: true, axis_y_type: undefined, @@ -5133,7 +5146,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { axis_y_tick_values: null, axis_y_tick_rotate: 0, axis_y_tick_count: undefined, - axis_y_tick_time_value: undefined, + axis_y_tick_time_type: undefined, axis_y_tick_time_interval: undefined, axis_y_padding: {}, axis_y_default: undefined, @@ -5278,7 +5291,7 @@ c3_chart_internal_fn.loadConfig = function (config) { c3_chart_internal_fn.convertUrlToData = function (url, mimeType, headers, keys, done) { var $$ = this, type = mimeType ? mimeType : 'csv'; - var req = $$.d3.xhr(url); + var req = $$.d3.request(url); if (headers) { Object.keys(headers).forEach(function (header) { req.header(header, headers[header]); @@ -5301,7 +5314,7 @@ c3_chart_internal_fn.convertUrlToData = function (url, mimeType, headers, keys, }); }; c3_chart_internal_fn.convertXsvToData = function (xsv, parser) { - var rows = parser.parseRows(xsv), + var rows = parser(xsv), d; if (rows.length === 1) { d = [{}]; @@ -5309,15 +5322,15 @@ c3_chart_internal_fn.convertXsvToData = function (xsv, parser) { d[0][id] = null; }); } else { - d = parser.parse(xsv); + d = parser(xsv); } return d; }; c3_chart_internal_fn.convertCsvToData = function (csv) { - return this.convertXsvToData(csv, this.d3.csv); + return this.convertXsvToData(csv, this.d3.csvParse); }; c3_chart_internal_fn.convertTsvToData = function (tsv) { - return this.convertXsvToData(tsv, this.d3.tsv); + return this.convertXsvToData(tsv, this.d3.tsvParse); }; c3_chart_internal_fn.convertJsonToData = function (json, keys) { var $$ = this, @@ -5558,11 +5571,6 @@ c3_chart_internal_fn.getXValuesOfXKey = function (key, targets) { }); return xValues; }; -c3_chart_internal_fn.getIndexByX = function (x) { - var $$ = this, - data = $$.filterByX($$.data.targets, x); - return data.length ? data[0].index : null; -}; c3_chart_internal_fn.getXValue = function (id, i) { var $$ = this; return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i; @@ -5582,14 +5590,6 @@ c3_chart_internal_fn.addXs = function (xs) { $$.config.data_xs[id] = xs[id]; }); }; -c3_chart_internal_fn.hasMultipleX = function (xs) { - return this.d3.set(Object.keys(xs).map(function (id) { - return xs[id]; - })).size() > 1; -}; -c3_chart_internal_fn.isMultipleX = function () { - return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType('scatter'); -}; c3_chart_internal_fn.addName = function (data) { var $$ = this, name; @@ -5643,53 +5643,12 @@ c3_chart_internal_fn.cloneTarget = function (target) { }) }; }; -c3_chart_internal_fn.updateXs = function () { - var $$ = this; - if ($$.data.targets.length) { - $$.xs = []; - $$.data.targets[0].values.forEach(function (v) { - $$.xs[v.index] = v.x; - }); - } -}; -c3_chart_internal_fn.getPrevX = function (i) { - var x = this.xs[i - 1]; - return typeof x !== 'undefined' ? x : null; -}; -c3_chart_internal_fn.getNextX = function (i) { - var x = this.xs[i + 1]; - return typeof x !== 'undefined' ? x : null; -}; c3_chart_internal_fn.getMaxDataCount = function () { var $$ = this; return $$.d3.max($$.data.targets, function (t) { return t.values.length; }); }; -c3_chart_internal_fn.getMaxDataCountTarget = function (targets) { - var length = targets.length, - max = 0, - maxTarget; - if (length > 1) { - targets.forEach(function (t) { - if (t.values.length > max) { - maxTarget = t; - max = t.values.length; - } - }); - } else { - maxTarget = length ? targets[0] : null; - } - return maxTarget; -}; -c3_chart_internal_fn.getEdgeX = function (targets) { - var $$ = this; - return !targets.length ? [0, 0] : [$$.d3.min(targets, function (t) { - return t.values[0].x; - }), $$.d3.max(targets, function (t) { - return t.values[t.values.length - 1].x; - })]; -}; c3_chart_internal_fn.mapToIds = function (targets) { return targets.map(function (d) { return d.id; @@ -5887,25 +5846,6 @@ c3_chart_internal_fn.isNoneArc = function (d) { }, c3_chart_internal_fn.isArc = function (d) { return 'data' in d && this.hasTarget(this.data.targets, d.data.id); }; -c3_chart_internal_fn.findSameXOfValues = function (values, index) { - var i, - targetX = values[index].x, - sames = []; - for (i = index - 1; i >= 0; i--) { - if (targetX !== values[i].x) { - break; - } - sames.push(values[i]); - } - for (i = index; i < values.length; i++) { - if (targetX !== values[i].x) { - break; - } - sames.push(values[i]); - } - return sames; -}; - c3_chart_internal_fn.findClosestFromTargets = function (targets, pos) { var $$ = this, candidates; @@ -5928,7 +5868,7 @@ c3_chart_internal_fn.findClosest = function (values, pos) { return v && $$.isBarType(v.id); }).forEach(function (v) { var shape = $$.main.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node(); - if (!closest && $$.isWithinBar(shape)) { + if (!closest && $$.isWithinBar($$.d3.mouse(shape), shape)) { closest = v; } }); @@ -6355,18 +6295,15 @@ c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withU $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); $$.orgXDomain = $$.x.domain(); if (config.zoom_enabled) { - $$.zoom.scale($$.x).updateScaleExtent(); + $$.zoom.update(); } $$.subX.domain($$.x.domain()); if ($$.brush) { - $$.brush.scale($$.subX); + $$.brush.updateScale($$.subX); } } if (withUpdateXDomain) { - $$.x.domain(domain ? domain : !$$.brush || $$.brush.empty() ? $$.orgXDomain : $$.brush.extent()); - if (config.zoom_enabled) { - $$.zoom.scale($$.x).updateScaleExtent(); - } + $$.x.domain(domain ? domain : !$$.brush || $$.brush.empty() ? $$.orgXDomain : $$.brush.selectionAsValue()); } // Trim domain when too big by zoom mousemove event @@ -6404,9 +6341,6 @@ c3_chart_internal_fn.drag = function (mouse) { if (!config.data_selection_enabled) { return; } // do nothing if not selectable - if (config.zoom_enabled && !$$.zoom.altDomain) { - return; - } // skip if zoomable because of conflict drag dehavior if (!config.data_selection_multiple) { return; } // skip when single selection because drag is used for multiple selection @@ -6593,25 +6527,31 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { 'y1': 0, 'y2': $$.height }; + $$.xgridAttr.opacity = function () { + var pos = +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1'); + return pos === (config.axis_rotated ? $$.height : 0) ? 0 : 1; + }; - $$.xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid).data(xgridData); - $$.xgrid.enter().append('line').attr("class", CLASS.xgrid); + var xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid).data(xgridData); + var xgridEnter = xgrid.enter().append('line').attr("class", CLASS.xgrid).attr('x1', $$.xgridAttr.x1).attr('x2', $$.xgridAttr.x2).attr('y1', $$.xgridAttr.y1).attr('y2', $$.xgridAttr.y2).style("opacity", 0); + $$.xgrid = xgridEnter.merge(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; - }); + $$.xgrid.attr('x1', $$.xgridAttr.x1).attr('x2', $$.xgridAttr.x2).attr('y1', $$.xgridAttr.y1).attr('y2', $$.xgridAttr.y2).style("opacity", $$.xgridAttr.opacity); } - $$.xgrid.exit().remove(); + xgrid.exit().remove(); }; c3_chart_internal_fn.updateYGrid = function () { var $$ = this, config = $$.config, gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); - $$.ygrid = $$.main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid).data(gridValues); - $$.ygrid.enter().append('line').attr('class', CLASS.ygrid); + var ygrid = $$.main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid).data(gridValues); + var ygridEnter = ygrid.enter().append('line') + // TODO: x1, x2, y1, y2, opacity need to be set here maybe + .attr('class', CLASS.ygrid); + $$.ygrid = ygridEnter.merge(ygrid); $$.ygrid.attr("x1", config.axis_rotated ? $$.y : 0).attr("x2", config.axis_rotated ? $$.y : $$.width).attr("y1", config.axis_rotated ? 0 : $$.y).attr("y2", config.axis_rotated ? $$.height : $$.y); - $$.ygrid.exit().remove(); + ygrid.exit().remove(); $$.smoothLines($$.ygrid, 'grid'); }; @@ -6632,8 +6572,13 @@ c3_chart_internal_fn.updateGrid = function (duration) { main = $$.main, config = $$.config, xgridLine, + xgridLineEnter, ygridLine, - yv; + ygridLineEnter, + xv = $$.xv.bind($$), + yv = $$.yv.bind($$), + xGridTextX = $$.xGridTextX.bind($$), + yGridTextX = $$.yGridTextX.bind($$); // hide if arc type $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); @@ -6642,45 +6587,46 @@ c3_chart_internal_fn.updateGrid = function (duration) { if (config.grid_x_show) { $$.updateXGrid(); } - $$.xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine).data(config.grid_x_lines); + xgridLine = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine).data(config.grid_x_lines); // enter - xgridLine = $$.xgridLines.enter().append('g').attr("class", function (d) { + xgridLineEnter = xgridLine.enter().append('g').attr("class", function (d) { return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : ''); }); - xgridLine.append('line').style("opacity", 0); - xgridLine.append('text').attr("text-anchor", $$.gridTextAnchor).attr("transform", config.axis_rotated ? "" : "rotate(-90)").attr('dx', $$.gridTextDx).attr('dy', -5).style("opacity", 0); + xgridLineEnter.append('line').attr("x1", config.axis_rotated ? 0 : xv).attr("x2", config.axis_rotated ? $$.width : xv).attr("y1", config.axis_rotated ? xv : 0).attr("y2", config.axis_rotated ? xv : $$.height).style("opacity", 0); + xgridLineEnter.append('text').attr("text-anchor", $$.gridTextAnchor).attr("transform", config.axis_rotated ? "" : "rotate(-90)").attr("x", config.axis_rotated ? yGridTextX : xGridTextX).attr("y", xv).attr('dx', $$.gridTextDx).attr('dy', -5).style("opacity", 0); // udpate + $$.xgridLines = xgridLineEnter.merge(xgridLine); // done in d3.transition() of the end of this function // exit - $$.xgridLines.exit().transition().duration(duration).style("opacity", 0).remove(); + xgridLine.exit().transition().duration(duration).style("opacity", 0).remove(); // Y-Grid if (config.grid_y_show) { $$.updateYGrid(); } - $$.ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine).data(config.grid_y_lines); + ygridLine = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine).data(config.grid_y_lines); // enter - ygridLine = $$.ygridLines.enter().append('g').attr("class", function (d) { + ygridLineEnter = ygridLine.enter().append('g').attr("class", function (d) { return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : ''); }); - ygridLine.append('line').style("opacity", 0); - ygridLine.append('text').attr("text-anchor", $$.gridTextAnchor).attr("transform", config.axis_rotated ? "rotate(-90)" : "").attr('dx', $$.gridTextDx).attr('dy', -5).style("opacity", 0); + ygridLineEnter.append('line').attr("x1", config.axis_rotated ? yv : 0).attr("x2", config.axis_rotated ? yv : $$.width).attr("y1", config.axis_rotated ? 0 : yv).attr("y2", config.axis_rotated ? $$.height : yv).style("opacity", 0); + ygridLineEnter.append('text').attr("text-anchor", $$.gridTextAnchor).attr("transform", config.axis_rotated ? "rotate(-90)" : "").attr("x", config.axis_rotated ? xGridTextX : yGridTextX).attr("y", yv).attr('dx', $$.gridTextDx).attr('dy', -5).style("opacity", 0); // update - yv = $$.yv.bind($$); + $$.ygridLines = ygridLineEnter.merge(ygridLine); $$.ygridLines.select('line').transition().duration(duration).attr("x1", config.axis_rotated ? yv : 0).attr("x2", config.axis_rotated ? yv : $$.width).attr("y1", config.axis_rotated ? 0 : yv).attr("y2", config.axis_rotated ? $$.height : yv).style("opacity", 1); $$.ygridLines.select('text').transition().duration(duration).attr("x", config.axis_rotated ? $$.xGridTextX.bind($$) : $$.yGridTextX.bind($$)).attr("y", yv).text(function (d) { return d.text; }).style("opacity", 1); // exit - $$.ygridLines.exit().transition().duration(duration).style("opacity", 0).remove(); + ygridLine.exit().transition().duration(duration).style("opacity", 0).remove(); }; -c3_chart_internal_fn.redrawGrid = function (withTransition) { +c3_chart_internal_fn.redrawGrid = function (withTransition, transition) { var $$ = this, config = $$.config, xv = $$.xv.bind($$), lines = $$.xgridLines.select('line'), texts = $$.xgridLines.select('text'); - return [(withTransition ? lines.transition() : lines).attr("x1", config.axis_rotated ? 0 : xv).attr("x2", config.axis_rotated ? $$.width : xv).attr("y1", config.axis_rotated ? xv : 0).attr("y2", config.axis_rotated ? xv : $$.height).style("opacity", 1), (withTransition ? texts.transition() : texts).attr("x", config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$)).attr("y", xv).text(function (d) { + return [(withTransition ? lines.transition(transition) : lines).attr("x1", config.axis_rotated ? 0 : xv).attr("x2", config.axis_rotated ? $$.width : xv).attr("y1", config.axis_rotated ? xv : 0).attr("y2", config.axis_rotated ? xv : $$.height).style("opacity", 1), (withTransition ? texts.transition(transition) : texts).attr("x", config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$)).attr("y", xv).text(function (d) { return d.text; }).style("opacity", 1)]; }; @@ -6767,253 +6713,35 @@ c3_chart_internal_fn.removeGridLines = function (params, forX) { }; c3_chart_internal_fn.initEventRect = function () { - 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, - eventRectUpdate, - maxDataCountTarget, - isMultipleX = $$.isMultipleX(); - - // rects for mouseover - 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); - - // clear old rects - eventRects.selectAll('.' + CLASS.eventRect).remove(); + config = $$.config; - // open as public variable - $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); + $$.main.select('.' + CLASS.chart).append("g").attr("class", CLASS.eventRects).style('fill-opacity', 0); + $$.eventRect = $$.main.select('.' + CLASS.eventRects).append('rect').attr('class', CLASS.eventRect); - if (isMultipleX) { - eventRectUpdate = $$.eventRect.data([0]); - // enter : only one rect will be added - $$.generateEventRectsForMultipleXs(eventRectUpdate.enter()); - // update - $$.updateEventRect(eventRectUpdate); - // exit : not needed because always only one rect exists - } else { - // Set data and update $$.eventRect - maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets); - eventRects.datum(maxDataCountTarget ? maxDataCountTarget.values : []); - $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); - eventRectUpdate = $$.eventRect.data(function (d) { - return d; - }); - // enter - $$.generateEventRectsForSingleX(eventRectUpdate.enter()); - // update - $$.updateEventRect(eventRectUpdate); - // exit - eventRectUpdate.exit().remove(); + // event rect handle zoom event as well + if (config.zoom_enabled && $$.zoom) { + $$.eventRect.call($$.zoom).on("dblclick.zoom", null); + if (config.zoom_initialRange) { + // WORKAROUND: Add transition to apply transform immediately when no subchart + $$.eventRect.transition().duration(0).call($$.zoom.transform, $$.zoomTransform(config.zoom_initialRange)); + } } }; -c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) { +c3_chart_internal_fn.redrawEventRect = function () { var $$ = this, + d3 = $$.d3, config = $$.config, x, y, w, - h, - rectW, - rectX; - - // set update selection if null - eventRectUpdate = eventRectUpdate || $$.eventRect.data(function (d) { - return d; - }); - - if ($$.isMultipleX()) { - // TODO: rotated not supported yet - x = 0; - y = 0; - w = $$.width; - h = $$.height; - } else { - if (($$.isCustomX() || $$.isTimeSeries()) && !$$.isCategorized()) { - - // update index for x that is used by prevX and nextX - $$.updateXs(); - - rectW = function rectW(d) { - var prevX = $$.getPrevX(d.index), - nextX = $$.getNextX(d.index); - - // if there this is a single data point make the eventRect full width (or height) - if (prevX === null && nextX === null) { - return config.axis_rotated ? $$.height : $$.width; - } - - if (prevX === null) { - prevX = $$.x.domain()[0]; - } - if (nextX === null) { - nextX = $$.x.domain()[1]; - } - - return Math.max(0, ($$.x(nextX) - $$.x(prevX)) / 2); - }; - rectX = function rectX(d) { - var prevX = $$.getPrevX(d.index), - nextX = $$.getNextX(d.index), - thisX = $$.data.xs[d.id][d.index]; - - // if there this is a single data point position the eventRect at 0 - if (prevX === null && nextX === null) { - return 0; - } - - if (prevX === null) { - prevX = $$.x.domain()[0]; - } - - return ($$.x(thisX) + $$.x(prevX)) / 2; - }; - } else { - rectW = $$.getEventRectWidth(); - rectX = function rectX(d) { - return $$.x(d.x) - rectW / 2; - }; - } - x = config.axis_rotated ? 0 : rectX; - y = config.axis_rotated ? rectX : 0; - w = config.axis_rotated ? $$.width : rectW; - h = config.axis_rotated ? rectW : $$.height; - } - - eventRectUpdate.attr('class', $$.classEvent.bind($$)).attr("x", x).attr("y", y).attr("width", w).attr("height", h); -}; -c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { - var $$ = this, - d3 = $$.d3, - config = $$.config; - eventRectEnter.append("rect").attr("class", $$.classEvent.bind($$)).style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null).on('mouseover', function (d) { - var index = d.index; - - if ($$.dragging || $$.flowing) { - return; - } // do nothing while dragging/flowing - if ($$.hasArcType()) { - return; - } - - // Expand shapes for selection - if (config.point_focus_expand_enabled) { - $$.expandCircles(index, null, true); - } - $$.expandBars(index, null, true); - - // Call event handler - $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { - config.data_onmouseover.call($$.api, d); - }); - }).on('mouseout', function (d) { - var index = d.index; - if (!$$.config) { - return; - } // chart is destroyed - if ($$.hasArcType()) { - return; - } - $$.hideXGridFocus(); - $$.hideTooltip(); - // Undo expanded shapes - $$.unexpandCircles(); - $$.unexpandBars(); - // Call event handler - $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { - config.data_onmouseout.call($$.api, d); - }); - }).on('mousemove', function (d) { - var selectedData, - index = d.index, - eventRect = $$.svg.select('.' + CLASS.eventRect + '-' + index); - - if ($$.dragging || $$.flowing) { - return; - } // do nothing while dragging/flowing - if ($$.hasArcType()) { - return; - } - - if ($$.isStepType(d) && $$.config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { - index -= 1; - } - - // Show tooltip - selectedData = $$.filterTargetsToShow($$.data.targets).map(function (t) { - return $$.addName($$.getValueOnIndex(t.values, index)); - }); - - if (config.tooltip_grouped) { - $$.showTooltip(selectedData, this); - $$.showXGridFocus(selectedData); - } - - if (config.tooltip_grouped && (!config.data_selection_enabled || config.data_selection_grouped)) { - return; - } - - $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function () { - d3.select(this).classed(CLASS.EXPANDED, true); - if (config.data_selection_enabled) { - eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); - } - if (!config.tooltip_grouped) { - $$.hideXGridFocus(); - $$.hideTooltip(); - if (!config.data_selection_grouped) { - $$.unexpandCircles(index); - $$.unexpandBars(index); - } - } - }).filter(function (d) { - return $$.isWithinShape(this, d); - }).each(function (d) { - if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) { - eventRect.style('cursor', 'pointer'); - } - if (!config.tooltip_grouped) { - $$.showTooltip([d], this); - $$.showXGridFocus([d]); - if (config.point_focus_expand_enabled) { - $$.expandCircles(index, d.id, true); - } - $$.expandBars(index, d.id, true); - } - }); - }).on('click', function (d) { - var index = d.index; - if ($$.hasArcType() || !$$.toggleShape) { - return; - } - if ($$.cancelClick) { - $$.cancelClick = false; - return; - } - if ($$.isStepType(d) && config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { - index -= 1; - } - $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { - if (config.data_selection_grouped || $$.isWithinShape(this, d)) { - $$.toggleShape(this, d, index); - $$.config.data_onclick.call($$.api, d, this); - } - }); - }).call(config.data_selection_draggable && $$.drag ? d3.behavior.drag().origin(Object).on('drag', function () { - $$.drag(d3.mouse(this)); - }).on('dragstart', function () { - $$.dragstart(d3.mouse(this)); - }).on('dragend', function () { - $$.dragend(); - }) : function () {}); -}; + h; -c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) { - var $$ = this, - d3 = $$.d3, - config = $$.config; + // TODO: rotated not supported yet + x = 0; + y = 0; + w = $$.width; + h = $$.height; function mouseout() { $$.svg.select('.' + CLASS.eventRect).style('cursor', null); @@ -7023,17 +6751,19 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) $$.unexpandBars(); } - eventRectEnter.append('rect').attr('x', 0).attr('y', 0).attr('width', $$.width).attr('height', $$.height).attr('class', CLASS.eventRect).on('mouseout', function () { - if (!$$.config) { + // rects for mouseover + $$.main.select('.' + CLASS.eventRects).style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null); + + $$.eventRect.attr('x', x).attr('y', y).attr('width', w).attr('height', h).on('mouseout', config.interaction_enabled ? function () { + if (!config) { return; } // chart is destroyed if ($$.hasArcType()) { return; } mouseout(); - }).on('mousemove', function () { - var targetsToShow = $$.filterTargetsToShow($$.data.targets); - var mouse, closest, sameXData, selectedData; + } : null).on('mousemove', config.interaction_enabled ? function () { + var targetsToShow, mouse, closest, sameXData, selectedData; if ($$.dragging) { return; @@ -7042,6 +6772,7 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) return; } + targetsToShow = $$.filterTargetsToShow($$.data.targets); mouse = d3.mouse(this); closest = $$.findClosestFromTargets(targetsToShow, mouse); @@ -7069,7 +6800,10 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) // expand points if (config.point_focus_expand_enabled) { - $$.expandCircles(closest.index, closest.id, true); + $$.unexpandCircles(); + selectedData.forEach(function (d) { + $$.expandCircles(d.index, d.id, false); + }); } $$.expandBars(closest.index, closest.id, true); @@ -7084,13 +6818,13 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) $$.mouseover = closest; } } - }).on('click', function () { - var targetsToShow = $$.filterTargetsToShow($$.data.targets); - var mouse, closest; + } : null).on('click', config.interaction_enabled ? function () { + var targetsToShow, mouse, closest, sameXData; if ($$.hasArcType(targetsToShow)) { return; } + targetsToShow = $$.filterTargetsToShow($$.data.targets); mouse = d3.mouse(this); closest = $$.findClosestFromTargets(targetsToShow, mouse); if (!closest) { @@ -7098,24 +6832,35 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) } // select if selection enabled if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) { - $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll('.' + CLASS.shape + '-' + closest.index).each(function () { - if (config.data_selection_grouped || $$.isWithinShape(this, closest)) { - $$.toggleShape(this, closest, closest.index); - $$.config.data_onclick.call($$.api, closest, this); - } + if ($$.isScatterType(closest) || !config.data_selection_grouped) { + sameXData = [closest]; + } else { + sameXData = $$.filterByX(targetsToShow, closest.x); + } + sameXData.forEach(function (d) { + $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.shape + '-' + d.index).each(function () { + if (config.data_selection_grouped || $$.isWithinShape(this, d)) { + $$.toggleShape(this, d, d.index); + config.data_onclick.call($$.api, d, this); + } + }); }); } - }).call(config.data_selection_draggable && $$.drag ? d3.behavior.drag().origin(Object).on('drag', function () { + } : null).call(config.interaction_enabled && config.data_selection_draggable && $$.drag ? d3.drag().on('drag', function () { $$.drag(d3.mouse(this)); - }).on('dragstart', function () { + }).on('start', function () { $$.dragstart(d3.mouse(this)); - }).on('dragend', function () { + }).on('end', function () { $$.dragend(); }) : function () {}); }; -c3_chart_internal_fn.dispatchEvent = function (type, index, mouse) { +c3_chart_internal_fn.getMousePosition = function (data) { + var $$ = this; + return [$$.x(data.x), $$.getYScale(data.id)(data.value)]; +}; +c3_chart_internal_fn.dispatchEvent = function (type, mouse) { var $$ = this, - selector = '.' + CLASS.eventRect + (!$$.isMultipleX() ? '-' + index : ''), + selector = '.' + CLASS.eventRect, eventRect = $$.main.select(selector).node(), box = eventRect.getBoundingClientRect(), x = box.left + (mouse ? mouse[0] : 0), @@ -7447,8 +7192,8 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { texts = $$.legend.selectAll('text').data(targetIds).text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; - } // MEMO: needed for update - ).each(function (id, i) { + }) // MEMO: needed for update + .each(function (id, i) { updatePositions(this, id, i); }); (withTransition ? texts.transition() : texts).attr('x', xForLegendText).attr('y', yForLegendText); @@ -7496,25 +7241,15 @@ c3_chart_internal_fn.updateRegion = function (duration) { // hide if arc type $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); - $$.mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region).data(config.regions); - $$.mainRegion.enter().append('g').append('rect').style("fill-opacity", 0); - $$.mainRegion.attr('class', $$.classRegion.bind($$)); - $$.mainRegion.exit().transition().duration(duration).style("opacity", 0).remove(); + var mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region).data(config.regions); + var mainRegionEnter = mainRegion.enter().append('rect').attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$)).style("fill-opacity", 0); + $$.mainRegion = mainRegionEnter.merge(mainRegion).attr('class', $$.classRegion.bind($$)); + mainRegion.exit().transition().duration(duration).style("opacity", 0).remove(); }; -c3_chart_internal_fn.redrawRegion = function (withTransition) { +c3_chart_internal_fn.redrawRegion = function (withTransition, transition) { var $$ = this, - regions = $$.mainRegion.selectAll('rect').each(function () { - // data is binded to g and it's not transferred to rect (child node) automatically, - // then data of each rect has to be updated manually. - // TODO: there should be more efficient way to solve this? - var parentData = $$.d3.select(this.parentNode).datum(); - $$.d3.select(this).datum(parentData); - }), - x = $$.regionX.bind($$), - y = $$.regionY.bind($$), - w = $$.regionWidth.bind($$), - h = $$.regionHeight.bind($$); - return [(withTransition ? regions.transition() : regions).attr("x", x).attr("y", y).attr("width", w).attr("height", h).style("fill-opacity", function (d) { + regions = $$.mainRegion; + return [(withTransition ? regions.transition(transition) : regions).attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$)).style("fill-opacity", function (d) { return isValue(d.opacity) ? d.opacity : 0.1; })]; }; @@ -7573,7 +7308,7 @@ c3_chart_internal_fn.isRegionOnX = function (d) { }; c3_chart_internal_fn.getScale = function (min, max, forTimeseries) { - return (forTimeseries ? this.d3.time.scale() : this.d3.scale.linear()).range([min, max]); + return (forTimeseries ? this.d3.scaleTime() : this.d3.scaleLinear()).range([min, max]); }; c3_chart_internal_fn.getX = function (min, max, domain, offset) { var $$ = this, @@ -7666,10 +7401,7 @@ c3_chart_internal_fn.updateScales = function () { // Set initialized scales to brush and zoom if (!forInit) { if ($$.brush) { - $$.brush.scale($$.subX); - } - if (config.zoom_enabled) { - $$.zoom.scale($$.x); + $$.brush.updateScale($$.subX); } } // update for arc @@ -7768,15 +7500,15 @@ c3_chart_internal_fn.initBar = function () { c3_chart_internal_fn.updateTargetsForBar = function (targets) { var $$ = this, config = $$.config, - mainBarUpdate, + mainBars, mainBarEnter, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classFocus = $$.classFocus.bind($$); - mainBarUpdate = $$.main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar).data(targets).attr('class', function (d) { + mainBars = $$.main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar).data(targets).attr('class', function (d) { return classChartBar(d) + classFocus(d); }); - mainBarEnter = mainBarUpdate.enter().append('g').attr('class', classChartBar).style("pointer-events", "none"); + mainBarEnter = mainBars.enter().append('g').attr('class', classChartBar).style("pointer-events", "none"); // Bars for each data mainBarEnter.append('g').attr("class", classBars).style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; @@ -7790,13 +7522,13 @@ c3_chart_internal_fn.updateBar = function (durationForExit) { color = function color(d) { return $$.color(d.id); }; - $$.mainBar = $$.main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar).data(barData); - $$.mainBar.enter().append('path').attr("class", classBar).style("stroke", color).style("fill", color); - $$.mainBar.style("opacity", initialOpacity); - $$.mainBar.exit().transition().duration(durationForExit).remove(); + var mainBar = $$.main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar).data(barData); + var mainBarEnter = mainBar.enter().append('path').attr("class", classBar).style("stroke", color).style("fill", color); + $$.mainBar = mainBarEnter.merge(mainBar).style("opacity", initialOpacity); + mainBar.exit().transition().duration(durationForExit).style("opacity", 0); }; -c3_chart_internal_fn.redrawBar = function (drawBar, withTransition) { - return [(withTransition ? this.mainBar.transition(Math.random().toString()) : this.mainBar).attr('d', drawBar).style("stroke", this.color).style("fill", this.color).style("opacity", 1)]; +c3_chart_internal_fn.redrawBar = function (drawBar, withTransition, transition) { + return [(withTransition ? this.mainBar.transition(transition) : this.mainBar).attr('d', drawBar).style("stroke", this.color).style("fill", this.color).style("opacity", 1)]; }; c3_chart_internal_fn.getBarW = function (axis, barTargetsNum) { var $$ = this, @@ -7862,9 +7594,8 @@ c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) { return [[posX + barSpaceOffset, offset], [posX + barSpaceOffset, posY - (y0 - offset)], [posX + barW - barSpaceOffset, posY - (y0 - offset)], [posX + barW - barSpaceOffset, offset]]; }; }; -c3_chart_internal_fn.isWithinBar = function (that) { - var mouse = this.d3.mouse(that), - box = that.getBoundingClientRect(), +c3_chart_internal_fn.isWithinBar = function (mouse, that) { + var box = that.getBoundingClientRect(), seg0 = that.pathSegList.getItem(0), seg1 = that.pathSegList.getItem(1), x = Math.min(seg0.x, seg1.x), @@ -7964,15 +7695,37 @@ c3_chart_internal_fn.isWithinShape = function (that, d) { } else if (that.nodeName === 'circle') { isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScale(d.id)(d.value)) : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); } else if (that.nodeName === 'path') { - isWithin = shape.classed(CLASS.bar) ? $$.isWithinBar(that) : true; + isWithin = shape.classed(CLASS.bar) ? $$.isWithinBar($$.d3.mouse(that), that) : true; } return isWithin; }; c3_chart_internal_fn.getInterpolate = function (d) { var $$ = this, - interpolation = $$.isInterpolationType($$.config.spline_interpolation_type) ? $$.config.spline_interpolation_type : 'cardinal'; - return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? $$.config.line_step_type : "linear"; + d3 = $$.d3, + types = { + 'linear': d3.curveLinear, + 'linear-closed': d3.curveLinearClosed, + 'basis': d3.curveBasis, + 'basis-open': d3.curveBasisOpen, + 'basis-closed': d3.curveBasisClosed, + 'bundle': d3.curveBundle, + 'cardinal': d3.curveCardinal, + 'cardinal-open': d3.curveCardinalOpen, + 'cardinal-closed': d3.curveCardinalClosed, + 'monotone': d3.curveMonotoneX, + 'step': d3.curveStep + }, + type; + + if ($$.isSplineType(d)) { + type = types[$$.config.spline_interpolation_type] || types.cardinal; + } else if ($$.isStepType(d)) { + type = types[$$.config.line_step_type]; + } else { + type = types.linear; + } + return type; }; c3_chart_internal_fn.initLine = function () { @@ -7982,17 +7735,17 @@ c3_chart_internal_fn.initLine = function () { c3_chart_internal_fn.updateTargetsForLine = function (targets) { var $$ = this, config = $$.config, - mainLineUpdate, + mainLines, mainLineEnter, classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$), classCircles = $$.classCircles.bind($$), classFocus = $$.classFocus.bind($$); - mainLineUpdate = $$.main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine).data(targets).attr('class', function (d) { + mainLines = $$.main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine).data(targets).attr('class', function (d) { return classChartLine(d) + classFocus(d); }); - mainLineEnter = mainLineUpdate.enter().append('g').attr('class', classChartLine).style('opacity', 0).style("pointer-events", "none"); + mainLineEnter = mainLines.enter().append('g').attr('class', classChartLine).style('opacity', 0).style("pointer-events", "none"); // Lines for each data mainLineEnter.append('g').attr("class", classLines); // Areas @@ -8015,20 +7768,20 @@ c3_chart_internal_fn.updateTargetsForLine = function (targets) { }; c3_chart_internal_fn.updateLine = function (durationForExit) { var $$ = this; - $$.mainLine = $$.main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line).data($$.lineData.bind($$)); - $$.mainLine.enter().append('path').attr('class', $$.classLine.bind($$)).style("stroke", $$.color); - $$.mainLine.style("opacity", $$.initialOpacity.bind($$)).style('shape-rendering', function (d) { + var mainLine = $$.main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line).data($$.lineData.bind($$)); + var mainLineEnter = mainLine.enter().append('path').attr('class', $$.classLine.bind($$)).style("stroke", $$.color); + $$.mainLine = mainLineEnter.merge(mainLine).style("opacity", $$.initialOpacity.bind($$)).style('shape-rendering', function (d) { return $$.isStepType(d) ? 'crispEdges' : ''; }).attr('transform', null); - $$.mainLine.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + mainLine.exit().transition().duration(durationForExit).style('opacity', 0); }; -c3_chart_internal_fn.redrawLine = function (drawLine, withTransition) { - return [(withTransition ? this.mainLine.transition(Math.random().toString()) : this.mainLine).attr("d", drawLine).style("stroke", this.color).style("opacity", 1)]; +c3_chart_internal_fn.redrawLine = function (drawLine, withTransition, transition) { + return [(withTransition ? this.mainLine.transition(transition) : this.mainLine).attr("d", drawLine).style("stroke", this.color).style("opacity", 1)]; }; c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { var $$ = this, config = $$.config, - line = $$.d3.svg.line(), + line = $$.d3.line(), getPoints = $$.generateGetLinePoints(lineIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function xValue(d) { @@ -8058,7 +7811,7 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); } - path = line.interpolate($$.getInterpolate(d))(values); + path = line.curve($$.getInterpolate(d))(values); } } else { if (values[0]) { @@ -8219,20 +7972,20 @@ c3_chart_internal_fn.lineWithRegions = function (d, x, y, _regions) { c3_chart_internal_fn.updateArea = function (durationForExit) { var $$ = this, d3 = $$.d3; - $$.mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area).data($$.lineData.bind($$)); - $$.mainArea.enter().append('path').attr("class", $$.classArea.bind($$)).style("fill", $$.color).style("opacity", function () { + var mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area).data($$.lineData.bind($$)); + var mainAreaEnter = mainArea.enter().append('path').attr("class", $$.classArea.bind($$)).style("fill", $$.color).style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity');return 0; }); - $$.mainArea.style("opacity", $$.orgAreaOpacity); - $$.mainArea.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + $$.mainArea = mainAreaEnter.merge(mainArea).style("opacity", $$.orgAreaOpacity); + mainArea.exit().transition().duration(durationForExit).style('opacity', 0); }; -c3_chart_internal_fn.redrawArea = function (drawArea, withTransition) { - return [(withTransition ? this.mainArea.transition(Math.random().toString()) : this.mainArea).attr("d", drawArea).style("fill", this.color).style("opacity", this.orgAreaOpacity)]; +c3_chart_internal_fn.redrawArea = function (drawArea, withTransition, transition) { + return [(withTransition ? this.mainArea.transition(transition) : this.mainArea).attr("d", drawArea).style("fill", this.color).style("opacity", this.orgAreaOpacity)]; }; c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { var $$ = this, config = $$.config, - area = $$.d3.svg.area(), + area = $$.d3.area(), getPoints = $$.generateGetAreaPoints(areaIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function xValue(d) { @@ -8261,7 +8014,7 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); } - path = area.interpolate($$.getInterpolate(d))(values); + path = area.curve($$.getInterpolate(d))(values); } else { if (values[0]) { x0 = $$.x(values[0].x); @@ -8303,16 +8056,17 @@ c3_chart_internal_fn.generateGetAreaPoints = function (areaIndices, isSub) { }; }; -c3_chart_internal_fn.updateCircle = function () { +c3_chart_internal_fn.updateCircle = function (cx, cy) { var $$ = this; - $$.mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle).data($$.lineOrScatterData.bind($$)); - $$.mainCircle.enter().append("circle").attr("class", $$.classCircle.bind($$)).attr("r", $$.pointR.bind($$)).style("fill", $$.color); - $$.mainCircle.style("opacity", $$.initialOpacityForCircle.bind($$)); - $$.mainCircle.exit().remove(); + var mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle).data($$.lineOrScatterData.bind($$)); + var mainCircleEnter = mainCircle.enter().append("circle").attr("class", $$.classCircle.bind($$)).attr("cx", cx).attr("cy", cy).attr("r", $$.pointR.bind($$)).style("fill", $$.color); + $$.mainCircle = mainCircleEnter.merge(mainCircle).style("opacity", $$.initialOpacityForCircle.bind($$)); + mainCircle.exit().style("opacity", 0); }; -c3_chart_internal_fn.redrawCircle = function (cx, cy, withTransition) { - var selectedCircles = this.main.selectAll('.' + CLASS.selectedCircle); - return [(withTransition ? this.mainCircle.transition(Math.random().toString()) : this.mainCircle).style('opacity', this.opacityForCircle.bind(this)).style("fill", this.color).attr("cx", cx).attr("cy", cy), (withTransition ? selectedCircles.transition(Math.random().toString()) : selectedCircles).attr("cx", cx).attr("cy", cy)]; +c3_chart_internal_fn.redrawCircle = function (cx, cy, withTransition, transition) { + var $$ = this, + selectedCircles = $$.main.selectAll('.' + CLASS.selectedCircle); + return [(withTransition ? $$.mainCircle.transition(transition) : $$.mainCircle).style('opacity', this.opacityForCircle.bind($$)).style("fill", $$.color).attr("cx", cx).attr("cy", cy), (withTransition ? selectedCircles.transition(transition) : selectedCircles).attr("cx", cx).attr("cy", cy)]; }; c3_chart_internal_fn.circleX = function (d) { return d.x || d.x === 0 ? this.x(d.x) : null; @@ -8510,25 +8264,67 @@ c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) { return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0); }; -c3_chart_internal_fn.getEventRectWidth = function () { - return Math.max(0, this.xAxis.tickInterval()); -}; - -c3_chart_internal_fn.initBrush = function () { +c3_chart_internal_fn.initBrush = function (scale) { var $$ = this, d3 = $$.d3; - $$.brush = d3.svg.brush().on("brush", function () { + // TODO: dynamically change brushY/brushX according to axis_rotated. + $$.brush = ($$.config.axis_rotated ? d3.brushY() : d3.brushX()).on("brush", function () { + var event = d3.event.sourceEvent; + if (event && event.type === "zoom") { + return; + } $$.redrawForBrush(); + }).on("end", function () { + var event = d3.event.sourceEvent; + if (event && event.type === "zoom") { + return; + } + if ($$.brush.empty() && event && event.type !== 'end') { + $$.brush.clear(); + } }); - $$.brush.update = function () { - if ($$.context) { - $$.context.select('.' + CLASS.brush).call(this); + $$.brush.updateExtent = function () { + var range = this.scale.range(), + extent; + if ($$.config.axis_rotated) { + extent = [[0, range[0]], [$$.width2, range[1]]]; + } else { + extent = [[range[0], 0], [range[1], $$.height2]]; } + this.extent(extent); + return this; + }; + $$.brush.updateScale = function (scale) { + this.scale = scale; return this; }; - $$.brush.scale = function (scale) { - return $$.config.axis_rotated ? this.y(scale) : this.x(scale); + $$.brush.update = function (scale) { + this.updateScale(scale || $$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call(this); + }; + $$.brush.clear = function () { + $$.context.select('.' + CLASS.brush).call($$.brush.move, null); + }; + $$.brush.selection = function () { + return d3.brushSelection($$.context.select('.' + CLASS.brush).node()); + }; + $$.brush.selectionAsValue = function (selectionAsValue) { + var selection; + if (selectionAsValue) { + if ($$.context) { + selection = [this.scale(selectionAsValue[0]), this.scale(selectionAsValue[1])]; + $$.brush.move($$.context.select('.' + CLASS.brush).transition(), selection); + } + return []; + } + selection = $$.brush.selection() || [0, 0]; + return [this.scale.invert(selection[0]), this.scale.invert(selection[1])]; + }; + $$.brush.empty = function () { + var selection = $$.brush.selection(); + return !selection || selection[0] === selection[1]; }; + return $$.brush.updateScale(scale); }; c3_chart_internal_fn.initSubchart = function () { var $$ = this, @@ -8536,6 +8332,7 @@ c3_chart_internal_fn.initSubchart = function () { context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context')), visibility = config.subchart_show ? 'visible' : 'hidden'; + // set style context.style('visibility', visibility); // Define g for chart area @@ -8548,20 +8345,26 @@ c3_chart_internal_fn.initSubchart = function () { 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).call($$.brush); + context.append("g").attr("clip-path", $$.clipPath).attr("class", CLASS.brush); // ATTENTION: This must be called AFTER chart added // Add Axis - $$.axes.subx = context.append("g").attr("class", CLASS.axisX).attr("transform", $$.getTranslate('subx')).attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis).style("visibility", config.subchart_axis_x_show ? visibility : 'hidden'); + $$.axes.subx = context.append("g").attr("class", CLASS.axisX).attr("transform", $$.getTranslate('subx')).attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis); +}; +c3_chart_internal_fn.initSubchartBrush = function () { + var $$ = this; + // Add extent rect for Brush + $$.initBrush($$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call($$.brush); }; c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { var $$ = this, context = $$.context, config = $$.config, contextLineEnter, - contextLineUpdate, + contextLine, contextBarEnter, - contextBarUpdate, + contextBar, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classChartLine = $$.classChartLine.bind($$), @@ -8570,14 +8373,16 @@ c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { if (config.subchart_show) { //-- Bar --// - contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar).data(targets).attr('class', classChartBar); - contextBarEnter = contextBarUpdate.enter().append('g').style('opacity', 0).attr('class', classChartBar); + contextBar = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar).data(targets); + contextBarEnter = contextBar.enter().append('g').style('opacity', 0); + contextBarEnter.merge(contextBar).attr('class', classChartBar); // Bars for each data contextBarEnter.append('g').attr("class", classBars); //-- Line --// - contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine).data(targets).attr('class', classChartLine); - contextLineEnter = contextLineUpdate.enter().append('g').style('opacity', 0).attr('class', classChartLine); + contextLine = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine).data(targets); + contextLineEnter = contextLine.enter().append('g').style('opacity', 0); + contextLineEnter.merge(contextLine).attr('class', classChartLine); // Lines for each data contextLineEnter.append("g").attr("class", classLines); // Area @@ -8589,20 +8394,20 @@ c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { }; c3_chart_internal_fn.updateBarForSubchart = function (durationForExit) { var $$ = this; - $$.contextBar = $$.context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar).data($$.barData.bind($$)); - $$.contextBar.enter().append('path').attr("class", $$.classBar.bind($$)).style("stroke", 'none').style("fill", $$.color); - $$.contextBar.style("opacity", $$.initialOpacity.bind($$)); - $$.contextBar.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + var contextBar = $$.context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar).data($$.barData.bind($$)); + var contextBarEnter = contextBar.enter().append('path').attr("class", $$.classBar.bind($$)).style("stroke", 'none').style("fill", $$.color); + contextBar.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + $$.contextBar = contextBarEnter.merge(contextBar).style("opacity", $$.initialOpacity.bind($$)); }; c3_chart_internal_fn.redrawBarForSubchart = function (drawBarOnSub, withTransition, duration) { (withTransition ? this.contextBar.transition(Math.random().toString()).duration(duration) : this.contextBar).attr('d', drawBarOnSub).style('opacity', 1); }; c3_chart_internal_fn.updateLineForSubchart = function (durationForExit) { var $$ = this; - $$.contextLine = $$.context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line).data($$.lineData.bind($$)); - $$.contextLine.enter().append('path').attr('class', $$.classLine.bind($$)).style('stroke', $$.color); - $$.contextLine.style("opacity", $$.initialOpacity.bind($$)); - $$.contextLine.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + var contextLine = $$.context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line).data($$.lineData.bind($$)); + var contextLineEnter = contextLine.enter().append('path').attr('class', $$.classLine.bind($$)).style('stroke', $$.color); + contextLine.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + $$.contextLine = contextLineEnter.merge(contextLine).style("opacity", $$.initialOpacity.bind($$)); }; c3_chart_internal_fn.redrawLineForSubchart = function (drawLineOnSub, withTransition, duration) { (withTransition ? this.contextLine.transition(Math.random().toString()).duration(duration) : this.contextLine).attr("d", drawLineOnSub).style('opacity', 1); @@ -8610,12 +8415,12 @@ c3_chart_internal_fn.redrawLineForSubchart = function (drawLineOnSub, withTransi c3_chart_internal_fn.updateAreaForSubchart = function (durationForExit) { var $$ = this, d3 = $$.d3; - $$.contextArea = $$.context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area).data($$.lineData.bind($$)); - $$.contextArea.enter().append('path').attr("class", $$.classArea.bind($$)).style("fill", $$.color).style("opacity", function () { + var contextArea = $$.context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area).data($$.lineData.bind($$)); + var contextAreaEnter = contextArea.enter().append('path').attr("class", $$.classArea.bind($$)).style("fill", $$.color).style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity');return 0; }); - $$.contextArea.style("opacity", 0); - $$.contextArea.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + contextArea.exit().transition().duration(durationForExit).style('opacity', 0).remove(); + $$.contextArea = contextAreaEnter.merge(contextArea).style("opacity", 0); }; c3_chart_internal_fn.redrawAreaForSubchart = function (drawAreaOnSub, withTransition, duration) { (withTransition ? this.contextArea.transition(Math.random().toString()).duration(duration) : this.contextArea).attr("d", drawAreaOnSub).style("fill", this.color).style("opacity", this.orgAreaOpacity); @@ -8634,14 +8439,13 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat if (config.subchart_show) { // reflect main chart to extent on subchart if zoomed if (d3.event && d3.event.type === 'zoom') { - $$.brush.extent($$.x.orgDomain()).update(); + $$.brush.selectionAsValue($$.x.orgDomain()); } // update subchart elements if needed if (withSubchart) { - // extent rect if (!$$.brush.empty()) { - $$.brush.extent($$.x.orgDomain()).update(); + $$.brush.selectionAsValue($$.x.orgDomain()); } // setup drawer - MEMO: this must be called after axis updated drawAreaOnSub = $$.generateDrawArea(areaIndices, true); @@ -8660,14 +8464,20 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat }; c3_chart_internal_fn.redrawForBrush = function () { var $$ = this, - x = $$.x; + x = $$.x, + d3 = $$.d3, + s; $$.redraw({ withTransition: false, withY: $$.config.zoom_rescale, withSubchart: false, withUpdateXDomain: true, + withEventRect: false, withDimension: false }); + // update zoom transation binded to event rect + s = d3.event.selection || $$.brush.scale.range(); + $$.main.select('.' + CLASS.eventRect).call($$.zoom.transform, d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0)); $$.config.subchart_onbrush.call($$.api, x.orgDomain()); }; c3_chart_internal_fn.transformContext = function (withTransition, transitions) { @@ -8684,14 +8494,14 @@ c3_chart_internal_fn.transformContext = function (withTransition, transitions) { $$.context.attr("transform", $$.getTranslate('context')); subXAxis.attr("transform", $$.getTranslate('subx')); }; -c3_chart_internal_fn.getDefaultExtent = function () { +c3_chart_internal_fn.getDefaultSelection = function () { var $$ = this, config = $$.config, - extent = isFunction(config.axis_x_extent) ? config.axis_x_extent($$.getXDomain($$.data.targets)) : config.axis_x_extent; + selection = isFunction(config.axis_x_selection) ? config.axis_x_selection($$.getXDomain($$.data.targets)) : config.axis_x_selection; if ($$.isTimeSeries()) { - extent = [$$.parseDate(extent[0]), $$.parseDate(extent[1])]; + selection = [$$.parseDate(selection[0]), $$.parseDate(selection[1])]; } - return extent; + return selection; }; c3_chart_internal_fn.initText = function () { @@ -8701,35 +8511,34 @@ c3_chart_internal_fn.initText = function () { }; c3_chart_internal_fn.updateTargetsForText = function (targets) { var $$ = this, - mainTextUpdate, - mainTextEnter, classChartText = $$.classChartText.bind($$), classTexts = $$.classTexts.bind($$), classFocus = $$.classFocus.bind($$); - mainTextUpdate = $$.main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText).data(targets).attr('class', function (d) { + var mainText = $$.main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText).data(targets); + var mainTextEnter = mainText.enter().append('g').attr('class', classChartText).style('opacity', 0).style("pointer-events", "none"); + mainTextEnter.append('g').attr('class', classTexts); + mainTextEnter.merge(mainText).attr('class', function (d) { return classChartText(d) + classFocus(d); }); - mainTextEnter = mainTextUpdate.enter().append('g').attr('class', classChartText).style('opacity', 0).style("pointer-events", "none"); - mainTextEnter.append('g').attr('class', classTexts); }; -c3_chart_internal_fn.updateText = function (durationForExit) { +c3_chart_internal_fn.updateText = function (xForText, yForText, durationForExit) { var $$ = this, config = $$.config, barOrLineData = $$.barOrLineData.bind($$), classText = $$.classText.bind($$); - $$.mainText = $$.main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text).data(barOrLineData); - $$.mainText.enter().append('text').attr("class", classText).attr('text-anchor', function (d) { + var mainText = $$.main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text).data(barOrLineData); + var mainTextEnter = mainText.enter().append('text').attr("class", classText).attr('text-anchor', function (d) { return config.axis_rotated ? d.value < 0 ? 'end' : 'start' : 'middle'; - }).style("stroke", 'none').style("fill", function (d) { + }).style("stroke", 'none').attr('x', xForText).attr('y', yForText).style("fill", function (d) { return $$.color(d); }).style("fill-opacity", 0); - $$.mainText.text(function (d, i, j) { + $$.mainText = mainTextEnter.merge(mainText).text(function (d, i, j) { return $$.dataLabelFormat(d.id)(d.value, d.id, i, j); }); - $$.mainText.exit().transition().duration(durationForExit).style('fill-opacity', 0).remove(); + mainText.exit().transition().duration(durationForExit).style('fill-opacity', 0).remove(); }; -c3_chart_internal_fn.redrawText = function (xForText, yForText, forFlow, withTransition) { - return [(withTransition ? this.mainText.transition() : this.mainText).attr('x', xForText).attr('y', yForText).style("fill", this.color).style("fill-opacity", forFlow ? 0 : this.opacityForText.bind(this))]; +c3_chart_internal_fn.redrawText = function (xForText, yForText, forFlow, withTransition, transition) { + return [(withTransition ? this.mainText.transition(transition) : this.mainText).attr('x', xForText).attr('y', yForText).style("fill", this.color).style("fill-opacity", forFlow ? 0 : this.opacityForText.bind(this))]; }; c3_chart_internal_fn.getTextRect = function (text, cls, element) { var dummy = this.d3.select('body').append('div').classed('c3', true), @@ -9135,9 +8944,6 @@ c3_chart_internal_fn.lineOrScatterData = function (d) { c3_chart_internal_fn.barOrLineData = function (d) { return this.isBarType(d) || this.isLineType(d) ? d.values : []; }; -c3_chart_internal_fn.isInterpolationType = function (type) { - return ['linear', 'linear-closed', 'basis', 'basis-open', 'basis-closed', 'bundle', 'cardinal', 'cardinal-open', 'cardinal-closed', 'monotone'].indexOf(type) >= 0; -}; c3_chart_internal_fn.isSafari = function () { var ua = window.navigator.userAgent; @@ -9154,36 +8960,53 @@ c3_chart_internal_fn.initZoom = function () { config = $$.config, startEvent; - $$.zoom = d3.behavior.zoom().on("zoomstart", function () { - startEvent = d3.event.sourceEvent; - $$.zoom.altDomain = d3.event.sourceEvent.altKey ? $$.x.orgDomain() : null; - config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); + $$.zoom = d3.zoom().on("start", function () { + var e = d3.event.sourceEvent; + if (e && e.type === "brush") { + return; + } + startEvent = e; + config.zoom_onzoomstart.call($$.api, e); }).on("zoom", function () { + var e = d3.event.sourceEvent; + if (e && e.type === "brush") { + return; + } $$.redrawForZoom.call($$); - }).on('zoomend', function () { - var event = d3.event.sourceEvent; + }).on('end', function () { + var e = d3.event.sourceEvent; + if (e && e.type === "brush") { + return; + } // if click, do nothing. otherwise, click interaction will be canceled. - if (event && startEvent.clientX === event.clientX && startEvent.clientY === event.clientY) { + if (e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY) { return; } - $$.redrawEventRect(); - $$.updateZoom(); config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); }); - $$.zoom.scale = function (scale) { - return config.axis_rotated ? this.y(scale) : this.x(scale); - }; - $$.zoom.orgScaleExtent = function () { - var extent = config.zoom_extent ? config.zoom_extent : [1, 10]; - return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])]; + + $$.zoom.updateDomain = function () { + if (d3.event && d3.event.transform) { + $$.x.domain(d3.event.transform.rescaleX($$.subX).domain()); + } + return this; }; - $$.zoom.updateScaleExtent = function () { - var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.getZoomDomain()), - extent = this.orgScaleExtent(); - this.scaleExtent([extent[0] * ratio, extent[1] * ratio]); + $$.zoom.updateExtent = function () { + this.scaleExtent([1, Infinity]).translateExtent([[0, 0], [$$.width, $$.height]]).extent([[0, 0], [$$.width, $$.height]]); return this; }; + $$.zoom.update = function () { + return this.updateExtent().updateDomain(); + }; + + return $$.zoom.updateExtent(); +}; +c3_chart_internal_fn.zoomTransform = function (range) { + var $$ = this, + s = [$$.x(range[0]), $$.x(range[1])]; + return $$.d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0); }; + c3_chart_internal_fn.getZoomDomain = function () { var $$ = this, config = $$.config, @@ -9192,12 +9015,6 @@ c3_chart_internal_fn.getZoomDomain = function () { max = d3.max([$$.orgXDomain[1], config.zoom_x_max]); return [min, max]; }; -c3_chart_internal_fn.updateZoom = function () { - var $$ = this, - z = $$.config.zoom_enabled ? $$.zoom : function () {}; - $$.main.select('.' + CLASS.zoomRect).call(z).on("dblclick.zoom", null); - $$.main.selectAll('.' + CLASS.eventRect).call(z).on("dblclick.zoom", null); -}; c3_chart_internal_fn.redrawForZoom = function () { var $$ = this, d3 = $$.d3, @@ -9210,11 +9027,9 @@ c3_chart_internal_fn.redrawForZoom = function () { if ($$.filterTargetsToShow($$.data.targets).length === 0) { return; } - if (d3.event.sourceEvent.type === 'mousemove' && zoom.altDomain) { - x.domain(zoom.altDomain); - zoom.scale(x).updateScaleExtent(); - return; - } + + zoom.update(); + if ($$.isCategorized() && x.orgDomain()[0] === $$.orgXDomain[0]) { x.domain([$$.orgXDomain[0] - 1e-10, x.orgDomain()[1]]); } @@ -9225,7 +9040,7 @@ c3_chart_internal_fn.redrawForZoom = function () { withEventRect: false, withDimension: false }); - if (d3.event.sourceEvent.type === 'mousemove') { + if (d3.event.sourceEvent && d3.event.sourceEvent.type === 'mousemove') { $$.cancelClick = true; } config.zoom_onzoom.call($$.api, x.orgDomain()); diff --git a/c3.min.js b/c3.min.js index f190816..f373078 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.c3=e()}(this,function(){"use strict";function t(t,e){var i=this;i.component=t,i.params=e||{},i.d3=t.d3,i.scale=i.d3.scale.linear(),i.range,i.orient="bottom",i.innerTickSize=6,i.outerTickSize=this.params.withOuterTick?6:0,i.tickPadding=3,i.tickValues=null,i.tickFormat,i.tickArguments,i.tickOffset=0,i.tickCulling=!0,i.tickCentered,i.tickTextCharSize,i.tickTextRotate=i.params.tickTextRotate,i.tickLength,i.axis=i.generateAxis()}function e(t){var e=this.internal=new i(this);e.loadConfig(t),e.beforeInit(t),e.init(),e.afterInit(t),function t(e,i,n){Object.keys(e).forEach(function(a){i[a]=e[a].bind(n),Object.keys(e[a]).length>0&&t(e[a],i[a],n)})}(P,this,this)}function i(t){var e=this;e.d3=window.d3?window.d3:"undefined"!=typeof require?require("d3"):void 0,e.api=t,e.config=e.getDefaultConfig(),e.data={},e.cache={},e.axes={}}var n,a,r={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",defocused:"c3-defocused",region:"c3-region",regions:"c3-regions",title:"c3-title",tooltipContainer:"c3-tooltip-container",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",gridLines:"c3-grid-lines",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_"},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},c=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},d=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},l=function(t){return t||0===t},u=function(t){return"function"==typeof t},h=function(t){return Array.isArray(t)},g=function(t){return"string"==typeof t},f=function(t){return void 0===t},p=function(t){return void 0!==t},_=function(t){return 10*Math.ceil(t/10)},x=function(t){return Math.ceil(t)+.5},m=function(t){return t[1]-t[0]},y=function(t){return void 0===t||null===t||g(t)&&0===t.length||"object"===(void 0===t?"undefined":o(t))&&0===Object.keys(t).length},S=function(t){return!C.isEmpty(t)},w=function(t,e,i){return void 0!==t[e]?t[e]:i},v=function(t,e){var i=!1;return Object.keys(t).forEach(function(n){t[n]===e&&(i=!0)}),i},b=function(t){return"string"==typeof t?t.replace(//g,">"):t},T=function(t){var e=t.getBoundingClientRect(),i=[t.pathSegList.getItem(0),t.pathSegList.getItem(1)];return{x:i[0].x,y:Math.min(i[0].y,i[1].y),width:e.width,height:e.height}};(a=t.prototype).axisX=function(t,e,i){t.attr("transform",function(t){return"translate("+Math.ceil(e(t)+i)+", 0)"})},a.axisY=function(t,e){t.attr("transform",function(t){return"translate(0,"+Math.ceil(e(t))+")"})},a.scaleExtent=function(t){var e=t[0],i=t[t.length-1];return e0&&a[0]>0&&a.unshift(a[0]-(a[1]-a[0])),a},a.copyScale=function(){var t,e=this,i=e.scale.copy();return e.params.isCategory&&(t=e.scale.domain(),i.domain([t[0],t[1]-1])),i},a.textFormatted=function(t){var e=this,i=e.tickFormat?e.tickFormat(t):t;return void 0!==i?i:""},a.updateRange=function(){var t=this;return t.range=t.scale.rangeExtent?t.scale.rangeExtent():t.scaleExtent(t.scale.range()),t.range},a.updateTickTextCharSize=function(t){var e=this;if(e.tickTextCharSize)return e.tickTextCharSize;var i={h:11.5,w:5.5};return t.select("text").text(function(t){return e.textFormatted(t)}).each(function(t){var n=this.getBoundingClientRect(),a=e.textFormatted(t),r=n.height,o=a?n.width/a.length:void 0;r&&o&&(i.h=r,i.w=o)}).text(""),e.tickTextCharSize=i,i},a.transitionise=function(t){return this.params.withoutTransition?t:this.d3.transition(t)},a.isVertical=function(){return"left"===this.orient||"right"===this.orient},a.tspanData=function(t,e,i,n){var a=this,r=a.params.tickMultiline?a.splitTickText(t,i,n):[].concat(a.textFormatted(t));return r.map(function(t){return{index:e,splitted:t,length:r.length}})},a.splitTickText=function(t,e,i){function n(t,e){r=void 0;for(var i=1;i0?1:-1):t.tickLength},a.textTransform=function(){var t=this.tickTextRotate;return t?"rotate("+t+")":""},a.textTextAnchor=function(){var t=this.tickTextRotate;return t?t>0?"start":"end":"middle"},a.tspanDx=function(){var t=this.tickTextRotate;return t?8*Math.sin(Math.PI*(t/180)):0},a.tspanDy=function(t,e){var i=this,n=i.tickTextCharSize.h;return 0===e&&(n=i.isVertical()?-((t.length-1)*(i.tickTextCharSize.h/2)-3):".71em"),n},a.generateAxis=function(){function t(a){a.each(function(){var a,r,o,s=t.g=i.select(this),c=this.__chart__||e.scale,d=this.__chart__=e.copyScale(),l=e.tickValues?e.tickValues:e.generateTicks(d),u=s.selectAll(".tick").data(l,d),h=u.enter().insert("g",".domain").attr("class","tick").style("opacity",1e-6),g=u.exit().remove(),f=e.transitionise(u).style("opacity",1);n.isCategory?(e.tickOffset=Math.ceil((d(1)-d(0))/2),r=e.tickCentered?0:e.tickOffset,o=e.tickCentered?e.tickOffset:0):e.tickOffset=r=0,h.append("line"),h.append("text"),e.updateRange(),e.updateTickLength(),e.updateTickTextCharSize(s.select(".tick"));var p=f.select("line"),_=f.select("text"),x=u.select("text").selectAll("tspan").data(function(t,i){return e.tspanData(t,i,l,d)});x.enter().append("tspan"),x.exit().remove(),x.text(function(t){return t.splitted});var m=s.selectAll(".domain").data([0]),y=(m.enter().append("path").attr("class","domain"),e.transitionise(m));switch(e.orient){case"bottom":a=e.axisX,p.attr("x1",r).attr("x2",r).attr("y2",function(t,i){return e.lineY2(t,i)}),_.attr("x",0).attr("y",function(t,i){return e.textY(t,i)}).attr("transform",function(t,i){return e.textTransform(t,i)}).style("text-anchor",function(t,i){return e.textTextAnchor(t,i)}),x.attr("x",0).attr("dy",function(t,i){return e.tspanDy(t,i)}).attr("dx",function(t,i){return e.tspanDx(t,i)}),y.attr("d","M"+e.range[0]+","+e.outerTickSize+"V0H"+e.range[1]+"V"+e.outerTickSize);break;case"top":a=e.axisX,p.attr("x2",0).attr("y2",-e.innerTickSize),_.attr("x",0).attr("y",-e.tickLength).style("text-anchor","middle"),x.attr("x",0).attr("dy","0em"),y.attr("d","M"+e.range[0]+","+-e.outerTickSize+"V0H"+e.range[1]+"V"+-e.outerTickSize);break;case"left":a=e.axisY,p.attr("x2",-e.innerTickSize).attr("y1",o).attr("y2",o),_.attr("x",-e.tickLength).attr("y",e.tickOffset).style("text-anchor","end"),x.attr("x",-e.tickLength).attr("dy",function(t,i){return e.tspanDy(t,i)}),y.attr("d","M"+-e.outerTickSize+","+e.range[0]+"H0V"+e.range[1]+"H"+-e.outerTickSize);break;case"right":a=e.axisY,p.attr("x2",e.innerTickSize).attr("y2",0),_.attr("x",e.tickLength).attr("y",0).style("text-anchor","start"),x.attr("x",e.tickLength).attr("dy",function(t,i){return e.tspanDy(t,i)}),y.attr("d","M"+e.outerTickSize+","+e.range[0]+"H0V"+e.range[1]+"H"+e.outerTickSize)}if(d.rangeBand){var S=d,w=S.rangeBand()/2;c=d=function(t){return S(t)+w}}else c.rangeBand?c=d:g.call(a,d,e.tickOffset);h.call(a,c,e.tickOffset),f.call(a,d,e.tickOffset)})}var e=this,i=e.d3,n=e.params;return t.scale=function(i){return arguments.length?(e.scale=i,t):e.scale},t.orient=function(i){return arguments.length?(e.orient=i in{top:1,right:1,bottom:1,left:1}?i+"":"bottom",t):e.orient},t.tickFormat=function(i){return arguments.length?(e.tickFormat=i,t):e.tickFormat},t.tickCentered=function(i){return arguments.length?(e.tickCentered=i,t):e.tickCentered},t.tickOffset=function(){return e.tickOffset},t.tickInterval=function(){var i;return i=n.isCategory?2*e.tickOffset:(t.g.select("path.domain").node().getTotalLength()-2*e.outerTickSize)/t.g.selectAll("line").size(),i===1/0?0:i},t.ticks=function(){return arguments.length?(e.tickArguments=arguments,t):e.tickArguments},t.tickCulling=function(i){return arguments.length?(e.tickCulling=i,t):e.tickCulling},t.tickValues=function(i){if("function"==typeof i)e.tickValues=function(){return i(e.scale.domain())};else{if(!arguments.length)return e.tickValues;e.tickValues=i}return t},t};var A=function(e){function i(e){s(this,i);var r={fn:n,internal:{fn:a}},o=d(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,"axis",r));return o.d3=e.d3,o.internal=t,o}return c(i,e),i}(function(t,e,i){this.owner=t,L.chart.internal[e]=i});(n=A.prototype).init=function(){var t=this.owner,e=t.config,i=t.main;t.axes.x=i.append("g").attr("class",r.axis+" "+r.axisX).attr("clip-path",t.clipPathForXAxis).attr("transform",t.getTranslate("x")).style("visibility",e.axis_x_show?"visible":"hidden"),t.axes.x.append("text").attr("class",r.axisXLabel).attr("transform",e.axis_rotated?"rotate(-90)":"").style("text-anchor",this.textAnchorForXAxisLabel.bind(this)),t.axes.y=i.append("g").attr("class",r.axis+" "+r.axisY).attr("clip-path",e.axis_y_inner?"":t.clipPathForYAxis).attr("transform",t.getTranslate("y")).style("visibility",e.axis_y_show?"visible":"hidden"),t.axes.y.append("text").attr("class",r.axisYLabel).attr("transform",e.axis_rotated?"":"rotate(-90)").style("text-anchor",this.textAnchorForYAxisLabel.bind(this)),t.axes.y2=i.append("g").attr("class",r.axis+" "+r.axisY2).attr("transform",t.getTranslate("y2")).style("visibility",e.axis_y2_show?"visible":"hidden"),t.axes.y2.append("text").attr("class",r.axisY2Label).attr("transform",e.axis_rotated?"":"rotate(-90)").style("text-anchor",this.textAnchorForY2AxisLabel.bind(this))},n.getXAxis=function(t,e,i,n,a,r,o){var s=this.owner,c=s.config,d={isCategory:s.isCategorized(),withOuterTick:a,tickMultiline:c.axis_x_tick_multiline,tickWidth:c.axis_x_tick_width,tickTextRotate:o?0:c.axis_x_tick_rotate,withoutTransition:r},l=new this.internal(this,d).axis.scale(t).orient(e);return s.isTimeSeries()&&n&&"function"!=typeof n&&(n=n.map(function(t){return s.parseDate(t)})),l.tickFormat(i).tickValues(n),s.isCategorized()&&(l.tickCentered(c.axis_x_tick_centered),y(c.axis_x_tick_culling)&&(c.axis_x_tick_culling=!1)),l},n.updateXAxisTickValues=function(t,e){var i,n=this.owner,a=n.config;return(a.axis_x_tick_fit||a.axis_x_tick_count)&&(i=this.generateTickValues(n.mapTargetsToUniqueXs(t),a.axis_x_tick_count,n.isTimeSeries())),e?e.tickValues(i):(n.xAxis.tickValues(i),n.subXAxis.tickValues(i)),i},n.getYAxis=function(t,e,i,n,a,r,o){var s=this.owner,c=s.config,d={withOuterTick:a,withoutTransition:r,tickTextRotate:o?0:c.axis_y_tick_rotate},l=new this.internal(this,d).axis.scale(t).orient(e).tickFormat(i);return s.isTimeSeriesY()?l.ticks(s.d3.time[c.axis_y_tick_time_value],c.axis_y_tick_time_interval):l.tickValues(n),l},n.getId=function(t){var e=this.owner.config;return t in e.data_axes?e.data_axes[t]:"y"},n.getXAxisTickFormat=function(){var t=this.owner,e=t.config,i=t.isTimeSeries()?t.defaultAxisTimeFormat:t.isCategorized()?t.categoryName:function(t){return t<0?t.toFixed(0):t};return e.axis_x_tick_format&&(u(e.axis_x_tick_format)?i=e.axis_x_tick_format:t.isTimeSeries()&&(i=function(i){return i?t.axisTimeFormat(e.axis_x_tick_format)(i):""})),u(i)?function(e){return i.call(t,e)}:i},n.getTickValues=function(t,e){return t||(e?e.tickValues():void 0)},n.getXAxisTickValues=function(){return this.getTickValues(this.owner.config.axis_x_tick_values,this.owner.xAxis)},n.getYAxisTickValues=function(){return this.getTickValues(this.owner.config.axis_y_tick_values,this.owner.yAxis)},n.getY2AxisTickValues=function(){return this.getTickValues(this.owner.config.axis_y2_tick_values,this.owner.y2Axis)},n.getLabelOptionByAxisId=function(t){var e,i=this.owner.config;return"y"===t?e=i.axis_y_label:"y2"===t?e=i.axis_y2_label:"x"===t&&(e=i.axis_x_label),e},n.getLabelText=function(t){var e=this.getLabelOptionByAxisId(t);return g(e)?e:e?e.text:null},n.setLabelText=function(t,e){var i=this.owner.config,n=this.getLabelOptionByAxisId(t);g(n)?"y"===t?i.axis_y_label=e:"y2"===t?i.axis_y2_label=e:"x"===t&&(i.axis_x_label=e):n&&(n.text=e)},n.getLabelPosition=function(t,e){var i=this.getLabelOptionByAxisId(t),n=i&&"object"===(void 0===i?"undefined":o(i))&&i.position?i.position:e;return{isInner:n.indexOf("inner")>=0,isOuter:n.indexOf("outer")>=0,isLeft:n.indexOf("left")>=0,isCenter:n.indexOf("center")>=0,isRight:n.indexOf("right")>=0,isTop:n.indexOf("top")>=0,isMiddle:n.indexOf("middle")>=0,isBottom:n.indexOf("bottom")>=0}},n.getXAxisLabelPosition=function(){return this.getLabelPosition("x",this.owner.config.axis_rotated?"inner-top":"inner-right")},n.getYAxisLabelPosition=function(){return this.getLabelPosition("y",this.owner.config.axis_rotated?"inner-right":"inner-top")},n.getY2AxisLabelPosition=function(){return this.getLabelPosition("y2",this.owner.config.axis_rotated?"inner-right":"inner-top")},n.getLabelPositionById=function(t){return"y2"===t?this.getY2AxisLabelPosition():"y"===t?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},n.textForXAxisLabel=function(){return this.getLabelText("x")},n.textForYAxisLabel=function(){return this.getLabelText("y")},n.textForY2AxisLabel=function(){return this.getLabelText("y2")},n.xForAxisLabel=function(t,e){var i=this.owner;return t?e.isLeft?0:e.isCenter?i.width/2:i.width:e.isBottom?-i.height:e.isMiddle?-i.height/2:0},n.dxForAxisLabel=function(t,e){return t?e.isLeft?"0.5em":e.isRight?"-0.5em":"0":e.isTop?"-0.5em":e.isBottom?"0.5em":"0"},n.textAnchorForAxisLabel=function(t,e){return t?e.isLeft?"start":e.isCenter?"middle":"end":e.isBottom?"start":e.isMiddle?"middle":"end"},n.xForXAxisLabel=function(){return this.xForAxisLabel(!this.owner.config.axis_rotated,this.getXAxisLabelPosition())},n.xForYAxisLabel=function(){return this.xForAxisLabel(this.owner.config.axis_rotated,this.getYAxisLabelPosition())},n.xForY2AxisLabel=function(){return this.xForAxisLabel(this.owner.config.axis_rotated,this.getY2AxisLabelPosition())},n.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.owner.config.axis_rotated,this.getXAxisLabelPosition())},n.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.owner.config.axis_rotated,this.getYAxisLabelPosition())},n.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.owner.config.axis_rotated,this.getY2AxisLabelPosition())},n.dyForXAxisLabel=function(){var t=this.owner.config,e=this.getXAxisLabelPosition();return t.axis_rotated?e.isInner?"1.2em":-25-this.getMaxTickWidth("x"):e.isInner?"-0.5em":t.axis_x_height?t.axis_x_height-10:"3em"},n.dyForYAxisLabel=function(){var t=this.owner,e=this.getYAxisLabelPosition();return t.config.axis_rotated?e.isInner?"-0.5em":"3em":e.isInner?"1.2em":-10-(t.config.axis_y_inner?0:this.getMaxTickWidth("y")+10)},n.dyForY2AxisLabel=function(){var t=this.owner,e=this.getY2AxisLabelPosition();return t.config.axis_rotated?e.isInner?"1.2em":"-2.2em":e.isInner?"-0.5em":15+(t.config.axis_y2_inner?0:this.getMaxTickWidth("y2")+15)},n.textAnchorForXAxisLabel=function(){var t=this.owner;return this.textAnchorForAxisLabel(!t.config.axis_rotated,this.getXAxisLabelPosition())},n.textAnchorForYAxisLabel=function(){var t=this.owner;return this.textAnchorForAxisLabel(t.config.axis_rotated,this.getYAxisLabelPosition())},n.textAnchorForY2AxisLabel=function(){var t=this.owner;return this.textAnchorForAxisLabel(t.config.axis_rotated,this.getY2AxisLabelPosition())},n.getMaxTickWidth=function(t,e){var i,n,a,r,o=this.owner,s=o.config,c=0;return e&&o.currentMaxTickWidths[t]?o.currentMaxTickWidths[t]:(o.svg&&(i=o.filterTargetsToShow(o.data.targets),"y"===t?(n=o.y.copy().domain(o.getYDomain(i,"y")),a=this.getYAxis(n,o.yOrient,s.axis_y_tick_format,o.yAxisTickValues,!1,!0,!0)):"y2"===t?(n=o.y2.copy().domain(o.getYDomain(i,"y2")),a=this.getYAxis(n,o.y2Orient,s.axis_y2_tick_format,o.y2AxisTickValues,!1,!0,!0)):(n=o.x.copy().domain(o.getXDomain(i)),a=this.getXAxis(n,o.xOrient,o.xAxisTickFormat,o.xAxisTickValues,!1,!0,!0),this.updateXAxisTickValues(i,a)),(r=o.d3.select("body").append("div").classed("c3",!0)).append("svg").style("visibility","hidden").style("position","fixed").style("top",0).style("left",0).append("g").call(a).each(function(){o.d3.select(this).selectAll("text").each(function(){var t=this.getBoundingClientRect();c2){for(o=n-2,a=t[0],s=((r=t[t.length-1])-a)/(o+1),l=[a],c=0;c=0&&k.select(this).style("display",e%V?"none":"block")})}else I.svg.selectAll("."+r.axisX+" .tick text").style("display","block");_=I.generateDrawArea?I.generateDrawArea(F,!1):void 0,x=I.generateDrawBar?I.generateDrawBar(X):void 0,m=I.generateDrawLine?I.generateDrawLine(M,!1):void 0,y=I.generateXYForText(F,X,M,!0),S=I.generateXYForText(F,X,M,!1),i&&(I.subY.domain(I.getYDomain(H,"y")),I.subY2.domain(I.getYDomain(H,"y2"))),I.updateXgridFocus(),R.select("text."+r.text+"."+r.empty).attr("x",I.width/2).attr("y",I.height/2).text(D.data_empty_label_text).transition().style("opacity",H.length?0:1),I.updateGrid(v),I.updateRegion(v),I.updateBar(b),I.updateLine(b),I.updateArea(b),I.updateCircle(),I.hasDataLabel()&&I.updateText(b),I.redrawTitle&&I.redrawTitle(),I.redrawArc&&I.redrawArc(v,b,c),I.redrawSubchart&&I.redrawSubchart(n,e,v,b,F,X,M),R.selectAll("."+r.selectedCircles).filter(I.isBarType.bind(I)).selectAll("circle").remove(),D.interaction_enabled&&!t.flow&&g&&(I.redrawEventRect(),I.updateZoom&&I.updateZoom()),I.updateCircleY(),E=(I.config.axis_rotated?I.circleY:I.circleX).bind(I),O=(I.config.axis_rotated?I.circleX:I.circleY).bind(I),t.flow&&(P=I.generateFlow({targets:H,flow:t.flow,duration:t.flow.duration,drawBar:x,drawLine:m,drawArea:_,cx:E,cy:O,xv:B,xForText:y,yForText:S})),(v||P)&&I.isTabVisible()?k.transition().duration(v).each(function(){var e=[];[I.redrawBar(x,!0),I.redrawLine(m,!0),I.redrawArea(_,!0),I.redrawCircle(E,O,!0),I.redrawText(y,S,t.flow,!0),I.redrawRegion(!0),I.redrawGrid(!0)].forEach(function(t){t.forEach(function(t){e.push(t)})}),A=I.generateWait(),e.forEach(function(t){A.add(t)})}).call(A,function(){P&&P(),D.onrendered&&D.onrendered.call(I)}):(I.redrawBar(x),I.redrawLine(m),I.redrawArea(_),I.redrawCircle(E,O),I.redrawText(y,S,t.flow),I.redrawRegion(),I.redrawGrid(),D.onrendered&&D.onrendered.call(I)),I.mapToIds(I.data.targets).forEach(function(t){I.withoutFadeIn[t]=!0})},C.updateAndRedraw=function(t){var e,i=this,n=i.config;(t=t||{}).withTransition=w(t,"withTransition",!0),t.withTransform=w(t,"withTransform",!1),t.withLegend=w(t,"withLegend",!1),t.withUpdateXDomain=!0,t.withUpdateOrgXDomain=!0,t.withTransitionForExit=!1,t.withTransitionForTransform=w(t,"withTransitionForTransform",t.withTransition),i.updateSizes(),t.withLegend&&n.legend_show||(e=i.axis.generateTransitions(t.withTransitionForAxis?n.transition_duration:0),i.updateScales(),i.updateSvgSize(),i.transformAll(t.withTransitionForTransform,e)),i.redraw(t,e)},C.redrawWithoutRescale=function(){this.redraw({withY:!1,withSubchart:!1,withEventRect:!1,withTransitionForAxis:!1})},C.isTimeSeries=function(){return"timeseries"===this.config.axis_x_type},C.isCategorized=function(){return this.config.axis_x_type.indexOf("categor")>=0},C.isCustomX=function(){var t=this,e=t.config;return!t.isTimeSeries()&&(e.data_x||S(e.data_xs))},C.isTimeSeriesY=function(){return"timeseries"===this.config.axis_y_type},C.getTranslate=function(t){var e,i,n=this,a=n.config;return"main"===t?(e=x(n.margin.left),i=x(n.margin.top)):"context"===t?(e=x(n.margin2.left),i=x(n.margin2.top)):"legend"===t?(e=n.margin3.left,i=n.margin3.top):"x"===t?(e=0,i=a.axis_rotated?0:n.height):"y"===t?(e=0,i=a.axis_rotated?n.height:0):"y2"===t?(e=a.axis_rotated?0:n.width,i=a.axis_rotated?1:0):"subx"===t?(e=0,i=a.axis_rotated?0:n.height2):"arc"===t&&(e=n.arcWidth/2,i=n.arcHeight/2),"translate("+e+","+i+")"},C.initialOpacity=function(t){return null!==t.value&&this.withoutFadeIn[t.id]?1:0},C.initialOpacityForCircle=function(t){return null!==t.value&&this.withoutFadeIn[t.id]?this.opacityForCircle(t):0},C.opacityForCircle=function(t){var e=(u(this.config.point_show)?this.config.point_show(t):this.config.point_show)?1:0;return l(t.value)?this.isScatterType(t)?.5:e:0},C.opacityForText=function(){return this.hasDataLabel()?1:0},C.xx=function(t){return t?this.x(t.x):null},C.xv=function(t){var e=this,i=t.value;return e.isTimeSeries()?i=e.parseDate(t.value):e.isCategorized()&&"string"==typeof t.value&&(i=e.config.axis_x_categories.indexOf(t.value)),Math.ceil(e.x(i))},C.yv=function(t){var e=this,i=t.axis&&"y2"===t.axis?e.y2:e.y;return Math.ceil(i(t.value))},C.subxx=function(t){return t?this.subX(t.x):null},C.transformMain=function(t,e){var i,n,a,o=this;e&&e.axisX?i=e.axisX:(i=o.main.select("."+r.axisX),t&&(i=i.transition())),e&&e.axisY?n=e.axisY:(n=o.main.select("."+r.axisY),t&&(n=n.transition())),e&&e.axisY2?a=e.axisY2:(a=o.main.select("."+r.axisY2),t&&(a=a.transition())),(t?o.main.transition():o.main).attr("transform",o.getTranslate("main")),i.attr("transform",o.getTranslate("x")),n.attr("transform",o.getTranslate("y")),a.attr("transform",o.getTranslate("y2")),o.main.select("."+r.chartArcs).attr("transform",o.getTranslate("arc"))},C.transformAll=function(t,e){var i=this;i.transformMain(t,e),i.config.subchart_show&&i.transformContext(t,e),i.legend&&i.transformLegend(t)},C.updateSvgSize=function(){var t=this,e=t.svg.select(".c3-brush .background");t.svg.attr("width",t.currentWidth).attr("height",t.currentHeight),t.svg.selectAll(["#"+t.clipId,"#"+t.clipIdForGrid]).select("rect").attr("width",t.width).attr("height",t.height),t.svg.select("#"+t.clipIdForXAxis).select("rect").attr("x",t.getXAxisClipX.bind(t)).attr("y",t.getXAxisClipY.bind(t)).attr("width",t.getXAxisClipWidth.bind(t)).attr("height",t.getXAxisClipHeight.bind(t)),t.svg.select("#"+t.clipIdForYAxis).select("rect").attr("x",t.getYAxisClipX.bind(t)).attr("y",t.getYAxisClipY.bind(t)).attr("width",t.getYAxisClipWidth.bind(t)).attr("height",t.getYAxisClipHeight.bind(t)),t.svg.select("#"+t.clipIdForSubchart).select("rect").attr("width",t.width).attr("height",e.size()?e.attr("height"):0),t.svg.select("."+r.zoomRect).attr("width",t.width).attr("height",t.height),t.selectChart.style("max-height",t.currentHeight+"px")},C.updateDimension=function(t){var e=this;t||(e.config.axis_rotated?(e.axes.x.call(e.xAxis),e.axes.subx.call(e.subXAxis)):(e.axes.y.call(e.yAxis),e.axes.y2.call(e.y2Axis))),e.updateSizes(),e.updateScales(),e.updateSvgSize(),e.transformAll(!1)},C.observeInserted=function(t){var e,i=this;"undefined"!=typeof MutationObserver?(e=new MutationObserver(function(n){n.forEach(function(n){"childList"===n.type&&n.previousSibling&&(e.disconnect(),i.intervalForObserveInserted=window.setInterval(function(){t.node().parentNode&&(window.clearInterval(i.intervalForObserveInserted),i.updateDimension(),i.brush&&i.brush.update(),i.config.oninit.call(i),i.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),t.transition().style("opacity",1))},10))})})).observe(t.node(),{attributes:!0,childList:!0,characterData:!0}):window.console.error("MutationObserver not defined.")},C.bindResize=function(){var t=this,e=t.config;if(t.resizeFunction=t.generateResize(),t.resizeFunction.add(function(){e.onresize.call(t)}),e.resize_auto&&t.resizeFunction.add(function(){void 0!==t.resizeTimeout&&window.clearTimeout(t.resizeTimeout),t.resizeTimeout=window.setTimeout(function(){delete t.resizeTimeout,t.api.flush()},100)}),t.resizeFunction.add(function(){e.onresized.call(t)}),window.attachEvent)window.attachEvent("onresize",t.resizeFunction);else if(window.addEventListener)window.addEventListener("resize",t.resizeFunction,!1);else{var i=window.onresize;i?i.add&&i.remove||(i=t.generateResize()).add(window.onresize):i=t.generateResize(),i.add(t.resizeFunction),window.onresize=i}},C.generateResize=function(){function t(){e.forEach(function(t){t()})}var e=[];return t.add=function(t){e.push(t)},t.remove=function(t){for(var i=0;ie.getTotalLength())break;i--}while(i>0);return i})),"SVGPathSegList"in window||(window.SVGPathSegList=function(t){this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.classname="SVGPathSegList",Object.defineProperty(window.SVGPathSegList.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"pathSegList",{get:function(){return this._pathSegList||(this._pathSegList=new window.SVGPathSegList(this)),this._pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),window.SVGPathSegList.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())},window.SVGPathSegList.prototype._updateListFromPathMutations=function(t){if(this._pathElement){var e=!1;t.forEach(function(t){"d"==t.attributeName&&(e=!0)}),e&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}},window.SVGPathSegList.prototype._writeListToPath=function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",window.SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.segmentChanged=function(t){this._writeListToPath()},window.SVGPathSegList.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach(function(t){t._owningPathSegList=null}),this._list=[],this._writeListToPath()},window.SVGPathSegList.prototype.initialize=function(t){return this._checkPathSynchronizedToList(),this._list=[t],t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype._checkValidIndex=function(t){if(isNaN(t)||t<0||t>=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),this._list[e]=t,t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){var e="",i=!0;return t.forEach(function(t){i?(i=!1,e+=t._asPathString()):e+=" "+t._asPathString()}),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t||0==t.length)return[];var e=this,i=function(){this.pathSegList=[]};i.prototype.appendSegment=function(t){this.pathSegList.push(t)};var n=function(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};n.prototype._isCurrentSpace=function(){var t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},n.prototype._skipOptionalSpaces=function(){for(;this._currentIndex="0"&&t<="9")&&e!=window.SVGPathSeg.PATHSEG_CLOSEPATH?e==window.SVGPathSeg.PATHSEG_MOVETO_ABS?window.SVGPathSeg.PATHSEG_LINETO_ABS:e==window.SVGPathSeg.PATHSEG_MOVETO_REL?window.SVGPathSeg.PATHSEG_LINETO_REL:e:window.SVGPathSeg.PATHSEG_UNKNOWN},n.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var t=this.peekSegmentType();return t==window.SVGPathSeg.PATHSEG_MOVETO_ABS||t==window.SVGPathSeg.PATHSEG_MOVETO_REL},n.prototype._parseNumber=function(){var t=0,e=0,i=1,n=0,a=1,r=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!=this._string.charAt(this._currentIndex))){for(var s=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=s)for(var c=this._currentIndex-1,d=1;c>=s;)e+=d*(this._string.charAt(c--)-"0"),d*=10;if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)i*=10,n+=(this._string.charAt(this._currentIndex)-"0")/i,this._currentIndex+=1}if(this._currentIndex!=o&&this._currentIndex+1=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)t*=10,t+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var l=e+n;if(l*=a,t&&(l*=Math.pow(10,r*t)),o!=this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),l}},n.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}},n.prototype.parseSegment=function(){var t=this._string[this._currentIndex],i=this._pathSegTypeFromChar(t);if(i==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if((i=this._nextCommandHelper(t,this._previousCommand))==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=i,i){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(e);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicRel(e,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:return n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicAbs(e,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:return n={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothRel(e,n.x,n.y,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:return n={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothAbs(e,n.x,n.y,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticRel(e,n.x,n.y,n.x1,n.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:return n={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticAbs(e,n.x,n.y,n.x1,n.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcRel(e,n.x,n.y,n.x1,n.y1,n.arcAngle,n.arcLarge,n.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:var n={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcAbs(e,n.x,n.y,n.x1,n.y1,n.arcAngle,n.arcLarge,n.arcSweep);default:throw"Unknown path seg type."}};var a=new i,r=new n(t);if(!r.initialCommandIsMoveTo())return[];for(;r.hasMoreData();){var o=r.parseSegment();if(!o)return[];a.appendSegment(o)}return a.pathSegList}),P.axis=function(){},P.axis.labels=function(t){var e=this.internal;arguments.length&&(Object.keys(t).forEach(function(i){e.axis.setLabelText(i,t[i])}),e.axis.updateLabels())},P.axis.max=function(t){var e=this.internal,i=e.config;if(!arguments.length)return{x:i.axis_x_max,y:i.axis_y_max,y2:i.axis_y2_max};"object"===(void 0===t?"undefined":o(t))?(l(t.x)&&(i.axis_x_max=t.x),l(t.y)&&(i.axis_y_max=t.y),l(t.y2)&&(i.axis_y2_max=t.y2)):i.axis_y_max=i.axis_y2_max=t,e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},P.axis.min=function(t){var e=this.internal,i=e.config;if(!arguments.length)return{x:i.axis_x_min,y:i.axis_y_min,y2:i.axis_y2_min};"object"===(void 0===t?"undefined":o(t))?(l(t.x)&&(i.axis_x_min=t.x),l(t.y)&&(i.axis_y_min=t.y),l(t.y2)&&(i.axis_y2_min=t.y2)):i.axis_y_min=i.axis_y2_min=t,e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},P.axis.range=function(t){if(!arguments.length)return{max:this.axis.max(),min:this.axis.min()};void 0!==t.max&&this.axis.max(t.max),void 0!==t.min&&this.axis.min(t.min)},P.category=function(t,e){var i=this.internal,n=i.config;return arguments.length>1&&(n.axis_x_categories[t]=e,i.redraw()),n.axis_x_categories[t]},P.categories=function(t){var e=this.internal,i=e.config;return arguments.length?(i.axis_x_categories=t,e.redraw(),i.axis_x_categories):i.axis_x_categories},P.resize=function(t){var e=this.internal.config;e.size_width=t?t.width:null,e.size_height=t?t.height:null,this.flush()},P.flush=function(){this.internal.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},P.destroy=function(){var t=this.internal;if(window.clearInterval(t.intervalForObserveInserted),void 0!==t.resizeTimeout&&window.clearTimeout(t.resizeTimeout),window.detachEvent)window.detachEvent("onresize",t.resizeFunction);else if(window.removeEventListener)window.removeEventListener("resize",t.resizeFunction);else{var e=window.onresize;e&&e.add&&e.remove&&e.remove(t.resizeFunction)}return t.selectChart.classed("c3",!1).html(""),Object.keys(t).forEach(function(e){t[e]=null}),null},P.color=function(t){return this.internal.color(t)},P.data=function(t){var e=this.internal.data.targets;return void 0===t?e:e.filter(function(e){return[].concat(t).indexOf(e.id)>=0})},P.data.shown=function(t){return this.internal.filterTargetsToShow(this.data(t))},P.data.values=function(t){var e,i=null;return t&&(i=(e=this.data(t))[0]?e[0].values.map(function(t){return t.value}):null),i},P.data.names=function(t){return this.internal.clearLegendItemTextBoxCache(),this.internal.updateDataAttributes("names",t)},P.data.colors=function(t){return this.internal.updateDataAttributes("colors",t)},P.data.axes=function(t){return this.internal.updateDataAttributes("axes",t)},P.flow=function(t){var e,i,n,a,r,o,s,c=this.internal,d=[],u=c.getMaxDataCount(),h=0,g=0;if(t.json)i=c.convertJsonToData(t.json,t.keys);else if(t.rows)i=c.convertRowsToData(t.rows);else{if(!t.columns)return;i=c.convertColumnsToData(t.columns)}e=c.convertDataToTargets(i,!0),c.data.targets.forEach(function(t){var i,n,a=!1;for(i=0;i1?a.values[a.values.length-1].x-r.x:r.x-c.getXDomain(c.data.targets)[0]:1,n=[r.x-o,r.x],c.updateXDomain(null,!0,!0,!1,n)),c.updateTargets(c.data.targets),c.redraw({flow:{index:r.index,length:h,duration:l(t.duration)?t.duration:c.config.transition_duration,done:t.done,orgDataCount:u},withLegend:!0,withTransition:u>1,withTrimXDomain:!1,withUpdateXAxis:!0})},C.generateFlow=function(t){var e=this,i=e.config,n=e.d3;return function(){var a,o,s,c=t.targets,d=t.flow,l=t.drawBar,u=t.drawLine,h=t.drawArea,g=t.cx,f=t.cy,p=t.xv,_=t.xForText,x=t.yForText,y=t.duration,S=1,w=d.index,v=d.length,b=e.getValueOnIndex(e.data.targets[0].values,w),T=e.getValueOnIndex(e.data.targets[0].values,w+v),A=e.x.domain(),P=d.duration||y,C=d.done||function(){},L=e.generateWait(),V=e.xgrid||n.selectAll([]),G=e.xgridLines||n.selectAll([]),E=e.mainRegion||n.selectAll([]),O=e.mainText||n.selectAll([]),I=e.mainBar||n.selectAll([]),R=e.mainLine||n.selectAll([]),k=e.mainArea||n.selectAll([]),D=e.mainCircle||n.selectAll([]);e.flowing=!0,e.data.targets.forEach(function(t){t.values.splice(0,v)}),s=e.updateXDomain(c,!0,!0),e.updateXGrid&&e.updateXGrid(!0),d.orgDataCount?a=1===d.orgDataCount||(b&&b.x)===(T&&T.x)?e.x(A[0])-e.x(s[0]):e.isTimeSeries()?e.x(A[0])-e.x(s[0]):e.x(b.x)-e.x(T.x):1!==e.data.targets[0].values.length?a=e.x(A[0])-e.x(s[0]):e.isTimeSeries()?(b=e.getValueOnIndex(e.data.targets[0].values,0),T=e.getValueOnIndex(e.data.targets[0].values,e.data.targets[0].values.length-1),a=e.x(b.x)-e.x(T.x)):a=m(s)/2,S=m(A)/m(s),o="translate("+a+",0) scale("+S+",1)",e.hideXGridFocus(),n.transition().ease("linear").duration(P).each(function(){L.add(e.axes.x.transition().call(e.xAxis)),L.add(I.transition().attr("transform",o)),L.add(R.transition().attr("transform",o)),L.add(k.transition().attr("transform",o)),L.add(D.transition().attr("transform",o)),L.add(O.transition().attr("transform",o)),L.add(E.filter(e.isRegionOnX).transition().attr("transform",o)),L.add(V.transition().attr("transform",o)),L.add(G.transition().attr("transform",o))}).call(L,function(){var t,n=[],a=[],o=[];if(v){for(t=0;t=0&&(e=!0)}),!e)}),o.regions},P.selected=function(t){var e=this.internal,i=e.d3;return i.merge(e.main.selectAll("."+r.shapes+e.getTargetSelectorSuffix(t)).selectAll("."+r.shape).filter(function(){return i.select(this).classed(r.SELECTED)}).map(function(t){return t.map(function(t){var e=t.__data__;return e.data?e.data:e})}))},P.select=function(t,e,i){var n=this.internal,a=n.d3,o=n.config;o.data_selection_enabled&&n.main.selectAll("."+r.shapes).selectAll("."+r.shape).each(function(s,c){var d=a.select(this),l=s.data?s.data.id:s.id,u=n.getToggle(this,s).bind(n),h=o.data_selection_grouped||!t||t.indexOf(l)>=0,g=!e||e.indexOf(c)>=0,f=d.classed(r.SELECTED);d.classed(r.line)||d.classed(r.area)||(h&&g?o.data_selection_isselectable(s)&&!f&&u(!0,d.classed(r.SELECTED,!0),s,c):void 0!==i&&i&&f&&u(!1,d.classed(r.SELECTED,!1),s,c))})},P.unselect=function(t,e){var i=this.internal,n=i.d3,a=i.config;a.data_selection_enabled&&i.main.selectAll("."+r.shapes).selectAll("."+r.shape).each(function(o,s){var c=n.select(this),d=o.data?o.data.id:o.id,l=i.getToggle(this,o).bind(i),u=a.data_selection_grouped||!t||t.indexOf(d)>=0,h=!e||e.indexOf(s)>=0,g=c.classed(r.SELECTED);c.classed(r.line)||c.classed(r.area)||u&&h&&a.data_selection_isselectable(o)&&g&&l(!1,c.classed(r.SELECTED,!1),o,s)})},P.show=function(t,e){var i,n=this.internal;t=n.mapToTargetIds(t),e=e||{},n.removeHiddenTargetIds(t),(i=n.svg.selectAll(n.selectorTargets(t))).transition().style("opacity",1,"important").call(n.endall,function(){i.style("opacity",null).style("opacity",1)}),e.withLegend&&n.showLegend(t),n.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},P.hide=function(t,e){var i,n=this.internal;t=n.mapToTargetIds(t),e=e||{},n.addHiddenTargetIds(t),(i=n.svg.selectAll(n.selectorTargets(t))).transition().style("opacity",0,"important").call(n.endall,function(){i.style("opacity",null).style("opacity",0)}),e.withLegend&&n.hideLegend(t),n.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},P.toggle=function(t,e){var i=this,n=this.internal;n.mapToTargetIds(t).forEach(function(t){n.isTargetToShow(t)?i.hide(t,e):i.show(t,e)})},P.tooltip=function(){},P.tooltip.show=function(t){var e,i,n=this.internal;t.mouse&&(i=t.mouse),t.data?n.isMultipleX()?(i=[n.x(t.data.x),n.getYScale(t.data.id)(t.data.value)],e=null):e=l(t.data.index)?t.data.index:n.getIndexByX(t.data.x):void 0!==t.x?e=n.getIndexByX(t.x):void 0!==t.index&&(e=t.index),n.dispatchEvent("mouseover",e,i),n.dispatchEvent("mousemove",e,i),n.config.tooltip_onshow.call(n,t.data)},P.tooltip.hide=function(){this.internal.dispatchEvent("mouseout",0),this.internal.config.tooltip_onhide.call(this)},P.transform=function(t,e){var i=this.internal,n=["pie","donut"].indexOf(t)>=0?{withTransform:!0}:null;i.transformTo(e,t,n)},C.transformTo=function(t,e,i){var n=this,a=!n.hasArcType(),r=i||{withTransitionForAxis:a};r.withTransitionForTransform=!1,n.transiting=!1,n.setTargetType(t,e),n.updateTargets(n.data.targets),n.updateAndRedraw(r)},P.x=function(t){var e=this.internal;return arguments.length&&(e.updateTargetX(e.data.targets,t),e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),e.data.xs},P.xs=function(t){var e=this.internal;return arguments.length&&(e.updateTargetXs(e.data.targets,t),e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),e.data.xs},P.zoom=function(t){var e=this.internal;return t&&(e.isTimeSeries()&&(t=t.map(function(t){return e.parseDate(t)})),e.brush.extent(t),e.redraw({withUpdateXDomain:!0,withY:e.config.zoom_rescale}),e.config.zoom_onzoom.call(this,e.x.orgDomain())),e.brush.extent()},P.zoom.enable=function(t){var e=this.internal;e.config.zoom_enabled=t,e.updateAndRedraw()},P.unzoom=function(){var t=this.internal;t.brush.clear().update(),t.redraw({withUpdateXDomain:!0})},P.zoom.max=function(t){var e=this.internal,i=e.config,n=e.d3;if(0!==t&&!t)return i.zoom_x_max;i.zoom_x_max=n.max([e.orgXDomain[1],t])},P.zoom.min=function(t){var e=this.internal,i=e.config,n=e.d3;if(0!==t&&!t)return i.zoom_x_min;i.zoom_x_min=n.min([e.orgXDomain[0],t])},P.zoom.range=function(t){if(!arguments.length)return{max:this.domain.max(),min:this.domain.min()};void 0!==t.max&&this.domain.max(t.max),void 0!==t.min&&this.domain.min(t.min)},C.initPie=function(){var t=this,e=t.d3;t.pie=e.layout.pie().value(function(t){return t.values.reduce(function(t,e){return t+e.value},0)}),t.pie.sort(t.getOrderFunction()||null)},C.updateRadius=function(){var t=this,e=t.config,i=e.gauge_width||e.donut_width;t.radiusExpanded=Math.min(t.arcWidth,t.arcHeight)/2,t.radius=.95*t.radiusExpanded,t.innerRadiusRatio=i?(t.radius-i)/t.radius:.6,t.innerRadius=t.hasType("donut")||t.hasType("gauge")?t.radius*t.innerRadiusRatio:0},C.updateArc=function(){var t=this;t.svgArc=t.getSvgArc(),t.svgArcExpanded=t.getSvgArcExpanded(),t.svgArcExpandedSub=t.getSvgArcExpanded(.98)},C.updateAngle=function(t){var e,i,n,a,r=this,o=r.config,s=!1,c=0;return o?(r.pie(r.filterTargetsToShow(r.data.targets)).forEach(function(e){s||e.data.id!==t.data.id||(s=!0,(t=e).index=c),c++}),isNaN(t.startAngle)&&(t.startAngle=0),isNaN(t.endAngle)&&(t.endAngle=t.startAngle),r.isGaugeType(t.data)&&(e=o.gauge_min,i=o.gauge_max,n=Math.PI*(o.gauge_fullCircle?2:1)/(i-e),a=t.value.375?1.175-36/o.radius:.8)*o.radius/a:0)+","+n*r+")"),d},C.getArcRatio=function(t){var e=this,i=e.config,n=Math.PI*(e.hasType("gauge")&&!i.gauge_fullCircle?1:2);return t?(t.endAngle-t.startAngle)/n:null},C.convertToArcData=function(t){return this.addName({id:t.data.id,value:t.value,ratio:this.getArcRatio(t),index:t.index})},C.textForArcLabel=function(t){var e,i,n,a,r,o=this;return o.shouldShowArcLabel()?(e=o.updateAngle(t),i=e?e.value:null,n=o.getArcRatio(e),a=t.data.id,o.hasType("gauge")||o.meetsArcLabelThreshold(n)?(r=o.getArcLabelFormat(),r?r(i,n,a):o.defaultArcValueFormat(i,n)):""):""},C.textForGaugeMinMax=function(t,e){var i=this.getGaugeLabelExtents();return i?i(t,e):t},C.expandArc=function(t){var e,i=this;i.transiting?e=window.setInterval(function(){i.transiting||(window.clearInterval(e),i.legend.selectAll(".c3-legend-item-focused").size()>0&&i.expandArc(t))},10):(t=i.mapToTargetIds(t),i.svg.selectAll(i.selectorTargets(t,"."+r.chartArc)).each(function(t){i.shouldExpand(t.data.id)&&i.d3.select(this).selectAll("path").transition().duration(i.expandDuration(t.data.id)).attr("d",i.svgArcExpanded).transition().duration(2*i.expandDuration(t.data.id)).attr("d",i.svgArcExpandedSub).each(function(t){i.isDonutType(t.data)})}))},C.unexpandArc=function(t){var e=this;e.transiting||(t=e.mapToTargetIds(t),e.svg.selectAll(e.selectorTargets(t,"."+r.chartArc)).selectAll("path").transition().duration(function(t){return e.expandDuration(t.data.id)}).attr("d",e.svgArc),e.svg.selectAll("."+r.arc))},C.expandDuration=function(t){var e=this,i=e.config;return e.isDonutType(t)?i.donut_expand_duration:e.isGaugeType(t)?i.gauge_expand_duration:e.isPieType(t)?i.pie_expand_duration:50},C.shouldExpand=function(t){var e=this,i=e.config;return e.isDonutType(t)&&i.donut_expand||e.isGaugeType(t)&&i.gauge_expand||e.isPieType(t)&&i.pie_expand},C.shouldShowArcLabel=function(){var t=this,e=t.config,i=!0;return t.hasType("donut")?i=e.donut_label_show:t.hasType("pie")&&(i=e.pie_label_show),i},C.meetsArcLabelThreshold=function(t){var e=this,i=e.config;return t>=(e.hasType("donut")?i.donut_label_threshold:i.pie_label_threshold)},C.getArcLabelFormat=function(){var t=this,e=t.config,i=e.pie_label_format;return t.hasType("gauge")?i=e.gauge_label_format:t.hasType("donut")&&(i=e.donut_label_format),i},C.getGaugeLabelExtents=function(){return this.config.gauge_label_extents},C.getArcTitle=function(){var t=this;return t.hasType("donut")?t.config.donut_title:""},C.updateTargetsForArc=function(t){var e,i=this,n=i.main,a=i.classChartArc.bind(i),o=i.classArcs.bind(i),s=i.classFocus.bind(i);(e=n.select("."+r.chartArcs).selectAll("."+r.chartArc).data(i.pie(t)).attr("class",function(t){return a(t)+s(t.data)}).enter().append("g").attr("class",a)).append("g").attr("class",o),e.append("text").attr("dy",i.hasType("gauge")?"-.1em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},C.initArc=function(){var t=this;t.arcs=t.main.select("."+r.chart).append("g").attr("class",r.chartArcs).attr("transform",t.getTranslate("arc")),t.arcs.append("text").attr("class",r.chartArcsTitle).style("text-anchor","middle").text(t.getArcTitle())},C.redrawArc=function(t,e,i){var n,a=this,o=a.d3,s=a.config,c=a.main;(n=c.selectAll("."+r.arcs).selectAll("."+r.arc).data(a.arcData.bind(a))).enter().append("path").attr("class",a.classArc.bind(a)).style("fill",function(t){return a.color(t.data)}).style("cursor",function(t){return s.interaction_enabled&&s.data_selection_isselectable(t)?"pointer":null}).each(function(t){a.isGaugeType(t.data)&&(t.startAngle=t.endAngle=s.gauge_startingAngle),this._current=t}),n.attr("transform",function(t){return!a.isGaugeType(t.data)&&i?"scale(0)":""}).on("mouseover",s.interaction_enabled?function(t){var e,i;a.transiting||(e=a.updateAngle(t))&&(i=a.convertToArcData(e),a.expandArc(e.data.id),a.api.focus(e.data.id),a.toggleFocusLegend(e.data.id,!0),a.config.data_onmouseover(i,this))}:null).on("mousemove",s.interaction_enabled?function(t){var e,i=a.updateAngle(t);i&&(e=[a.convertToArcData(i)],a.showTooltip(e,this))}:null).on("mouseout",s.interaction_enabled?function(t){var e,i;a.transiting||(e=a.updateAngle(t))&&(i=a.convertToArcData(e),a.unexpandArc(e.data.id),a.api.revert(),a.revertLegend(),a.hideTooltip(),a.config.data_onmouseout(i,this))}:null).on("click",s.interaction_enabled?function(t,e){var i,n=a.updateAngle(t);n&&(i=a.convertToArcData(n),a.toggleShape&&a.toggleShape(this,i,e),a.config.data_onclick.call(a.api,i,this))}:null).each(function(){a.transiting=!0}).transition().duration(t).attrTween("d",function(t){var e,i=a.updateAngle(t);return i?(isNaN(this._current.startAngle)&&(this._current.startAngle=0),isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),e=o.interpolate(this._current,i),this._current=e(0),function(i){var n=e(i);return n.data=t.data,a.getArc(n,!0)}):function(){return"M 0 0"}}).attr("transform",i?"scale(1)":"").style("fill",function(t){return a.levelColor?a.levelColor(t.data.values[0].value):a.color(t.data.id)}).call(a.endall,function(){a.transiting=!1}),n.exit().transition().duration(e).style("opacity",0).remove(),c.selectAll("."+r.chartArc).select("text").style("opacity",0).attr("class",function(t){return a.isGaugeType(t.data)?r.gaugeValue:""}).text(a.textForArcLabel.bind(a)).attr("transform",a.transformForArcLabel.bind(a)).style("font-size",function(t){return a.isGaugeType(t.data)?Math.round(a.radius/5)+"px":""}).transition().duration(t).style("opacity",function(t){return a.isTargetToShow(t.data.id)&&a.isArcType(t.data)?1:0}),c.select("."+r.chartArcsTitle).style("opacity",a.hasType("donut")||a.hasType("gauge")?1:0),a.hasType("gauge")&&(a.arcs.select("."+r.chartArcsBackground).attr("d",function(){var t={data:[{value:s.gauge_max}],startAngle:s.gauge_startingAngle,endAngle:-1*s.gauge_startingAngle};return a.getArc(t,!0,!0)}),a.arcs.select("."+r.chartArcsGaugeUnit).attr("dy",".75em").text(s.gauge_label_show?s.gauge_units:""),a.arcs.select("."+r.chartArcsGaugeMin).attr("dx",-1*(a.innerRadius+(a.radius-a.innerRadius)/(s.gauge_fullCircle?1:2))+"px").attr("dy","1.2em").text(s.gauge_label_show?a.textForGaugeMinMax(s.gauge_min,!1):""),a.arcs.select("."+r.chartArcsGaugeMax).attr("dx",a.innerRadius+(a.radius-a.innerRadius)/(s.gauge_fullCircle?1:2)+"px").attr("dy","1.2em").text(s.gauge_label_show?a.textForGaugeMinMax(s.gauge_max,!0):""))},C.initGauge=function(){var t=this.arcs;this.hasType("gauge")&&(t.append("path").attr("class",r.chartArcsBackground),t.append("text").attr("class",r.chartArcsGaugeUnit).style("text-anchor","middle").style("pointer-events","none"),t.append("text").attr("class",r.chartArcsGaugeMin).style("text-anchor","middle").style("pointer-events","none"),t.append("text").attr("class",r.chartArcsGaugeMax).style("text-anchor","middle").style("pointer-events","none"))},C.getGaugeLabelHeight=function(){return this.config.gauge_label_show?20:0},C.hasCaches=function(t){for(var e=0;e=0?r.focused:"")},C.classDefocused=function(t){return" "+(this.defocusedTargetIds.indexOf(t.id)>=0?r.defocused:"")},C.classChartText=function(t){return r.chartText+this.classTarget(t.id)},C.classChartLine=function(t){return r.chartLine+this.classTarget(t.id)},C.classChartBar=function(t){return r.chartBar+this.classTarget(t.id)},C.classChartArc=function(t){return r.chartArc+this.classTarget(t.data.id)},C.getTargetSelectorSuffix=function(t){return t||0===t?("-"+t).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g,"-"):""},C.selectorTarget=function(t,e){return(e||"")+"."+r.target+this.getTargetSelectorSuffix(t)},C.selectorTargets=function(t,e){var i=this;return t=t||[],t.length?t.map(function(t){return i.selectorTarget(t,e)}):null},C.selectorLegend=function(t){return"."+r.legendItem+this.getTargetSelectorSuffix(t)},C.selectorLegends=function(t){var e=this;return t&&t.length?t.map(function(t){return e.selectorLegend(t)}):null},C.getClipPath=function(t){return"url("+(window.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0?"":document.URL.split("#")[0])+"#"+t+")"},C.appendClip=function(t,e){return t.append("clipPath").attr("id",e).append("rect")},C.getAxisClipX=function(t){var e=Math.max(30,this.margin.left);return t?-(1+e):-(e-1)},C.getAxisClipY=function(t){return t?-20:-this.margin.top},C.getXAxisClipX=function(){var t=this;return t.getAxisClipX(!t.config.axis_rotated)},C.getXAxisClipY=function(){var t=this;return t.getAxisClipY(!t.config.axis_rotated)},C.getYAxisClipX=function(){var t=this;return t.config.axis_y_inner?-1:t.getAxisClipX(t.config.axis_rotated)},C.getYAxisClipY=function(){var t=this;return t.getAxisClipY(t.config.axis_rotated)},C.getAxisClipWidth=function(t){var e=this,i=Math.max(30,e.margin.left),n=Math.max(30,e.margin.right);return t?e.width+2+i+n:e.margin.left+20},C.getAxisClipHeight=function(t){return(t?this.margin.bottom:this.margin.top+this.height)+20},C.getXAxisClipWidth=function(){var t=this;return t.getAxisClipWidth(!t.config.axis_rotated)},C.getXAxisClipHeight=function(){var t=this;return t.getAxisClipHeight(!t.config.axis_rotated)},C.getYAxisClipWidth=function(){var t=this;return t.getAxisClipWidth(t.config.axis_rotated)+(t.config.axis_y_inner?20:0)},C.getYAxisClipHeight=function(){var t=this;return t.getAxisClipHeight(t.config.axis_rotated)},C.generateColor=function(){var t=this,e=t.config,i=t.d3,n=e.data_colors,a=S(e.color_pattern)?e.color_pattern:i.scale.category10().range(),r=e.data_color,o=[];return function(t){var e,i=t.id||t.data&&t.data.id||t;return n[i]instanceof Function?e=n[i](t):n[i]?e=n[i]:(o.indexOf(i)<0&&o.push(i),e=a[o.indexOf(i)%a.length],n[i]=e),r instanceof Function?r(e,t):e}},C.generateLevelColor=function(){var t=this.config,e=t.color_pattern,i=t.color_threshold,n="value"===i.unit,a=i.values&&i.values.length?i.values:[],r=i.max||100;return S(t.color_threshold)?function(t){var i,o=e[e.length-1];for(i=0;i=0?n.data.xs[i]=(e&&n.data.xs[i]?n.data.xs[i]:[]).concat(t.map(function(t){return t[r]}).filter(l).map(function(t,e){return n.generateTargetX(t,i,e)})):a.data_x?n.data.xs[i]=n.getOtherTargetXs():S(a.data_xs)&&(n.data.xs[i]=n.getXValuesOfXKey(r,n.data.targets)):n.data.xs[i]=t.map(function(t,e){return e})}),r.forEach(function(t){if(!n.data.xs[t])throw new Error('x is not defined for id = "'+t+'".')}),(i=r.map(function(e,i){var r=a.data_idConverter(e);return{id:r,id_org:e,values:t.map(function(t,o){var s,c=t[n.getXKey(e)],d=null===t[e]||isNaN(t[e])?null:+t[e];return n.isCustomX()&&n.isCategorized()&&void 0!==c?(0===i&&0===o&&(a.axis_x_categories=[]),-1===(s=a.axis_x_categories.indexOf(c))&&(s=a.axis_x_categories.length,a.axis_x_categories.push(c))):s=n.generateTargetX(c,e,o),(void 0===t[e]||n.data.xs[e].length<=o)&&(s=void 0),{x:s,value:d,id:r}}).filter(function(t){return p(t.x)})}})).forEach(function(t){var e;a.data_xSort&&(t.values=t.values.sort(function(t,e){return(t.x||0===t.x?t.x:1/0)-(e.x||0===e.x?e.x:1/0)})),e=0,t.values.forEach(function(t){t.index=e++}),n.data.xs[t.id].sort(function(t,e){return t-e})}),n.hasNegativeValue=n.hasNegativeValueInTargets(i),n.hasPositiveValue=n.hasPositiveValueInTargets(i),a.data_type&&n.setTargetType(n.mapToIds(i).filter(function(t){return!(t in a.data_types)}),a.data_type),i.forEach(function(t){n.addCache(t.id_org,t)}),i},C.isX=function(t){var e=this.config;return e.data_x&&t===e.data_x||S(e.data_xs)&&v(e.data_xs,t)},C.isNotX=function(t){return!this.isX(t)},C.getXKey=function(t){var e=this.config;return e.data_x?e.data_x:S(e.data_xs)?e.data_xs[t]:null},C.getXValuesOfXKey=function(t,e){var i,n=this;return(e&&S(e)?n.mapToIds(e):[]).forEach(function(e){n.getXKey(e)===t&&(i=n.data.xs[e])}),i},C.getIndexByX=function(t){var e=this,i=e.filterByX(e.data.targets,t);return i.length?i[0].index:null},C.getXValue=function(t,e){var i=this;return t in i.data.xs&&i.data.xs[t]&&l(i.data.xs[t][e])?i.data.xs[t][e]:e},C.getOtherTargetXs=function(){var t=this,e=Object.keys(t.data.xs);return e.length?t.data.xs[e[0]]:null},C.getOtherTargetX=function(t){var e=this.getOtherTargetXs();return e&&t1},C.isMultipleX=function(){return S(this.config.data_xs)||!this.config.data_xSort||this.hasType("scatter")},C.addName=function(t){var e,i=this;return t&&(e=i.config.data_names[t.id],t.name=void 0!==e?e:t.id),t},C.getValueOnIndex=function(t,e){var i=t.filter(function(t){return t.index===e});return i.length?i[0]:null},C.updateTargetX=function(t,e){var i=this;t.forEach(function(t){t.values.forEach(function(n,a){n.x=i.generateTargetX(e[a],t.id,a)}),i.data.xs[t.id]=e})},C.updateTargetXs=function(t,e){var i=this;t.forEach(function(t){e[t.id]&&i.updateTargetX([t],e[t.id])})},C.generateTargetX=function(t,e,i){var n=this;return n.isTimeSeries()?t?n.parseDate(t):n.parseDate(n.getXValue(e,i)):n.isCustomX()&&!n.isCategorized()?l(t)?+t:n.getXValue(e,i):i},C.cloneTarget=function(t){return{id:t.id,id_org:t.id_org,values:t.values.map(function(t){return{x:t.x,value:t.value,id:t.id}})}},C.updateXs=function(){var t=this;t.data.targets.length&&(t.xs=[],t.data.targets[0].values.forEach(function(e){t.xs[e.index]=e.x}))},C.getPrevX=function(t){var e=this.xs[t-1];return void 0!==e?e:null},C.getNextX=function(t){var e=this.xs[t+1];return void 0!==e?e:null},C.getMaxDataCount=function(){var t=this;return t.d3.max(t.data.targets,function(t){return t.values.length})},C.getMaxDataCountTarget=function(t){var e,i=t.length,n=0;return i>1?t.forEach(function(t){t.values.length>n&&(e=t,n=t.values.length)}):e=i?t[0]:null,e},C.getEdgeX=function(t){var e=this;return t.length?[e.d3.min(t,function(t){return t.values[0].x}),e.d3.max(t,function(t){return t.values[t.values.length-1].x})]:[0,0]},C.mapToIds=function(t){return t.map(function(t){return t.id})},C.mapToTargetIds=function(t){var e=this;return t?[].concat(t):e.mapToIds(e.data.targets)},C.hasTarget=function(t,e){var i,n=this.mapToIds(t);for(i=0;ie?1:t>=e?0:NaN})},C.addHiddenTargetIds=function(t){t=t instanceof Array?t:new Array(t);for(var e=0;e0})},C.isOrderDesc=function(){var t=this.config;return"string"==typeof t.data_order&&"desc"===t.data_order.toLowerCase()},C.isOrderAsc=function(){var t=this.config;return"string"==typeof t.data_order&&"asc"===t.data_order.toLowerCase()},C.getOrderFunction=function(){var t=this,e=t.config,i=t.isOrderAsc(),n=t.isOrderDesc();if(i||n)return function(t,e){var i=function(t,e){return t+Math.abs(e.value)},a=t.values.reduce(i,0),r=e.values.reduce(i,0);return n?r-a:a-r};if(u(e.data_order))return e.data_order;if(h(e.data_order)){var a=e.data_order;return function(t,e){return a.indexOf(t.id)-a.indexOf(e.id)}}},C.orderTargets=function(t){var e=this.getOrderFunction();return e&&(t.sort(e),(this.isOrderAsc()||this.isOrderDesc())&&t.reverse()),t},C.filterByX=function(t,e){return this.d3.merge(t.map(function(t){return t.values})).filter(function(t){return t.x-e==0})},C.filterRemoveNull=function(t){return t.filter(function(t){return l(t.value)})},C.filterByXDomain=function(t,e){return t.map(function(t){return{id:t.id,id_org:t.id_org,values:t.values.filter(function(t){return e[0]<=t.x&&t.x<=e[1]})}})},C.hasDataLabel=function(){var t=this.config;return!("boolean"!=typeof t.data_labels||!t.data_labels)||!("object"!==o(t.data_labels)||!S(t.data_labels))},C.getDataLabelLength=function(t,e,i){var n=this,a=[0,0];return n.selectChart.select("svg").selectAll(".dummy").data([t,e]).enter().append("text").text(function(t){return n.dataLabelFormat(t.id)(t)}).each(function(t,e){a[e]=1.3*this.getBoundingClientRect()[i]}).remove(),a},C.isNoneArc=function(t){return this.hasTarget(this.data.targets,t.id)},C.isArc=function(t){return"data"in t&&this.hasTarget(this.data.targets,t.data.id)},C.findSameXOfValues=function(t,e){var i,n=t[e].x,a=[];for(i=e-1;i>=0&&n===t[i].x;i--)a.push(t[i]);for(i=e;i0)for(o=s.hasNegativeValueInTargets(t),e=0;e=0})).length)for(n=a[0],o&&l[n]&&l[n].forEach(function(t,e){l[n][e]=t<0?t:0}),i=1;i0||(l[n][e]+=+t)});return s.d3.min(Object.keys(l).map(function(t){return s.d3.min(l[t])}))},C.getYDomainMax=function(t){var e,i,n,a,r,o,s=this,c=s.config,d=s.mapToIds(t),l=s.getValuesAsIdKeyed(t);if(c.data_groups.length>0)for(o=s.hasPositiveValueInTargets(t),e=0;e=0})).length)for(n=a[0],o&&l[n]&&l[n].forEach(function(t,e){l[n][e]=t>0?t:0}),i=1;i=0&&b>=0,g=v<=0&&b<=0,(l(y)&&h||l(w)&&g)&&(A=!1),A&&(h&&(v=0),g&&(b=0)),a=Math.abs(b-v),r=o=.1*a,void 0!==T&&(b=T+(s=Math.max(Math.abs(v),Math.abs(b))),v=T-s),C?(c=f.getDataLabelLength(v,b,"width"),d=m(f.y.range()),r+=a*((u=[c[0]/d,c[1]/d])[1]/(1-u[0]-u[1])),o+=a*(u[0]/(1-u[0]-u[1]))):L&&(c=f.getDataLabelLength(v,b,"height"),r+=f.axis.convertPixelsToAxisPadding(c[1],a),o+=f.axis.convertPixelsToAxisPadding(c[0],a)),"y"===e&&S(p.axis_y_padding)&&(r=f.axis.getPadding(p.axis_y_padding,"top",r,a),o=f.axis.getPadding(p.axis_y_padding,"bottom",o,a)),"y2"===e&&S(p.axis_y2_padding)&&(r=f.axis.getPadding(p.axis_y2_padding,"top",r,a),o=f.axis.getPadding(p.axis_y2_padding,"bottom",o,a)),A&&(h&&(o=v),g&&(r=-b)),n=[v-o,b+r],P?n.reverse():n)},C.getXDomainMin=function(t){var e=this,i=e.config;return void 0!==i.axis_x_min?e.isTimeSeries()?this.parseDate(i.axis_x_min):i.axis_x_min:e.d3.min(t,function(t){return e.d3.min(t.values,function(t){return t.x})})},C.getXDomainMax=function(t){var e=this,i=e.config;return void 0!==i.axis_x_max?e.isTimeSeries()?this.parseDate(i.axis_x_max):i.axis_x_max:e.d3.max(t,function(t){return e.d3.max(t.values,function(t){return t.x})})},C.getXDomainPadding=function(t){var e,i,n,a,r=this,s=r.config,c=t[1]-t[0];return i=r.isCategorized()?0:r.hasType("bar")?(e=r.getMaxDataCount())>1?c/(e-1)/2:.5:.01*c,"object"===o(s.axis_x_padding)&&S(s.axis_x_padding)?(n=l(s.axis_x_padding.left)?s.axis_x_padding.left:i,a=l(s.axis_x_padding.right)?s.axis_x_padding.right:i):n=a="number"==typeof s.axis_x_padding?s.axis_x_padding:i,{left:n,right:a}},C.getXDomain=function(t){var e=this,i=[e.getXDomainMin(t),e.getXDomainMax(t)],n=i[0],a=i[1],r=e.getXDomainPadding(i),o=0,s=0;return n-a!=0||e.isCategorized()||(e.isTimeSeries()?(n=new Date(.5*n.getTime()),a=new Date(1.5*a.getTime())):(n=0===n?1:.5*n,a=0===a?-1:1.5*a)),(n||0===n)&&(o=e.isTimeSeries()?new Date(n.getTime()-r.left):n-r.left),(a||0===a)&&(s=e.isTimeSeries()?new Date(a.getTime()+r.right):a+r.right),[o,s]},C.updateXDomain=function(t,e,i,n,a){var r=this,o=r.config;return i&&(r.x.domain(a||r.d3.extent(r.getXDomain(t))),r.orgXDomain=r.x.domain(),o.zoom_enabled&&r.zoom.scale(r.x).updateScaleExtent(),r.subX.domain(r.x.domain()),r.brush&&r.brush.scale(r.subX)),e&&(r.x.domain(a||(!r.brush||r.brush.empty()?r.orgXDomain:r.brush.extent())),o.zoom_enabled&&r.zoom.scale(r.x).updateScaleExtent()),n&&r.x.domain(r.trimXDomain(r.x.orgDomain())),r.x.domain()},C.trimXDomain=function(t){var e=this.getZoomDomain(),i=e[0],n=e[1];return t[0]<=i&&(t[1]=+t[1]+(i-t[0]),t[0]=i),n<=t[1]&&(t[0]=+t[0]-(t[1]-n),t[1]=n),t},C.drag=function(t){var e,i,n,a,o,s,c,d,l=this,u=l.config,h=l.main,g=l.d3;l.hasArcType()||u.data_selection_enabled&&(u.zoom_enabled&&!l.zoom.altDomain||u.data_selection_multiple&&(e=l.dragStart[0],i=l.dragStart[1],n=t[0],a=t[1],o=Math.min(e,n),s=Math.max(e,n),c=u.data_selection_grouped?l.margin.top:Math.min(i,a),d=u.data_selection_grouped?l.height:Math.max(i,a),h.select("."+r.dragarea).attr("x",o).attr("y",c).attr("width",s-o).attr("height",d-c),h.selectAll("."+r.shapes).selectAll("."+r.shape).filter(function(t){return u.data_selection_isselectable(t)}).each(function(t,e){var i,n,a,u,h,f,p=g.select(this),_=p.classed(r.SELECTED),x=p.classed(r.INCLUDED),m=!1;if(p.classed(r.circle))i=1*p.attr("cx"),n=1*p.attr("cy"),h=l.togglePoint,m=od&&(c=c.filter(function(t){return(""+t).indexOf(".")<0}));return c},C.getGridFilterToRemove=function(t){return t?function(e){var i=!1;return[].concat(t).forEach(function(t){("value"in t&&e.value===t.value||"class"in t&&e.class===t.class)&&(i=!0)}),i}:function(){return!0}},C.removeGridLines=function(t,e){var i=this,n=i.config,a=i.getGridFilterToRemove(t),o=function(t){return!a(t)},s=e?r.xgridLines:r.ygridLines,c=e?r.xgridLine:r.ygridLine;i.main.select("."+s).selectAll("."+c).filter(a).transition().duration(n.transition_duration).style("opacity",0).remove(),e?n.grid_x_lines=n.grid_x_lines.filter(o):n.grid_y_lines=n.grid_y_lines.filter(o)},C.initEventRect=function(){this.main.select("."+r.chart).append("g").attr("class",r.eventRects).style("fill-opacity",0)},C.redrawEventRect=function(){var t,e,i=this,n=i.config,a=i.isMultipleX(),o=i.main.select("."+r.eventRects).style("cursor",n.zoom_enabled?n.axis_rotated?"ns-resize":"ew-resize":null).classed(r.eventRectsMultiple,a).classed(r.eventRectsSingle,!a);o.selectAll("."+r.eventRect).remove(),i.eventRect=o.selectAll("."+r.eventRect),a?(t=i.eventRect.data([0]),i.generateEventRectsForMultipleXs(t.enter()),i.updateEventRect(t)):(e=i.getMaxDataCountTarget(i.data.targets),o.datum(e?e.values:[]),i.eventRect=o.selectAll("."+r.eventRect),t=i.eventRect.data(function(t){return t}),i.generateEventRectsForSingleX(t.enter()),i.updateEventRect(t),t.exit().remove())},C.updateEventRect=function(t){var e,i,n,a,r,o,s=this,c=s.config;t=t||s.eventRect.data(function(t){return t}),s.isMultipleX()?(e=0,i=0,n=s.width,a=s.height):(!s.isCustomX()&&!s.isTimeSeries()||s.isCategorized()?(r=s.getEventRectWidth(),o=function(t){return s.x(t.x)-r/2}):(s.updateXs(),r=function(t){var e=s.getPrevX(t.index),i=s.getNextX(t.index);return null===e&&null===i?c.axis_rotated?s.height:s.width:(null===e&&(e=s.x.domain()[0]),null===i&&(i=s.x.domain()[1]),Math.max(0,(s.x(i)-s.x(e))/2))},o=function(t){var e=s.getPrevX(t.index),i=s.getNextX(t.index),n=s.data.xs[t.id][t.index];return null===e&&null===i?0:(null===e&&(e=s.x.domain()[0]),(s.x(n)+s.x(e))/2)}),e=c.axis_rotated?0:o,i=c.axis_rotated?o:0,n=c.axis_rotated?s.width:r,a=c.axis_rotated?r:s.height),t.attr("class",s.classEvent.bind(s)).attr("x",e).attr("y",i).attr("width",n).attr("height",a)},C.generateEventRectsForSingleX=function(t){var e=this,i=e.d3,n=e.config;t.append("rect").attr("class",e.classEvent.bind(e)).style("cursor",n.data_selection_enabled&&n.data_selection_grouped?"pointer":null).on("mouseover",function(t){var i=t.index;e.dragging||e.flowing||e.hasArcType()||(n.point_focus_expand_enabled&&e.expandCircles(i,null,!0),e.expandBars(i,null,!0),e.main.selectAll("."+r.shape+"-"+i).each(function(t){n.data_onmouseover.call(e.api,t)}))}).on("mouseout",function(t){var i=t.index;e.config&&(e.hasArcType()||(e.hideXGridFocus(),e.hideTooltip(),e.unexpandCircles(),e.unexpandBars(),e.main.selectAll("."+r.shape+"-"+i).each(function(t){n.data_onmouseout.call(e.api,t)})))}).on("mousemove",function(t){var a,o=t.index,s=e.svg.select("."+r.eventRect+"-"+o);e.dragging||e.flowing||e.hasArcType()||(e.isStepType(t)&&"step-after"===e.config.line_step_type&&i.mouse(this)[0]=0}).classed(r.legendItemFocused,e).transition().duration(100).style("opacity",function(){return(e?i.opacityForLegend:i.opacityForUnfocusedLegend).call(i,i.d3.select(this))})},C.revertLegend=function(){var t=this,e=t.d3;t.legend.selectAll("."+r.legendItem).classed(r.legendItemFocused,!1).transition().duration(100).style("opacity",function(){return t.opacityForLegend(e.select(this))})},C.showLegend=function(t){var e=this,i=e.config;i.legend_show||(i.legend_show=!0,e.legend.style("visibility","visible"),e.legendHasRendered||e.updateLegendWithDefaults()),e.removeHiddenLegendIds(t),e.legend.selectAll(e.selectorLegends(t)).style("visibility","visible").transition().style("opacity",function(){return e.opacityForLegend(e.d3.select(this))})},C.hideLegend=function(t){var e=this,i=e.config;i.legend_show&&y(t)&&(i.legend_show=!1,e.legend.style("visibility","hidden")),e.addHiddenLegendIds(t),e.legend.selectAll(e.selectorLegends(t)).style("opacity",0).style("visibility","hidden")},C.clearLegendItemTextBoxCache=function(){this.legendItemTextBox={}},C.updateLegend=function(t,e,i){function n(t,e){return b.legendItemTextBox[e]||(b.legendItemTextBox[e]=b.getTextRect(t.textContent,r.legendItem,t)),b.legendItemTextBox[e]}function a(e,i,a){function r(t,e){e||(o=(f-E-g)/2)=C)&&(C=u),(!L||h>=L)&&(L=h),s=b.isLegendRight||b.isLegendInset?L:C,T.legend_equally?(Object.keys(I).forEach(function(t){I[t]=C}),Object.keys(R).forEach(function(t){R[t]=L}),(o=(f-s*t.length)/2)0&&0===v.size()&&(v=b.legend.insert("g","."+r.legendItem).attr("class",r.legendBackground).append("rect")),m=b.legend.selectAll("text").data(t).text(function(t){return void 0!==T.data_names[t]?T.data_names[t]:t}).each(function(t,e){a(this,t,e)}),(_?m.transition():m).attr("x",s).attr("y",l),y=b.legend.selectAll("rect."+r.legendItemEvent).data(t),(_?y.transition():y).attr("width",function(t){return I[t]}).attr("height",function(t){return R[t]}).attr("x",c).attr("y",u),S=b.legend.selectAll("line."+r.legendItemTile).data(t),(_?S.transition():S).style("stroke",b.color).attr("x1",h).attr("y1",f).attr("x2",g).attr("y2",f),v&&(_?v.transition():v).attr("height",b.getLegendHeight()-12).attr("width",C*(F+1)+10),b.legend.selectAll("."+r.legendItem).classed(r.legendItemHidden,function(t){return!b.isTargetToShow(t)}),b.updateLegendItemWidth(C),b.updateLegendItemHeight(L),b.updateLegendStep(F),b.updateSizes(),b.updateScales(),b.updateSvgSize(),b.transformAll(x,i),b.legendHasRendered=!0},C.initRegion=function(){var t=this;t.region=t.main.append("g").attr("clip-path",t.clipPath).attr("class",r.regions)},C.updateRegion=function(t){var e=this,i=e.config;e.region.style("visibility",e.hasArcType()?"hidden":"visible"),e.mainRegion=e.main.select("."+r.regions).selectAll("."+r.region).data(i.regions),e.mainRegion.enter().append("g").append("rect").style("fill-opacity",0),e.mainRegion.attr("class",e.classRegion.bind(e)),e.mainRegion.exit().transition().duration(t).style("opacity",0).remove()},C.redrawRegion=function(t){var e=this,i=e.mainRegion.selectAll("rect").each(function(){var t=e.d3.select(this.parentNode).datum();e.d3.select(this).datum(t)}),n=e.regionX.bind(e),a=e.regionY.bind(e),r=e.regionWidth.bind(e),o=e.regionHeight.bind(e);return[(t?i.transition():i).attr("x",n).attr("y",a).attr("width",r).attr("height",o).style("fill-opacity",function(t){return l(t.opacity)?t.opacity:.1})]},C.regionX=function(t){var e=this,i=e.config,n="y"===t.axis?e.y:e.y2;return"y"===t.axis||"y2"===t.axis?i.axis_rotated&&"start"in t?n(t.start):0:i.axis_rotated?0:"start"in t?e.x(e.isTimeSeries()?e.parseDate(t.start):t.start):0},C.regionY=function(t){var e=this,i=e.config,n="y"===t.axis?e.y:e.y2;return"y"===t.axis||"y2"===t.axis?i.axis_rotated?0:"end"in t?n(t.end):0:i.axis_rotated&&"start"in t?e.x(e.isTimeSeries()?e.parseDate(t.start):t.start):0},C.regionWidth=function(t){var e,i=this,n=i.config,a=i.regionX(t),r="y"===t.axis?i.y:i.y2;return e="y"===t.axis||"y2"===t.axis?n.axis_rotated&&"end"in t?r(t.end):i.width:n.axis_rotated?i.width:"end"in t?i.x(i.isTimeSeries()?i.parseDate(t.end):t.end):i.width,ei.bar_width_max?i.bar_width_max:n},C.getBars=function(t,e){var i=this;return(e?i.main.selectAll("."+r.bars+i.getTargetSelectorSuffix(e)):i.main).selectAll("."+r.bar+(l(t)?"-"+t:""))},C.expandBars=function(t,e,i){var n=this;i&&n.unexpandBars(),n.getBars(t,e).classed(r.EXPANDED,!0)},C.unexpandBars=function(t){this.getBars(t).classed(r.EXPANDED,!1)},C.generateDrawBar=function(t,e){var i=this,n=i.config,a=i.generateGetBarPoints(t,e);return function(t,e){var i=a(t,e),r=n.axis_rotated?1:0,o=n.axis_rotated?0:1;return"M "+i[0][r]+","+i[0][o]+" L"+i[1][r]+","+i[1][o]+" L"+i[2][r]+","+i[2][o]+" L"+i[3][r]+","+i[3][o]+" z"}},C.generateGetBarPoints=function(t,e){var i=this,n=e?i.subXAxis:i.xAxis,a=t.__max__+1,r=i.getBarW(n,a),o=i.getShapeX(r,a,t,!!e),s=i.getShapeY(!!e),c=i.getShapeOffset(i.isBarType,t,!!e),d=r*(i.config.bar_space/2),l=e?i.getSubYScale:i.getYScale;return function(t,e){var n=l.call(i,t.id)(0),a=c(t,e)||n,u=o(t),h=s(t);return i.config.axis_rotated&&(0=0&&(d+=s(a[o].value)-c))}),d}},C.isWithinShape=function(t,e){var i,n=this,a=n.d3.select(t);return n.isTargetToShow(e.id)?"circle"===t.nodeName?i=n.isStepType(e)?n.isWithinStep(t,n.getYScale(e.id)(e.value)):n.isWithinCircle(t,1.5*n.pointSelectR(e)):"path"===t.nodeName&&(i=!a.classed(r.bar)||n.isWithinBar(t)):i=!1,i},C.getInterpolate=function(t){var e=this,i=e.isInterpolationType(e.config.spline_interpolation_type)?e.config.spline_interpolation_type:"cardinal";return e.isSplineType(t)?i:e.isStepType(t)?e.config.line_step_type:"linear"},C.initLine=function(){this.main.select("."+r.chart).append("g").attr("class",r.chartLines)},C.updateTargetsForLine=function(t){var e,i=this,n=i.config,a=i.classChartLine.bind(i),o=i.classLines.bind(i),s=i.classAreas.bind(i),c=i.classCircles.bind(i),d=i.classFocus.bind(i);(e=i.main.select("."+r.chartLines).selectAll("."+r.chartLine).data(t).attr("class",function(t){return a(t)+d(t)}).enter().append("g").attr("class",a).style("opacity",0).style("pointer-events","none")).append("g").attr("class",o),e.append("g").attr("class",s),e.append("g").attr("class",function(t){return i.generateClass(r.selectedCircles,t.id)}),e.append("g").attr("class",c).style("cursor",function(t){return n.data_selection_isselectable(t)?"pointer":null}),t.forEach(function(t){i.main.selectAll("."+r.selectedCircles+i.getTargetSelectorSuffix(t.id)).selectAll("."+r.selectedCircle).each(function(e){e.value=t.values[e.index].value})})},C.updateLine=function(t){var e=this;e.mainLine=e.main.selectAll("."+r.lines).selectAll("."+r.line).data(e.lineData.bind(e)),e.mainLine.enter().append("path").attr("class",e.classLine.bind(e)).style("stroke",e.color),e.mainLine.style("opacity",e.initialOpacity.bind(e)).style("shape-rendering",function(t){return e.isStepType(t)?"crispEdges":""}).attr("transform",null),e.mainLine.exit().transition().duration(t).style("opacity",0).remove()},C.redrawLine=function(t,e){return[(e?this.mainLine.transition(Math.random().toString()):this.mainLine).attr("d",t).style("stroke",this.color).style("opacity",1)]},C.generateDrawLine=function(t,e){var i=this,n=i.config,a=i.d3.svg.line(),r=i.generateGetLinePoints(t,e),o=e?i.getSubYScale:i.getYScale,s=function(t){return(e?i.subxx:i.xx).call(i,t)},c=function(t,e){return n.data_groups.length>0?r(t,e)[0][1]:o.call(i,t.id)(t.value)};return a=n.axis_rotated?a.x(c).y(s):a.x(s).y(c),n.line_connectNull||(a=a.defined(function(t){return null!=t.value})),function(t){var r,s=n.line_connectNull?i.filterRemoveNull(t.values):t.values,c=e?i.x:i.subX,d=o.call(i,t.id),l=0,u=0;return i.isLineType(t)?n.data_regions[t.id]?r=i.lineWithRegions(s,c,d,n.data_regions[t.id]):(i.isStepType(t)&&(s=i.convertValuesToStep(s)),r=a.interpolate(i.getInterpolate(t))(s)):(s[0]&&(l=c(s[0].x),u=d(s[0].value)),r=n.axis_rotated?"M "+u+" "+l:"M "+l+" "+u),r||"M 0 0"}},C.generateGetLinePoints=function(t,e){var i=this,n=i.config,a=t.__max__+1,r=i.getShapeX(0,a,t,!!e),o=i.getShapeY(!!e),s=i.getShapeOffset(i.isLineType,t,!!e),c=e?i.getSubYScale:i.getYScale;return function(t,e){var a=c.call(i,t.id)(0),d=s(t,e)||a,l=r(t),u=o(t);return n.axis_rotated&&(00?r(t,e)[0][1]:o.call(i,t.id)(i.getAreaBaseValue(t.id))},d=function(t,e){return n.data_groups.length>0?r(t,e)[1][1]:o.call(i,t.id)(t.value)};return a=n.axis_rotated?a.x0(c).x1(d).y(s):a.x(s).y0(n.area_above?0:c).y1(d),n.line_connectNull||(a=a.defined(function(t){return null!==t.value})),function(t){var e,r=n.line_connectNull?i.filterRemoveNull(t.values):t.values,o=0,s=0;return i.isAreaType(t)?(i.isStepType(t)&&(r=i.convertValuesToStep(r)),e=a.interpolate(i.getInterpolate(t))(r)):(r[0]&&(o=i.x(r[0].x),s=i.getYScale(t.id)(r[0].value)),e=n.axis_rotated?"M "+s+" "+o:"M "+o+" "+s),e||"M 0 0"}},C.getAreaBaseValue=function(){return 0},C.generateGetAreaPoints=function(t,e){var i=this,n=i.config,a=t.__max__+1,r=i.getShapeX(0,a,t,!!e),o=i.getShapeY(!!e),s=i.getShapeOffset(i.isAreaType,t,!!e),c=e?i.getSubYScale:i.getYScale;return function(t,e){var a=c.call(i,t.id)(0),d=s(t,e)||a,l=r(t),u=o(t);return n.axis_rotated&&(00?(t=i.getShapeIndices(i.isLineType),e=i.generateGetLinePoints(t),i.circleY=function(t,i){return e(t,i)[0][1]}):i.circleY=function(t){return i.getYScale(t.id)(t.value)}},C.getCircles=function(t,e){var i=this;return(e?i.main.selectAll("."+r.circles+i.getTargetSelectorSuffix(e)):i.main).selectAll("."+r.circle+(l(t)?"-"+t:""))},C.expandCircles=function(t,e,i){var n=this,a=n.pointExpandedR.bind(n);i&&n.unexpandCircles(),n.getCircles(t,e).classed(r.EXPANDED,!0).attr("r",a)},C.unexpandCircles=function(t){var e=this,i=e.pointR.bind(e);e.getCircles(t).filter(function(){return e.d3.select(this).classed(r.EXPANDED)}).classed(r.EXPANDED,!1).attr("r",i)},C.pointR=function(t){var e=this,i=e.config;return e.isStepType(t)?0:u(i.point_r)?i.point_r(t):i.point_r},C.pointExpandedR=function(t){var e=this,i=e.config;return i.point_focus_expand_enabled?u(i.point_focus_expand_r)?i.point_focus_expand_r(t):i.point_focus_expand_r?i.point_focus_expand_r:1.75*e.pointR(t):e.pointR(t)},C.pointSelectR=function(t){var e=this,i=e.config;return u(i.point_select_r)?i.point_select_r(t):i.point_select_r?i.point_select_r:4*e.pointR(t)},C.isWithinCircle=function(t,e){var i=this.d3,n=i.mouse(t),a=i.select(t),r=+a.attr("cx"),o=+a.attr("cy");return Math.sqrt(Math.pow(r-n[0],2)+Math.pow(o-n[1],2))0?i:320/(t.hasType("gauge")&&!e.gauge_fullCircle?2:1)},C.getCurrentPaddingTop=function(){var t=this,e=t.config,i=l(e.padding_top)?e.padding_top:0;return t.title&&t.title.node()&&(i+=t.getTitlePadding()),i},C.getCurrentPaddingBottom=function(){var t=this.config;return l(t.padding_bottom)?t.padding_bottom:0},C.getCurrentPaddingLeft=function(t){var e=this,i=e.config;return l(i.padding_left)?i.padding_left:i.axis_rotated?i.axis_x_show?Math.max(_(e.getAxisWidthByAxisId("x",t)),40):1:!i.axis_y_show||i.axis_y_inner?e.axis.getYAxisLabelPosition().isOuter?30:1:_(e.getAxisWidthByAxisId("y",t))},C.getCurrentPaddingRight=function(){var t=this,e=t.config,i=t.isLegendRight?t.getLegendWidth()+20:0;return l(e.padding_right)?e.padding_right+1:e.axis_rotated?10+i:!e.axis_y2_show||e.axis_y2_inner?2+i+(t.axis.getY2AxisLabelPosition().isOuter?20:0):_(t.getAxisWidthByAxisId("y2"))+i},C.getParentRectValue=function(t){for(var e,i=this.selectChart.node();i&&"BODY"!==i.tagName;){try{e=i.getBoundingClientRect()[t]}catch(n){"width"===t&&(e=i.offsetWidth)}if(e)break;i=i.parentNode}return e},C.getParentWidth=function(){return this.getParentRectValue("width")},C.getParentHeight=function(){var t=this.selectChart.style("height");return t.indexOf("px")>0?+t.replace("px",""):0},C.getSvgLeft=function(t){var e=this,i=e.config,n=i.axis_rotated||!i.axis_rotated&&!i.axis_y_inner,a=i.axis_rotated?r.axisX:r.axisY,o=e.main.select("."+a).node(),s=o&&n?o.getBoundingClientRect():{right:0},c=e.selectChart.node().getBoundingClientRect(),d=e.hasArcType(),l=s.right-c.left-(d?0:e.getCurrentPaddingLeft(t));return l>0?l:0},C.getAxisWidthByAxisId=function(t,e){var i=this,n=i.axis.getLabelPositionById(t);return i.axis.getMaxTickWidth(t,e)+(n.isInner?20:40)},C.getHorizontalAxisHeight=function(t){var e=this,i=e.config,n=30;return"x"!==t||i.axis_x_show?"x"===t&&i.axis_x_height?i.axis_x_height:"y"!==t||i.axis_y_show?"y2"!==t||i.axis_y2_show?("x"===t&&!i.axis_rotated&&i.axis_x_tick_rotate&&(n=30+e.axis.getMaxTickWidth(t)*Math.cos(Math.PI*(90-i.axis_x_tick_rotate)/180)),"y"===t&&i.axis_rotated&&i.axis_y_tick_rotate&&(n=30+e.axis.getMaxTickWidth(t)*Math.cos(Math.PI*(90-i.axis_y_tick_rotate)/180)),n+(e.axis.getLabelPositionById(t).isInner?0:10)+("y2"===t?-10:0)):e.rotated_padding_top:!i.legend_show||e.isLegendRight||e.isLegendInset?1:10:8},C.getEventRectWidth=function(){return Math.max(0,this.xAxis.tickInterval())},C.initBrush=function(){var t=this,e=t.d3;t.brush=e.svg.brush().on("brush",function(){t.redrawForBrush()}),t.brush.update=function(){return t.context&&t.context.select("."+r.brush).call(this),this},t.brush.scale=function(e){return t.config.axis_rotated?this.y(e):this.x(e)}},C.initSubchart=function(){var t=this,e=t.config,i=t.context=t.svg.append("g").attr("transform",t.getTranslate("context")),n=e.subchart_show?"visible":"hidden";i.style("visibility",n),i.append("g").attr("clip-path",t.clipPathForSubchart).attr("class",r.chart),i.select("."+r.chart).append("g").attr("class",r.chartBars),i.select("."+r.chart).append("g").attr("class",r.chartLines),i.append("g").attr("clip-path",t.clipPath).attr("class",r.brush).call(t.brush),t.axes.subx=i.append("g").attr("class",r.axisX).attr("transform",t.getTranslate("subx")).attr("clip-path",e.axis_rotated?"":t.clipPathForXAxis).style("visibility",e.subchart_axis_x_show?n:"hidden")},C.updateTargetsForSubchart=function(t){var e,i=this,n=i.context,a=i.config,o=i.classChartBar.bind(i),s=i.classBars.bind(i),c=i.classChartLine.bind(i),d=i.classLines.bind(i),l=i.classAreas.bind(i);a.subchart_show&&(n.select("."+r.chartBars).selectAll("."+r.chartBar).data(t).attr("class",o).enter().append("g").style("opacity",0).attr("class",o).append("g").attr("class",s),(e=n.select("."+r.chartLines).selectAll("."+r.chartLine).data(t).attr("class",c).enter().append("g").style("opacity",0).attr("class",c)).append("g").attr("class",d),e.append("g").attr("class",l),n.selectAll("."+r.brush+" rect").attr(a.axis_rotated?"width":"height",a.axis_rotated?i.width2:i.height2))},C.updateBarForSubchart=function(t){var e=this;e.contextBar=e.context.selectAll("."+r.bars).selectAll("."+r.bar).data(e.barData.bind(e)),e.contextBar.enter().append("path").attr("class",e.classBar.bind(e)).style("stroke","none").style("fill",e.color),e.contextBar.style("opacity",e.initialOpacity.bind(e)),e.contextBar.exit().transition().duration(t).style("opacity",0).remove()},C.redrawBarForSubchart=function(t,e,i){(e?this.contextBar.transition(Math.random().toString()).duration(i):this.contextBar).attr("d",t).style("opacity",1)},C.updateLineForSubchart=function(t){var e=this;e.contextLine=e.context.selectAll("."+r.lines).selectAll("."+r.line).data(e.lineData.bind(e)),e.contextLine.enter().append("path").attr("class",e.classLine.bind(e)).style("stroke",e.color),e.contextLine.style("opacity",e.initialOpacity.bind(e)),e.contextLine.exit().transition().duration(t).style("opacity",0).remove()},C.redrawLineForSubchart=function(t,e,i){(e?this.contextLine.transition(Math.random().toString()).duration(i):this.contextLine).attr("d",t).style("opacity",1)},C.updateAreaForSubchart=function(t){var e=this,i=e.d3;e.contextArea=e.context.selectAll("."+r.areas).selectAll("."+r.area).data(e.lineData.bind(e)),e.contextArea.enter().append("path").attr("class",e.classArea.bind(e)).style("fill",e.color).style("opacity",function(){return e.orgAreaOpacity=+i.select(this).style("opacity"),0}),e.contextArea.style("opacity",0),e.contextArea.exit().transition().duration(t).style("opacity",0).remove()},C.redrawAreaForSubchart=function(t,e,i){(e?this.contextArea.transition(Math.random().toString()).duration(i):this.contextArea).attr("d",t).style("fill",this.color).style("opacity",this.orgAreaOpacity)},C.redrawSubchart=function(t,e,i,n,a,r,o){var s,c,d,l=this,u=l.d3,h=l.config;l.context.style("visibility",h.subchart_show?"visible":"hidden"),h.subchart_show&&(u.event&&"zoom"===u.event.type&&l.brush.extent(l.x.orgDomain()).update(),t&&(l.brush.empty()||l.brush.extent(l.x.orgDomain()).update(),s=l.generateDrawArea(a,!0),c=l.generateDrawBar(r,!0),d=l.generateDrawLine(o,!0),l.updateBarForSubchart(i),l.updateLineForSubchart(i),l.updateAreaForSubchart(i),l.redrawBarForSubchart(c,i,i),l.redrawLineForSubchart(d,i,i),l.redrawAreaForSubchart(s,i,i)))},C.redrawForBrush=function(){var t=this,e=t.x;t.redraw({withTransition:!1,withY:t.config.zoom_rescale,withSubchart:!1,withUpdateXDomain:!0,withDimension:!1}),t.config.subchart_onbrush.call(t.api,e.orgDomain())},C.transformContext=function(t,e){var i,n=this;e&&e.axisSubX?i=e.axisSubX:(i=n.context.select("."+r.axisX),t&&(i=i.transition())),n.context.attr("transform",n.getTranslate("context")),i.attr("transform",n.getTranslate("subx"))},C.getDefaultExtent=function(){var t=this,e=t.config,i=u(e.axis_x_extent)?e.axis_x_extent(t.getXDomain(t.data.targets)):e.axis_x_extent;return t.isTimeSeries()&&(i=[t.parseDate(i[0]),t.parseDate(i[1])]),i},C.initText=function(){var t=this;t.main.select("."+r.chart).append("g").attr("class",r.chartTexts),t.mainText=t.d3.selectAll([])},C.updateTargetsForText=function(t){var e=this,i=e.classChartText.bind(e),n=e.classTexts.bind(e),a=e.classFocus.bind(e);e.main.select("."+r.chartTexts).selectAll("."+r.chartText).data(t).attr("class",function(t){return i(t)+a(t)}).enter().append("g").attr("class",i).style("opacity",0).style("pointer-events","none").append("g").attr("class",n)},C.updateText=function(t){var e=this,i=e.config,n=e.barOrLineData.bind(e),a=e.classText.bind(e);e.mainText=e.main.selectAll("."+r.texts).selectAll("."+r.text).data(n),e.mainText.enter().append("text").attr("class",a).attr("text-anchor",function(t){return i.axis_rotated?t.value<0?"end":"start":"middle"}).style("stroke","none").style("fill",function(t){return e.color(t)}).style("fill-opacity",0),e.mainText.text(function(t,i,n){return e.dataLabelFormat(t.id)(t.value,t.id,i,n)}),e.mainText.exit().transition().duration(t).style("fill-opacity",0).remove()},C.redrawText=function(t,e,i,n){return[(n?this.mainText.transition():this.mainText).attr("x",t).attr("y",e).style("fill",this.color).style("fill-opacity",i?0:this.opacityForText.bind(this))]},C.getTextRect=function(t,e,i){var n,a=this.d3.select("body").append("div").classed("c3",!0),r=a.append("svg").style("visibility","hidden").style("position","fixed").style("top",0).style("left",0),o=this.d3.select(i).style("font");return r.selectAll(".dummy").data([t]).enter().append("text").classed(e||"",!0).style("font",o).text(t).each(function(){n=this.getBoundingClientRect()}),a.remove(),n},C.generateXYForText=function(t,e,i,n){var a=this,r=a.generateGetAreaPoints(t,!1),o=a.generateGetBarPoints(e,!1),s=a.generateGetLinePoints(i,!1),c=n?a.getXForText:a.getYForText;return function(t,e){var i=a.isAreaType(t)?r:a.isBarType(t)?o:s;return c.call(a,i(t,e),t,this)}},C.getXForText=function(t,e,i){var n,a,r=this,o=i.getBoundingClientRect();return r.config.axis_rotated?(a=r.isBarType(e)?4:6,n=t[2][1]+a*(e.value<0?-1:1)):n=r.hasType("bar")?(t[2][0]+t[0][0])/2:t[0][0],null===e.value&&(n>r.width?n=r.width-o.width:n<0&&(n=4)),n},C.getYForText=function(t,e,i){var n,a=this,r=i.getBoundingClientRect();return a.config.axis_rotated?n=(t[0][0]+t[2][0]+.6*r.height)/2:(n=t[2][1],e.value<0||0===e.value&&!a.hasPositiveValue?(n+=r.height,a.isBarType(e)&&a.isSafari()?n-=3:!a.isBarType(e)&&a.isChrome()&&(n+=3)):n+=a.isBarType(e)?-3:-6),null!==e.value||a.config.axis_rotated||(nthis.height&&(n=this.height-4)),n},C.initTitle=function(){var t=this;t.title=t.svg.append("text").text(t.config.title_text).attr("class",t.CLASS.title)},C.redrawTitle=function(){var t=this;t.title.attr("x",t.xForTitle.bind(t)).attr("y",t.yForTitle.bind(t))},C.xForTitle=function(){var t=this,e=t.config,i=e.title_position||"left";return i.indexOf("right")>=0?t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width-e.title_padding.right:i.indexOf("center")>=0?(t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width)/2:e.title_padding.left},C.yForTitle=function(){var t=this;return t.config.title_padding.top+t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).height},C.getTitlePadding=function(){var t=this;return t.yForTitle()+t.config.title_padding.bottom},C.initTooltip=function(){var t,e=this,i=e.config;if(e.tooltip=e.selectChart.style("position","relative").append("div").attr("class",r.tooltipContainer).style("position","absolute").style("pointer-events","none").style("display","none"),i.tooltip_init_show){if(e.isTimeSeries()&&g(i.tooltip_init_x)){for(i.tooltip_init_x=e.parseDate(i.tooltip_init_x),t=0;t"+(o||0===o?""+o+"":"")),void 0!==(s=b(f(t[r].value,t[r].ratio,t[r].id,t[r].index,t))))){if(null===t[r].name)continue;c=b(g(t[r].name,t[r].ratio,t[r].id,t[r].index)),d=l.levelColor?l.levelColor(t[r].value):n(t[r].id),a+="",a+=""+c+"",a+=""+s+"",a+=""}return a+""},C.tooltipPosition=function(t,e,i,n){var a,r,o,s,c,d=this,l=d.config,u=d.d3,h=d.hasArcType(),g=u.mouse(n);return h?(r=(d.width-(d.isLegendRight?d.getLegendWidth():0))/2+g[0],s=d.height/2+g[1]+20):(a=d.getSvgLeft(!0),l.axis_rotated?(o=(r=a+g[0]+100)+e,c=d.currentWidth-d.getCurrentPaddingRight(),s=d.x(t[0].x)+20):(o=(r=a+d.getCurrentPaddingLeft(!0)+d.x(t[0].x)+20)+e,c=a+d.currentWidth-d.getCurrentPaddingRight(),s=g[1]+15),o>c&&(r-=o-c+20),s+i>d.currentHeight&&(s-=i+30)),s<0&&(s=0),{top:s,left:r}},C.showTooltip=function(t,e){var i,n,a,r=this,o=r.config,s=r.hasArcType(),c=t.filter(function(t){return t&&l(t.value)}),d=o.tooltip_position||C.tooltipPosition;0!==c.length&&o.tooltip_show&&(r.tooltip.html(o.tooltip_contents.call(r,t,r.axis.getXAxisTickFormat(),r.getYFormat(s),r.color)).style("display","block"),i=r.tooltip.property("offsetWidth"),n=r.tooltip.property("offsetHeight"),a=d.call(this,c,i,n,e),r.tooltip.style("top",a.top+"px").style("left",a.left+"px"))},C.hideTooltip=function(){this.tooltip.style("display","none")},C.setTargetType=function(t,e){var i=this,n=i.config;i.mapToTargetIds(t).forEach(function(t){i.withoutFadeIn[t]=e===n.data_types[t],n.data_types[t]=e}),t||(n.data_type=e)},C.hasType=function(t,e){var i=this,n=i.config.data_types,a=!1;return e=e||i.data.targets,e&&e.length?e.forEach(function(e){var i=n[e.id];(i&&i.indexOf(t)>=0||!i&&"line"===t)&&(a=!0)}):Object.keys(n).length?Object.keys(n).forEach(function(e){n[e]===t&&(a=!0)}):a=i.config.data_type===t,a},C.hasArcType=function(t){return this.hasType("pie",t)||this.hasType("donut",t)||this.hasType("gauge",t)},C.isLineType=function(t){var e=this.config,i=g(t)?t:t.id;return!e.data_types[i]||["line","spline","area","area-spline","step","area-step"].indexOf(e.data_types[i])>=0},C.isStepType=function(t){var e=g(t)?t:t.id;return["step","area-step"].indexOf(this.config.data_types[e])>=0},C.isSplineType=function(t){var e=g(t)?t:t.id;return["spline","area-spline"].indexOf(this.config.data_types[e])>=0},C.isAreaType=function(t){var e=g(t)?t:t.id;return["area","area-spline","area-step"].indexOf(this.config.data_types[e])>=0},C.isBarType=function(t){var e=g(t)?t:t.id;return"bar"===this.config.data_types[e]},C.isScatterType=function(t){var e=g(t)?t:t.id;return"scatter"===this.config.data_types[e]},C.isPieType=function(t){var e=g(t)?t:t.id;return"pie"===this.config.data_types[e]},C.isGaugeType=function(t){var e=g(t)?t:t.id;return"gauge"===this.config.data_types[e]},C.isDonutType=function(t){var e=g(t)?t:t.id;return"donut"===this.config.data_types[e]},C.isArcType=function(t){return this.isPieType(t)||this.isDonutType(t)||this.isGaugeType(t)},C.lineData=function(t){return this.isLineType(t)?[t]:[]},C.arcData=function(t){return this.isArcType(t.data)?[t]:[]},C.barData=function(t){return this.isBarType(t)?t.values:[]},C.lineOrScatterData=function(t){return this.isLineType(t)||this.isScatterType(t)?t.values:[]},C.barOrLineData=function(t){return this.isBarType(t)||this.isLineType(t)?t.values:[]},C.isInterpolationType=function(t){return["linear","linear-closed","basis","basis-open","basis-closed","bundle","cardinal","cardinal-open","cardinal-closed","monotone"].indexOf(t)>=0},C.isSafari=function(){var t=window.navigator.userAgent;return t.indexOf("Safari")>=0&&t.indexOf("Chrome")<0},C.isChrome=function(){return window.navigator.userAgent.indexOf("Chrome")>=0},C.initZoom=function(){var t,e=this,i=e.d3,n=e.config;e.zoom=i.behavior.zoom().on("zoomstart",function(){t=i.event.sourceEvent,e.zoom.altDomain=i.event.sourceEvent.altKey?e.x.orgDomain():null,n.zoom_onzoomstart.call(e.api,i.event.sourceEvent)}).on("zoom",function(){e.redrawForZoom.call(e)}).on("zoomend",function(){var a=i.event.sourceEvent;a&&t.clientX===a.clientX&&t.clientY===a.clientY||(e.redrawEventRect(),e.updateZoom(),n.zoom_onzoomend.call(e.api,e.x.orgDomain()))}),e.zoom.scale=function(t){return n.axis_rotated?this.y(t):this.x(t)},e.zoom.orgScaleExtent=function(){var t=n.zoom_extent?n.zoom_extent:[1,10];return[t[0],Math.max(e.getMaxDataCount()/t[1],t[1])]},e.zoom.updateScaleExtent=function(){var t=m(e.x.orgDomain())/m(e.getZoomDomain()),i=this.orgScaleExtent();return this.scaleExtent([i[0]*t,i[1]*t]),this}},C.getZoomDomain=function(){var t=this,e=t.config,i=t.d3;return[i.min([t.orgXDomain[0],e.zoom_x_min]),i.max([t.orgXDomain[1],e.zoom_x_max])]},C.updateZoom=function(){var t=this,e=t.config.zoom_enabled?t.zoom:function(){};t.main.select("."+r.zoomRect).call(e).on("dblclick.zoom",null),t.main.selectAll("."+r.eventRect).call(e).on("dblclick.zoom",null)},C.redrawForZoom=function(){var t=this,e=t.d3,i=t.config,n=t.zoom,a=t.x;if(i.zoom_enabled&&0!==t.filterTargetsToShow(t.data.targets).length){if("mousemove"===e.event.sourceEvent.type&&n.altDomain)return a.domain(n.altDomain),void n.scale(a).updateScaleExtent();t.isCategorized()&&a.orgDomain()[0]===t.orgXDomain[0]&&a.domain([t.orgXDomain[0]-1e-10,a.orgDomain()[1]]),t.redraw({withTransition:!1,withY:i.zoom_rescale,withSubchart:!1,withEventRect:!1,withDimension:!1}),"mousemove"===e.event.sourceEvent.type&&(t.cancelClick=!0),i.zoom_onzoom.call(t.api,a.orgDomain())}},L}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.c3=e()}(this,function(){"use strict";function t(t,e){var i=this;i.component=t,i.params=e||{},i.d3=t.d3,i.scale=i.d3.scaleLinear(),i.range,i.orient="bottom",i.innerTickSize=6,i.outerTickSize=this.params.withOuterTick?6:0,i.tickPadding=3,i.tickValues=null,i.tickFormat,i.tickArguments,i.tickOffset=0,i.tickCulling=!0,i.tickCentered,i.tickTextCharSize,i.tickTextRotate=i.params.tickTextRotate,i.tickLength,i.axis=i.generateAxis()}function e(t){var e=this.internal=new i(this);e.loadConfig(t),e.beforeInit(t),e.init(),e.afterInit(t),function t(e,i,n){Object.keys(e).forEach(function(a){i[a]=e[a].bind(n),Object.keys(e[a]).length>0&&t(e[a],i[a],n)})}(P,this,this)}function i(t){var e=this;e.d3=window.d3?window.d3:"undefined"!=typeof require?require("d3"):void 0,e.api=t,e.config=e.getDefaultConfig(),e.data={},e.cache={},e.axes={}}var n,a,r={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",defocused:"c3-defocused",region:"c3-region",regions:"c3-regions",title:"c3-title",tooltipContainer:"c3-tooltip-container",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",gridLines:"c3-grid-lines",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_"},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},c=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},d=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},u=function(t){return t||0===t},l=function(t){return"function"==typeof t},h=function(t){return Array.isArray(t)},g=function(t){return"string"==typeof t},f=function(t){return void 0===t},p=function(t){return void 0!==t},_=function(t){return 10*Math.ceil(t/10)},x=function(t){return Math.ceil(t)+.5},y=function(t){return t[1]-t[0]},m=function(t){return void 0===t||null===t||g(t)&&0===t.length||"object"===(void 0===t?"undefined":o(t))&&0===Object.keys(t).length},S=function(t){return!C.isEmpty(t)},w=function(t,e,i){return p(t[e])?t[e]:i},v=function(t,e){var i=!1;return Object.keys(t).forEach(function(n){t[n]===e&&(i=!0)}),i},b=function(t){return"string"==typeof t?t.replace(//g,">"):t},T=function(t){var e=t.getBoundingClientRect(),i=[t.pathSegList.getItem(0),t.pathSegList.getItem(1)];return{x:i[0].x,y:Math.min(i[0].y,i[1].y),width:e.width,height:e.height}};(a=t.prototype).axisX=function(t,e,i){t.attr("transform",function(t){return"translate("+Math.ceil(e(t)+i)+", 0)"})},a.axisY=function(t,e){t.attr("transform",function(t){return"translate(0,"+Math.ceil(e(t))+")"})},a.scaleExtent=function(t){var e=t[0],i=t[t.length-1];return e0&&a[0]>0&&a.unshift(a[0]-(a[1]-a[0])),a},a.copyScale=function(){var t,e=this,i=e.scale.copy();return e.params.isCategory&&(t=e.scale.domain(),i.domain([t[0],t[1]-1])),i},a.textFormatted=function(t){var e=this,i=e.tickFormat?e.tickFormat(t):t;return void 0!==i?i:""},a.updateRange=function(){var t=this;return t.range=t.scale.rangeExtent?t.scale.rangeExtent():t.scaleExtent(t.scale.range()),t.range},a.updateTickTextCharSize=function(t){var e=this;if(e.tickTextCharSize)return e.tickTextCharSize;var i={h:11.5,w:5.5};return t.select("text").text(function(t){return e.textFormatted(t)}).each(function(t){var n=this.getBoundingClientRect(),a=e.textFormatted(t),r=n.height,o=a?n.width/a.length:void 0;r&&o&&(i.h=r,i.w=o)}).text(""),e.tickTextCharSize=i,i},a.isVertical=function(){return"left"===this.orient||"right"===this.orient},a.tspanData=function(t,e,i){var n=this,a=n.params.tickMultiline?n.splitTickText(t,i):[].concat(n.textFormatted(t));return a.map(function(t){return{index:e,splitted:t,length:a.length}})},a.splitTickText=function(t,e){function i(t,e){a=void 0;for(var s=1;s0?1:-1):t.tickLength},a.textTransform=function(){var t=this.tickTextRotate;return t?"rotate("+t+")":""},a.textTextAnchor=function(){var t=this.tickTextRotate;return t?t>0?"start":"end":"middle"},a.tspanDx=function(){var t=this.tickTextRotate;return t?8*Math.sin(Math.PI*(t/180)):0},a.tspanDy=function(t,e){var i=this,n=i.tickTextCharSize.h;return 0===e&&(n=i.isVertical()?-((t.length-1)*(i.tickTextCharSize.h/2)-3):".71em"),n},a.generateAxis=function(){function t(a,r){var o;return a.each(function(){var a,s,c,d=t.g=i.select(this),u=this.__chart__||e.scale,l=this.__chart__=e.copyScale(),h=e.tickValues?e.tickValues:e.generateTicks(l),g=d.selectAll(".tick").data(h,l),f=g.enter().insert("g",".domain").attr("class","tick").style("opacity",1e-6),p=g.exit().remove(),_=g.merge(f);n.isCategory?(e.tickOffset=Math.ceil((l(1)-l(0))/2),s=e.tickCentered?0:e.tickOffset,c=e.tickCentered?e.tickOffset:0):e.tickOffset=s=0,e.updateRange(),e.updateTickLength(),e.updateTickTextCharSize(d.select(".tick"));var x=_.select("line").merge(f.append("line")),y=_.select("text").merge(f.append("text")),m=_.selectAll("text").selectAll("tspan").data(function(t,i){return e.tspanData(t,i,l)}),S=m.enter().append("tspan").merge(m).text(function(t){return t.splitted});m.exit().remove();var w=d.selectAll(".domain").data([0]),v=w.enter().append("path").merge(w).attr("class","domain");switch(e.orient){case"bottom":a=e.axisX,x.attr("x1",s).attr("x2",s).attr("y2",function(t,i){return e.lineY2(t,i)}),y.attr("x",0).attr("y",function(t,i){return e.textY(t,i)}).attr("transform",function(t,i){return e.textTransform(t,i)}).style("text-anchor",function(t,i){return e.textTextAnchor(t,i)}),S.attr("x",0).attr("dy",function(t,i){return e.tspanDy(t,i)}).attr("dx",function(t,i){return e.tspanDx(t,i)}),v.attr("d","M"+e.range[0]+","+e.outerTickSize+"V0H"+e.range[1]+"V"+e.outerTickSize);break;case"top":a=e.axisX,x.attr("x2",0).attr("y2",-e.innerTickSize),y.attr("x",0).attr("y",-e.tickLength).style("text-anchor","middle"),S.attr("x",0).attr("dy","0em"),v.attr("d","M"+e.range[0]+","+-e.outerTickSize+"V0H"+e.range[1]+"V"+-e.outerTickSize);break;case"left":a=e.axisY,x.attr("x2",-e.innerTickSize).attr("y1",c).attr("y2",c),y.attr("x",-e.tickLength).attr("y",e.tickOffset).style("text-anchor","end"),S.attr("x",-e.tickLength).attr("dy",function(t,i){return e.tspanDy(t,i)}),v.attr("d","M"+-e.outerTickSize+","+e.range[0]+"H0V"+e.range[1]+"H"+-e.outerTickSize);break;case"right":a=e.axisY,x.attr("x2",e.innerTickSize).attr("y2",0),y.attr("x",e.tickLength).attr("y",0).style("text-anchor","start"),S.attr("x",e.tickLength).attr("dy",function(t,i){return e.tspanDy(t,i)}),v.attr("d","M"+e.outerTickSize+","+e.range[0]+"H0V"+e.range[1]+"H"+e.outerTickSize)}if(l.rangeBand){var b=l,T=b.rangeBand()/2;u=l=function(t){return b(t)+T}}else u.rangeBand?u=l:p.call(a,l,e.tickOffset);f.call(a,u,e.tickOffset),o=(r?_.transition(r):_).style("opacity",1).call(a,l,e.tickOffset)}),o}var e=this,i=e.d3,n=e.params;return t.scale=function(i){return arguments.length?(e.scale=i,t):e.scale},t.orient=function(i){return arguments.length?(e.orient=i in{top:1,right:1,bottom:1,left:1}?i+"":"bottom",t):e.orient},t.tickFormat=function(i){return arguments.length?(e.tickFormat=i,t):e.tickFormat},t.tickCentered=function(i){return arguments.length?(e.tickCentered=i,t):e.tickCentered},t.tickOffset=function(){return e.tickOffset},t.tickInterval=function(){var i;return(i=n.isCategory?2*e.tickOffset:(t.g.select("path.domain").node().getTotalLength()-2*e.outerTickSize)/t.g.selectAll("line").size())===1/0?0:i},t.ticks=function(){return arguments.length?(e.tickArguments=arguments,t):e.tickArguments},t.tickCulling=function(i){return arguments.length?(e.tickCulling=i,t):e.tickCulling},t.tickValues=function(i){if("function"==typeof i)e.tickValues=function(){return i(e.scale.domain())};else{if(!arguments.length)return e.tickValues;e.tickValues=i}return t},t};var A=function(e){function i(e){s(this,i);var r={fn:n,internal:{fn:a}},o=d(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,"axis",r));return o.d3=e.d3,o.internal=t,o}return c(i,e),i}(function(t,e,i){this.owner=t,L.chart.internal[e]=i});(n=A.prototype).init=function(){var t=this.owner,e=t.config,i=t.main;t.axes.x=i.append("g").attr("class",r.axis+" "+r.axisX).attr("clip-path",t.clipPathForXAxis).attr("transform",t.getTranslate("x")).style("visibility",e.axis_x_show?"visible":"hidden"),t.axes.x.append("text").attr("class",r.axisXLabel).attr("transform",e.axis_rotated?"rotate(-90)":"").style("text-anchor",this.textAnchorForXAxisLabel.bind(this)),t.axes.y=i.append("g").attr("class",r.axis+" "+r.axisY).attr("clip-path",e.axis_y_inner?"":t.clipPathForYAxis).attr("transform",t.getTranslate("y")).style("visibility",e.axis_y_show?"visible":"hidden"),t.axes.y.append("text").attr("class",r.axisYLabel).attr("transform",e.axis_rotated?"":"rotate(-90)").style("text-anchor",this.textAnchorForYAxisLabel.bind(this)),t.axes.y2=i.append("g").attr("class",r.axis+" "+r.axisY2).attr("transform",t.getTranslate("y2")).style("visibility",e.axis_y2_show?"visible":"hidden"),t.axes.y2.append("text").attr("class",r.axisY2Label).attr("transform",e.axis_rotated?"":"rotate(-90)").style("text-anchor",this.textAnchorForY2AxisLabel.bind(this))},n.getXAxis=function(t,e,i,n,a,r,o){var s=this.owner,c=s.config,d={isCategory:s.isCategorized(),withOuterTick:a,tickMultiline:c.axis_x_tick_multiline,tickWidth:c.axis_x_tick_width,tickTextRotate:o?0:c.axis_x_tick_rotate,withoutTransition:r},u=new this.internal(this,d).axis.scale(t).orient(e);return s.isTimeSeries()&&n&&"function"!=typeof n&&(n=n.map(function(t){return s.parseDate(t)})),u.tickFormat(i).tickValues(n),s.isCategorized()&&(u.tickCentered(c.axis_x_tick_centered),m(c.axis_x_tick_culling)&&(c.axis_x_tick_culling=!1)),u},n.updateXAxisTickValues=function(t,e){var i,n=this.owner,a=n.config;return(a.axis_x_tick_fit||a.axis_x_tick_count)&&(i=this.generateTickValues(n.mapTargetsToUniqueXs(t),a.axis_x_tick_count,n.isTimeSeries())),e?e.tickValues(i):(n.xAxis.tickValues(i),n.subXAxis.tickValues(i)),i},n.getYAxis=function(t,e,i,n,a,r,o){var s=this.owner,c=s.config,d=(s.d3,{withOuterTick:a,withoutTransition:r,tickTextRotate:o?0:c.axis_y_tick_rotate}),u=new this.internal(this,d).axis.scale(t).orient(e).tickFormat(i);return s.isTimeSeriesY()?u.ticks(c.axis_y_tick_time_type,c.axis_y_tick_time_interval):u.tickValues(n),u},n.getId=function(t){var e=this.owner.config;return t in e.data_axes?e.data_axes[t]:"y"},n.getXAxisTickFormat=function(){var t=this.owner,e=t.config,i=t.isTimeSeries()?t.defaultAxisTimeFormat:t.isCategorized()?t.categoryName:function(t){return t<0?t.toFixed(0):t};return e.axis_x_tick_format&&(l(e.axis_x_tick_format)?i=e.axis_x_tick_format:t.isTimeSeries()&&(i=function(i){return i?t.axisTimeFormat(e.axis_x_tick_format)(i):""})),l(i)?function(e){return i.call(t,e)}:i},n.getTickValues=function(t,e){return t||(e?e.tickValues():void 0)},n.getXAxisTickValues=function(){return this.getTickValues(this.owner.config.axis_x_tick_values,this.owner.xAxis)},n.getYAxisTickValues=function(){return this.getTickValues(this.owner.config.axis_y_tick_values,this.owner.yAxis)},n.getY2AxisTickValues=function(){return this.getTickValues(this.owner.config.axis_y2_tick_values,this.owner.y2Axis)},n.getLabelOptionByAxisId=function(t){var e,i=this.owner.config;return"y"===t?e=i.axis_y_label:"y2"===t?e=i.axis_y2_label:"x"===t&&(e=i.axis_x_label),e},n.getLabelText=function(t){var e=this.getLabelOptionByAxisId(t);return g(e)?e:e?e.text:null},n.setLabelText=function(t,e){var i=this.owner.config,n=this.getLabelOptionByAxisId(t);g(n)?"y"===t?i.axis_y_label=e:"y2"===t?i.axis_y2_label=e:"x"===t&&(i.axis_x_label=e):n&&(n.text=e)},n.getLabelPosition=function(t,e){var i=this.getLabelOptionByAxisId(t),n=i&&"object"===(void 0===i?"undefined":o(i))&&i.position?i.position:e;return{isInner:n.indexOf("inner")>=0,isOuter:n.indexOf("outer")>=0,isLeft:n.indexOf("left")>=0,isCenter:n.indexOf("center")>=0,isRight:n.indexOf("right")>=0,isTop:n.indexOf("top")>=0,isMiddle:n.indexOf("middle")>=0,isBottom:n.indexOf("bottom")>=0}},n.getXAxisLabelPosition=function(){return this.getLabelPosition("x",this.owner.config.axis_rotated?"inner-top":"inner-right")},n.getYAxisLabelPosition=function(){return this.getLabelPosition("y",this.owner.config.axis_rotated?"inner-right":"inner-top")},n.getY2AxisLabelPosition=function(){return this.getLabelPosition("y2",this.owner.config.axis_rotated?"inner-right":"inner-top")},n.getLabelPositionById=function(t){return"y2"===t?this.getY2AxisLabelPosition():"y"===t?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},n.textForXAxisLabel=function(){return this.getLabelText("x")},n.textForYAxisLabel=function(){return this.getLabelText("y")},n.textForY2AxisLabel=function(){return this.getLabelText("y2")},n.xForAxisLabel=function(t,e){var i=this.owner;return t?e.isLeft?0:e.isCenter?i.width/2:i.width:e.isBottom?-i.height:e.isMiddle?-i.height/2:0},n.dxForAxisLabel=function(t,e){return t?e.isLeft?"0.5em":e.isRight?"-0.5em":"0":e.isTop?"-0.5em":e.isBottom?"0.5em":"0"},n.textAnchorForAxisLabel=function(t,e){return t?e.isLeft?"start":e.isCenter?"middle":"end":e.isBottom?"start":e.isMiddle?"middle":"end"},n.xForXAxisLabel=function(){return this.xForAxisLabel(!this.owner.config.axis_rotated,this.getXAxisLabelPosition())},n.xForYAxisLabel=function(){return this.xForAxisLabel(this.owner.config.axis_rotated,this.getYAxisLabelPosition())},n.xForY2AxisLabel=function(){return this.xForAxisLabel(this.owner.config.axis_rotated,this.getY2AxisLabelPosition())},n.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.owner.config.axis_rotated,this.getXAxisLabelPosition())},n.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.owner.config.axis_rotated,this.getYAxisLabelPosition())},n.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.owner.config.axis_rotated,this.getY2AxisLabelPosition())},n.dyForXAxisLabel=function(){var t=this.owner.config,e=this.getXAxisLabelPosition();return t.axis_rotated?e.isInner?"1.2em":-25-this.getMaxTickWidth("x"):e.isInner?"-0.5em":t.axis_x_height?t.axis_x_height-10:"3em"},n.dyForYAxisLabel=function(){var t=this.owner,e=this.getYAxisLabelPosition();return t.config.axis_rotated?e.isInner?"-0.5em":"3em":e.isInner?"1.2em":-10-(t.config.axis_y_inner?0:this.getMaxTickWidth("y")+10)},n.dyForY2AxisLabel=function(){var t=this.owner,e=this.getY2AxisLabelPosition();return t.config.axis_rotated?e.isInner?"1.2em":"-2.2em":e.isInner?"-0.5em":15+(t.config.axis_y2_inner?0:this.getMaxTickWidth("y2")+15)},n.textAnchorForXAxisLabel=function(){var t=this.owner;return this.textAnchorForAxisLabel(!t.config.axis_rotated,this.getXAxisLabelPosition())},n.textAnchorForYAxisLabel=function(){var t=this.owner;return this.textAnchorForAxisLabel(t.config.axis_rotated,this.getYAxisLabelPosition())},n.textAnchorForY2AxisLabel=function(){var t=this.owner;return this.textAnchorForAxisLabel(t.config.axis_rotated,this.getY2AxisLabelPosition())},n.getMaxTickWidth=function(t,e){var i,n,a,r,o=this.owner,s=o.config,c=0;return e&&o.currentMaxTickWidths[t]?o.currentMaxTickWidths[t]:(o.svg&&(i=o.filterTargetsToShow(o.data.targets),"y"===t?(n=o.y.copy().domain(o.getYDomain(i,"y")),a=this.getYAxis(n,o.yOrient,s.axis_y_tick_format,o.yAxisTickValues,!1,!0,!0)):"y2"===t?(n=o.y2.copy().domain(o.getYDomain(i,"y2")),a=this.getYAxis(n,o.y2Orient,s.axis_y2_tick_format,o.y2AxisTickValues,!1,!0,!0)):(n=o.x.copy().domain(o.getXDomain(i)),a=this.getXAxis(n,o.xOrient,o.xAxisTickFormat,o.xAxisTickValues,!1,!0,!0),this.updateXAxisTickValues(i,a)),(r=o.d3.select("body").append("div").classed("c3",!0)).append("svg").style("visibility","hidden").style("position","fixed").style("top",0).style("left",0).append("g").call(a).each(function(){o.d3.select(this).selectAll("text").each(function(){var t=this.getBoundingClientRect();c2){for(o=n-2,a=t[0],s=((r=t[t.length-1])-a)/(o+1),u=[a],c=0;c=0&&F.select(this).style("display",e%E?"none":"block")})}else k.svg.selectAll("."+r.axisX+" .tick text").style("display","block");_=k.generateDrawArea?k.generateDrawArea(z,!1):void 0,x=k.generateDrawBar?k.generateDrawBar(H):void 0,y=k.generateDrawLine?k.generateDrawLine(M,!1):void 0,m=k.generateXYForText(z,H,M,!0),S=k.generateXYForText(z,H,M,!1),k.updateCircleY(),I=(k.config.axis_rotated?k.circleY:k.circleX).bind(k),R=(k.config.axis_rotated?k.circleX:k.circleY).bind(k),i&&(k.subY.domain(k.getYDomain(Y,"y")),k.subY2.domain(k.getYDomain(Y,"y2"))),k.updateXgridFocus(),D.select("text."+r.text+"."+r.empty).attr("x",k.width/2).attr("y",k.height/2).text(X.data_empty_label_text).transition().style("opacity",Y.length?0:1),g&&k.redrawEventRect(),k.updateGrid(v),k.updateRegion(v),k.updateBar(b),k.updateLine(b),k.updateArea(b),k.updateCircle(I,R),k.hasDataLabel()&&k.updateText(m,S,b),k.redrawTitle&&k.redrawTitle(),k.redrawArc&&k.redrawArc(v,b,c),k.redrawSubchart&&k.redrawSubchart(n,e,v,b,z,H,M),D.selectAll("."+r.selectedCircles).filter(k.isBarType.bind(k)).selectAll("circle").remove(),t.flow&&(C=k.generateFlow({targets:Y,flow:t.flow,duration:t.flow.duration,drawBar:x,drawLine:y,drawArea:_,cx:I,cy:R,xv:N,xForText:m,yForText:S})),k.isTabVisible()&&(v?(L=F.transition().duration(v),A=[],[k.redrawBar(x,!0,L),k.redrawLine(y,!0,L),k.redrawArea(_,!0,L),k.redrawCircle(I,R,!0,L),k.redrawText(m,S,t.flow,!0,L),k.redrawRegion(!0,L),k.redrawGrid(!0,L)].forEach(function(t){t.forEach(function(t){A.push(t)})}),P=k.generateWait(),A.forEach(function(t){P.add(t)}),P(function(){C&&C(),X.onrendered&&X.onrendered.call(k)})):(k.redrawBar(x),k.redrawLine(y),k.redrawArea(_),k.redrawCircle(I,R),k.redrawText(m,S,t.flow),k.redrawRegion(),k.redrawGrid(),C&&C(),X.onrendered&&X.onrendered.call(k))),k.mapToIds(k.data.targets).forEach(function(t){k.withoutFadeIn[t]=!0})},C.updateAndRedraw=function(t){var e,i=this,n=i.config;(t=t||{}).withTransition=w(t,"withTransition",!0),t.withTransform=w(t,"withTransform",!1),t.withLegend=w(t,"withLegend",!1),t.withUpdateXDomain=w(t,"withUpdateXDomain",!0),t.withUpdateOrgXDomain=w(t,"withUpdateOrgXDomain",!0),t.withTransitionForExit=!1,t.withTransitionForTransform=w(t,"withTransitionForTransform",t.withTransition),i.updateSizes(),t.withLegend&&n.legend_show||(e=i.axis.generateTransitions(t.withTransitionForAxis?n.transition_duration:0),i.updateScales(),i.updateSvgSize(),i.transformAll(t.withTransitionForTransform,e)),i.redraw(t,e)},C.redrawWithoutRescale=function(){this.redraw({withY:!1,withSubchart:!1,withEventRect:!1,withTransitionForAxis:!1})},C.isTimeSeries=function(){return"timeseries"===this.config.axis_x_type},C.isCategorized=function(){return this.config.axis_x_type.indexOf("categor")>=0},C.isCustomX=function(){var t=this,e=t.config;return!t.isTimeSeries()&&(e.data_x||S(e.data_xs))},C.isTimeSeriesY=function(){return"timeseries"===this.config.axis_y_type},C.getTranslate=function(t){var e,i,n=this,a=n.config;return"main"===t?(e=x(n.margin.left),i=x(n.margin.top)):"context"===t?(e=x(n.margin2.left),i=x(n.margin2.top)):"legend"===t?(e=n.margin3.left,i=n.margin3.top):"x"===t?(e=0,i=a.axis_rotated?0:n.height):"y"===t?(e=0,i=a.axis_rotated?n.height:0):"y2"===t?(e=a.axis_rotated?0:n.width,i=a.axis_rotated?1:0):"subx"===t?(e=0,i=a.axis_rotated?0:n.height2):"arc"===t&&(e=n.arcWidth/2,i=n.arcHeight/2),"translate("+e+","+i+")"},C.initialOpacity=function(t){return null!==t.value&&this.withoutFadeIn[t.id]?1:0},C.initialOpacityForCircle=function(t){return null!==t.value&&this.withoutFadeIn[t.id]?this.opacityForCircle(t):0},C.opacityForCircle=function(t){var e=(l(this.config.point_show)?this.config.point_show(t):this.config.point_show)?1:0;return u(t.value)?this.isScatterType(t)?.5:e:0},C.opacityForText=function(){return this.hasDataLabel()?1:0},C.xx=function(t){return t?this.x(t.x):null},C.xv=function(t){var e=this,i=t.value;return e.isTimeSeries()?i=e.parseDate(t.value):e.isCategorized()&&"string"==typeof t.value&&(i=e.config.axis_x_categories.indexOf(t.value)),Math.ceil(e.x(i))},C.yv=function(t){var e=this,i=t.axis&&"y2"===t.axis?e.y2:e.y;return Math.ceil(i(t.value))},C.subxx=function(t){return t?this.subX(t.x):null},C.transformMain=function(t,e){var i,n,a,o=this;e&&e.axisX?i=e.axisX:(i=o.main.select("."+r.axisX),t&&(i=i.transition())),e&&e.axisY?n=e.axisY:(n=o.main.select("."+r.axisY),t&&(n=n.transition())),e&&e.axisY2?a=e.axisY2:(a=o.main.select("."+r.axisY2),t&&(a=a.transition())),(t?o.main.transition():o.main).attr("transform",o.getTranslate("main")),i.attr("transform",o.getTranslate("x")),n.attr("transform",o.getTranslate("y")),a.attr("transform",o.getTranslate("y2")),o.main.select("."+r.chartArcs).attr("transform",o.getTranslate("arc"))},C.transformAll=function(t,e){var i=this;i.transformMain(t,e),i.config.subchart_show&&i.transformContext(t,e),i.legend&&i.transformLegend(t)},C.updateSvgSize=function(){var t=this,e=t.svg.select(".c3-brush .overlay");t.svg.attr("width",t.currentWidth).attr("height",t.currentHeight),t.svg.selectAll(["#"+t.clipId,"#"+t.clipIdForGrid]).select("rect").attr("width",t.width).attr("height",t.height),t.svg.select("#"+t.clipIdForXAxis).select("rect").attr("x",t.getXAxisClipX.bind(t)).attr("y",t.getXAxisClipY.bind(t)).attr("width",t.getXAxisClipWidth.bind(t)).attr("height",t.getXAxisClipHeight.bind(t)),t.svg.select("#"+t.clipIdForYAxis).select("rect").attr("x",t.getYAxisClipX.bind(t)).attr("y",t.getYAxisClipY.bind(t)).attr("width",t.getYAxisClipWidth.bind(t)).attr("height",t.getYAxisClipHeight.bind(t)),t.svg.select("#"+t.clipIdForSubchart).select("rect").attr("width",t.width).attr("height",e.size()?e.attr("height"):0),t.selectChart.style("max-height",t.currentHeight+"px")},C.updateDimension=function(t){var e=this;t||(e.config.axis_rotated?(e.axes.x.call(e.xAxis),e.axes.subx.call(e.subXAxis)):(e.axes.y.call(e.yAxis),e.axes.y2.call(e.y2Axis))),e.updateSizes(),e.updateScales(),e.updateSvgSize(),e.transformAll(!1)},C.observeInserted=function(t){var e,i=this;"undefined"!=typeof MutationObserver?(e=new MutationObserver(function(n){n.forEach(function(n){"childList"===n.type&&n.previousSibling&&(e.disconnect(),i.intervalForObserveInserted=window.setInterval(function(){t.node().parentNode&&(window.clearInterval(i.intervalForObserveInserted),i.updateDimension(),i.brush&&i.brush.update(),i.config.oninit.call(i),i.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),t.transition().style("opacity",1))},10))})})).observe(t.node(),{attributes:!0,childList:!0,characterData:!0}):window.console.error("MutationObserver not defined.")},C.bindResize=function(){var t=this,e=t.config;t.resizeFunction=t.generateResize(),t.resizeFunction.add(function(){e.onresize.call(t)}),e.resize_auto&&t.resizeFunction.add(function(){void 0!==t.resizeTimeout&&window.clearTimeout(t.resizeTimeout),t.resizeTimeout=window.setTimeout(function(){delete t.resizeTimeout,t.updateAndRedraw({withUpdateXDomain:!1,withUpdateOrgXDomain:!1,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),t.brush&&t.brush.update()},100)}),t.resizeFunction.add(function(){e.onresized.call(t)});var i=function(){t.api.element.offsetParent&&t.resizeFunction()};if(window.attachEvent)window.attachEvent("onresize",i);else if(window.addEventListener)window.addEventListener("resize",i,!1);else{var n=window.onresize;n?n.add&&n.remove||(n=t.generateResize()).add(window.onresize):n=t.generateResize(),n.add(t.resizeFunction),window.onresize=function(){t.api.element.offsetParent&&n()}}},C.generateResize=function(){function t(){e.forEach(function(t){t()})}var e=[];return t.add=function(t){e.push(t)},t.remove=function(t){for(var i=0;ie.getTotalLength())break;i--}while(i>0);return i})),"SVGPathSegList"in window||(window.SVGPathSegList=function(t){this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.classname="SVGPathSegList",Object.defineProperty(window.SVGPathSegList.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"pathSegList",{get:function(){return this._pathSegList||(this._pathSegList=new window.SVGPathSegList(this)),this._pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),window.SVGPathSegList.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())},window.SVGPathSegList.prototype._updateListFromPathMutations=function(t){if(this._pathElement){var e=!1;t.forEach(function(t){"d"==t.attributeName&&(e=!0)}),e&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}},window.SVGPathSegList.prototype._writeListToPath=function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",window.SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.segmentChanged=function(t){this._writeListToPath()},window.SVGPathSegList.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach(function(t){t._owningPathSegList=null}),this._list=[],this._writeListToPath()},window.SVGPathSegList.prototype.initialize=function(t){return this._checkPathSynchronizedToList(),this._list=[t],t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype._checkValidIndex=function(t){if(isNaN(t)||t<0||t>=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),this._list[e]=t,t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){var e="",i=!0;return t.forEach(function(t){i?(i=!1,e+=t._asPathString()):e+=" "+t._asPathString()}),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t||0==t.length)return[];var e=this,i=function(){this.pathSegList=[]};i.prototype.appendSegment=function(t){this.pathSegList.push(t)};var n=function(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};n.prototype._isCurrentSpace=function(){var t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},n.prototype._skipOptionalSpaces=function(){for(;this._currentIndex="0"&&t<="9")&&e!=window.SVGPathSeg.PATHSEG_CLOSEPATH?e==window.SVGPathSeg.PATHSEG_MOVETO_ABS?window.SVGPathSeg.PATHSEG_LINETO_ABS:e==window.SVGPathSeg.PATHSEG_MOVETO_REL?window.SVGPathSeg.PATHSEG_LINETO_REL:e:window.SVGPathSeg.PATHSEG_UNKNOWN},n.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var t=this.peekSegmentType();return t==window.SVGPathSeg.PATHSEG_MOVETO_ABS||t==window.SVGPathSeg.PATHSEG_MOVETO_REL},n.prototype._parseNumber=function(){var t=0,e=0,i=1,n=0,a=1,r=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!=this._string.charAt(this._currentIndex))){for(var s=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=s)for(var c=this._currentIndex-1,d=1;c>=s;)e+=d*(this._string.charAt(c--)-"0"),d*=10;if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)i*=10,n+=(this._string.charAt(this._currentIndex)-"0")/i,this._currentIndex+=1}if(this._currentIndex!=o&&this._currentIndex+1=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)t*=10,t+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var u=e+n;if(u*=a,t&&(u*=Math.pow(10,r*t)),o!=this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}},n.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}},n.prototype.parseSegment=function(){var t=this._string[this._currentIndex],i=this._pathSegTypeFromChar(t);if(i==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if((i=this._nextCommandHelper(t,this._previousCommand))==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=i,i){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(e);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicRel(e,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:return n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicAbs(e,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:return n={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothRel(e,n.x,n.y,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:return n={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothAbs(e,n.x,n.y,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticRel(e,n.x,n.y,n.x1,n.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:return n={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticAbs(e,n.x,n.y,n.x1,n.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcRel(e,n.x,n.y,n.x1,n.y1,n.arcAngle,n.arcLarge,n.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:var n={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcAbs(e,n.x,n.y,n.x1,n.y1,n.arcAngle,n.arcLarge,n.arcSweep);default:throw"Unknown path seg type."}};var a=new i,r=new n(t);if(!r.initialCommandIsMoveTo())return[];for(;r.hasMoreData();){var o=r.parseSegment();if(!o)return[];a.appendSegment(o)}return a.pathSegList}),P.axis=function(){},P.axis.labels=function(t){var e=this.internal;arguments.length&&(Object.keys(t).forEach(function(i){e.axis.setLabelText(i,t[i])}),e.axis.updateLabels())},P.axis.max=function(t){var e=this.internal,i=e.config;if(!arguments.length)return{x:i.axis_x_max,y:i.axis_y_max,y2:i.axis_y2_max};"object"===(void 0===t?"undefined":o(t))?(u(t.x)&&(i.axis_x_max=t.x),u(t.y)&&(i.axis_y_max=t.y),u(t.y2)&&(i.axis_y2_max=t.y2)):i.axis_y_max=i.axis_y2_max=t,e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},P.axis.min=function(t){var e=this.internal,i=e.config;if(!arguments.length)return{x:i.axis_x_min,y:i.axis_y_min,y2:i.axis_y2_min};"object"===(void 0===t?"undefined":o(t))?(u(t.x)&&(i.axis_x_min=t.x),u(t.y)&&(i.axis_y_min=t.y),u(t.y2)&&(i.axis_y2_min=t.y2)):i.axis_y_min=i.axis_y2_min=t,e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},P.axis.range=function(t){if(!arguments.length)return{max:this.axis.max(),min:this.axis.min()};p(t.max)&&this.axis.max(t.max),p(t.min)&&this.axis.min(t.min)},P.category=function(t,e){var i=this.internal,n=i.config;return arguments.length>1&&(n.axis_x_categories[t]=e,i.redraw()),n.axis_x_categories[t]},P.categories=function(t){var e=this.internal,i=e.config;return arguments.length?(i.axis_x_categories=t,e.redraw(),i.axis_x_categories):i.axis_x_categories},P.resize=function(t){var e=this.internal.config;e.size_width=t?t.width:null,e.size_height=t?t.height:null,this.flush()},P.flush=function(){this.internal.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},P.destroy=function(){var t=this.internal;if(window.clearInterval(t.intervalForObserveInserted),void 0!==t.resizeTimeout&&window.clearTimeout(t.resizeTimeout),window.detachEvent)window.detachEvent("onresize",t.resizeFunction);else if(window.removeEventListener)window.removeEventListener("resize",t.resizeFunction);else{var e=window.onresize;e&&e.add&&e.remove&&e.remove(t.resizeFunction)}return t.selectChart.classed("c3",!1).html(""),Object.keys(t).forEach(function(e){t[e]=null}),null},P.color=function(t){return this.internal.color(t)},P.data=function(t){var e=this.internal.data.targets;return void 0===t?e:e.filter(function(e){return[].concat(t).indexOf(e.id)>=0})},P.data.shown=function(t){return this.internal.filterTargetsToShow(this.data(t))},P.data.values=function(t){var e,i=null;return t&&(i=(e=this.data(t))[0]?e[0].values.map(function(t){return t.value}):null),i},P.data.names=function(t){return this.internal.clearLegendItemTextBoxCache(),this.internal.updateDataAttributes("names",t)},P.data.colors=function(t){return this.internal.updateDataAttributes("colors",t)},P.data.axes=function(t){return this.internal.updateDataAttributes("axes",t)},P.flow=function(t){var e,i,n,a,r,o,s,c=this.internal,d=[],l=c.getMaxDataCount(),h=0,g=0;if(t.json)i=c.convertJsonToData(t.json,t.keys);else if(t.rows)i=c.convertRowsToData(t.rows);else{if(!t.columns)return;i=c.convertColumnsToData(t.columns)}e=c.convertDataToTargets(i,!0),c.data.targets.forEach(function(t){var i,n,a=!1;for(i=0;i1?a.values[a.values.length-1].x-r.x:r.x-c.getXDomain(c.data.targets)[0]:1,n=[r.x-o,r.x],c.updateXDomain(null,!0,!0,!1,n)),c.updateTargets(c.data.targets),c.redraw({flow:{index:r.index,length:h,duration:u(t.duration)?t.duration:c.config.transition_duration,done:t.done,orgDataCount:l},withLegend:!0,withTransition:l>1,withTrimXDomain:!1,withUpdateXAxis:!0})},C.generateFlow=function(t){var e=this,i=e.config,n=e.d3;return function(){var a,o,s,c,d,u,l,h,g,f,p,_=t.targets,x=t.flow,m=t.drawBar,S=t.drawLine,w=t.drawArea,v=t.cx,b=t.cy,T=t.xv,A=t.xForText,P=t.yForText,C=t.duration,L=x.index,V=x.length,G=e.getValueOnIndex(e.data.targets[0].values,L),E=e.getValueOnIndex(e.data.targets[0].values,L+V),O=e.x.domain(),I=x.duration||C,R=x.done||function(){},k=e.generateWait();e.flowing=!0,e.data.targets.forEach(function(t){t.values.splice(0,V)}),s=e.updateXDomain(_,!0,!0),e.updateXGrid&&e.updateXGrid(!0),c=e.xgrid||n.selectAll([]),d=e.xgridLines||n.selectAll([]),u=e.mainRegion||n.selectAll([]),l=e.mainText||n.selectAll([]),h=e.mainBar||n.selectAll([]),g=e.mainLine||n.selectAll([]),f=e.mainArea||n.selectAll([]),p=e.mainCircle||n.selectAll([]),x.orgDataCount?a=1===x.orgDataCount||(G&&G.x)===(E&&E.x)?e.x(O[0])-e.x(s[0]):e.isTimeSeries()?e.x(O[0])-e.x(s[0]):e.x(G.x)-e.x(E.x):1!==e.data.targets[0].values.length?a=e.x(O[0])-e.x(s[0]):e.isTimeSeries()?(G=e.getValueOnIndex(e.data.targets[0].values,0),E=e.getValueOnIndex(e.data.targets[0].values,e.data.targets[0].values.length-1),a=e.x(G.x)-e.x(E.x)):a=y(s)/2,o="translate("+a+",0) scale("+y(O)/y(s)+",1)",e.hideXGridFocus();var D=n.transition().ease(n.easeLinear).duration(I);k.add(e.xAxis(e.axes.x,D)),k.add(h.transition(D).attr("transform",o)),k.add(g.transition(D).attr("transform",o)),k.add(f.transition(D).attr("transform",o)),k.add(p.transition(D).attr("transform",o)),k.add(l.transition(D).attr("transform",o)),k.add(u.filter(e.isRegionOnX).transition(D).attr("transform",o)),k.add(c.transition(D).attr("transform",o)),k.add(d.transition(D).attr("transform",o)),k(function(){var t,n=[],a=[];if(V){for(t=0;t=0&&(e=!0)}),!e)}),o.regions},P.selected=function(t){var e=this.internal,i=e.d3;return i.merge(e.main.selectAll("."+r.shapes+e.getTargetSelectorSuffix(t)).selectAll("."+r.shape).filter(function(){return i.select(this).classed(r.SELECTED)}).map(function(t){return t.map(function(t){var e=t.__data__;return e.data?e.data:e})}))},P.select=function(t,e,i){var n=this.internal,a=n.d3,o=n.config;o.data_selection_enabled&&n.main.selectAll("."+r.shapes).selectAll("."+r.shape).each(function(s,c){var d=a.select(this),u=s.data?s.data.id:s.id,l=n.getToggle(this,s).bind(n),h=o.data_selection_grouped||!t||t.indexOf(u)>=0,g=!e||e.indexOf(c)>=0,f=d.classed(r.SELECTED);d.classed(r.line)||d.classed(r.area)||(h&&g?o.data_selection_isselectable(s)&&!f&&l(!0,d.classed(r.SELECTED,!0),s,c):p(i)&&i&&f&&l(!1,d.classed(r.SELECTED,!1),s,c))})},P.unselect=function(t,e){var i=this.internal,n=i.d3,a=i.config;a.data_selection_enabled&&i.main.selectAll("."+r.shapes).selectAll("."+r.shape).each(function(o,s){var c=n.select(this),d=o.data?o.data.id:o.id,u=i.getToggle(this,o).bind(i),l=a.data_selection_grouped||!t||t.indexOf(d)>=0,h=!e||e.indexOf(s)>=0,g=c.classed(r.SELECTED);c.classed(r.line)||c.classed(r.area)||l&&h&&a.data_selection_isselectable(o)&&g&&u(!1,c.classed(r.SELECTED,!1),o,s)})},P.show=function(t,e){var i,n=this.internal;t=n.mapToTargetIds(t),e=e||{},n.removeHiddenTargetIds(t),(i=n.svg.selectAll(n.selectorTargets(t))).transition().style("opacity",1,"important").call(n.endall,function(){i.style("opacity",null).style("opacity",1)}),e.withLegend&&n.showLegend(t),n.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},P.hide=function(t,e){var i,n=this.internal;t=n.mapToTargetIds(t),e=e||{},n.addHiddenTargetIds(t),(i=n.svg.selectAll(n.selectorTargets(t))).transition().style("opacity",0,"important").call(n.endall,function(){i.style("opacity",null).style("opacity",0)}),e.withLegend&&n.hideLegend(t),n.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},P.toggle=function(t,e){var i=this,n=this.internal;n.mapToTargetIds(t).forEach(function(t){n.isTargetToShow(t)?i.hide(t,e):i.show(t,e)})},P.tooltip=function(){},P.tooltip.show=function(t){var e,i,n=this.internal,a={};t.mouse?a=t.mouse:(t.data?i=t.data:void 0!==t.x&&(e=t.id?n.data.targets.filter(function(e){return e.id===t.id}):n.data.targets,i=n.filterByX(e,t.x).slice(0,1)[0]),a=i?n.getMousePosition(i):null),n.dispatchEvent("mousemove",a),n.config.tooltip_onshow.call(n,i)},P.tooltip.hide=function(){this.internal.dispatchEvent("mouseout",0),this.internal.config.tooltip_onhide.call(this)},P.transform=function(t,e){var i=this.internal,n=["pie","donut"].indexOf(t)>=0?{withTransform:!0}:null;i.transformTo(e,t,n)},C.transformTo=function(t,e,i){var n=this,a=!n.hasArcType(),r=i||{withTransitionForAxis:a};r.withTransitionForTransform=!1,n.transiting=!1,n.setTargetType(t,e),n.updateTargets(n.data.targets),n.updateAndRedraw(r)},P.x=function(t){var e=this.internal;return arguments.length&&(e.updateTargetX(e.data.targets,t),e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),e.data.xs},P.xs=function(t){var e=this.internal;return arguments.length&&(e.updateTargetXs(e.data.targets,t),e.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),e.data.xs},P.zoom=function(t){var e=this.internal;return t&&(e.isTimeSeries()&&(t=t.map(function(t){return e.parseDate(t)})),e.config.subchart_show?e.brush.selectionAsValue(t):(e.updateXDomain(null,!0,!1,!1,t),e.redraw({withY:e.config.zoom_rescale,withSubchart:!1})),e.config.zoom_onzoom.call(this,e.x.orgDomain())),t},P.zoom.enable=function(t){var e=this.internal;e.config.zoom_enabled=t,e.updateAndRedraw()},P.unzoom=function(){var t=this.internal;t.config.subchart_show?t.brush.clear():(t.updateXDomain(null,!0,!1,!1,t.subX.domain()),t.redraw({withY:t.config.zoom_rescale,withSubchart:!1}))},P.zoom.max=function(t){var e=this.internal,i=e.config,n=e.d3;if(0!==t&&!t)return i.zoom_x_max;i.zoom_x_max=n.max([e.orgXDomain[1],t])},P.zoom.min=function(t){var e=this.internal,i=e.config,n=e.d3;if(0!==t&&!t)return i.zoom_x_min;i.zoom_x_min=n.min([e.orgXDomain[0],t])},P.zoom.range=function(t){if(!arguments.length)return{max:this.domain.max(),min:this.domain.min()};p(t.max)&&this.domain.max(t.max),p(t.min)&&this.domain.min(t.min)},C.initPie=function(){var t=this,e=t.d3;t.pie=e.pie().value(function(t){return t.values.reduce(function(t,e){return t+e.value},0)}),t.pie.sort(t.getOrderFunction()||null)},C.updateRadius=function(){var t=this,e=t.config,i=e.gauge_width||e.donut_width;t.radiusExpanded=Math.min(t.arcWidth,t.arcHeight)/2,t.radius=.95*t.radiusExpanded,t.innerRadiusRatio=i?(t.radius-i)/t.radius:.6,t.innerRadius=t.hasType("donut")||t.hasType("gauge")?t.radius*t.innerRadiusRatio:0},C.updateArc=function(){var t=this;t.svgArc=t.getSvgArc(),t.svgArcExpanded=t.getSvgArcExpanded(),t.svgArcExpandedSub=t.getSvgArcExpanded(.98)},C.updateAngle=function(t){var e,i,n,a,r=this,o=r.config,s=!1,c=0;return o?(r.pie(r.filterTargetsToShow(r.data.targets)).forEach(function(e){s||e.data.id!==t.data.id||(s=!0,(t=e).index=c),c++}),isNaN(t.startAngle)&&(t.startAngle=0),isNaN(t.endAngle)&&(t.endAngle=t.startAngle),r.isGaugeType(t.data)&&(e=o.gauge_min,i=o.gauge_max,n=Math.PI*(o.gauge_fullCircle?2:1)/(i-e),a=t.value.375?1.175-36/o.radius:.8)*o.radius/a:0)+","+n*r+")"),d},C.getArcRatio=function(t){var e=this,i=e.config,n=Math.PI*(e.hasType("gauge")&&!i.gauge_fullCircle?1:2);return t?(t.endAngle-t.startAngle)/n:null},C.convertToArcData=function(t){return this.addName({id:t.data.id,value:t.value,ratio:this.getArcRatio(t),index:t.index})},C.textForArcLabel=function(t){var e,i,n,a,r,o=this;return o.shouldShowArcLabel()?(e=o.updateAngle(t),i=e?e.value:null,n=o.getArcRatio(e),a=t.data.id,o.hasType("gauge")||o.meetsArcLabelThreshold(n)?(r=o.getArcLabelFormat())?r(i,n,a):o.defaultArcValueFormat(i,n):""):""},C.textForGaugeMinMax=function(t,e){var i=this.getGaugeLabelExtents();return i?i(t,e):t},C.expandArc=function(t){var e,i=this;i.transiting?e=window.setInterval(function(){i.transiting||(window.clearInterval(e),i.legend.selectAll(".c3-legend-item-focused").size()>0&&i.expandArc(t))},10):(t=i.mapToTargetIds(t),i.svg.selectAll(i.selectorTargets(t,"."+r.chartArc)).each(function(t){i.shouldExpand(t.data.id)&&i.d3.select(this).selectAll("path").transition().duration(i.expandDuration(t.data.id)).attr("d",i.svgArcExpanded).transition().duration(2*i.expandDuration(t.data.id)).attr("d",i.svgArcExpandedSub).each(function(t){i.isDonutType(t.data)})}))},C.unexpandArc=function(t){var e=this;e.transiting||(t=e.mapToTargetIds(t),e.svg.selectAll(e.selectorTargets(t,"."+r.chartArc)).selectAll("path").transition().duration(function(t){return e.expandDuration(t.data.id)}).attr("d",e.svgArc),e.svg.selectAll("."+r.arc))},C.expandDuration=function(t){var e=this,i=e.config;return e.isDonutType(t)?i.donut_expand_duration:e.isGaugeType(t)?i.gauge_expand_duration:e.isPieType(t)?i.pie_expand_duration:50},C.shouldExpand=function(t){var e=this,i=e.config;return e.isDonutType(t)&&i.donut_expand||e.isGaugeType(t)&&i.gauge_expand||e.isPieType(t)&&i.pie_expand},C.shouldShowArcLabel=function(){var t=this,e=t.config,i=!0;return t.hasType("donut")?i=e.donut_label_show:t.hasType("pie")&&(i=e.pie_label_show),i},C.meetsArcLabelThreshold=function(t){var e=this,i=e.config;return t>=(e.hasType("donut")?i.donut_label_threshold:i.pie_label_threshold)},C.getArcLabelFormat=function(){var t=this,e=t.config,i=e.pie_label_format;return t.hasType("gauge")?i=e.gauge_label_format:t.hasType("donut")&&(i=e.donut_label_format),i},C.getGaugeLabelExtents=function(){return this.config.gauge_label_extents},C.getArcTitle=function(){var t=this;return t.hasType("donut")?t.config.donut_title:""},C.updateTargetsForArc=function(t){var e,i=this,n=i.main,a=i.classChartArc.bind(i),o=i.classArcs.bind(i),s=i.classFocus.bind(i);(e=n.select("."+r.chartArcs).selectAll("."+r.chartArc).data(i.pie(t)).attr("class",function(t){return a(t)+s(t.data)}).enter().append("g").attr("class",a)).append("g").attr("class",o),e.append("text").attr("dy",i.hasType("gauge")?"-.1em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},C.initArc=function(){var t=this;t.arcs=t.main.select("."+r.chart).append("g").attr("class",r.chartArcs).attr("transform",t.getTranslate("arc")),t.arcs.append("text").attr("class",r.chartArcsTitle).style("text-anchor","middle").text(t.getArcTitle())},C.redrawArc=function(t,e,i){var n,a=this,o=a.d3,s=a.config,c=a.main;(n=c.selectAll("."+r.arcs).selectAll("."+r.arc).data(a.arcData.bind(a))).enter().append("path").attr("class",a.classArc.bind(a)).style("fill",function(t){return a.color(t.data)}).style("cursor",function(t){return s.interaction_enabled&&s.data_selection_isselectable(t)?"pointer":null}).each(function(t){a.isGaugeType(t.data)&&(t.startAngle=t.endAngle=s.gauge_startingAngle),this._current=t}).merge(n).attr("transform",function(t){return!a.isGaugeType(t.data)&&i?"scale(0)":""}).on("mouseover",s.interaction_enabled?function(t){var e,i;a.transiting||(e=a.updateAngle(t))&&(i=a.convertToArcData(e),a.expandArc(e.data.id),a.api.focus(e.data.id),a.toggleFocusLegend(e.data.id,!0),a.config.data_onmouseover(i,this))}:null).on("mousemove",s.interaction_enabled?function(t){var e,i=a.updateAngle(t);i&&(e=[a.convertToArcData(i)],a.showTooltip(e,this))}:null).on("mouseout",s.interaction_enabled?function(t){var e,i;a.transiting||(e=a.updateAngle(t))&&(i=a.convertToArcData(e),a.unexpandArc(e.data.id),a.api.revert(),a.revertLegend(),a.hideTooltip(),a.config.data_onmouseout(i,this))}:null).on("click",s.interaction_enabled?function(t,e){var i,n=a.updateAngle(t);n&&(i=a.convertToArcData(n),a.toggleShape&&a.toggleShape(this,i,e),a.config.data_onclick.call(a.api,i,this))}:null).each(function(){a.transiting=!0}).transition().duration(t).attrTween("d",function(t){var e,i=a.updateAngle(t);return i?(isNaN(this._current.startAngle)&&(this._current.startAngle=0),isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),e=o.interpolate(this._current,i),this._current=e(0),function(i){var n=e(i);return n.data=t.data,a.getArc(n,!0)}):function(){return"M 0 0"}}).attr("transform",i?"scale(1)":"").style("fill",function(t){return a.levelColor?a.levelColor(t.data.values[0].value):a.color(t.data.id)}).call(a.endall,function(){a.transiting=!1}),n.exit().transition().duration(e).style("opacity",0).remove(),c.selectAll("."+r.chartArc).select("text").style("opacity",0).attr("class",function(t){return a.isGaugeType(t.data)?r.gaugeValue:""}).text(a.textForArcLabel.bind(a)).attr("transform",a.transformForArcLabel.bind(a)).style("font-size",function(t){return a.isGaugeType(t.data)?Math.round(a.radius/5)+"px":""}).transition().duration(t).style("opacity",function(t){return a.isTargetToShow(t.data.id)&&a.isArcType(t.data)?1:0}),c.select("."+r.chartArcsTitle).style("opacity",a.hasType("donut")||a.hasType("gauge")?1:0),a.hasType("gauge")&&(a.arcs.select("."+r.chartArcsBackground).attr("d",function(){var t={data:[{value:s.gauge_max}],startAngle:s.gauge_startingAngle,endAngle:-1*s.gauge_startingAngle};return a.getArc(t,!0,!0)}),a.arcs.select("."+r.chartArcsGaugeUnit).attr("dy",".75em").text(s.gauge_label_show?s.gauge_units:""),a.arcs.select("."+r.chartArcsGaugeMin).attr("dx",-1*(a.innerRadius+(a.radius-a.innerRadius)/(s.gauge_fullCircle?1:2))+"px").attr("dy","1.2em").text(s.gauge_label_show?a.textForGaugeMinMax(s.gauge_min,!1):""),a.arcs.select("."+r.chartArcsGaugeMax).attr("dx",a.innerRadius+(a.radius-a.innerRadius)/(s.gauge_fullCircle?1:2)+"px").attr("dy","1.2em").text(s.gauge_label_show?a.textForGaugeMinMax(s.gauge_max,!0):""))},C.initGauge=function(){var t=this.arcs;this.hasType("gauge")&&(t.append("path").attr("class",r.chartArcsBackground),t.append("text").attr("class",r.chartArcsGaugeUnit).style("text-anchor","middle").style("pointer-events","none"),t.append("text").attr("class",r.chartArcsGaugeMin).style("text-anchor","middle").style("pointer-events","none"),t.append("text").attr("class",r.chartArcsGaugeMax).style("text-anchor","middle").style("pointer-events","none"))},C.getGaugeLabelHeight=function(){return this.config.gauge_label_show?20:0},C.hasCaches=function(t){for(var e=0;e=0?r.focused:"")},C.classDefocused=function(t){return" "+(this.defocusedTargetIds.indexOf(t.id)>=0?r.defocused:"")},C.classChartText=function(t){return r.chartText+this.classTarget(t.id)},C.classChartLine=function(t){return r.chartLine+this.classTarget(t.id)},C.classChartBar=function(t){return r.chartBar+this.classTarget(t.id)},C.classChartArc=function(t){return r.chartArc+this.classTarget(t.data.id)},C.getTargetSelectorSuffix=function(t){return t||0===t?("-"+t).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g,"-"):""},C.selectorTarget=function(t,e){return(e||"")+"."+r.target+this.getTargetSelectorSuffix(t)},C.selectorTargets=function(t,e){var i=this;return(t=t||[]).length?t.map(function(t){return i.selectorTarget(t,e)}):null},C.selectorLegend=function(t){return"."+r.legendItem+this.getTargetSelectorSuffix(t)},C.selectorLegends=function(t){var e=this;return t&&t.length?t.map(function(t){return e.selectorLegend(t)}):null},C.getClipPath=function(t){return"url("+(window.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0?"":document.URL.split("#")[0])+"#"+t+")"},C.appendClip=function(t,e){return t.append("clipPath").attr("id",e).append("rect")},C.getAxisClipX=function(t){var e=Math.max(30,this.margin.left);return t?-(1+e):-(e-1)},C.getAxisClipY=function(t){return t?-20:-this.margin.top},C.getXAxisClipX=function(){var t=this;return t.getAxisClipX(!t.config.axis_rotated)},C.getXAxisClipY=function(){var t=this;return t.getAxisClipY(!t.config.axis_rotated)},C.getYAxisClipX=function(){var t=this;return t.config.axis_y_inner?-1:t.getAxisClipX(t.config.axis_rotated)},C.getYAxisClipY=function(){var t=this;return t.getAxisClipY(t.config.axis_rotated)},C.getAxisClipWidth=function(t){var e=this,i=Math.max(30,e.margin.left),n=Math.max(30,e.margin.right);return t?e.width+2+i+n:e.margin.left+20},C.getAxisClipHeight=function(t){return(t?this.margin.bottom:this.margin.top+this.height)+20},C.getXAxisClipWidth=function(){var t=this;return t.getAxisClipWidth(!t.config.axis_rotated)},C.getXAxisClipHeight=function(){var t=this;return t.getAxisClipHeight(!t.config.axis_rotated)},C.getYAxisClipWidth=function(){var t=this;return t.getAxisClipWidth(t.config.axis_rotated)+(t.config.axis_y_inner?20:0)},C.getYAxisClipHeight=function(){var t=this;return t.getAxisClipHeight(t.config.axis_rotated)},C.generateColor=function(){var t=this,e=t.config,i=t.d3,n=e.data_colors,a=S(e.color_pattern)?e.color_pattern:i.schemeCategory10,r=e.data_color,o=[];return function(t){var e,i=t.id||t.data&&t.data.id||t;return n[i]instanceof Function?e=n[i](t):n[i]?e=n[i]:(o.indexOf(i)<0&&o.push(i),e=a[o.indexOf(i)%a.length],n[i]=e),r instanceof Function?r(e,t):e}},C.generateLevelColor=function(){var t=this.config,e=t.color_pattern,i=t.color_threshold,n="value"===i.unit,a=i.values&&i.values.length?i.values:[],r=i.max||100;return S(t.color_threshold)?function(t){var i,o=e[e.length-1];for(i=0;i=0?n.data.xs[i]=(e&&n.data.xs[i]?n.data.xs[i]:[]).concat(t.map(function(t){return t[r]}).filter(u).map(function(t,e){return n.generateTargetX(t,i,e)})):a.data_x?n.data.xs[i]=n.getOtherTargetXs():S(a.data_xs)&&(n.data.xs[i]=n.getXValuesOfXKey(r,n.data.targets)):n.data.xs[i]=t.map(function(t,e){return e})}),r.forEach(function(t){if(!n.data.xs[t])throw new Error('x is not defined for id = "'+t+'".')}),(i=r.map(function(e,i){var r=a.data_idConverter(e);return{id:r,id_org:e,values:t.map(function(t,o){var s,c=t[n.getXKey(e)],d=null===t[e]||isNaN(t[e])?null:+t[e];return n.isCustomX()&&n.isCategorized()&&!f(c)?(0===i&&0===o&&(a.axis_x_categories=[]),-1===(s=a.axis_x_categories.indexOf(c))&&(s=a.axis_x_categories.length,a.axis_x_categories.push(c))):s=n.generateTargetX(c,e,o),(f(t[e])||n.data.xs[e].length<=o)&&(s=void 0),{x:s,value:d,id:r}}).filter(function(t){return p(t.x)})}})).forEach(function(t){var e;a.data_xSort&&(t.values=t.values.sort(function(t,e){return(t.x||0===t.x?t.x:1/0)-(e.x||0===e.x?e.x:1/0)})),e=0,t.values.forEach(function(t){t.index=e++}),n.data.xs[t.id].sort(function(t,e){return t-e})}),n.hasNegativeValue=n.hasNegativeValueInTargets(i),n.hasPositiveValue=n.hasPositiveValueInTargets(i),a.data_type&&n.setTargetType(n.mapToIds(i).filter(function(t){return!(t in a.data_types)}),a.data_type),i.forEach(function(t){n.addCache(t.id_org,t)}),i},C.isX=function(t){var e=this.config;return e.data_x&&t===e.data_x||S(e.data_xs)&&v(e.data_xs,t)},C.isNotX=function(t){return!this.isX(t)},C.getXKey=function(t){var e=this.config;return e.data_x?e.data_x:S(e.data_xs)?e.data_xs[t]:null},C.getXValuesOfXKey=function(t,e){var i,n=this;return(e&&S(e)?n.mapToIds(e):[]).forEach(function(e){n.getXKey(e)===t&&(i=n.data.xs[e])}),i},C.getXValue=function(t,e){var i=this;return t in i.data.xs&&i.data.xs[t]&&u(i.data.xs[t][e])?i.data.xs[t][e]:e},C.getOtherTargetXs=function(){var t=this,e=Object.keys(t.data.xs);return e.length?t.data.xs[e[0]]:null},C.getOtherTargetX=function(t){var e=this.getOtherTargetXs();return e&&te?1:t>=e?0:NaN})},C.addHiddenTargetIds=function(t){t=t instanceof Array?t:new Array(t);for(var e=0;e0})},C.isOrderDesc=function(){var t=this.config;return"string"==typeof t.data_order&&"desc"===t.data_order.toLowerCase()},C.isOrderAsc=function(){var t=this.config;return"string"==typeof t.data_order&&"asc"===t.data_order.toLowerCase()},C.getOrderFunction=function(){var t=this,e=t.config,i=t.isOrderAsc(),n=t.isOrderDesc();if(i||n)return function(t,e){var i=function(t,e){return t+Math.abs(e.value)},a=t.values.reduce(i,0),r=e.values.reduce(i,0);return n?r-a:a-r};if(l(e.data_order))return e.data_order;if(h(e.data_order)){var a=e.data_order;return function(t,e){return a.indexOf(t.id)-a.indexOf(e.id)}}},C.orderTargets=function(t){var e=this.getOrderFunction();return e&&(t.sort(e),(this.isOrderAsc()||this.isOrderDesc())&&t.reverse()),t},C.filterByX=function(t,e){return this.d3.merge(t.map(function(t){return t.values})).filter(function(t){return t.x-e==0})},C.filterRemoveNull=function(t){return t.filter(function(t){return u(t.value)})},C.filterByXDomain=function(t,e){return t.map(function(t){return{id:t.id,id_org:t.id_org,values:t.values.filter(function(t){return e[0]<=t.x&&t.x<=e[1]})}})},C.hasDataLabel=function(){var t=this.config;return!("boolean"!=typeof t.data_labels||!t.data_labels)||!("object"!==o(t.data_labels)||!S(t.data_labels))},C.getDataLabelLength=function(t,e,i){var n=this,a=[0,0];return n.selectChart.select("svg").selectAll(".dummy").data([t,e]).enter().append("text").text(function(t){return n.dataLabelFormat(t.id)(t)}).each(function(t,e){a[e]=1.3*this.getBoundingClientRect()[i]}).remove(),a},C.isNoneArc=function(t){return this.hasTarget(this.data.targets,t.id)},C.isArc=function(t){return"data"in t&&this.hasTarget(this.data.targets,t.data.id)},C.findClosestFromTargets=function(t,e){var i,n=this;return i=t.map(function(t){return n.findClosest(t.values,e)}),n.findClosest(i,e)},C.findClosest=function(t,e){var i,n=this,a=n.config.point_sensitivity;return t.filter(function(t){return t&&n.isBarType(t.id)}).forEach(function(t){var e=n.main.select("."+r.bars+n.getTargetSelectorSuffix(t.id)+" ."+r.bar+"-"+t.index).node();!i&&n.isWithinBar(n.d3.mouse(e),e)&&(i=t)}),t.filter(function(t){return t&&!n.isBarType(t.id)}).forEach(function(t){var r=n.dist(t,e);r0)for(o=s.hasNegativeValueInTargets(t),e=0;e=0})).length)for(n=a[0],o&&u[n]&&u[n].forEach(function(t,e){u[n][e]=t<0?t:0}),i=1;i0||(u[n][e]+=+t)});return s.d3.min(Object.keys(u).map(function(t){return s.d3.min(u[t])}))},C.getYDomainMax=function(t){var e,i,n,a,r,o,s=this,c=s.config,d=s.mapToIds(t),u=s.getValuesAsIdKeyed(t);if(c.data_groups.length>0)for(o=s.hasPositiveValueInTargets(t),e=0;e=0})).length)for(n=a[0],o&&u[n]&&u[n].forEach(function(t,e){u[n][e]=t>0?t:0}),i=1;i=0&&b>=0,g=v<=0&&b<=0,(u(m)&&h||u(w)&&g)&&(A=!1),A&&(h&&(v=0),g&&(b=0)),a=Math.abs(b-v),r=o=.1*a,void 0!==T&&(b=T+(s=Math.max(Math.abs(v),Math.abs(b))),v=T-s),C?(c=f.getDataLabelLength(v,b,"width"),d=y(f.y.range()),r+=a*((l=[c[0]/d,c[1]/d])[1]/(1-l[0]-l[1])),o+=a*(l[0]/(1-l[0]-l[1]))):L&&(c=f.getDataLabelLength(v,b,"height"),r+=f.axis.convertPixelsToAxisPadding(c[1],a),o+=f.axis.convertPixelsToAxisPadding(c[0],a)),"y"===e&&S(p.axis_y_padding)&&(r=f.axis.getPadding(p.axis_y_padding,"top",r,a),o=f.axis.getPadding(p.axis_y_padding,"bottom",o,a)),"y2"===e&&S(p.axis_y2_padding)&&(r=f.axis.getPadding(p.axis_y2_padding,"top",r,a),o=f.axis.getPadding(p.axis_y2_padding,"bottom",o,a)),A&&(h&&(o=v),g&&(r=-b)),n=[v-o,b+r],P?n.reverse():n)},C.getXDomainMin=function(t){var e=this,i=e.config;return p(i.axis_x_min)?e.isTimeSeries()?this.parseDate(i.axis_x_min):i.axis_x_min:e.d3.min(t,function(t){return e.d3.min(t.values,function(t){return t.x})})},C.getXDomainMax=function(t){var e=this,i=e.config;return p(i.axis_x_max)?e.isTimeSeries()?this.parseDate(i.axis_x_max):i.axis_x_max:e.d3.max(t,function(t){return e.d3.max(t.values,function(t){return t.x})})},C.getXDomainPadding=function(t){var e,i,n,a,r=this,s=r.config,c=t[1]-t[0];return i=r.isCategorized()?0:r.hasType("bar")?(e=r.getMaxDataCount())>1?c/(e-1)/2:.5:.01*c,"object"===o(s.axis_x_padding)&&S(s.axis_x_padding)?(n=u(s.axis_x_padding.left)?s.axis_x_padding.left:i,a=u(s.axis_x_padding.right)?s.axis_x_padding.right:i):n=a="number"==typeof s.axis_x_padding?s.axis_x_padding:i,{left:n,right:a}},C.getXDomain=function(t){var e=this,i=[e.getXDomainMin(t),e.getXDomainMax(t)],n=i[0],a=i[1],r=e.getXDomainPadding(i),o=0,s=0;return n-a!=0||e.isCategorized()||(e.isTimeSeries()?(n=new Date(.5*n.getTime()),a=new Date(1.5*a.getTime())):(n=0===n?1:.5*n,a=0===a?-1:1.5*a)),(n||0===n)&&(o=e.isTimeSeries()?new Date(n.getTime()-r.left):n-r.left),(a||0===a)&&(s=e.isTimeSeries()?new Date(a.getTime()+r.right):a+r.right),[o,s]},C.updateXDomain=function(t,e,i,n,a){var r=this,o=r.config;return i&&(r.x.domain(a||r.d3.extent(r.getXDomain(t))),r.orgXDomain=r.x.domain(),o.zoom_enabled&&r.zoom.update(),r.subX.domain(r.x.domain()),r.brush&&r.brush.updateScale(r.subX)),e&&r.x.domain(a||(!r.brush||r.brush.empty()?r.orgXDomain:r.brush.selectionAsValue())),n&&r.x.domain(r.trimXDomain(r.x.orgDomain())),r.x.domain()},C.trimXDomain=function(t){var e=this.getZoomDomain(),i=e[0],n=e[1];return t[0]<=i&&(t[1]=+t[1]+(i-t[0]),t[0]=i),n<=t[1]&&(t[0]=+t[0]-(t[1]-n),t[1]=n),t},C.drag=function(t){var e,i,n,a,o,s,c,d,u=this,l=u.config,h=u.main,g=u.d3;u.hasArcType()||l.data_selection_enabled&&l.data_selection_multiple&&(e=u.dragStart[0],i=u.dragStart[1],n=t[0],a=t[1],o=Math.min(e,n),s=Math.max(e,n),c=l.data_selection_grouped?u.margin.top:Math.min(i,a),d=l.data_selection_grouped?u.height:Math.max(i,a),h.select("."+r.dragarea).attr("x",o).attr("y",c).attr("width",s-o).attr("height",d-c),h.selectAll("."+r.shapes).selectAll("."+r.shape).filter(function(t){return l.data_selection_isselectable(t)}).each(function(t,e){var i,n,a,l,h,f,p=g.select(this),_=p.classed(r.SELECTED),x=p.classed(r.INCLUDED),y=!1;if(p.classed(r.circle))i=1*p.attr("cx"),n=1*p.attr("cy"),h=u.togglePoint,y=od&&(c=c.filter(function(t){return(""+t).indexOf(".")<0}));return c},C.getGridFilterToRemove=function(t){return t?function(e){var i=!1;return[].concat(t).forEach(function(t){("value"in t&&e.value===t.value||"class"in t&&e.class===t.class)&&(i=!0)}),i}:function(){return!0}},C.removeGridLines=function(t,e){var i=this,n=i.config,a=i.getGridFilterToRemove(t),o=function(t){return!a(t)},s=e?r.xgridLines:r.ygridLines,c=e?r.xgridLine:r.ygridLine;i.main.select("."+s).selectAll("."+c).filter(a).transition().duration(n.transition_duration).style("opacity",0).remove(),e?n.grid_x_lines=n.grid_x_lines.filter(o):n.grid_y_lines=n.grid_y_lines.filter(o)},C.initEventRect=function(){var t=this,e=t.config;t.main.select("."+r.chart).append("g").attr("class",r.eventRects).style("fill-opacity",0),t.eventRect=t.main.select("."+r.eventRects).append("rect").attr("class",r.eventRect),e.zoom_enabled&&t.zoom&&(t.eventRect.call(t.zoom).on("dblclick.zoom",null),e.zoom_initialRange&&t.eventRect.transition().duration(0).call(t.zoom.transform,t.zoomTransform(e.zoom_initialRange)))},C.redrawEventRect=function(){function t(){n.svg.select("."+r.eventRect).style("cursor",null),n.hideXGridFocus(),n.hideTooltip(),n.unexpandCircles(),n.unexpandBars()}var e,i,n=this,a=n.d3,o=n.config;e=n.width,i=n.height,n.main.select("."+r.eventRects).style("cursor",o.zoom_enabled?o.axis_rotated?"ns-resize":"ew-resize":null),n.eventRect.attr("x",0).attr("y",0).attr("width",e).attr("height",i).on("mouseout",o.interaction_enabled?function(){o&&(n.hasArcType()||t())}:null).on("mousemove",o.interaction_enabled?function(){var e,i,s,c;n.dragging||n.hasArcType(e)||(e=n.filterTargetsToShow(n.data.targets),i=a.mouse(this),s=n.findClosestFromTargets(e,i),!n.mouseover||s&&s.id===n.mouseover.id||(o.data_onmouseout.call(n.api,n.mouseover),n.mouseover=void 0),s?(c=(n.isScatterType(s)||!o.tooltip_grouped?[s]:n.filterByX(e,s.x)).map(function(t){return n.addName(t)}),n.showTooltip(c,this),o.point_focus_expand_enabled&&(n.unexpandCircles(),c.forEach(function(t){n.expandCircles(t.index,t.id,!1)})),n.expandBars(s.index,s.id,!0),n.showXGridFocus(c),(n.isBarType(s.id)||n.dist(s,i)=0}).classed(r.legendItemFocused,e).transition().duration(100).style("opacity",function(){return(e?i.opacityForLegend:i.opacityForUnfocusedLegend).call(i,i.d3.select(this))})},C.revertLegend=function(){var t=this,e=t.d3;t.legend.selectAll("."+r.legendItem).classed(r.legendItemFocused,!1).transition().duration(100).style("opacity",function(){return t.opacityForLegend(e.select(this))})},C.showLegend=function(t){var e=this,i=e.config;i.legend_show||(i.legend_show=!0,e.legend.style("visibility","visible"),e.legendHasRendered||e.updateLegendWithDefaults()),e.removeHiddenLegendIds(t),e.legend.selectAll(e.selectorLegends(t)).style("visibility","visible").transition().style("opacity",function(){return e.opacityForLegend(e.d3.select(this))})},C.hideLegend=function(t){var e=this,i=e.config;i.legend_show&&m(t)&&(i.legend_show=!1,e.legend.style("visibility","hidden")),e.addHiddenLegendIds(t),e.legend.selectAll(e.selectorLegends(t)).style("opacity",0).style("visibility","hidden")},C.clearLegendItemTextBoxCache=function(){this.legendItemTextBox={}},C.updateLegend=function(t,e,i){function n(t,e){return T.legendItemTextBox[e]||(T.legendItemTextBox[e]=T.getTextRect(t.textContent,r.legendItem,t)),T.legendItemTextBox[e]}function a(e,i,a){function r(t,e){e||(o=(f-O-g)/2)=L)&&(L=l),(!V||h>=V)&&(V=h),s=T.isLegendRight||T.isLegendInset?V:L,A.legend_equally?(Object.keys(R).forEach(function(t){R[t]=L}),Object.keys(k).forEach(function(t){k[t]=V}),(o=(f-s*t.length)/2)0&&0===b.size()&&(b=T.legend.insert("g","."+r.legendItem).attr("class",r.legendBackground).append("rect")),m=T.legend.selectAll("text").data(t).text(function(t){return p(A.data_names[t])?A.data_names[t]:t}).each(function(t,e){a(this,t,e)}),(x?m.transition():m).attr("x",s).attr("y",u),S=T.legend.selectAll("rect."+r.legendItemEvent).data(t),(x?S.transition():S).attr("width",function(t){return R[t]}).attr("height",function(t){return k[t]}).attr("x",c).attr("y",l),v=T.legend.selectAll("line."+r.legendItemTile).data(t),(x?v.transition():v).style("stroke",T.color).attr("x1",h).attr("y1",f).attr("x2",g).attr("y2",f),b&&(x?b.transition():b).attr("height",T.getLegendHeight()-12).attr("width",L*(X+1)+10),T.legend.selectAll("."+r.legendItem).classed(r.legendItemHidden,function(t){return!T.isTargetToShow(t)}),T.updateLegendItemWidth(L),T.updateLegendItemHeight(V),T.updateLegendStep(X),T.updateSizes(),T.updateScales(),T.updateSvgSize(),T.transformAll(y,i),T.legendHasRendered=!0},C.initRegion=function(){var t=this;t.region=t.main.append("g").attr("clip-path",t.clipPath).attr("class",r.regions)},C.updateRegion=function(t){var e=this,i=e.config;e.region.style("visibility",e.hasArcType()?"hidden":"visible");var n=e.main.select("."+r.regions).selectAll("."+r.region).data(i.regions),a=n.enter().append("rect").attr("x",e.regionX.bind(e)).attr("y",e.regionY.bind(e)).attr("width",e.regionWidth.bind(e)).attr("height",e.regionHeight.bind(e)).style("fill-opacity",0);e.mainRegion=a.merge(n).attr("class",e.classRegion.bind(e)),n.exit().transition().duration(t).style("opacity",0).remove()},C.redrawRegion=function(t,e){var i=this,n=i.mainRegion;return[(t?n.transition(e):n).attr("x",i.regionX.bind(i)).attr("y",i.regionY.bind(i)).attr("width",i.regionWidth.bind(i)).attr("height",i.regionHeight.bind(i)).style("fill-opacity",function(t){return u(t.opacity)?t.opacity:.1})]},C.regionX=function(t){var e=this,i=e.config,n="y"===t.axis?e.y:e.y2;return"y"===t.axis||"y2"===t.axis?i.axis_rotated&&"start"in t?n(t.start):0:i.axis_rotated?0:"start"in t?e.x(e.isTimeSeries()?e.parseDate(t.start):t.start):0},C.regionY=function(t){var e=this,i=e.config,n="y"===t.axis?e.y:e.y2;return"y"===t.axis||"y2"===t.axis?i.axis_rotated?0:"end"in t?n(t.end):0:i.axis_rotated&&"start"in t?e.x(e.isTimeSeries()?e.parseDate(t.start):t.start):0},C.regionWidth=function(t){var e,i=this,n=i.config,a=i.regionX(t),r="y"===t.axis?i.y:i.y2;return(e="y"===t.axis||"y2"===t.axis?n.axis_rotated&&"end"in t?r(t.end):i.width:n.axis_rotated?i.width:"end"in t?i.x(i.isTimeSeries()?i.parseDate(t.end):t.end):i.width)i.bar_width_max?i.bar_width_max:n},C.getBars=function(t,e){var i=this;return(e?i.main.selectAll("."+r.bars+i.getTargetSelectorSuffix(e)):i.main).selectAll("."+r.bar+(u(t)?"-"+t:""))},C.expandBars=function(t,e,i){var n=this;i&&n.unexpandBars(),n.getBars(t,e).classed(r.EXPANDED,!0)},C.unexpandBars=function(t){this.getBars(t).classed(r.EXPANDED,!1)},C.generateDrawBar=function(t,e){var i=this,n=i.config,a=i.generateGetBarPoints(t,e);return function(t,e){var i=a(t,e),r=n.axis_rotated?1:0,o=n.axis_rotated?0:1;return"M "+i[0][r]+","+i[0][o]+" L"+i[1][r]+","+i[1][o]+" L"+i[2][r]+","+i[2][o]+" L"+i[3][r]+","+i[3][o]+" z"}},C.generateGetBarPoints=function(t,e){var i=this,n=e?i.subXAxis:i.xAxis,a=t.__max__+1,r=i.getBarW(n,a),o=i.getShapeX(r,a,t,!!e),s=i.getShapeY(!!e),c=i.getShapeOffset(i.isBarType,t,!!e),d=r*(i.config.bar_space/2),u=e?i.getSubYScale:i.getYScale;return function(t,e){var n=u.call(i,t.id)(0),a=c(t,e)||n,l=o(t),h=s(t);return i.config.axis_rotated&&(0=0&&(d+=s(a[o].value)-c))}),d}},C.isWithinShape=function(t,e){var i,n=this,a=n.d3.select(t);return n.isTargetToShow(e.id)?"circle"===t.nodeName?i=n.isStepType(e)?n.isWithinStep(t,n.getYScale(e.id)(e.value)):n.isWithinCircle(t,1.5*n.pointSelectR(e)):"path"===t.nodeName&&(i=!a.classed(r.bar)||n.isWithinBar(n.d3.mouse(t),t)):i=!1,i},C.getInterpolate=function(t){var e=this,i=e.d3,n={linear:i.curveLinear,"linear-closed":i.curveLinearClosed,basis:i.curveBasis,"basis-open":i.curveBasisOpen,"basis-closed":i.curveBasisClosed,bundle:i.curveBundle,cardinal:i.curveCardinal,"cardinal-open":i.curveCardinalOpen,"cardinal-closed":i.curveCardinalClosed,monotone:i.curveMonotoneX,step:i.curveStep};return e.isSplineType(t)?n[e.config.spline_interpolation_type]||n.cardinal:e.isStepType(t)?n[e.config.line_step_type]:n.linear},C.initLine=function(){this.main.select("."+r.chart).append("g").attr("class",r.chartLines)},C.updateTargetsForLine=function(t){var e,i=this,n=i.config,a=i.classChartLine.bind(i),o=i.classLines.bind(i),s=i.classAreas.bind(i),c=i.classCircles.bind(i),d=i.classFocus.bind(i);(e=i.main.select("."+r.chartLines).selectAll("."+r.chartLine).data(t).attr("class",function(t){return a(t)+d(t)}).enter().append("g").attr("class",a).style("opacity",0).style("pointer-events","none")).append("g").attr("class",o),e.append("g").attr("class",s),e.append("g").attr("class",function(t){return i.generateClass(r.selectedCircles,t.id)}),e.append("g").attr("class",c).style("cursor",function(t){return n.data_selection_isselectable(t)?"pointer":null}),t.forEach(function(t){i.main.selectAll("."+r.selectedCircles+i.getTargetSelectorSuffix(t.id)).selectAll("."+r.selectedCircle).each(function(e){e.value=t.values[e.index].value})})},C.updateLine=function(t){var e=this,i=e.main.selectAll("."+r.lines).selectAll("."+r.line).data(e.lineData.bind(e)),n=i.enter().append("path").attr("class",e.classLine.bind(e)).style("stroke",e.color);e.mainLine=n.merge(i).style("opacity",e.initialOpacity.bind(e)).style("shape-rendering",function(t){return e.isStepType(t)?"crispEdges":""}).attr("transform",null),i.exit().transition().duration(t).style("opacity",0)},C.redrawLine=function(t,e,i){return[(e?this.mainLine.transition(i):this.mainLine).attr("d",t).style("stroke",this.color).style("opacity",1)]},C.generateDrawLine=function(t,e){var i=this,n=i.config,a=i.d3.line(),r=i.generateGetLinePoints(t,e),o=e?i.getSubYScale:i.getYScale,s=function(t){return(e?i.subxx:i.xx).call(i,t)},c=function(t,e){return n.data_groups.length>0?r(t,e)[0][1]:o.call(i,t.id)(t.value)};return a=n.axis_rotated?a.x(c).y(s):a.x(s).y(c),n.line_connectNull||(a=a.defined(function(t){return null!=t.value})),function(t){var r,s=n.line_connectNull?i.filterRemoveNull(t.values):t.values,c=e?i.x:i.subX,d=o.call(i,t.id),u=0,l=0;return i.isLineType(t)?n.data_regions[t.id]?r=i.lineWithRegions(s,c,d,n.data_regions[t.id]):(i.isStepType(t)&&(s=i.convertValuesToStep(s)),r=a.curve(i.getInterpolate(t))(s)):(s[0]&&(u=c(s[0].x),l=d(s[0].value)),r=n.axis_rotated?"M "+l+" "+u:"M "+u+" "+l),r||"M 0 0"}},C.generateGetLinePoints=function(t,e){var i=this,n=i.config,a=t.__max__+1,r=i.getShapeX(0,a,t,!!e),o=i.getShapeY(!!e),s=i.getShapeOffset(i.isLineType,t,!!e),c=e?i.getSubYScale:i.getYScale;return function(t,e){var a=c.call(i,t.id)(0),d=s(t,e)||a,u=r(t),l=o(t);return n.axis_rotated&&(00?r(t,e)[0][1]:o.call(i,t.id)(i.getAreaBaseValue(t.id))},d=function(t,e){return n.data_groups.length>0?r(t,e)[1][1]:o.call(i,t.id)(t.value)};return a=n.axis_rotated?a.x0(c).x1(d).y(s):a.x(s).y0(n.area_above?0:c).y1(d),n.line_connectNull||(a=a.defined(function(t){return null!==t.value})),function(t){var e,r=n.line_connectNull?i.filterRemoveNull(t.values):t.values,o=0,s=0;return i.isAreaType(t)?(i.isStepType(t)&&(r=i.convertValuesToStep(r)),e=a.curve(i.getInterpolate(t))(r)):(r[0]&&(o=i.x(r[0].x),s=i.getYScale(t.id)(r[0].value)),e=n.axis_rotated?"M "+s+" "+o:"M "+o+" "+s),e||"M 0 0"}},C.getAreaBaseValue=function(){return 0},C.generateGetAreaPoints=function(t,e){var i=this,n=i.config,a=t.__max__+1,r=i.getShapeX(0,a,t,!!e),o=i.getShapeY(!!e),s=i.getShapeOffset(i.isAreaType,t,!!e),c=e?i.getSubYScale:i.getYScale;return function(t,e){var a=c.call(i,t.id)(0),d=s(t,e)||a,u=r(t),l=o(t);return n.axis_rotated&&(00?(t=i.getShapeIndices(i.isLineType),e=i.generateGetLinePoints(t),i.circleY=function(t,i){return e(t,i)[0][1]}):i.circleY=function(t){return i.getYScale(t.id)(t.value)}},C.getCircles=function(t,e){var i=this;return(e?i.main.selectAll("."+r.circles+i.getTargetSelectorSuffix(e)):i.main).selectAll("."+r.circle+(u(t)?"-"+t:""))},C.expandCircles=function(t,e,i){var n=this,a=n.pointExpandedR.bind(n);i&&n.unexpandCircles(),n.getCircles(t,e).classed(r.EXPANDED,!0).attr("r",a)},C.unexpandCircles=function(t){var e=this,i=e.pointR.bind(e);e.getCircles(t).filter(function(){return e.d3.select(this).classed(r.EXPANDED)}).classed(r.EXPANDED,!1).attr("r",i)},C.pointR=function(t){var e=this,i=e.config;return e.isStepType(t)?0:l(i.point_r)?i.point_r(t):i.point_r},C.pointExpandedR=function(t){var e=this,i=e.config;return i.point_focus_expand_enabled?l(i.point_focus_expand_r)?i.point_focus_expand_r(t):i.point_focus_expand_r?i.point_focus_expand_r:1.75*e.pointR(t):e.pointR(t)},C.pointSelectR=function(t){var e=this,i=e.config;return l(i.point_select_r)?i.point_select_r(t):i.point_select_r?i.point_select_r:4*e.pointR(t)},C.isWithinCircle=function(t,e){var i=this.d3,n=i.mouse(t),a=i.select(t),r=+a.attr("cx"),o=+a.attr("cy");return Math.sqrt(Math.pow(r-n[0],2)+Math.pow(o-n[1],2))0?i:320/(t.hasType("gauge")&&!e.gauge_fullCircle?2:1)},C.getCurrentPaddingTop=function(){var t=this,e=t.config,i=u(e.padding_top)?e.padding_top:0;return t.title&&t.title.node()&&(i+=t.getTitlePadding()),i},C.getCurrentPaddingBottom=function(){var t=this.config;return u(t.padding_bottom)?t.padding_bottom:0},C.getCurrentPaddingLeft=function(t){var e=this,i=e.config;return u(i.padding_left)?i.padding_left:i.axis_rotated?i.axis_x_show?Math.max(_(e.getAxisWidthByAxisId("x",t)),40):1:!i.axis_y_show||i.axis_y_inner?e.axis.getYAxisLabelPosition().isOuter?30:1:_(e.getAxisWidthByAxisId("y",t))},C.getCurrentPaddingRight=function(){var t=this,e=t.config,i=t.isLegendRight?t.getLegendWidth()+20:0;return u(e.padding_right)?e.padding_right+1:e.axis_rotated?10+i:!e.axis_y2_show||e.axis_y2_inner?2+i+(t.axis.getY2AxisLabelPosition().isOuter?20:0):_(t.getAxisWidthByAxisId("y2"))+i},C.getParentRectValue=function(t){for(var e,i=this.selectChart.node();i&&"BODY"!==i.tagName;){try{e=i.getBoundingClientRect()[t]}catch(n){"width"===t&&(e=i.offsetWidth)}if(e)break;i=i.parentNode}return e},C.getParentWidth=function(){return this.getParentRectValue("width")},C.getParentHeight=function(){var t=this.selectChart.style("height");return t.indexOf("px")>0?+t.replace("px",""):0},C.getSvgLeft=function(t){var e=this,i=e.config,n=i.axis_rotated||!i.axis_rotated&&!i.axis_y_inner,a=i.axis_rotated?r.axisX:r.axisY,o=e.main.select("."+a).node(),s=o&&n?o.getBoundingClientRect():{right:0},c=e.selectChart.node().getBoundingClientRect(),d=e.hasArcType(),u=s.right-c.left-(d?0:e.getCurrentPaddingLeft(t));return u>0?u:0},C.getAxisWidthByAxisId=function(t,e){var i=this,n=i.axis.getLabelPositionById(t);return i.axis.getMaxTickWidth(t,e)+(n.isInner?20:40)},C.getHorizontalAxisHeight=function(t){var e=this,i=e.config,n=30;return"x"!==t||i.axis_x_show?"x"===t&&i.axis_x_height?i.axis_x_height:"y"!==t||i.axis_y_show?"y2"!==t||i.axis_y2_show?("x"===t&&!i.axis_rotated&&i.axis_x_tick_rotate&&(n=30+e.axis.getMaxTickWidth(t)*Math.cos(Math.PI*(90-i.axis_x_tick_rotate)/180)),"y"===t&&i.axis_rotated&&i.axis_y_tick_rotate&&(n=30+e.axis.getMaxTickWidth(t)*Math.cos(Math.PI*(90-i.axis_y_tick_rotate)/180)),n+(e.axis.getLabelPositionById(t).isInner?0:10)+("y2"===t?-10:0)):e.rotated_padding_top:!i.legend_show||e.isLegendRight||e.isLegendInset?1:10:8},C.initBrush=function(t){var e=this,i=e.d3;return e.brush=(e.config.axis_rotated?i.brushY():i.brushX()).on("brush",function(){var t=i.event.sourceEvent;t&&"zoom"===t.type||e.redrawForBrush()}).on("end",function(){var t=i.event.sourceEvent;t&&"zoom"===t.type||e.brush.empty()&&t&&"end"!==t.type&&e.brush.clear()}),e.brush.updateExtent=function(){var t,i=this.scale.range();return t=e.config.axis_rotated?[[0,i[0]],[e.width2,i[1]]]:[[i[0],0],[i[1],e.height2]],this.extent(t),this},e.brush.updateScale=function(t){return this.scale=t,this},e.brush.update=function(t){this.updateScale(t||e.subX).updateExtent(),e.context.select("."+r.brush).call(this)},e.brush.clear=function(){e.context.select("."+r.brush).call(e.brush.move,null)},e.brush.selection=function(){return i.brushSelection(e.context.select("."+r.brush).node())},e.brush.selectionAsValue=function(t){var i;return t?(e.context&&(i=[this.scale(t[0]),this.scale(t[1])],e.brush.move(e.context.select("."+r.brush).transition(),i)),[]):(i=e.brush.selection()||[0,0],[this.scale.invert(i[0]),this.scale.invert(i[1])])},e.brush.empty=function(){var t=e.brush.selection();return!t||t[0]===t[1]},e.brush.updateScale(t)},C.initSubchart=function(){var t=this,e=t.config,i=t.context=t.svg.append("g").attr("transform",t.getTranslate("context")),n=e.subchart_show?"visible":"hidden";i.style("visibility",n),i.append("g").attr("clip-path",t.clipPathForSubchart).attr("class",r.chart),i.select("."+r.chart).append("g").attr("class",r.chartBars),i.select("."+r.chart).append("g").attr("class",r.chartLines),i.append("g").attr("clip-path",t.clipPath).attr("class",r.brush),t.axes.subx=i.append("g").attr("class",r.axisX).attr("transform",t.getTranslate("subx")).attr("clip-path",e.axis_rotated?"":t.clipPathForXAxis)},C.initSubchartBrush=function(){var t=this;t.initBrush(t.subX).updateExtent(),t.context.select("."+r.brush).call(t.brush)},C.updateTargetsForSubchart=function(t){var e,i,n,a,o=this,s=o.context,c=o.config,d=o.classChartBar.bind(o),u=o.classBars.bind(o),l=o.classChartLine.bind(o),h=o.classLines.bind(o),g=o.classAreas.bind(o);c.subchart_show&&((n=(a=s.select("."+r.chartBars).selectAll("."+r.chartBar).data(t)).enter().append("g").style("opacity",0)).merge(a).attr("class",d),n.append("g").attr("class",u),(e=(i=s.select("."+r.chartLines).selectAll("."+r.chartLine).data(t)).enter().append("g").style("opacity",0)).merge(i).attr("class",l),e.append("g").attr("class",h),e.append("g").attr("class",g),s.selectAll("."+r.brush+" rect").attr(c.axis_rotated?"width":"height",c.axis_rotated?o.width2:o.height2))},C.updateBarForSubchart=function(t){var e=this,i=e.context.selectAll("."+r.bars).selectAll("."+r.bar).data(e.barData.bind(e)),n=i.enter().append("path").attr("class",e.classBar.bind(e)).style("stroke","none").style("fill",e.color);i.exit().transition().duration(t).style("opacity",0).remove(),e.contextBar=n.merge(i).style("opacity",e.initialOpacity.bind(e))},C.redrawBarForSubchart=function(t,e,i){(e?this.contextBar.transition(Math.random().toString()).duration(i):this.contextBar).attr("d",t).style("opacity",1)},C.updateLineForSubchart=function(t){var e=this,i=e.context.selectAll("."+r.lines).selectAll("."+r.line).data(e.lineData.bind(e)),n=i.enter().append("path").attr("class",e.classLine.bind(e)).style("stroke",e.color);i.exit().transition().duration(t).style("opacity",0).remove(),e.contextLine=n.merge(i).style("opacity",e.initialOpacity.bind(e))},C.redrawLineForSubchart=function(t,e,i){(e?this.contextLine.transition(Math.random().toString()).duration(i):this.contextLine).attr("d",t).style("opacity",1)},C.updateAreaForSubchart=function(t){var e=this,i=e.d3,n=e.context.selectAll("."+r.areas).selectAll("."+r.area).data(e.lineData.bind(e)),a=n.enter().append("path").attr("class",e.classArea.bind(e)).style("fill",e.color).style("opacity",function(){return e.orgAreaOpacity=+i.select(this).style("opacity"),0});n.exit().transition().duration(t).style("opacity",0).remove(),e.contextArea=a.merge(n).style("opacity",0)},C.redrawAreaForSubchart=function(t,e,i){(e?this.contextArea.transition(Math.random().toString()).duration(i):this.contextArea).attr("d",t).style("fill",this.color).style("opacity",this.orgAreaOpacity)},C.redrawSubchart=function(t,e,i,n,a,r,o){var s,c,d,u=this,l=u.d3,h=u.config;u.context.style("visibility",h.subchart_show?"visible":"hidden"),h.subchart_show&&(l.event&&"zoom"===l.event.type&&u.brush.selectionAsValue(u.x.orgDomain()),t&&(u.brush.empty()||u.brush.selectionAsValue(u.x.orgDomain()),s=u.generateDrawArea(a,!0),c=u.generateDrawBar(r,!0),d=u.generateDrawLine(o,!0),u.updateBarForSubchart(i),u.updateLineForSubchart(i),u.updateAreaForSubchart(i),u.redrawBarForSubchart(c,i,i),u.redrawLineForSubchart(d,i,i),u.redrawAreaForSubchart(s,i,i)))},C.redrawForBrush=function(){var t,e=this,i=e.x,n=e.d3;e.redraw({withTransition:!1,withY:e.config.zoom_rescale,withSubchart:!1,withUpdateXDomain:!0,withEventRect:!1,withDimension:!1}),t=n.event.selection||e.brush.scale.range(),e.main.select("."+r.eventRect).call(e.zoom.transform,n.zoomIdentity.scale(e.width/(t[1]-t[0])).translate(-t[0],0)),e.config.subchart_onbrush.call(e.api,i.orgDomain())},C.transformContext=function(t,e){var i,n=this;e&&e.axisSubX?i=e.axisSubX:(i=n.context.select("."+r.axisX),t&&(i=i.transition())),n.context.attr("transform",n.getTranslate("context")),i.attr("transform",n.getTranslate("subx"))},C.getDefaultSelection=function(){var t=this,e=t.config,i=l(e.axis_x_selection)?e.axis_x_selection(t.getXDomain(t.data.targets)):e.axis_x_selection;return t.isTimeSeries()&&(i=[t.parseDate(i[0]),t.parseDate(i[1])]),i},C.initText=function(){var t=this;t.main.select("."+r.chart).append("g").attr("class",r.chartTexts),t.mainText=t.d3.selectAll([])},C.updateTargetsForText=function(t){var e=this,i=e.classChartText.bind(e),n=e.classTexts.bind(e),a=e.classFocus.bind(e),o=e.main.select("."+r.chartTexts).selectAll("."+r.chartText).data(t),s=o.enter().append("g").attr("class",i).style("opacity",0).style("pointer-events","none");s.append("g").attr("class",n),s.merge(o).attr("class",function(t){return i(t)+a(t)})},C.updateText=function(t,e,i){var n=this,a=n.config,o=n.barOrLineData.bind(n),s=n.classText.bind(n),c=n.main.selectAll("."+r.texts).selectAll("."+r.text).data(o),d=c.enter().append("text").attr("class",s).attr("text-anchor",function(t){return a.axis_rotated?t.value<0?"end":"start":"middle"}).style("stroke","none").attr("x",t).attr("y",e).style("fill",function(t){return n.color(t)}).style("fill-opacity",0);n.mainText=d.merge(c).text(function(t,e,i){return n.dataLabelFormat(t.id)(t.value,t.id,e,i)}),c.exit().transition().duration(i).style("fill-opacity",0).remove()},C.redrawText=function(t,e,i,n,a){return[(n?this.mainText.transition(a):this.mainText).attr("x",t).attr("y",e).style("fill",this.color).style("fill-opacity",i?0:this.opacityForText.bind(this))]},C.getTextRect=function(t,e,i){var n,a=this.d3.select("body").append("div").classed("c3",!0),r=a.append("svg").style("visibility","hidden").style("position","fixed").style("top",0).style("left",0),o=this.d3.select(i).style("font");return r.selectAll(".dummy").data([t]).enter().append("text").classed(e||"",!0).style("font",o).text(t).each(function(){n=this.getBoundingClientRect()}),a.remove(),n},C.generateXYForText=function(t,e,i,n){var a=this,r=a.generateGetAreaPoints(t,!1),o=a.generateGetBarPoints(e,!1),s=a.generateGetLinePoints(i,!1),c=n?a.getXForText:a.getYForText;return function(t,e){var i=a.isAreaType(t)?r:a.isBarType(t)?o:s;return c.call(a,i(t,e),t,this)}},C.getXForText=function(t,e,i){var n,a,r=this,o=i.getBoundingClientRect();return r.config.axis_rotated?(a=r.isBarType(e)?4:6,n=t[2][1]+a*(e.value<0?-1:1)):n=r.hasType("bar")?(t[2][0]+t[0][0])/2:t[0][0],null===e.value&&(n>r.width?n=r.width-o.width:n<0&&(n=4)),n},C.getYForText=function(t,e,i){var n,a=this,r=i.getBoundingClientRect();return a.config.axis_rotated?n=(t[0][0]+t[2][0]+.6*r.height)/2:(n=t[2][1],e.value<0||0===e.value&&!a.hasPositiveValue?(n+=r.height,a.isBarType(e)&&a.isSafari()?n-=3:!a.isBarType(e)&&a.isChrome()&&(n+=3)):n+=a.isBarType(e)?-3:-6),null!==e.value||a.config.axis_rotated||(nthis.height&&(n=this.height-4)),n},C.initTitle=function(){var t=this;t.title=t.svg.append("text").text(t.config.title_text).attr("class",t.CLASS.title)},C.redrawTitle=function(){var t=this;t.title.attr("x",t.xForTitle.bind(t)).attr("y",t.yForTitle.bind(t))},C.xForTitle=function(){var t=this,e=t.config,i=e.title_position||"left";return i.indexOf("right")>=0?t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width-e.title_padding.right:i.indexOf("center")>=0?(t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width)/2:e.title_padding.left},C.yForTitle=function(){var t=this;return t.config.title_padding.top+t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).height},C.getTitlePadding=function(){var t=this;return t.yForTitle()+t.config.title_padding.bottom},C.initTooltip=function(){var t,e=this,i=e.config;if(e.tooltip=e.selectChart.style("position","relative").append("div").attr("class",r.tooltipContainer).style("position","absolute").style("pointer-events","none").style("display","none"),i.tooltip_init_show){if(e.isTimeSeries()&&g(i.tooltip_init_x)){for(i.tooltip_init_x=e.parseDate(i.tooltip_init_x),t=0;t"+(o||0===o?""+o+"":"")),void 0!==(s=b(f(t[r].value,t[r].ratio,t[r].id,t[r].index,t))))){if(null===t[r].name)continue;c=b(g(t[r].name,t[r].ratio,t[r].id,t[r].index)),d=u.levelColor?u.levelColor(t[r].value):n(t[r].id),a+="",a+=""+c+"",a+=""+s+"",a+=""}return a+""},C.tooltipPosition=function(t,e,i,n){var a,r,o,s,c,d=this,u=d.config,l=d.d3,h=d.hasArcType(),g=l.mouse(n);return h?(r=(d.width-(d.isLegendRight?d.getLegendWidth():0))/2+g[0],s=d.height/2+g[1]+20):(a=d.getSvgLeft(!0),u.axis_rotated?(o=(r=a+g[0]+100)+e,c=d.currentWidth-d.getCurrentPaddingRight(),s=d.x(t[0].x)+20):(o=(r=a+d.getCurrentPaddingLeft(!0)+d.x(t[0].x)+20)+e,c=a+d.currentWidth-d.getCurrentPaddingRight(),s=g[1]+15),o>c&&(r-=o-c+20),s+i>d.currentHeight&&(s-=i+30)),s<0&&(s=0),{top:s,left:r}},C.showTooltip=function(t,e){var i,n,a,r=this,o=r.config,s=r.hasArcType(),c=t.filter(function(t){return t&&u(t.value)}),d=o.tooltip_position||C.tooltipPosition;0!==c.length&&o.tooltip_show&&(r.tooltip.html(o.tooltip_contents.call(r,t,r.axis.getXAxisTickFormat(),r.getYFormat(s),r.color)).style("display","block"),i=r.tooltip.property("offsetWidth"),n=r.tooltip.property("offsetHeight"),a=d.call(this,c,i,n,e),r.tooltip.style("top",a.top+"px").style("left",a.left+"px"))},C.hideTooltip=function(){this.tooltip.style("display","none")},C.setTargetType=function(t,e){var i=this,n=i.config;i.mapToTargetIds(t).forEach(function(t){i.withoutFadeIn[t]=e===n.data_types[t],n.data_types[t]=e}),t||(n.data_type=e)},C.hasType=function(t,e){var i=this,n=i.config.data_types,a=!1;return(e=e||i.data.targets)&&e.length?e.forEach(function(e){var i=n[e.id];(i&&i.indexOf(t)>=0||!i&&"line"===t)&&(a=!0)}):Object.keys(n).length?Object.keys(n).forEach(function(e){n[e]===t&&(a=!0)}):a=i.config.data_type===t,a},C.hasArcType=function(t){return this.hasType("pie",t)||this.hasType("donut",t)||this.hasType("gauge",t)},C.isLineType=function(t){var e=this.config,i=g(t)?t:t.id;return!e.data_types[i]||["line","spline","area","area-spline","step","area-step"].indexOf(e.data_types[i])>=0},C.isStepType=function(t){var e=g(t)?t:t.id;return["step","area-step"].indexOf(this.config.data_types[e])>=0},C.isSplineType=function(t){var e=g(t)?t:t.id;return["spline","area-spline"].indexOf(this.config.data_types[e])>=0},C.isAreaType=function(t){var e=g(t)?t:t.id;return["area","area-spline","area-step"].indexOf(this.config.data_types[e])>=0},C.isBarType=function(t){var e=g(t)?t:t.id;return"bar"===this.config.data_types[e]},C.isScatterType=function(t){var e=g(t)?t:t.id;return"scatter"===this.config.data_types[e]},C.isPieType=function(t){var e=g(t)?t:t.id;return"pie"===this.config.data_types[e]},C.isGaugeType=function(t){var e=g(t)?t:t.id;return"gauge"===this.config.data_types[e]},C.isDonutType=function(t){var e=g(t)?t:t.id;return"donut"===this.config.data_types[e]},C.isArcType=function(t){return this.isPieType(t)||this.isDonutType(t)||this.isGaugeType(t)},C.lineData=function(t){return this.isLineType(t)?[t]:[]},C.arcData=function(t){return this.isArcType(t.data)?[t]:[]},C.barData=function(t){return this.isBarType(t)?t.values:[]},C.lineOrScatterData=function(t){return this.isLineType(t)||this.isScatterType(t)?t.values:[]},C.barOrLineData=function(t){return this.isBarType(t)||this.isLineType(t)?t.values:[]},C.isSafari=function(){var t=window.navigator.userAgent;return t.indexOf("Safari")>=0&&t.indexOf("Chrome")<0},C.isChrome=function(){return window.navigator.userAgent.indexOf("Chrome")>=0},C.initZoom=function(){var t,e=this,i=e.d3,n=e.config;return e.zoom=i.zoom().on("start",function(){var a=i.event.sourceEvent;a&&"brush"===a.type||(t=a,n.zoom_onzoomstart.call(e.api,a))}).on("zoom",function(){var t=i.event.sourceEvent;t&&"brush"===t.type||e.redrawForZoom.call(e)}).on("end",function(){var a=i.event.sourceEvent;a&&"brush"===a.type||a&&t.clientX===a.clientX&&t.clientY===a.clientY||n.zoom_onzoomend.call(e.api,e.x.orgDomain())}),e.zoom.updateDomain=function(){return i.event&&i.event.transform&&e.x.domain(i.event.transform.rescaleX(e.subX).domain()),this},e.zoom.updateExtent=function(){return this.scaleExtent([1,1/0]).translateExtent([[0,0],[e.width,e.height]]).extent([[0,0],[e.width,e.height]]),this},e.zoom.update=function(){return this.updateExtent().updateDomain()},e.zoom.updateExtent()},C.zoomTransform=function(t){var e=this,i=[e.x(t[0]),e.x(t[1])];return e.d3.zoomIdentity.scale(e.width/(i[1]-i[0])).translate(-i[0],0)},C.getZoomDomain=function(){var t=this,e=t.config,i=t.d3;return[i.min([t.orgXDomain[0],e.zoom_x_min]),i.max([t.orgXDomain[1],e.zoom_x_max])]},C.redrawForZoom=function(){var t=this,e=t.d3,i=t.config,n=t.zoom,a=t.x;i.zoom_enabled&&0!==t.filterTargetsToShow(t.data.targets).length&&(n.update(),t.isCategorized()&&a.orgDomain()[0]===t.orgXDomain[0]&&a.domain([t.orgXDomain[0]-1e-10,a.orgDomain()[1]]),t.redraw({withTransition:!1,withY:i.zoom_rescale,withSubchart:!1,withEventRect:!1,withDimension:!1}),e.event.sourceEvent&&"mousemove"===e.event.sourceEvent.type&&(t.cancelClick=!0),i.zoom_onzoom.call(t.api,a.orgDomain()))},L}); \ No newline at end of file diff --git a/spec/api.region-spec.js b/spec/api.region-spec.js index 915ad0d..f3d35d8 100644 --- a/spec/api.region-spec.js +++ b/spec/api.region-spec.js @@ -59,9 +59,8 @@ describe('c3 api region', function () { regions.each(function (d, i) { var region = d3.select(this), - rect = region.select('rect'), - y = +rect.attr('y'), - height = +rect.attr('height'), + y = +region.attr('y'), + height = +region.attr('height'), expectedClass = 'red', unexpectedClass = 'green', expectedStart = Math.round(chart.internal.y(expectedRegions[i].start)), @@ -151,9 +150,8 @@ describe('c3 api region', function () { regions.each(function (d, i) { var region = d3.select(this), - rect = region.select('rect'), - y = +rect.attr('y'), - height = +rect.attr('height'), + y = +region.attr('y'), + height = +region.attr('height'), expectedClass = expectedClasses[i], expectedStart = Math.round(chart.internal.y(expectedRegions[i].start)), expectedEnd = Math.round(chart.internal.y(expectedRegions[i].end)), @@ -224,9 +222,8 @@ describe('c3 api region', function () { regions.each(function (d, i) { var region = d3.select(this), - rect = region.select('rect'), - y = +rect.attr('y'), - height = +rect.attr('height'), + y = +region.attr('y'), + height = +region.attr('height'), expectedClass = expectedClasses[i], expectedStart = Math.round(chart.internal.y(expectedRegions[i].start)), expectedEnd = Math.round(chart.internal.y(expectedRegions[i].end)), diff --git a/spec/arc-spec.js b/spec/arc-spec.js index 1c39d35..56120b7 100644 --- a/spec/arc-spec.js +++ b/spec/arc-spec.js @@ -41,9 +41,9 @@ describe('c3 chart arc', function () { }); it('should have correct d', function () { - expect(d3.select('.c3-arc-data1').attr('d')).toMatch(/M-124\..+,-171\..+A211\..+,211\..+ 0 0,1 -3\..+,-211\..+L0,0Z/); - expect(d3.select('.c3-arc-data2').attr('d')).toMatch(/M1\..+,-211\..+A211\..+,211\..+ 0 0,1 1\..+,211\..+L0,0Z/); - expect(d3.select('.c3-arc-data3').attr('d')).toMatch(/M1\..+,211\..+A211\..+,211\..+ 0 0,1 -124\..+,-171\..+L0,0Z/); + expect(d3.select('.c3-arc-data1').attr('d')).toMatch(/M-124\..+,-171\..+A211\..+,211\..+,0,0,1,-3\..+,-211\..+L0,0Z/); + expect(d3.select('.c3-arc-data2').attr('d')).toMatch(/M1\..+,-211\..+211\..+,211\..+,0,0,1,1\..+,211\..+L0,0Z/); + expect(d3.select('.c3-arc-data3').attr('d')).toMatch(/M1\..+,211\..+211\..+,211\..+,0,0,1,-124\..+,-171\..+L0,0Z/); }); describe('with data id that can be converted to a color', function () { @@ -57,7 +57,7 @@ describe('c3 chart arc', function () { it('should have correct d even if data id can be converted to a color', function (done) { setTimeout(function () { - expect(d3.select('.c3-arc-black').attr('d')).toMatch(/M-124\..+,-171\..+A211\..+,211\..+ 0 0,1 -3\..+,-211\..+L0,0Z/); + expect(d3.select('.c3-arc-black').attr('d')).toMatch(/M-124\..+,-171\..+A211\..+,211\..+,0,0,1,-3\..+,-211\..+L0,0Z/); done(); }, 500); }); @@ -198,7 +198,7 @@ describe('c3 chart arc', function () { .select('g.c3-shapes.c3-shapes-data.c3-arcs.c3-arcs-data') .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data'); - expect(data.attr('d')).toMatch(/M-304,-3\..+A304,304 0 0,1 245\..+,-178\..+L237\..+,-172\..+A294,294 0 0,0 -294,-3\..+Z/); + expect(data.attr('d')).toMatch(/M-304,-3\..+A304,304,0,0,1,245\..+,-178\..+L237\..+,-172\..+A294,294,0,0,0,-294,-3\..+Z/); }); }); @@ -229,7 +229,7 @@ describe('c3 chart arc', function () { .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data'); // This test has bee updated to make tests pass. @TODO double-check this test is accurate. - expect(data.attr('d')).toMatch(/M-221.*?,-2\..+A221.*?,221.*? 0 1,1 -68.*?,210.*?L-65.*?,201.*?A211.*?,211.*? 0 1,0 -211.*?,-2.*?Z/); + expect(data.attr('d')).toMatch(/M-221.*?,-2\..+A221.*?,221.*?,0,1,1,-68.*?,210.*?L-65.*?,201.*?A211.*?,211.*?,0,1,0,-211.*?,-2.*?Z/); }); describe('with labels use custom text', function() { diff --git a/spec/axis-spec.js b/spec/axis-spec.js index f56534f..1904c97 100644 --- a/spec/axis-spec.js +++ b/spec/axis-spec.js @@ -129,7 +129,7 @@ describe('c3 chart axis', function () { describe('with axis.y.time', function () { beforeAll(function(){ args.axis.y.tick.time = { - value : 'seconds', + type : d3.timeSecond, interval : 60 }; }); @@ -235,7 +235,7 @@ describe('c3 chart axis', function () { it('should split x axis tick text to multiple lines', function () { var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'), - expectedTexts = ['very long tick text on x', 'axis'], + expectedTexts = ['very long tick text', 'on x axis'], expectedX = '0'; expect(ticks.size()).toBe(6); ticks.each(function () { diff --git a/spec/c3-helper.js b/spec/c3-helper.js index 452e7a3..88ce3ad 100644 --- a/spec/c3-helper.js +++ b/spec/c3-helper.js @@ -21,7 +21,6 @@ window.setMouseEvent = function(chart, name, x, y, element) { event.initMouseEvent(name, true, true, window, 0, 0, 0, x + paddingLeft, y + 5, false, false, false, false, 0, null); - chart.internal.d3.event = event; if (element) { element.dispatchEvent(event); } }; diff --git a/spec/grid-spec.js b/spec/grid-spec.js index 9f0422d..c996e24 100644 --- a/spec/grid-spec.js +++ b/spec/grid-spec.js @@ -67,13 +67,13 @@ describe('c3 chart grid', function () { var ygrids = chart.internal.main.select('.c3-ygrids'), expectedYs = []; ygrids.selectAll('.c3-ygrid').each(function (d, i) { - expectedYs[i] = +d3.select(this).attr('y1'); + expectedYs[i] = Math.ceil(+d3.select(this).attr('y1')); }); expect(ygrids.size()).toBe(1); expect(ygrids.selectAll('.c3-ygrid').size()).toBe(5); chart.internal.main.select('.c3-axis-y').selectAll('.tick').each(function (d, i) { - var t = d3.transform(d3.select(this).attr('transform')); - expect(t.translate[1]).toBe(expectedYs[i]); + var t = d3.select(this).attr('transform'); + expect(t).toBe('translate(0,' + expectedYs[i] + ')'); }); }); }); diff --git a/spec/interaction-spec.js b/spec/interaction-spec.js index aec686a..7acf1ff 100644 --- a/spec/interaction-spec.js +++ b/spec/interaction-spec.js @@ -24,13 +24,13 @@ describe('c3 chart interaction', function () { }; }); - it('should have 4 event rects properly', function () { - var lefts = [78, 138, 205.5, 407.5], - widths = [60, 67.5, 202, 194]; - d3.selectAll('.c3-event-rect').each(function (d, i) { + it('should have only 1 event rect properly', function () { + var eventRects = d3.selectAll('.c3-event-rect'); + expect(eventRects.size()).toBe(1); + eventRects.each(function () { var box = d3.select(this).node().getBoundingClientRect(); - expect(box.left).toBeCloseTo(lefts[i], -2); - expect(box.width).toBeCloseTo(widths[i], -2); + expect(box.left).toBeCloseTo(40.5, -2); + expect(box.width).toBeCloseTo(598, -2); }); }); @@ -73,15 +73,14 @@ describe('c3 chart interaction', function () { }; }); - it('should have 4 event rects properly', function () { - var lefts = [43.5, 193, 353, 500], - widths = [149.5, 160, 147, 136]; - d3.selectAll('.c3-event-rect').each(function (d, i) { + it('should have only 1 event rect properly', function () { + var eventRects = d3.selectAll('.c3-event-rect'); + expect(eventRects.size()).toBe(1); + eventRects.each(function () { var box = d3.select(this).node().getBoundingClientRect(); - expect(box.left).toBeCloseTo(lefts[i], -2); - expect(box.width).toBeCloseTo(widths[i], -2); + expect(box.left).toBeCloseTo(40.5, -2); + expect(box.width).toBeCloseTo(598, -2); }); - }); describe('should generate line chart with only 1 data timeseries', function () { diff --git a/spec/shape.bar-spec.js b/spec/shape.bar-spec.js index f8f6b3c..38a20b8 100644 --- a/spec/shape.bar-spec.js +++ b/spec/shape.bar-spec.js @@ -122,28 +122,23 @@ describe('c3 chart shape bar', function () { it('should not be within bar', function () { var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); - setMouseEvent(chart, 'click', 0, 0); - expect(chart.internal.isWithinBar(bar)).toBeFalsy(); + expect(chart.internal.isWithinBar([0, 0], bar)).toBeFalsy(); }); it('should be within bar', function () { var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); - setMouseEvent(chart, 'click', 31, 280); - expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + expect(chart.internal.isWithinBar([31, 280], bar)).toBeTruthy(); }); it('should not be within bar of negative value', function () { var bar = d3.select('.c3-target-data3 .c3-bar-0').node(); - setMouseEvent(chart, 'click', 68, 280); - expect(chart.internal.isWithinBar(bar)).toBeFalsy(); + expect(chart.internal.isWithinBar([68, 280], bar)).toBeFalsy(); }); it('should be within bar of negative value', function () { var bar = d3.select('.c3-target-data3 .c3-bar-0').node(); - setMouseEvent(chart, 'click', 68, 350); - expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + expect(chart.internal.isWithinBar([68, 350], bar)).toBeTruthy(); }); - }); describe('with rotated axis', function () { @@ -154,20 +149,17 @@ describe('c3 chart shape bar', function () { it('should not be within bar', function () { var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); - setMouseEvent(chart, 'click', 0, 0); - expect(chart.internal.isWithinBar(bar)).toBeFalsy(); + expect(chart.internal.isWithinBar([0, 0], bar)).toBeFalsy(); }); it('should be within bar', function () { var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); - setMouseEvent(chart, 'click', 190, 20); - expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + expect(chart.internal.isWithinBar([190, 20], bar)).toBeTruthy(); }); it('should be within bar of negative value', function () { var bar = d3.select('.c3-target-data3 .c3-bar-0').node(); - setMouseEvent(chart, 'click', 68, 50); - expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + expect(chart.internal.isWithinBar([68, 50], bar)).toBeTruthy(); }); }); diff --git a/spec/shape.line-spec.js b/spec/shape.line-spec.js index 9c8df34..61e6fa5 100644 --- a/spec/shape.line-spec.js +++ b/spec/shape.line-spec.js @@ -176,7 +176,7 @@ describe('c3 chart shape line', function () { }); it('updates interpolation function', function() { - expect(chart.internal.getInterpolate(chart.data()[0])).toBe('monotone'); + expect(chart.internal.getInterpolate(chart.data()[0])).toBe(d3.curveMonotoneX); }); describe('should not use a non-valid interpolation', function () { @@ -185,7 +185,7 @@ describe('c3 chart shape line', function () { }); it('should use cardinal interpolation when given option is not valid', function() { - expect(chart.internal.getInterpolate(chart.data()[0])).toBe('cardinal'); + expect(chart.internal.getInterpolate(chart.data()[0])).toBe(d3.curveCardinal); }); }); }); diff --git a/spec/tooltip-spec.js b/spec/tooltip-spec.js index 21879d1..01d0b44 100644 --- a/spec/tooltip-spec.js +++ b/spec/tooltip-spec.js @@ -35,16 +35,16 @@ describe('c3 chart tooltip', function () { describe('without left margin', function () { it('should show tooltip on proper position', function () { - var eventRect = d3.select('.c3-event-rect-2').node(); - window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(1), + y = chart.internal.y(200); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); var tooltipContainer = d3.select('.c3-tooltip-container'), top = Math.floor(+tooltipContainer.style('top').replace(/px/, '')), - left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')), - topExpected = 115, - leftExpected = 280; - expect(top).toBe(topExpected); - expect(left).toBeGreaterThan(leftExpected); + left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')); + expect(top).toBeGreaterThan(0); + expect(left).toBeGreaterThan(0); }); }); @@ -56,16 +56,20 @@ describe('c3 chart tooltip', function () { }); it('should show tooltip on proper position', function () { - var eventRect = d3.select('.c3-event-rect-2').node(); - window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(1) + 300, // add margin-left + y = chart.internal.y(200); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); var tooltipContainer = d3.select('.c3-tooltip-container'), top = Math.floor(+tooltipContainer.style('top').replace(/px/, '')), - left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')), - topExpected = 115, - leftExpected = 280; - expect(top).toBe(topExpected); - expect(left).toBeGreaterThan(leftExpected); + left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')); + expect(top).toBeGreaterThan(0); + expect(left).toBeGreaterThan(0); + }); + + afterAll(function () { + d3.select('#chart').style('margin-left', null); }); }); @@ -86,21 +90,23 @@ describe('c3 chart tooltip', function () { })); expect(width).toBeGreaterThan(0); expect(height).toBeGreaterThan(0); - expect(element).toBe(d3.select('.c3-event-rect-2').node()); + expect(element).toBe(d3.select('.c3-event-rect').node()); return {top: topExpected, left: leftExpected}; } }; }); it('should be set to the coordinate where the function returned', function () { - var eventRect = d3.select('.c3-event-rect-2').node(); - window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); var tooltipContainer = d3.select('.c3-tooltip-container'), top = Math.floor(+tooltipContainer.style('top').replace(/px/, '')), left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')); - expect(top).toBe(topExpected); - expect(left).toBe(leftExpected); + expect(top).toBeGreaterThan(0); + expect(left).toBeGreaterThan(0); }); }); @@ -112,16 +118,19 @@ describe('c3 chart tooltip', function () { }); it('should sort values desc', function () { - var eventRect = d3.select('.c3-event-rect-2').node(); - window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var tooltipTable = d3.select('.c3-tooltip')[0]; - var expected = ["", "c3-tooltip-name--data3", - "c3-tooltip-name--data1", "c3-tooltip-name--data2"]; - var i; - for (i = 0; i < tooltipTable[0].rows.length; i++) { - expect(tooltipTable[0].rows[i].className).toBe(expected[i]); - } + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { + return node.className; + }); + + expect(classes[0]).toBe(''); // header + expect(classes[1]).toBe('c3-tooltip-name--data3'); + expect(classes[2]).toBe('c3-tooltip-name--data1'); + expect(classes[3]).toBe('c3-tooltip-name--data2'); }); }); @@ -132,9 +141,12 @@ describe('c3 chart tooltip', function () { }); it('should display each data in descending order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(220); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -152,9 +164,12 @@ describe('c3 chart tooltip', function () { }); it('should display each data in ascending order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(220); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -172,9 +187,12 @@ describe('c3 chart tooltip', function () { }); it('should display each data in given order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(220); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -195,9 +213,12 @@ describe('c3 chart tooltip', function () { }); it('should display each data in order given by function', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(220); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -215,9 +236,12 @@ describe('c3 chart tooltip', function () { }); it('should display each data in order given by array', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(220); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -234,9 +258,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value descending order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -253,9 +280,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in ascending order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -272,9 +302,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in given data order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -294,9 +327,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in data order given by function', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -313,9 +349,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in data order given by array', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -338,9 +377,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value descending order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -363,9 +405,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in ascending order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(220); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -384,9 +429,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in given order', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -408,9 +456,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in data order given by function', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); @@ -429,9 +480,12 @@ describe('c3 chart tooltip', function () { }); it('should display each tooltip value in data order given by array', function() { - window.setMouseEvent(chart, 'mousemove', 100, 100, d3.select('.c3-event-rect-2').node()); + var eventRect = d3.select('.c3-event-rect').node(), + x = chart.internal.x(2), + y = chart.internal.y(100); + window.setMouseEvent(chart, 'mousemove', x, y, eventRect); - var classes = d3.selectAll('.c3-tooltip tr')[0].map(function(node) { + var classes = d3.selectAll('.c3-tooltip tr').nodes().map(function(node) { return node.className; }); diff --git a/spec/zoom-spec.js b/spec/zoom-spec.js index 7f1490b..f25e3b1 100644 --- a/spec/zoom-spec.js +++ b/spec/zoom-spec.js @@ -10,13 +10,9 @@ describe('c3 chart zoom', function () { ['data2', 50, 20, 10, 40, 15, 6025] ] }, - axis: { - x: { - extent: [1, 2] - } - }, zoom: { - enable: true + enabled: true, + initialRange: [1, 2] }, subchart: { show: true @@ -54,10 +50,10 @@ describe('c3 chart zoom', function () { describe('main chart domain', function () { it('should have specified brush extent', function () { - var brushExtent = chart.internal.brush.extent(), - expectedBrushExtent = [1, 2]; - expect(brushExtent[0]).toBe(expectedBrushExtent[0]); - expect(brushExtent[1]).toBe(expectedBrushExtent[1]); + var brushSelection = chart.internal.brush.selectionAsValue(), + expectedBrushSelection = [1, 2]; + expect(brushSelection[0]).toBeCloseTo(expectedBrushSelection[0], 1); + expect(brushSelection[1]).toBeCloseTo(expectedBrushSelection[1], 1); }); }); diff --git a/src/axis.js b/src/axis.js index 3593635..3f15c89 100644 --- a/src/axis.js +++ b/src/axis.js @@ -452,7 +452,7 @@ c3_axis_fn.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) return tickValues; }; c3_axis_fn.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { - var $$ = this.owner, config = $$.config, + var $$ = this.owner, config = $$.config, d3 = $$.d3, axisParams = { withOuterTick: withOuterTick, withoutTransition: withoutTransition, @@ -460,7 +460,7 @@ c3_axis_fn.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, w }, axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient).tickFormat(tickFormat); if ($$.isTimeSeriesY()) { - axis.ticks($$.d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval); + axis.ticks(config.axis_y_tick_time_type, config.axis_y_tick_time_interval); } else { axis.tickValues(tickValues); } diff --git a/src/config.js b/src/config.js index 267fdf8..27e6b48 100644 --- a/src/config.js +++ b/src/config.js @@ -127,7 +127,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { axis_y_tick_values: null, axis_y_tick_rotate: 0, axis_y_tick_count: undefined, - axis_y_tick_time_value: undefined, + axis_y_tick_time_type: undefined, axis_y_tick_time_interval: undefined, axis_y_padding: {}, axis_y_default: undefined, diff --git a/src/data.js b/src/data.js index a3d8517..e7009b6 100644 --- a/src/data.js +++ b/src/data.js @@ -277,7 +277,7 @@ c3_chart_internal_fn.findClosest = function (values, pos) { // find mouseovering bar values.filter(function (v) { return v && $$.isBarType(v.id); }).forEach(function (v) { var shape = $$.main.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node(); - if (!closest && $$.isWithinBar(shape)) { + if (!closest && $$.isWithinBar($$.d3.mouse(shape), shape)) { closest = v; } }); diff --git a/src/region.js b/src/region.js index 66da2e1..2497cfd 100644 --- a/src/region.js +++ b/src/region.js @@ -16,8 +16,7 @@ c3_chart_internal_fn.updateRegion = function (duration) { var mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region) .data(config.regions); - var mainRegionEnter = mainRegion.enter().append('g') - .append('rect') + var mainRegionEnter = mainRegion.enter().append('rect') .attr("x", $$.regionX.bind($$)) .attr("y", $$.regionY.bind($$)) .attr("width", $$.regionWidth.bind($$)) diff --git a/src/shape.bar.js b/src/shape.bar.js index dea7276..79deffe 100644 --- a/src/shape.bar.js +++ b/src/shape.bar.js @@ -116,8 +116,8 @@ c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) { ]; }; }; -c3_chart_internal_fn.isWithinBar = function (that) { - var mouse = this.d3.mouse(that), box = that.getBoundingClientRect(), +c3_chart_internal_fn.isWithinBar = function (mouse, that) { + var box = that.getBoundingClientRect(), seg0 = that.pathSegList.getItem(0), seg1 = that.pathSegList.getItem(1), x = Math.min(seg0.x, seg1.x), y = Math.min(seg0.y, seg1.y), w = box.width, h = box.height, offset = 2, diff --git a/src/shape.js b/src/shape.js index b0f403f..84917b7 100644 --- a/src/shape.js +++ b/src/shape.js @@ -73,7 +73,7 @@ c3_chart_internal_fn.isWithinShape = function (that, d) { isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScale(d.id)(d.value)) : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); } else if (that.nodeName === 'path') { - isWithin = shape.classed(CLASS.bar) ? $$.isWithinBar(that) : true; + isWithin = shape.classed(CLASS.bar) ? $$.isWithinBar($$.d3.mouse(that), that) : true; } return isWithin; }; @@ -91,8 +91,7 @@ c3_chart_internal_fn.getInterpolate = function (d) { 'cardinal': d3.curveCardinal, 'cardinal-open': d3.curveCardinalOpen, 'cardinal-closed': d3.curveCardinalClosed, - 'monotone-x': d3.curveMonotoneX, - 'monotone-y': d3.curveMonotoneY, + 'monotone': d3.curveMonotoneX, 'step': d3.curveStep, }, type;