diff --git a/c3.js b/c3.js index 461ccd2..9284882 100644 --- a/c3.js +++ b/c3.js @@ -4,17 +4,17 @@ /*global define, module, exports, require */ var c3 = { version: "0.4.10-rc4" }; - + var c3_chart_fn, c3_chart_internal_fn, c3_chart_internal_axis_fn; - + function API(owner) { this.owner = owner; } - + function inherit(base, derived) { - + if (Object.create) { derived.prototype = Object.create(base.prototype); } else { @@ -22,17 +22,17 @@ f.prototype = base.prototype; derived.prototype = new f(); } - + derived.prototype.constructor = derived; - + return derived; } - + function Chart(config) { var $$ = this.internal = new ChartInternal(this); $$.loadConfig(config); $$.init(); - + // bind "this" to nested API (function bindThis(fn, target, argThis) { Object.keys(fn).forEach(function (key) { @@ -43,7 +43,7 @@ }); })(c3_chart_fn, this, this); } - + function ChartInternal(api) { var $$ = this; $$.d3 = window.d3 ? window.d3 : typeof require !== 'undefined' ? require("d3") : undefined; @@ -53,11 +53,11 @@ $$.cache = {}; $$.axes = {}; } - + c3.generate = function (config) { return new Chart(config); }; - + c3.chart = { fn: Chart.prototype, internal: { @@ -70,12 +70,12 @@ c3_chart_fn = c3.chart.fn; c3_chart_internal_fn = c3.chart.internal.fn; c3_chart_internal_axis_fn = c3.chart.internal.axis.fn; - + c3_chart_internal_fn.init = function () { var $$ = this, config = $$.config; - + $$.initParams(); - + if (config.data_url) { $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_keys, $$.initWithData); } @@ -92,10 +92,10 @@ throw Error('url or json or rows or columns is required.'); } }; - + c3_chart_internal_fn.initParams = function () { var $$ = this, d3 = $$.d3, config = $$.config; - + // MEMO: clipId needs to be unique because it conflicts when multiple charts exist $$.clipId = "c3-" + (+new Date()) + '-clip', $$.clipIdForXAxis = $$.clipId + '-xaxis', @@ -107,17 +107,17 @@ $$.clipPathForYAxis = $$.getClipPath($$.clipIdForYAxis); $$.clipPathForGrid = $$.getClipPath($$.clipIdForGrid), $$.clipPathForSubchart = $$.getClipPath($$.clipIdForSubchart), - + $$.dragStart = null; $$.dragging = false; $$.flowing = false; $$.cancelClick = false; $$.mouseover = false; $$.transiting = false; - + $$.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([ @@ -130,17 +130,17 @@ ["%-m/%-d", function (d) { return d.getMonth(); }], ["%Y/%-m/%-d", function () { return true; }] ]); - + $$.hiddenTargetIds = []; $$.hiddenLegendIds = []; $$.focusedTargetIds = []; $$.defocusedTargetIds = []; - + $$.xOrient = config.axis_rotated ? "left" : "bottom"; $$.yOrient = config.axis_rotated ? (config.axis_y_inner ? "top" : "bottom") : (config.axis_y_inner ? "right" : "left"); $$.y2Orient = config.axis_rotated ? (config.axis_y2_inner ? "bottom" : "top") : (config.axis_y2_inner ? "left" : "right"); $$.subXOrient = config.axis_rotated ? "left" : "bottom"; - + $$.isLegendRight = config.legend_position === 'right'; $$.isLegendInset = config.legend_position === 'inset'; $$.isLegendTop = config.legend_inset_anchor === 'top-left' || config.legend_inset_anchor === 'top-right'; @@ -148,24 +148,24 @@ $$.legendStep = 0; $$.legendItemWidth = 0; $$.legendItemHeight = 0; - + $$.currentMaxTickWidths = { x: 0, y: 0, y2: 0 }; - + $$.rotated_padding_left = 30; $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; $$.rotated_padding_top = 5; - + $$.withoutFadeIn = {}; - + $$.intervalForObserveInserted = undefined; - + $$.axes.subx = d3.selectAll([]); // needs when excluding subchart.js }; - + c3_chart_internal_fn.initChartElements = function () { if (this.initBar) { this.initBar(); } if (this.initLine) { this.initLine(); } @@ -173,17 +173,17 @@ if (this.initGauge) { this.initGauge(); } if (this.initText) { this.initText(); } }; - + c3_chart_internal_fn.initWithData = function (data) { var $$ = this, d3 = $$.d3, config = $$.config; var defs, main, binding = true; - + $$.axis = new Axis($$); - + if ($$.initPie) { $$.initPie(); } if ($$.initBrush) { $$.initBrush(); } if ($$.initZoom) { $$.initZoom(); } - + if (!config.bindto) { $$.selectChart = d3.selectAll([]); } @@ -199,15 +199,15 @@ binding = false; } $$.selectChart.html("").classed("c3", true); - + // Init data as targets $$.data.xs = {}; $$.data.targets = $$.convertDataToTargets(data); - + if (config.data_filter) { $$.data.targets = $$.data.targets.filter(config.data_filter); } - + // Set targets to hide if needed if (config.data_hide) { $$.addHiddenTargetIds(config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide); @@ -215,16 +215,16 @@ if (config.legend_hide) { $$.addHiddenLegendIds(config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide); } - + // when gauge, hide legend // TODO: fix if ($$.hasType('gauge')) { config.legend_show = false; } - + // Init sizes and scales $$.updateSizes(); $$.updateScales(); - + // Set domains for each scale $$.x.domain(d3.extent($$.getXDomain($$.data.targets))); $$.y.domain($$.getYDomain($$.data.targets, 'y')); @@ -232,22 +232,22 @@ $$.subX.domain($$.x.domain()); $$.subY.domain($$.y.domain()); $$.subY2.domain($$.y2.domain()); - + // 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 $$.svg = $$.selectChart.append("svg") .style("overflow", "hidden") .on('mouseenter', function () { return config.onmouseover.call($$); }) .on('mouseleave', function () { return config.onmouseout.call($$); }); - + // Define defs defs = $$.svg.append("defs"); $$.clipChart = $$.appendClip(defs, $$.clipId); @@ -256,42 +256,42 @@ $$.clipGrid = $$.appendClip(defs, $$.clipIdForGrid); $$.clipSubchart = $$.appendClip(defs, $$.clipIdForSubchart); $$.updateSvgSize(); - + // Define regions main = $$.main = $$.svg.append("g").attr("transform", $$.getTranslate('main')); - + if ($$.initSubchart) { $$.initSubchart(); } if ($$.initTooltip) { $$.initTooltip(); } if ($$.initLegend) { $$.initLegend(); } - + /*-- 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. - + // Regions $$.initRegion(); - + // Grids $$.initGrid(); - + // Define g for chart area main.append('g') .attr("clip-path", $$.clipPath) .attr('class', CLASS.chart); - + // Grid lines if (config.grid_lines_front) { $$.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) @@ -300,16 +300,16 @@ .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); - + // Draw with targets if (binding) { $$.updateDimension(); @@ -322,7 +322,7 @@ withTransitionForAxis: false }); } - + // Bind resize event if (window.onresize == null) { window.onresize = $$.generateResize(); @@ -338,11 +338,11 @@ config.onresized.call($$); }); } - + // export element of the chart $$.api.element = $$.selectChart.node(); }; - + c3_chart_internal_fn.smoothLines = function (el, type) { var $$ = this; if (type === 'grid') { @@ -361,8 +361,8 @@ }); } }; - - + + c3_chart_internal_fn.updateSizes = function () { var $$ = this, config = $$.config; var legendHeight = $$.legend ? $$.getLegendHeight() : 0, @@ -371,10 +371,10 @@ hasArc = $$.hasArcType(), xAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), subchartHeight = config.subchart_show && !hasArc ? (config.subchart_size_height + xAxisHeight) : 0; - + $$.currentWidth = $$.getCurrentWidth(); $$.currentHeight = $$.getCurrentHeight(); - + // for main $$.margin = config.axis_rotated ? { top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), @@ -387,7 +387,7 @@ bottom: xAxisHeight + subchartHeight + legendHeightForBottom + $$.getCurrentPaddingBottom(), left: hasArc ? 0 : $$.getCurrentPaddingLeft() }; - + // for subchart $$.margin2 = config.axis_rotated ? { top: $$.margin.top, @@ -400,7 +400,7 @@ bottom: xAxisHeight + legendHeightForBottom, left: $$.margin.left }; - + // for legend $$.margin3 = { top: 0, @@ -409,17 +409,17 @@ left: 0 }; if ($$.updateSizeForLegend) { $$.updateSizeForLegend(legendHeight, legendWidth); } - + $$.width = $$.currentWidth - $$.margin.left - $$.margin.right; $$.height = $$.currentHeight - $$.margin.top - $$.margin.bottom; if ($$.width < 0) { $$.width = 0; } if ($$.height < 0) { $$.height = 0; } - + $$.width2 = config.axis_rotated ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right : $$.width; $$.height2 = config.axis_rotated ? $$.height : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; if ($$.width2 < 0) { $$.width2 = 0; } if ($$.height2 < 0) { $$.height2 = 0; } - + // for arc $$.arcWidth = $$.width - ($$.isLegendRight ? legendWidth + 10 : 0); $$.arcHeight = $$.height - ($$.isLegendRight ? 0 : 10); @@ -427,33 +427,33 @@ $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); } if ($$.updateRadius) { $$.updateRadius(); } - + if ($$.isLegendRight && hasArc) { $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; } }; - + c3_chart_internal_fn.updateTargets = function (targets) { var $$ = this; - + /*-- Main --*/ - + //-- Text --// $$.updateTargetsForText(targets); - + //-- Bar --// $$.updateTargetsForBar(targets); - + //-- Line --// $$.updateTargetsForLine(targets); - + //-- Arc --// if ($$.hasArcType() && $$.updateTargetsForArc) { $$.updateTargetsForArc(targets); } - + /*-- Sub --*/ - + if ($$.updateTargetsForSubchart) { $$.updateTargetsForSubchart(targets); } - + // Fade-in each chart $$.showTargets(); }; @@ -463,7 +463,7 @@ .transition().duration($$.config.transition_duration) .style("opacity", 1); }; - + c3_chart_internal_fn.redraw = function (options, transitions) { var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config; var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType); @@ -476,7 +476,7 @@ var waitForDraw, flow; var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom; var xv = $$.xv.bind($$), cx, cy; - + options = options || {}; withY = getOption(options, "withY", true); withSubchart = getOption(options, "withSubchart", true); @@ -491,13 +491,13 @@ withDimension = getOption(options, "withDimension", true); withTransitionForExit = getOption(options, "withTransitionForExit", withTransition); withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition); - + duration = withTransition ? config.transition_duration : 0; durationForExit = withTransitionForExit ? duration : 0; durationForAxis = withTransitionForAxis ? duration : 0; - + transitions = transitions || $$.axis.generateTransitions(durationForAxis); - + // update legend and transform each g if (withLegend && config.legend_show) { $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); @@ -506,12 +506,12 @@ // no need to update axis in it because they will be updated in redraw() $$.updateDimension(true); } - + // MEMO: needed for grids calculation if ($$.isCategorized() && targetsToShow.length === 0) { $$.x.domain([0, $$.axes.x.selectAll('.tick').size()]); } - + if (targetsToShow.length) { $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain); if (!config.axis_x_tick_values) { @@ -521,27 +521,27 @@ $$.xAxis.tickValues([]); $$.subXAxis.tickValues([]); } - + if (config.zoom_rescale && !options.flow) { xDomainForZoom = $$.x.orgDomain(); } - + $$.y.domain($$.getYDomain(targetsToShow, 'y', xDomainForZoom)); $$.y2.domain($$.getYDomain(targetsToShow, 'y2', xDomainForZoom)); - + if (!config.axis_y_tick_values && config.axis_y_tick_count) { $$.yAxis.tickValues($$.axis.generateTickValues($$.y.domain(), config.axis_y_tick_count)); } if (!config.axis_y2_tick_values && config.axis_y2_tick_count) { $$.y2Axis.tickValues($$.axis.generateTickValues($$.y2.domain(), config.axis_y2_tick_count)); } - + // axes $$.axis.redraw(transitions, hideAxis); - + // Update axis label $$.axis.updateLabels(withTransition); - + // show/hide if manual culling needed if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) { if (config.axis_x_tick_culling && tickValues) { @@ -561,26 +561,26 @@ $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').style('display', 'block'); } } - + // setup drawer - MEMO: these must be called after axis updated drawArea = $$.generateDrawArea ? $$.generateDrawArea(areaIndices, false) : undefined; drawBar = $$.generateDrawBar ? $$.generateDrawBar(barIndices) : undefined; drawLine = $$.generateDrawLine ? $$.generateDrawLine(lineIndices, false) : undefined; xForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, true); yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false); - + // Update sub domain if (withY) { $$.subY.domain($$.getYDomain(targetsToShow, 'y')); $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); } - + // tooltip $$.tooltip.style("display", "none"); - + // xgrid focus $$.updateXgridFocus(); - + // Data empty label positioning and text. main.select("text." + CLASS.text + '.' + CLASS.empty) .attr("x", $$.width / 2) @@ -588,53 +588,53 @@ .text(config.data_empty_label_text) .transition() .style('opacity', targetsToShow.length ? 0 : 1); - + // grid $$.updateGrid(duration); - + // rect for regions $$.updateRegion(duration); - + // bars $$.updateBar(durationForExit); - + // lines, areas and cricles $$.updateLine(durationForExit); $$.updateArea(durationForExit); $$.updateCircle(); - + // text if ($$.hasDataLabel()) { $$.updateText(durationForExit); } - + // arc if ($$.redrawArc) { $$.redrawArc(duration, durationForExit, withTransform); } - + // subchart if ($$.redrawSubchart) { $$.redrawSubchart(withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices); } - + // 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, @@ -650,12 +650,12 @@ yForText: yForText }); } - + if ((duration || flow) && $$.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), @@ -670,7 +670,7 @@ transitionsToWait.push(transition); }); }); - + // Wait for end of transitions to call flow and onrendered callback waitForDraw = $$.generateWait(); transitionsToWait.forEach(function (t) { @@ -698,13 +698,13 @@ config.onrendered.call($$); } } - + // update fadein condition $$.mapToIds($$.data.targets).forEach(function (id) { $$.withoutFadeIn[id] = true; }); }; - + c3_chart_internal_fn.updateAndRedraw = function (options) { var $$ = this, config = $$.config, transitions; options = options || {}; @@ -739,7 +739,7 @@ withTransitionForAxis: false }); }; - + c3_chart_internal_fn.isTimeSeries = function () { return this.config.axis_x_type === 'timeseries'; }; @@ -750,11 +750,11 @@ var $$ = this, config = $$.config; return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); }; - + c3_chart_internal_fn.isTimeSeriesY = function () { return this.config.axis_y_type === 'timeseries'; }; - + c3_chart_internal_fn.getTranslate = function (target) { var $$ = this, config = $$.config, x, y; if (target === 'main') { @@ -818,7 +818,7 @@ c3_chart_internal_fn.subxx = function (d) { return d ? this.subX(d.x) : null; }; - + c3_chart_internal_fn.transformMain = function (withTransition, transitions) { var $$ = this, xAxis, yAxis, y2Axis; @@ -852,7 +852,7 @@ if ($$.config.subchart_show) { $$.transformContext(withTransition, transitions); } if ($$.legend) { $$.transformLegend(withTransition); } }; - + c3_chart_internal_fn.updateSvgSize = function () { var $$ = this, brush = $$.svg.select(".c3-brush .background"); @@ -879,8 +879,8 @@ // MEMO: parent div's height will be bigger than svg when $$.selectChart.style('max-height', $$.currentHeight + "px"); }; - - + + c3_chart_internal_fn.updateDimension = function (withoutAxis) { var $$ = this; if (!withoutAxis) { @@ -897,7 +897,7 @@ $$.updateSvgSize(); $$.transformAll(false); }; - + c3_chart_internal_fn.observeInserted = function (selection) { var $$ = this, observer; if (typeof MutationObserver === 'undefined') { @@ -931,8 +931,8 @@ }); observer.observe(selection.node(), {attributes: true, childList: true, characterData: true}); }; - - + + c3_chart_internal_fn.generateResize = function () { var resizeFunctions = []; function callResizeFunctions() { @@ -945,7 +945,7 @@ }; return callResizeFunctions; }; - + c3_chart_internal_fn.endall = function (transition, callback) { var n = 0; transition @@ -981,7 +981,7 @@ }; return f; }; - + c3_chart_internal_fn.parseDate = function (date) { var $$ = this, parsedDate; if (date instanceof Date) { @@ -996,7 +996,7 @@ } return parsedDate; }; - + c3_chart_internal_fn.isTabVisible = function () { var hidden; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support @@ -1008,7 +1008,7 @@ } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; } - + return document[hidden] ? false : true; }; @@ -1207,15 +1207,15 @@ tooltip_init_x: 0, tooltip_init_position: {top: '0px', left: '50px'} }; - + Object.keys(this.additionalConfig).forEach(function (key) { config[key] = this.additionalConfig[key]; }, this); - + return config; }; c3_chart_internal_fn.additionalConfig = {}; - + c3_chart_internal_fn.loadConfig = function (config) { var this_config = this.config, target, keys, read; function find() { @@ -1318,12 +1318,12 @@ $$.xAxisTickValues = $$.axis.getXAxisTickValues(); $$.yAxisTickValues = $$.axis.getYAxisTickValues(); $$.y2AxisTickValues = $$.axis.getY2AxisTickValues(); - + $$.xAxis = $$.axis.getXAxis($$.x, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); $$.subXAxis = $$.axis.getXAxis($$.subX, $$.subXOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); $$.yAxis = $$.axis.getYAxis($$.y, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, config.axis_y_tick_outer); $$.y2Axis = $$.axis.getYAxis($$.y2, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, config.axis_y2_tick_outer); - + // Set initialized scales to brush and zoom if (!forInit) { if ($$.brush) { $$.brush.scale($$.subX); } @@ -1410,11 +1410,11 @@ isInverted = axisId === 'y2' ? config.axis_y2_inverted : config.axis_y_inverted, showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; - + // MEMO: avoid inverting domain unexpectedly yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? (yDomainMin < yMax ? yDomainMin : yMax - 10) : yDomainMin; yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? (yMin < yDomainMax ? yDomainMax : yMin + 10) : yDomainMax; - + if (yTargets.length === 0) { // use current domain if target of axisId is none return axisId === 'y2' ? $$.y2.domain() : $$.y.domain(); } @@ -1429,21 +1429,21 @@ } isAllPositive = yDomainMin >= 0 && yDomainMax >= 0; isAllNegative = yDomainMin <= 0 && yDomainMax <= 0; - + // Cancel zerobased if axis_*_min / axis_*_max specified if ((isValue(yMin) && isAllPositive) || (isValue(yMax) && isAllNegative)) { isZeroBased = false; } - + // Bar/Area chart should be 0-based if all positive|negative if (isZeroBased) { if (isAllPositive) { yDomainMin = 0; } if (isAllNegative) { yDomainMax = 0; } } - + domainLength = Math.abs(yDomainMax - yDomainMin); padding = padding_top = padding_bottom = domainLength * 0.1; - + if (typeof center !== 'undefined') { yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax)); yDomainMax = center + yDomainAbs; @@ -1537,7 +1537,7 @@ }; c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) { var $$ = this, config = $$.config; - + if (withUpdateOrgXDomain) { $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); $$.orgXDomain = $$.x.domain(); @@ -1549,10 +1549,10 @@ $$.x.domain(domain ? domain : (!$$.brush || $$.brush.empty()) ? $$.orgXDomain : $$.brush.extent()); if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } } - + // Trim domain when too big by zoom mousemove event if (withTrim) { $$.x.domain($$.trimXDomain($$.x.orgDomain())); } - + return $$.x.domain(); }; c3_chart_internal_fn.trimXDomain = function (domain) { @@ -1862,21 +1862,21 @@ } return sames; }; - + c3_chart_internal_fn.findClosestFromTargets = function (targets, pos) { var $$ = this, candidates; - + // map to array of closest points of each target candidates = targets.map(function (target) { return $$.findClosest(target.values, pos); }); - + // decide closest point and return return $$.findClosest(candidates, pos); }; c3_chart_internal_fn.findClosest = function (values, pos) { var $$ = this, minDist = 100, closest; - + // 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(); @@ -1884,7 +1884,7 @@ closest = v; } }); - + // find closest point from non-bar values.filter(function (v) { return v && !$$.isBarType(v.id); }).forEach(function (v) { var d = $$.dist(v, pos); @@ -1893,7 +1893,7 @@ closest = v; } }); - + return closest; }; c3_chart_internal_fn.dist = function (data, pos) { @@ -1906,15 +1906,15 @@ }; c3_chart_internal_fn.convertValuesToStep = function (values) { var converted = [].concat(values), i; - + if (!this.isCategorized()) { return values; } - + for (i = values.length + 1; 0 < i; i--) { converted[i] = converted[i - 1]; } - + converted[0] = { x: converted[0].x - 1, value: converted[0].value, @@ -1925,7 +1925,7 @@ value: converted[values.length].value, id: converted[values.length].id }; - + return converted; }; c3_chart_internal_fn.updateDataAttributes = function (name, attrs) { @@ -2036,11 +2036,11 @@ ids = $$.d3.keys(data[0]).filter($$.isNotX, $$), xs = $$.d3.keys(data[0]).filter($$.isX, $$), targets; - + // save x for update data by load when custom x and c3.x API ids.forEach(function (id) { var xKey = $$.getXKey(id); - + if ($$.isCustomX() || $$.isTimeSeries()) { // if included in input data if (xs.indexOf(xKey) >= 0) { @@ -2063,15 +2063,15 @@ $$.data.xs[id] = data.map(function (d, i) { return i; }); } }); - - + + // check x is defined ids.forEach(function (id) { if (!$$.data.xs[id]) { throw new Error('x is not defined for id = "' + id + '".'); } }); - + // convert to target targets = ids.map(function (id, index) { var convertedId = config.data_idConverter(id); @@ -2093,7 +2093,7 @@ }).filter(function (v) { return isDefined(v.x); }) }; }); - + // finish targets targets.forEach(function (t) { var i; @@ -2115,17 +2115,17 @@ return v1 - v2; }); }); - + // set target types if (config.data_type) { $$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type); } - + // cache as original id keyed targets.forEach(function (d) { $$.addCache(d.id_org, d); }); - + return targets; }; @@ -2154,13 +2154,13 @@ }); $$.data.targets = $$.data.targets.concat(targets); // add remained } - + // Set targets $$.updateTargets($$.data.targets); - + // Redraw with new targets $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); - + if (args.done) { args.done(); } }; c3_chart_internal_fn.loadFromArgs = function (args) { @@ -2232,19 +2232,19 @@ 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(); - + // open as public variable $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); - + if (isMultipleX) { eventRectUpdate = $$.eventRect.data([0]); // enter : only one rect will be added @@ -2270,10 +2270,10 @@ c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) { var $$ = this, 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; @@ -2283,34 +2283,34 @@ } else { if (($$.isCustomX() || $$.isTimeSeries()) && !$$.isCategorized()) { - + // update index for x that is used by prevX and nextX $$.updateXs(); - + rectW = function (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 (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 { @@ -2324,7 +2324,7 @@ w = config.axis_rotated ? $$.width : rectW; h = config.axis_rotated ? rectW : $$.height; } - + eventRectUpdate .attr('class', $$.classEvent.bind($$)) .attr("x", x) @@ -2339,14 +2339,14 @@ .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); @@ -2368,28 +2368,28 @@ .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); @@ -2446,10 +2446,10 @@ ) : function () {} ); }; - + c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) { var $$ = this, d3 = $$.d3, config = $$.config; - + function mouseout() { $$.svg.select('.' + CLASS.eventRect).style('cursor', null); $$.hideXGridFocus(); @@ -2457,7 +2457,7 @@ $$.unexpandCircles(); $$.unexpandBars(); } - + eventRectEnter.append('rect') .attr('x', 0) .attr('y', 0) @@ -2471,44 +2471,44 @@ .on('mousemove', function () { var targetsToShow = $$.filterTargetsToShow($$.data.targets); var mouse, closest, sameXData, selectedData; - + if ($$.dragging) { return; } // do nothing when dragging if ($$.hasArcType(targetsToShow)) { return; } - + mouse = d3.mouse(this); closest = $$.findClosestFromTargets(targetsToShow, mouse); - + if ($$.mouseover && (!closest || closest.id !== $$.mouseover.id)) { config.data_onmouseout.call($$.api, $$.mouseover); $$.mouseover = undefined; } - + if (! closest) { mouseout(); return; } - + if ($$.isScatterType(closest) || !config.tooltip_grouped) { sameXData = [closest]; } else { sameXData = $$.filterByX(targetsToShow, closest.x); } - + // show tooltip when cursor is close to some point selectedData = sameXData.map(function (d) { return $$.addName(d); }); $$.showTooltip(selectedData, this); - + // expand points if (config.point_focus_expand_enabled) { $$.expandCircles(closest.index, closest.id, true); } $$.expandBars(closest.index, closest.id, true); - + // Show xgrid focus line $$.showXGridFocus(selectedData); - + // Show cursor as pointer if point is close to mouse position if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < 100) { $$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer'); @@ -2521,14 +2521,14 @@ .on('click', function () { var targetsToShow = $$.filterTargetsToShow($$.data.targets); var mouse, closest; - + if ($$.hasArcType(targetsToShow)) { return; } - + mouse = d3.mouse(this); closest = $$.findClosestFromTargets(targetsToShow, mouse); - + if (! closest) { return; } - + // select if selection enabled if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < 100) { $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll('.' + CLASS.shape + '-' + closest.index).each(function () { @@ -2556,7 +2556,7 @@ x = box.left + (mouse ? mouse[0] : 0), y = box.top + (mouse ? mouse[1] : 0), event = document.createEvent("MouseEvents"); - + event.initMouseEvent(type, true, true, window, 0, x, y, x, y, false, false, false, false, 0, null); eventRect.dispatchEvent(event); @@ -2604,7 +2604,7 @@ return ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; } }; - + c3_chart_internal_fn.getParentRectValue = function (key) { var parent = this.selectChart.node(), v; while (parent && parent.tagName !== 'BODY') { @@ -2623,8 +2623,8 @@ var h = this.selectChart.style('height'); return h.indexOf('px') > 0 ? +h.replace('px', '') : 0; }; - - + + c3_chart_internal_fn.getSvgLeft = function (withoutRecompute) { var $$ = this, config = $$.config, hasLeftAxisRect = config.axis_rotated || (!config.axis_rotated && !config.axis_y_inner), @@ -2636,8 +2636,8 @@ svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute)); return svgLeft > 0 ? svgLeft : 0; }; - - + + c3_chart_internal_fn.getAxisWidthByAxisId = function (id, withoutRecompute) { var $$ = this, position = $$.axis.getLabelPositionById(id); return $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40); @@ -2654,7 +2654,7 @@ } return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0); }; - + c3_chart_internal_fn.getEventRectWidth = function () { return this.xAxis.tickInterval(); }; @@ -2724,8 +2724,8 @@ } return isWithin; }; - - + + c3_chart_internal_fn.getInterpolate = function (d) { var $$ = this; return $$.isSplineType(d) ? "cardinal" : $$.isStepType(d) ? $$.config.line_step_type : "linear"; @@ -2804,7 +2804,7 @@ yValue = function (d, i) { return config.data_groups.length > 0 ? getPoints(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value); }; - + line = config.axis_rotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue); if (!config.line_connectNull) { line = line.defined(function (d) { return d.value != null; }); } return function (d) { @@ -2851,8 +2851,8 @@ ]; }; }; - - + + c3_chart_internal_fn.lineWithRegions = function (d, x, y, _regions) { var $$ = this, config = $$.config, prev = -1, i, j, @@ -2860,7 +2860,7 @@ xp, yp, dx, dy, dd, diff, diffx2, xValue, yValue, regions = []; - + function isWithinRegions(x, regions) { var i; for (i = 0; i < regions.length; i++) { @@ -2868,7 +2868,7 @@ } return false; } - + // Check start/end of regions if (isDefined(_regions)) { for (i = 0; i < _regions.length; i++) { @@ -2885,11 +2885,11 @@ } } } - + // Set scales xValue = config.axis_rotated ? function (d) { return y(d.value); } : function (d) { return x(d.x); }; yValue = config.axis_rotated ? function (d) { return x(d.x); } : function (d) { return y(d.value); }; - + // Define svg generator function for region if ($$.isTimeSeries()) { sWithRegion = function (d0, d1, j, diff) { @@ -2903,10 +2903,10 @@ return "M" + x(xp(j), true) + " " + y(yp(j)) + " " + x(xp(j + diff), true) + " " + y(yp(j + diff)); }; } - + // Generate for (i = 0; i < d.length; i++) { - + // Draw as normal if (isUndefined(regions) || ! isWithinRegions(d[i].x, regions)) { s += " " + xValue(d[i]) + " " + yValue(d[i]); @@ -2915,24 +2915,24 @@ else { xp = $$.getScale(d[i - 1].x, d[i].x, $$.isTimeSeries()); yp = $$.getScale(d[i - 1].value, d[i].value); - + dx = x(d[i].x) - x(d[i - 1].x); dy = y(d[i].value) - y(d[i - 1].value); dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); diff = 2 / dd; diffx2 = diff * 2; - + for (j = diff; j <= 1; j += diffx2) { s += sWithRegion(d[i - 1], d[i], j, diff); } } prev = d[i].x; } - + return s; }; - - + + c3_chart_internal_fn.updateArea = function (durationForExit) { var $$ = this, d3 = $$.d3; $$.mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) @@ -2966,12 +2966,12 @@ value1 = function (d, i) { return config.data_groups.length > 0 ? getPoints(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value); }; - + area = config.axis_rotated ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(value0).y1(value1); if (!config.line_connectNull) { area = area.defined(function (d) { return d.value !== null; }); } - + return function (d) { var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path; @@ -3015,8 +3015,8 @@ ]; }; }; - - + + c3_chart_internal_fn.updateCircle = function () { var $$ = this; $$.mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle) @@ -3123,7 +3123,7 @@ mainBarEnter.append('g') .attr("class", classBars) .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); - + }; c3_chart_internal_fn.updateBar = function (durationForExit) { var $$ = this, @@ -3175,17 +3175,17 @@ return function (d, i) { // 4 points that make a bar var points = getPoints(d, i); - + // switch points if axis is rotated, not applicable for sub chart var indexX = config.axis_rotated ? 1 : 0; var indexY = config.axis_rotated ? 0 : 1; - + var path = 'M ' + points[0][indexX] + ',' + points[0][indexY] + ' ' + 'L' + points[1][indexX] + ',' + points[1][indexY] + ' ' + 'L' + points[2][indexX] + ',' + points[2][indexY] + ' ' + 'L' + points[3][indexX] + ',' + points[3][indexY] + ' ' + 'z'; - + return path; }; }; @@ -3461,7 +3461,7 @@ var $$ = this, config = $$.config, d3 = $$.d3, xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; - + $$.xgridAttr = config.axis_rotated ? { 'x1': 0, 'x2': $$.width, @@ -3473,7 +3473,7 @@ 'y1': 0, 'y2': $$.height }; - + $$.xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid) .data(xgridData); $$.xgrid.enter().append('line').attr("class", CLASS.xgrid); @@ -3483,7 +3483,7 @@ } $$.xgrid.exit().remove(); }; - + c3_chart_internal_fn.updateYGrid = function () { var $$ = this, config = $$.config, gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); @@ -3498,7 +3498,7 @@ $$.ygrid.exit().remove(); $$.smoothLines($$.ygrid, 'grid'); }; - + c3_chart_internal_fn.gridTextAnchor = function (d) { return d.position ? d.position : "end"; }; @@ -3514,10 +3514,10 @@ c3_chart_internal_fn.updateGrid = function (duration) { var $$ = this, main = $$.main, config = $$.config, xgridLine, ygridLine, yv; - + // hide if arc type $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); - + main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); if (config.grid_x_show) { $$.updateXGrid(); @@ -3541,7 +3541,7 @@ $$.xgridLines.exit().transition().duration(duration) .style("opacity", 0) .remove(); - + // Y-Grid if (config.grid_y_show) { $$.updateYGrid(); @@ -3703,17 +3703,17 @@ text, i, title, value, name, bgcolor; for (i = 0; i < d.length; i++) { if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; } - + if (! text) { title = titleFormat ? titleFormat(d[i].x) : d[i].x; text = "
" + title + " | |||||
---|---|---|---|---|---|
" + name + " | "; text += "" + value + " | "; @@ -3744,7 +3744,7 @@ chartRight = svgLeft + $$.currentWidth - $$.getCurrentPaddingRight(); tooltipTop = mouse[1] + 15; } - + if (tooltipRight > chartRight) { // 20 is needed for Firefox to keep tooletip width tooltipLeft -= tooltipRight - chartRight + 20; @@ -3768,11 +3768,11 @@ return; } $$.tooltip.html(config.tooltip_contents.call($$, selectedData, $$.axis.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block"); - + // Get tooltip dimensions tWidth = $$.tooltip.property('offsetWidth'); tHeight = $$.tooltip.property('offsetHeight'); - + position = positionFunction.call(this, dataToShow, tWidth, tHeight, element); // Set tooltip $$.tooltip @@ -3805,7 +3805,7 @@ top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config.legend_inset_y, left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config.legend_inset_x + 0.5 }; - + $$.margin3 = { top: $$.isLegendRight ? 0 : $$.isLegendInset ? insetLegendPosition.top : $$.currentHeight - legendHeight, right: NaN, @@ -3903,18 +3903,18 @@ var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; var withTransition, withTransitionForTransform; var texts, rects, tiles, background; - + options = options || {}; withTransition = getOption(options, "withTransition", true); withTransitionForTransform = getOption(options, "withTransitionForTransform", true); - + function getTextBox(textElement, id) { if (!legendItemTextBox[id]) { legendItemTextBox[id] = $$.getTextRect(textElement.textContent, CLASS.legendItem); } return legendItemTextBox[id]; } - + function updatePositions(textElement, id, index) { var reset = index === 0, isLast = index === targetIds.length - 1, box = getTextBox(textElement, id), @@ -3923,7 +3923,7 @@ itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, areaLength = $$.isLegendRight || $$.isLegendInset ? $$.getLegendHeight() : $$.getLegendWidth(), margin, maxLength; - + // MEMO: care about condifion of step, totalLength function updateValues(id, withoutStep) { if (!withoutStep) { @@ -3939,26 +3939,26 @@ offsets[id] = totalLength; totalLength += itemLength; } - + if (reset) { totalLength = 0; step = 0; maxWidth = 0; maxHeight = 0; } - + if (config.legend_show && !$$.isLegendToShow(id)) { widths[id] = heights[id] = steps[id] = offsets[id] = 0; return; } - + widths[id] = itemWidth; heights[id] = itemHeight; - + if (!maxWidth || itemWidth >= maxWidth) { maxWidth = itemWidth; } if (!maxHeight || itemHeight >= maxHeight) { maxHeight = itemHeight; } maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; - + if (config.legend_equally) { Object.keys(widths).forEach(function (id) { widths[id] = maxWidth; }); Object.keys(heights).forEach(function (id) { heights[id] = maxHeight; }); @@ -3975,12 +3975,12 @@ updateValues(id); } } - + if ($$.isLegendInset) { step = config.legend_inset_step ? config.legend_inset_step : targetIds.length; $$.updateLegendStep(step); } - + if ($$.isLegendRight) { xForLegend = function (id) { return maxWidth * steps[id]; }; yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; @@ -3995,7 +3995,7 @@ yForLegendText = function (id, i) { return yForLegend(id, i) + 9; }; xForLegendRect = function (id, i) { return xForLegend(id, i); }; yForLegendRect = function (id, i) { return yForLegend(id, i) - 5; }; - + // Define g for legend area l = $$.legend.selectAll('.' + CLASS.legendItem) .data(targetIds) @@ -4051,7 +4051,7 @@ .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegend) .attr('width', 10) .attr('height', 10); - + // Set background for inset legend background = $$.legend.select('.' + CLASS.legendBackground + ' rect'); if ($$.isLegendInset && maxWidth > 0 && background.size() === 0) { @@ -4059,7 +4059,7 @@ .attr("class", CLASS.legendBackground) .append('rect'); } - + texts = $$.legend.selectAll('text') .data(targetIds) .text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) // MEMO: needed for update @@ -4067,7 +4067,7 @@ (withTransition ? texts.transition() : texts) .attr('x', xForLegendText) .attr('y', yForLegendText); - + rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent) .data(targetIds); (withTransition ? rects.transition() : rects) @@ -4075,24 +4075,24 @@ .attr('height', function (id) { return heights[id]; }) .attr('x', xForLegendRect) .attr('y', yForLegendRect); - + tiles = $$.legend.selectAll('rect.' + CLASS.legendItemTile) .data(targetIds); (withTransition ? tiles.transition() : tiles) .style('fill', $$.color) .attr('x', xForLegend) .attr('y', yForLegend); - + if (background) { (withTransition ? background.transition() : background) .attr('height', $$.getLegendHeight() - 12) .attr('width', maxWidth * (step + 1) + 10); } - + // toggle legend state $$.legend.selectAll('.' + CLASS.legendItem) .classed(CLASS.legendItemHidden, function (id) { return !$$.isTargetToShow(id); }); - + // Update all to reflect change of legend $$.updateLegendItemWidth(maxWidth); $$.updateLegendItemHeight(maxHeight); @@ -4109,11 +4109,11 @@ function Axis(owner) { API.call(this, owner); } - + inherit(API, Axis); - + Axis.prototype.init = function init() { - + var $$ = this.owner, config = $$.config, main = $$.main; $$.axes.x = main.append("g") .attr("class", CLASS.axis + ' ' + CLASS.axisX) @@ -4133,7 +4133,7 @@ .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) // clip-path? @@ -4154,11 +4154,11 @@ withoutTransition: withoutTransition, }, axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient); - + if ($$.isTimeSeries() && tickValues) { tickValues = tickValues.map(function (v) { return $$.parseDate(v); }); } - + // Set tick axis.tickFormat(tickFormat).tickValues(tickValues); if ($$.isCategorized()) { @@ -4167,7 +4167,7 @@ config.axis_x_tick_culling = false; } } - + return axis; }; Axis.prototype.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) { @@ -4421,7 +4421,7 @@ $$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; return $$.currentMaxTickWidths[id]; }; - + Axis.prototype.updateLabels = function updateLabels(withTransition) { var $$ = this.owner; var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), @@ -4836,18 +4836,22 @@ return; } updated = $$.updateAngle(d); - arcData = $$.convertToArcData(updated); - // transitions - $$.expandArc(updated.data.id); - $$.api.focus(updated.data.id); - $$.toggleFocusLegend(updated.data.id, true); - $$.config.data_onmouseover(arcData, this); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.expandArc(updated.data.id); + $$.api.focus(updated.data.id); + $$.toggleFocusLegend(updated.data.id, true); + $$.config.data_onmouseover(arcData, this); + } } : null) .on('mousemove', config.interaction_enabled ? function (d) { - var updated = $$.updateAngle(d), - arcData = $$.convertToArcData(updated), - selectedData = [arcData]; - $$.showTooltip(selectedData, this); + var updated = $$.updateAngle(d); + if (updated) { + var arcData = $$.convertToArcData(updated), + selectedData = [arcData]; + $$.showTooltip(selectedData, this); + } } : null) .on('mouseout', config.interaction_enabled ? function (d) { var updated, arcData; @@ -4855,19 +4859,25 @@ return; } updated = $$.updateAngle(d); - arcData = $$.convertToArcData(updated); - // transitions - $$.unexpandArc(updated.data.id); - $$.api.revert(); - $$.revertLegend(); - $$.hideTooltip(); - $$.config.data_onmouseout(arcData, this); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.unexpandArc(updated.data.id); + $$.api.revert(); + $$.revertLegend(); + $$.hideTooltip(); + $$.config.data_onmouseout(arcData, this); + } } : null) .on('click', config.interaction_enabled ? function (d, i) { - var updated = $$.updateAngle(d), - arcData = $$.convertToArcData(updated); - if ($$.toggleShape) { $$.toggleShape(this, arcData, i); } - $$.config.data_onclick.call($$.api, arcData, this); + var updated = $$.updateAngle(d); + if (updated) { + var arcData = $$.convertToArcData(updated); + if ($$.toggleShape) { + $$.toggleShape(this, arcData, i); + } + $$.config.data_onclick.call($$.api, arcData, this); + } } : null) .each(function () { $$.transiting = true; }) .transition().duration(duration) @@ -4972,10 +4982,10 @@ }; c3_chart_internal_fn.updateRegion = function (duration) { var $$ = this, config = $$.config; - + // 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') @@ -5049,12 +5059,12 @@ c3_chart_internal_fn.drag = function (mouse) { var $$ = this, config = $$.config, main = $$.main, d3 = $$.d3; var sx, sy, mx, my, minX, maxX, minY, maxY; - + if ($$.hasArcType()) { return; } 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 - + sx = $$.dragStart[0]; sy = $$.dragStart[1]; mx = mouse[0]; @@ -5063,7 +5073,7 @@ maxX = Math.max(sx, mx); minY = (config.data_selection_grouped) ? $$.margin.top : Math.min(sy, my); maxY = (config.data_selection_grouped) ? $$.height : Math.max(sy, my); - + main.select('.' + CLASS.dragarea) .attr('x', minX) .attr('y', minY) @@ -5103,7 +5113,7 @@ } }); }; - + c3_chart_internal_fn.dragstart = function (mouse) { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } @@ -5114,7 +5124,7 @@ .style('opacity', 0.1); $$.dragging = true; }; - + c3_chart_internal_fn.dragend = function () { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } @@ -5191,7 +5201,7 @@ var $$ = this, d3 = $$.d3, config = $$.config, shape = d3.select(that), isSelected = shape.classed(CLASS.SELECTED), toggle = $$.getToggle(that, d).bind($$); - + if (config.data_selection_enabled && config.data_selection_isselectable(d)) { if (!config.data_selection_multiple) { $$.main.selectAll('.' + CLASS.shapes + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS.shape).each(function (d, i) { @@ -5218,28 +5228,28 @@ c3_chart_internal_fn.initSubchart = function () { var $$ = this, config = $$.config, context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context')); - + context.style('visibility', config.subchart_show ? 'visible' : 'hidden'); - + // Define g for chart area context.append('g') .attr("clip-path", $$.clipPathForSubchart) .attr('class', CLASS.chart); - + // Define g for bar chart area context.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartBars); - + // Define g for line chart area context.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartLines); - + // Add extent rect for Brush context.append("g") .attr("clip-path", $$.clipPath) .attr("class", CLASS.brush) .call($$.brush); - + // ATTENTION: This must be called AFTER chart added // Add Axis $$.axes.subx = context.append("g") @@ -5255,7 +5265,7 @@ classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$); - + if (config.subchart_show) { //-- Bar --// contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) @@ -5267,7 +5277,7 @@ // Bars for each data contextBarEnter.append('g') .attr("class", classBars); - + //-- Line --// contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) .data(targets) @@ -5281,7 +5291,7 @@ // Area contextLineEnter.append("g") .attr("class", classAreas); - + //-- Brush --// context.selectAll('.' + CLASS.brush + ' rect') .attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? $$.width2 : $$.height2); @@ -5347,9 +5357,9 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices) { var $$ = this, d3 = $$.d3, config = $$.config, drawAreaOnSub, drawBarOnSub, drawLineOnSub; - + $$.context.style('visibility', config.subchart_show ? 'visible' : 'hidden'); - + // subchart if (config.subchart_show) { // reflect main chart to extent on subchart if zoomed @@ -5358,7 +5368,7 @@ } // update subchart elements if needed if (withSubchart) { - + // extent rect if (!$$.brush.empty()) { $$.brush.extent($$.x.orgDomain()).update(); @@ -5367,11 +5377,11 @@ drawAreaOnSub = $$.generateDrawArea(areaIndices, true); drawBarOnSub = $$.generateDrawBar(barIndices, true); drawLineOnSub = $$.generateDrawLine(lineIndices, true); - + $$.updateBarForSubchart(duration); $$.updateLineForSubchart(duration); $$.updateAreaForSubchart(duration); - + $$.redrawBarForSubchart(drawBarOnSub, duration, duration); $$.redrawLineForSubchart(drawLineOnSub, duration, duration); $$.redrawAreaForSubchart(drawAreaOnSub, duration, duration); @@ -5411,7 +5421,7 @@ c3_chart_internal_fn.initZoom = function () { var $$ = this, d3 = $$.d3, config = $$.config, startEvent; - + $$.zoom = d3.behavior.zoom() .on("zoomstart", function () { startEvent = d3.event.sourceEvent; @@ -5485,10 +5495,10 @@ pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(), callback = config.data_color, ids = []; - + return function (d) { var id = d.id || (d.data && d.data.id) || d, color; - + // if callback function is provided if (colors[id] instanceof Function) { color = colors[id](d); @@ -5810,10 +5820,10 @@ c3_chart_fn.focus = function (targetIds) { var $$ = this.internal, candidates; - + targetIds = $$.mapToTargetIds(targetIds); candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$))), - + this.revert(); this.defocus(); candidates.classed(CLASS.focused, true).classed(CLASS.defocused, false); @@ -5821,37 +5831,37 @@ $$.expandArc(targetIds); } $$.toggleFocusLegend(targetIds, true); - + $$.focusedTargetIds = targetIds; $$.defocusedTargetIds = $$.defocusedTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); }; - + c3_chart_fn.defocus = function (targetIds) { var $$ = this.internal, candidates; - + targetIds = $$.mapToTargetIds(targetIds); candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$))), - + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, true); if ($$.hasArcType()) { $$.unexpandArc(targetIds); } $$.toggleFocusLegend(targetIds, false); - + $$.focusedTargetIds = $$.focusedTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); $$.defocusedTargetIds = targetIds; }; - + c3_chart_fn.revert = function (targetIds) { var $$ = this.internal, candidates; - + targetIds = $$.mapToTargetIds(targetIds); candidates = $$.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets - + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, false); if ($$.hasArcType()) { $$.unexpandArc(targetIds); @@ -5864,55 +5874,55 @@ }) .classed(CLASS.legendItemFocused, false); } - + $$.focusedTargetIds = []; $$.defocusedTargetIds = []; }; c3_chart_fn.show = function (targetIds, options) { var $$ = this.internal, targets; - + targetIds = $$.mapToTargetIds(targetIds); options = options || {}; - + $$.removeHiddenTargetIds(targetIds); targets = $$.svg.selectAll($$.selectorTargets(targetIds)); - + targets.transition() .style('opacity', 1, 'important') .call($$.endall, function () { targets.style('opacity', null).style('opacity', 1); }); - + if (options.withLegend) { $$.showLegend(targetIds); } - + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); }; - + c3_chart_fn.hide = function (targetIds, options) { var $$ = this.internal, targets; - + targetIds = $$.mapToTargetIds(targetIds); options = options || {}; - + $$.addHiddenTargetIds(targetIds); targets = $$.svg.selectAll($$.selectorTargets(targetIds)); - + targets.transition() .style('opacity', 0, 'important') .call($$.endall, function () { targets.style('opacity', null).style('opacity', 0); }); - + if (options.withLegend) { $$.hideLegend(targetIds); } - + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); }; - + c3_chart_fn.toggle = function (targetIds, options) { var that = this, $$ = this.internal; $$.mapToTargetIds(targetIds).forEach(function (targetId) { @@ -5980,7 +5990,7 @@ $$.loadFromArgs(args); } }; - + c3_chart_fn.unload = function (args) { var $$ = this.internal; args = args || {}; @@ -5999,7 +6009,7 @@ var $$ = this.internal, targets, data, notfoundIds = [], orgDataCount = $$.getMaxDataCount(), dataCount, domain, baseTarget, baseValue, length = 0, tail = 0, diff, to; - + if (args.json) { data = $$.convertJsonToData(args.json, args.keys); } @@ -6013,19 +6023,19 @@ return; } targets = $$.convertDataToTargets(data, true); - + // Update/Add data $$.data.targets.forEach(function (t) { var found = false, i, j; for (i = 0; i < targets.length; i++) { if (t.id === targets[i].id) { found = true; - + if (t.values[t.values.length - 1]) { tail = t.values[t.values.length - 1].index + 1; } length = targets[i].values.length; - + for (j = 0; j < length; j++) { targets[i].values[j].index = tail + j; if (!$$.isTimeSeries()) { @@ -6033,14 +6043,14 @@ } } t.values = t.values.concat(targets[i].values); - + targets.splice(i, 1); break; } } if (!found) { notfoundIds.push(t.id); } }); - + // Append null for not found targets $$.data.targets.forEach(function (t) { var i, j; @@ -6058,7 +6068,7 @@ } } }); - + // Generate null values for new target if ($$.data.targets.length) { targets.forEach(function (t) { @@ -6081,12 +6091,12 @@ }); } $$.data.targets = $$.data.targets.concat(targets); // add remained - + // check data count because behavior needs to change when it's only one dataCount = $$.getMaxDataCount(); baseTarget = $$.data.targets[0]; baseValue = baseTarget.values[0]; - + // Update length to flow if needed if (isDefined(args.to)) { length = 0; @@ -6097,7 +6107,7 @@ } else if (isDefined(args.length)) { length = args.length; } - + // If only one data, update the domain to flow from left edge of the chart if (!orgDataCount) { if ($$.isTimeSeries()) { @@ -6118,10 +6128,10 @@ $$.updateXDomain(null, true, true, false, domain); } } - + // Set targets $$.updateTargets($$.data.targets); - + // Redraw with new targets $$.redraw({ flow: { @@ -6137,10 +6147,10 @@ withUpdateXAxis: true, }); }; - + c3_chart_internal_fn.generateFlow = function (args) { var $$ = this, config = $$.config, d3 = $$.d3; - + return function () { var targets = args.targets, flow = args.flow, @@ -6153,7 +6163,7 @@ xForText = args.xForText, yForText = args.yForText, duration = args.duration; - + var translateX, scaleX = 1, transform, flowIndex = flow.index, flowLength = flow.length, @@ -6163,7 +6173,7 @@ durationForFlow = flow.duration || duration, done = flow.done || function () {}, wait = $$.generateWait(); - + var xgrid = $$.xgrid || d3.selectAll([]), xgridLines = $$.xgridLines || d3.selectAll([]), mainRegion = $$.mainRegion || d3.selectAll([]), @@ -6172,20 +6182,20 @@ mainLine = $$.mainLine || d3.selectAll([]), mainArea = $$.mainArea || d3.selectAll([]), mainCircle = $$.mainCircle || d3.selectAll([]); - + // set flag $$.flowing = true; - + // remove head data after rendered $$.data.targets.forEach(function (d) { d.values.splice(0, flowLength); }); - + // update x domain to generate axis elements for flow domain = $$.updateXDomain(targets, true, true); // update elements related to x scale if ($$.updateXGrid) { $$.updateXGrid(true); } - + // generate transform to flow if (!flow.orgDataCount) { // if empty if ($$.data.targets[0].values.length !== 1) { @@ -6210,11 +6220,11 @@ } scaleX = (diffDomain(orgDomain) / diffDomain(domain)); transform = 'translate(' + translateX + ',0) scale(' + scaleX + ',1)'; - + // hide tooltip $$.hideXGridFocus(); $$.hideTooltip(); - + d3.transition().ease('linear').duration(durationForFlow).each(function () { wait.add($$.axes.x.transition().call($$.xAxis)); wait.add(mainBar.transition().attr('transform', transform)); @@ -6228,7 +6238,7 @@ }) .call(wait, function () { var i, shapes = [], texts = [], eventRects = []; - + // remove flowed elements if (flowLength) { for (i = 0; i < flowLength; i++) { @@ -6241,7 +6251,7 @@ $$.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) @@ -6277,14 +6287,14 @@ mainRegion.select('rect').filter($$.isRegionOnX) .attr("x", $$.regionX.bind($$)) .attr("width", $$.regionWidth.bind($$)); - + if (config.interaction_enabled) { $$.redrawEventRect(); } - + // callback for end of flow done(); - + $$.flowing = false; }); }; @@ -6350,7 +6360,7 @@ options = ['pie', 'donut'].indexOf(type) >= 0 ? {withTransform: true} : null; $$.transformTo(targetIds, type, options); }; - + c3_chart_internal_fn.transformTo = function (targetIds, type, optionsForRedraw) { var $$ = this, withTransitionForAxis = !$$.hasArcType(), @@ -6385,7 +6395,7 @@ var $$ = this.internal; $$.removeGridLines(params, true); }; - + c3_chart_fn.ygrids = function (grids) { var $$ = this.internal, config = $$.config; if (! grids) { return config.grid_y_lines; } @@ -6419,16 +6429,16 @@ c3_chart_fn.regions.remove = function (options) { var $$ = this.internal, config = $$.config, duration, classes, regions; - + options = options || {}; duration = $$.getOption(options, "duration", config.transition_duration); classes = $$.getOption(options, "classes", [CLASS.region]); - + regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { return '.' + c; })); (duration ? regions.transition().duration(duration) : regions) .style('opacity', 0) .remove(); - + config.regions = config.regions.filter(function (region) { var found = false; if (!region['class']) { @@ -6439,7 +6449,7 @@ }); return !found; }); - + return config.regions; }; @@ -6589,37 +6599,37 @@ config.size_height = size ? size.height : null; this.flush(); }; - + c3_chart_fn.flush = function () { var $$ = this.internal; $$.updateAndRedraw({withLegend: true, withTransition: false, withTransitionForTransform: false}); }; - + c3_chart_fn.destroy = function () { var $$ = this.internal; - + window.clearInterval($$.intervalForObserveInserted); window.onresize = null; - + $$.selectChart.classed('c3', false).html(""); - + // MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen. Object.keys($$).forEach(function (key) { $$[key] = null; }); - + return null; }; c3_chart_fn.tooltip = function () {}; c3_chart_fn.tooltip.show = function (args) { var $$ = this.internal, index, mouse; - + // determine mouse position on the chart if (args.mouse) { mouse = args.mouse; } - + // determine focus data if (args.data) { if ($$.isMultipleX()) { @@ -6637,7 +6647,7 @@ else if (typeof args.index !== 'undefined') { index = args.index; } - + // emulate mouse events to show $$.dispatchEvent('mouseover', index, mouse); $$.dispatchEvent('mousemove', index, mouse); @@ -6654,12 +6664,12 @@ var tickTextCharSize; function c3_axis(d3, params) { var scale = d3.scale.linear(), orient = "bottom", innerTickSize = 6, outerTickSize, tickPadding = 3, tickValues = null, tickFormat, tickArguments; - + var tickOffset = 0, tickCulling = true, tickCentered; - + params = params || {}; outerTickSize = params.withOuterTick ? 6 : 0; - + function axisX(selection, x) { selection.attr("transform", function (d) { return "translate(" + Math.ceil(x(d) + tickOffset) + ", 0)"; @@ -6724,9 +6734,9 @@ function axis(g) { g.each(function () { var g = axis.g = d3.select(this); - + var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = copyScale(); - + var ticks = tickValues ? tickValues : generateTicks(scale1), tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6), @@ -6734,18 +6744,18 @@ tickExit = tick.exit().remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform, tickX, tickY; - + var range = scale.rangeExtent ? scale.rangeExtent() : scaleExtent(scale.range()), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), d3.transition(path)); tickEnter.append("line"); tickEnter.append("text"); - + var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); - + if (params.isCategory) { tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); tickX = tickCentered ? 0 : tickOffset; @@ -6753,24 +6763,24 @@ } else { tickOffset = tickX = 0; } - + var text, tspan, sizeFor1Char = getSizeFor1Char(g.select('.tick')), counts = []; var tickLength = Math.max(innerTickSize, 0) + tickPadding, isVertical = orient === 'left' || orient === 'right'; - + // this should be called only when category axis function splitTickText(d, maxWidth) { var tickText = textFormatted(d), subtext, spaceIndex, textWidth, splitted = []; - + if (Object.prototype.toString.call(tickText) === "[object Array]") { return tickText; } - + if (!maxWidth || maxWidth <= 0) { maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 12) : 110; } - + function split(splitted, text) { spaceIndex = undefined; for (var i = 1; i < text.length; i++) { @@ -6789,10 +6799,10 @@ } return splitted.concat(text); } - + return split(splitted, tickText + ""); } - + function tspanDy(d, i) { var dy = sizeFor1Char.h; if (i === 0) { @@ -6804,12 +6814,12 @@ } return dy; } - + function tickSize(d) { var tickPosition = scale(d) + (tickCentered ? 0 : tickOffset); return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0; } - + text = tick.select("text"); tspan = text.selectAll('tspan') .data(function (d, i) { @@ -6822,7 +6832,7 @@ tspan.enter().append('tspan'); tspan.exit().remove(); tspan.text(function (d) { return d.splitted; }); - + switch (orient) { case "bottom": { diff --git a/c3.min.js b/c3.min.js index e0f88ec..1d82148 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,5 +1,5 @@ !function(a){"use strict";function b(a){this.owner=a}function c(a,b){if(Object.create)b.prototype=Object.create(a.prototype);else{var c=function(){};c.prototype=a.prototype,b.prototype=new c}return b.prototype.constructor=b,b}function d(a){var b=this.internal=new e(this);b.loadConfig(a),b.init(),function c(a,b,d){Object.keys(a).forEach(function(e){b[e]=a[e].bind(d),Object.keys(a[e]).length>0&&c(a[e],b[e],d)})}(h,this,this)}function e(b){var c=this;c.d3=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,c.api=b,c.config=c.getDefaultConfig(),c.data={},c.cache={},c.axes={}}function f(a){b.call(this,a)}function g(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+t)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,m);for(c=a.domain(),b=Math.ceil(c[0]);b||||
"+g+" | |||||
"+i+" | ",e+=""+h+" | ",e+="