dc.js Source: core.js (original) (raw)

/**

*/ var dc = { version: '<%= conf.pkg.version %>', constants: { CHART_CLASS: 'dc-chart', DEBUG_GROUP_CLASS: 'debug', STACK_CLASS: 'stack', DESELECTED_CLASS: 'deselected', SELECTED_CLASS: 'selected', NODE_INDEX_NAME: 'index', GROUP_INDEX_NAME: 'group_index', DEFAULT_CHART_GROUP: 'default_chart_group', EVENT_DELAY: 40, NEGLIGIBLE_NUMBER: 1e-10 }, _renderlet: null };

/**

})();

/**

/**

/**

/**

/**

/**

/**

};

/**

};

/**

/**

};

/* somewhat silly, but to avoid duplicating logic */ dc.optionalTransition = function (enable, duration, delay, name) { if (enable) { return function (selection) { return dc.transition(selection, duration, delay, name); }; } else { return function (selection) { return selection; }; } };

// See http://stackoverflow.com/a/20773846 dc.afterTransition = function (transition, callback) { if (transition.empty() || !transition.duration) { callback.call(transition); } else { var n = 0; transition .each(function () { ++n; }) .on('end', function () { if (!--n) { callback.call(transition); } }); } };

/**

/**

/**

*/ dc.units.ordinal = function () { throw new Error('dc.units.ordinal should not be called - it is a placeholder'); };

/**

dc.round = {}; dc.round.floor = function (n) { return Math.floor(n); }; dc.round.ceil = function (n) { return Math.ceil(n); }; dc.round.round = function (n) { return Math.round(n); };

dc.override = function (obj, functionName, newFunction) { var existingFunction = obj[functionName]; obj['_' + functionName] = existingFunction; obj[functionName] = newFunction; };

dc.renderlet = function (_) { if (!arguments.length) { return dc._renderlet; } dc._renderlet = _; return dc; };

dc.instanceOfChart = function (o) { return o instanceof Object && o.dcFlag && true; };

// polyfill for IE // from https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function (s) { var matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length; do { --i; } while (i >= 0 && matches.item(i) !== this); return i > -1; }; }