code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function computeMinSampleSize(scale, pixels) {
var min = scale.isHorizontal() ? scale.width : scale.height;
var ticks = scale.getTicks();
var prev, curr, i, ilen;
for (i = 1, ilen = pixels.length; i < ilen; ++i) {
min = Math.min(min, pixels[i] - pixels[i - 1]);
}
for (i = 0, ilen = ticks.length; i < ilen; ++i... | Computes the "optimal" sample size to maintain bars equally sized while preventing overlap.
@private | computeMinSampleSize | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function computeFitCategoryTraits(index, ruler, options) {
var thickness = options.barThickness;
var count = ruler.stackCount;
var curr = ruler.pixels[index];
var size, ratio;
if (helpers.isNullOrUndef(thickness)) {
size = ruler.min * options.categoryPercentage;
ratio = options.barPercentage;
} else {
// W... | Computes an "ideal" category based on the absolute bar thickness or, if undefined or null,
uses the smallest interval (see computeMinSampleSize) that prevents bar overlapping. This
mode currently always generates bars equally sized (until we introduce scriptable options?).
@private | computeFitCategoryTraits | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function computeFlexCategoryTraits(index, ruler, options) {
var pixels = ruler.pixels;
var curr = pixels[index];
var prev = index > 0 ? pixels[index - 1] : null;
var next = index < pixels.length - 1 ? pixels[index + 1] : null;
var percent = options.categoryPercentage;
var start, size;
if (prev === null) {
// ... | Computes an "optimal" category that globally arranges bars side by side (no gap when
percentage options are 1), based on the previous and following categories. This mode
generates bars with different widths when data are not evenly spaced.
@private | computeFlexCategoryTraits | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function initConfig(config) {
config = config || {};
// Do NOT use configMerge() for the data object because this method merges arrays
// and so would change references to labels and datasets, preventing data updates.
var data = config.data = config.data || {};
data.datasets = data.datasets || [];
data.lab... | Initializes the given config with global and chart default values. | initConfig | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function updateConfig(chart) {
var newOptions = chart.options;
helpers.each(chart.scales, function(scale) {
layouts.removeBox(chart, scale);
});
newOptions = helpers.configMerge(
Chart.defaults.global,
Chart.defaults[chart.config.type],
newOptions);
chart.options = chart.config.options = newOpt... | Updates the config of the chart
@param chart {Chart} chart to update the options for | updateConfig | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function positionIsHorizontal(position) {
return position === 'top' || position === 'bottom';
} | Updates the config of the chart
@param chart {Chart} chart to update the options for | positionIsHorizontal | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
onComplete = function(animation) {
plugins.notify(me, 'afterRender');
helpers.callback(animationOptions && animationOptions.onComplete, [animation], me);
} | Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate`
hook, in which case, plugins will not be called on `afterDatasetUpdate`.
@private | onComplete | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function listenArrayEvents(array, listener) {
if (array._chartjs) {
array._chartjs.listeners.push(listener);
return;
}
Object.defineProperty(array, '_chartjs', {
configurable: true,
enumerable: false,
value: {
listeners: [listener]
}
});
arrayEvents.forEach(function(key) {
var metho... | Hooks the array methods that add or remove values ('push', pop', 'shift', 'splice',
'unshift') and notify the listener AFTER the array has been altered. Listeners are
called on the 'onData*' callbacks (e.g. onDataPush, etc.) with same arguments. | listenArrayEvents | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function unlistenArrayEvents(array, listener) {
var stub = array._chartjs;
if (!stub) {
return;
}
var listeners = stub.listeners;
var index = listeners.indexOf(listener);
if (index !== -1) {
listeners.splice(index, 1);
}
if (listeners.length > 0) {
return;
}
arrayEvents.forEach(function(... | Removes the given array event listener and cleanup extra attached properties (such as
the _chartjs stub and overridden methods) if array doesn't have any more listeners. | unlistenArrayEvents | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function isConstrainedValue(value) {
return value !== undefined && value !== null && value !== 'none';
} | Returns if the given value contains an effective constraint.
@private | isConstrainedValue | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getConstraintDimension(domNode, maxStyle, percentageProperty) {
var view = document.defaultView;
var parentNode = helpers._getParentNode(domNode);
var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
var hasCNode = isC... | Returns if the given value contains an effective constraint.
@private | getConstraintDimension | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getRelativePosition(e, chart) {
if (e.native) {
return {
x: e.x,
y: e.y
};
}
return helpers.getRelativePosition(e, chart);
} | Helper function to get relative position for an event
@param {Event|IEvent} event - The event to get the position for
@param {Chart} chart - The chart
@returns {Point} the event position | getRelativePosition | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function parseVisibleItems(chart, handler) {
var datasets = chart.data.datasets;
var meta, i, j, ilen, jlen;
for (i = 0, ilen = datasets.length; i < ilen; ++i) {
if (!chart.isDatasetVisible(i)) {
continue;
}
meta = chart.getDatasetMeta(i);
for (j = 0, jlen = meta.data.length; j < jlen; ++j) {
var ele... | Helper function to traverse all of the visible elements in the chart
@param chart {chart} the chart
@param handler {Function} the callback to execute for each visible item | parseVisibleItems | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getIntersectItems(chart, position) {
var elements = [];
parseVisibleItems(chart, function(element) {
if (element.inRange(position.x, position.y)) {
elements.push(element);
}
});
return elements;
} | Helper function to get the items that intersect the event position
@param items {ChartElement[]} elements to filter
@param position {Point} the point to be nearest to
@return {ChartElement[]} the nearest items | getIntersectItems | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getNearestItems(chart, position, intersect, distanceMetric) {
var minDistance = Number.POSITIVE_INFINITY;
var nearestItems = [];
parseVisibleItems(chart, function(element) {
if (intersect && !element.inRange(position.x, position.y)) {
return;
}
var center = element.getCenterPoint();
var distanc... | Helper function to get the items nearest to the event position considering all visible items in teh chart
@param chart {Chart} the chart to look at elements from
@param position {Point} the point to be nearest to
@param intersect {Boolean} if true, only consider items that intersect the position
@param distanceMetric {... | getNearestItems | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getDistanceMetricForAxis(axis) {
var useX = axis.indexOf('x') !== -1;
var useY = axis.indexOf('y') !== -1;
return function(pt1, pt2) {
var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;
var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;
return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
};
} | Get a distance metric function for two points based on the
axis mode setting
@param {String} axis the axis mode. x|y|xy | getDistanceMetricForAxis | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function indexMode(chart, e, options) {
var position = getRelativePosition(e, chart);
// Default axis for index mode is 'x' to match old behaviour
options.axis = options.axis || 'x';
var distanceMetric = getDistanceMetricForAxis(options.axis);
var items = options.intersect ? getIntersectItems(chart, position) : ge... | Get a distance metric function for two points based on the
axis mode setting
@param {String} axis the axis mode. x|y|xy | indexMode | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
Chart = function(item, config) {
this.construct(item, config);
return this;
} | y mode returns the elements that hit-test at the current y coordinate
@function Chart.Interaction.modes.y
@param chart {chart} the chart we are returning items from
@param e {Event} the event we are find things at
@param options {IInteractionOptions} options to use
@return {Chart.Element[]} Array of elements that are u... | Chart | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function filterByPosition(array, position) {
return helpers.where(array, function(v) {
return v.position === position;
});
} | y mode returns the elements that hit-test at the current y coordinate
@function Chart.Interaction.modes.y
@param chart {chart} the chart we are returning items from
@param e {Event} the event we are find things at
@param options {IInteractionOptions} options to use
@return {Chart.Element[]} Array of elements that are u... | filterByPosition | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function sortByWeight(array, reverse) {
array.forEach(function(v, i) {
v._tmpIndex_ = i;
return v;
});
array.sort(function(a, b) {
var v0 = reverse ? b : a;
var v1 = reverse ? a : b;
return v0.weight === v1.weight ?
v0._tmpIndex_ - v1._tmpIndex_ :
v0.weight - v1.weight;
});
array.forEach(function(v... | y mode returns the elements that hit-test at the current y coordinate
@function Chart.Interaction.modes.y
@param chart {chart} the chart we are returning items from
@param e {Event} the event we are find things at
@param options {IInteractionOptions} options to use
@return {Chart.Element[]} Array of elements that are u... | sortByWeight | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getMinimumBoxSize(box) {
var minSize;
var isHorizontal = box.isHorizontal();
if (isHorizontal) {
minSize = box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, horizontalBoxHeight);
maxChartAreaHeight -= minSize.height;
} else {
minSize = box.update(verticalBoxWidth, maxChartArea... | Fits boxes of the given chart into the given size by having each box measure itself
then running a fitting algorithm
@param {Chart} chart - the chart
@param {Number} width - the width to fit into
@param {Number} height - the height to fit into | getMinimumBoxSize | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function fitBox(box) {
var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minBox) {
return minBox.box === box;
});
if (minBoxSize) {
if (box.isHorizontal()) {
var scaleMargin = {
left: Math.max(totalLeftBoxesWidth, maxHorizontalLeftPadding),
right: Math.max(totalRightBoxesWi... | Fits boxes of the given chart into the given size by having each box measure itself
then running a fitting algorithm
@param {Chart} chart - the chart
@param {Number} width - the width to fit into
@param {Number} height - the height to fit into | fitBox | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function finalFitVerticalBox(box) {
var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minSize) {
return minSize.box === box;
});
var scaleMargin = {
left: 0,
right: 0,
top: totalTopBoxesHeight,
bottom: totalBottomBoxesHeight
};
if (minBoxSize) {
box.update(minBoxSize.... | Fits boxes of the given chart into the given size by having each box measure itself
then running a fitting algorithm
@param {Chart} chart - the chart
@param {Number} width - the width to fit into
@param {Number} height - the height to fit into | finalFitVerticalBox | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function placeBox(box) {
if (box.isHorizontal()) {
box.left = box.fullWidth ? leftPadding : totalLeftBoxesWidth;
box.right = box.fullWidth ? width - rightPadding : totalLeftBoxesWidth + maxChartAreaWidth;
box.top = top;
box.bottom = top + box.height;
// Move to next point
top = box.bottom;
... | Fits boxes of the given chart into the given size by having each box measure itself
then running a fitting algorithm
@param {Chart} chart - the chart
@param {Number} width - the width to fit into
@param {Number} height - the height to fit into | placeBox | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function labelsFromTicks(ticks) {
var labels = [];
var i, ilen;
for (i = 0, ilen = ticks.length; i < ilen; ++i) {
labels.push(ticks[i].label);
}
return labels;
} | @method IPlugin#destroy
@desc Called after the chart as been destroyed.
@param {Chart.Controller} chart - The chart instance.
@param {Object} options - The plugin options. | labelsFromTicks | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getLineValue(scale, index, offsetGridLines) {
var lineValue = scale.getPixelForTick(index);
if (offsetGridLines) {
if (index === 0) {
lineValue -= (scale.getPixelForTick(1) - lineValue) / 2;
} else {
lineValue -= (lineValue - scale.getPixelForTick(index - 1)) / 2;
}
}
return lineValue;
} | @method IPlugin#destroy
@desc Called after the chart as been destroyed.
@param {Chart.Controller} chart - The chart instance.
@param {Object} options - The plugin options. | getLineValue | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function computeTextSize(context, tick, font) {
return helpers.isArray(tick) ?
helpers.longestText(context, font, tick) :
context.measureText(tick).width;
} | @method IPlugin#destroy
@desc Called after the chart as been destroyed.
@param {Chart.Controller} chart - The chart instance.
@param {Object} options - The plugin options. | computeTextSize | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function parseFontOptions(options) {
var valueOrDefault = helpers.valueOrDefault;
var globalDefaults = defaults.global;
var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
var style = valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle);
var family = valueOrDefault(options.fo... | @method IPlugin#destroy
@desc Called after the chart as been destroyed.
@param {Chart.Controller} chart - The chart instance.
@param {Object} options - The plugin options. | parseFontOptions | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function parseLineHeight(options) {
return helpers.options.toLineHeight(
helpers.valueOrDefault(options.lineHeight, 1.2),
helpers.valueOrDefault(options.fontSize, defaults.global.defaultFontSize));
} | @method IPlugin#destroy
@desc Called after the chart as been destroyed.
@param {Chart.Controller} chart - The chart instance.
@param {Object} options - The plugin options. | parseLineHeight | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function mergeOpacity(colorString, opacity) {
var color = helpers.color(colorString);
return color.alpha(opacity * color.alpha()).rgbaString();
} | Helper method to merge the opacity into a color | mergeOpacity | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function pushOrConcat(base, toPush) {
if (toPush) {
if (helpers.isArray(toPush)) {
// base = base.concat(toPush);
Array.prototype.push.apply(base, toPush);
} else {
base.push(toPush);
}
}
return base;
} | Helper method to merge the opacity into a color | pushOrConcat | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function splitNewlines(str) {
if ((typeof str === 'string' || str instanceof String) && str.indexOf('\n') > -1) {
return str.split('\n');
}
return str;
} | Returns array of strings split by newline
@param {String} value - The value to split by newline.
@returns {Array} value if newline present - Returned from String split() method
@function | splitNewlines | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function createTooltipItem(element) {
var xScale = element._xScale;
var yScale = element._yScale || element._scale; // handle radar || polarArea charts
var index = element._index;
var datasetIndex = element._datasetIndex;
return {
xLabel: xScale ? xScale.getLabelForIndex(index, datasetIndex) : '',
yLabel: ySc... | Returns array of strings split by newline
@param {String} value - The value to split by newline.
@returns {Array} value if newline present - Returned from String split() method
@function | createTooltipItem | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getBaseModel(tooltipOpts) {
var globalDefaults = defaults.global;
var valueOrDefault = helpers.valueOrDefault;
return {
// Positioning
xPadding: tooltipOpts.xPadding,
yPadding: tooltipOpts.yPadding,
xAlign: tooltipOpts.xAlign,
yAlign: tooltipOpts.yAlign,
// Body
bodyFontColor: tooltipOpts.bo... | Helper to get the reset model for the tooltip
@param tooltipOpts {Object} the tooltip options | getBaseModel | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getTooltipSize(tooltip, model) {
var ctx = tooltip._chart.ctx;
var height = model.yPadding * 2; // Tooltip Padding
var width = 0;
// Count of all lines in the body
var body = model.body;
var combinedBodyLength = body.reduce(function(count, bodyItem) {
return count + bodyItem.before.length + bodyItem.... | Get the size of the tooltip | getTooltipSize | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
maxLineWidth = function(line) {
width = Math.max(width, ctx.measureText(line).width + widthPadding);
} | Get the size of the tooltip | maxLineWidth | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function determineAlignment(tooltip, size) {
var model = tooltip._model;
var chart = tooltip._chart;
var chartArea = tooltip._chart.chartArea;
var xAlign = 'center';
var yAlign = 'center';
if (model.y < size.height) {
yAlign = 'top';
} else if (model.y > (chart.height - size.height)) {
yAlign = 'bottom';
}... | Helper to get the alignment of a tooltip given the size | determineAlignment | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getBackgroundPoint(vm, size, alignment, chart) {
// Background Position
var x = vm.x;
var y = vm.y;
var caretSize = vm.caretSize;
var caretPadding = vm.caretPadding;
var cornerRadius = vm.cornerRadius;
var xAlign = alignment.xAlign;
var yAlign = alignment.yAlign;
var paddingAndSize = caretSize + care... | Helper to get the location a tooltip needs to be placed at given the initial position (via the vm) and the size and alignment | getBackgroundPoint | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getBeforeAfterBodyLines(callback) {
return pushOrConcat([], splitNewlines(callback));
} | Helper to build before and after body lines | getBeforeAfterBodyLines | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
fillLineOfText = function(line) {
ctx.fillText(line, pt.x + xLinePadding, pt.y);
pt.y += bodyFontSize + bodySpacing;
} | Helper to build before and after body lines | fillLineOfText | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getBarBounds(bar) {
var vm = bar._view;
var x1, x2, y1, y2;
if (isVertical(bar)) {
// vertical
var halfWidth = vm.width / 2;
x1 = vm.x - halfWidth;
x2 = vm.x + halfWidth;
y1 = Math.min(vm.y, vm.base);
y2 = Math.max(vm.y, vm.base);
} else {
// horizontal bar
var halfHeight = vm.height / 2;
... | Helper function to get the bounds of the bar regardless of the orientation
@param bar {Chart.Element.Rectangle} the bar
@return {Bounds} bounds of the bar
@private | getBarBounds | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function cornerAt(index) {
return corners[(startCorner + index) % 4];
} | Helper function to get the bounds of the bar regardless of the orientation
@param bar {Chart.Element.Rectangle} the bar
@return {Bounds} bounds of the bar
@private | cornerAt | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
setFn = function(value, key) {
target[key] = value;
} | Applies the contents of two or more objects together into the first object.
@param {Object} target - The target object in which all objects are merged into.
@param {Object} arg1 - Object containing additional properties to merge in target.
@param {Object} argN - Additional objects containing properties to merge in targ... | setFn | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
Surrogate = function() {
this.constructor = ChartElement;
} | Basic javascript inheritance based on the model created in Backbone.js | Surrogate | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function initCanvas(canvas, config) {
var style = canvas.style;
// NOTE(SB) canvas.getAttribute('width') !== canvas.width: in the first case it
// returns null or '' if no explicit value has been set to the canvas attribute.
var renderHeight = canvas.getAttribute('height');
var renderWidth = canvas.getAttribute('... | Initializes the canvas style and render size without modifying the canvas display size,
since responsiveness is handled by the controller.resize() method. The config is used
to determine the aspect ratio to apply in case no explicit height has been specified. | initCanvas | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function decodeFill(el, index, count) {
var model = el._model || {};
var fill = model.fill;
var target;
if (fill === undefined) {
fill = !!model.backgroundColor;
}
if (fill === false || fill === null) {
return false;
}
if (fill === true) {
return 'origin';
}
target = parseFloat(fill, 10);
if (isFin... | Plugin based on discussion from the following Chart.js issues:
@see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
@see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897 | decodeFill | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function computeBoundary(source) {
var model = source.el._model || {};
var scale = source.el._scale || {};
var fill = source.fill;
var target = null;
var horizontal;
if (isFinite(fill)) {
return null;
}
// Backward compatibility: until v3, we still need to support boundary values set on
// the model (scale... | Plugin based on discussion from the following Chart.js issues:
@see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
@see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897 | computeBoundary | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function resolveTarget(sources, index, propagate) {
var source = sources[index];
var fill = source.fill;
var visited = [index];
var target;
if (!propagate) {
return fill;
}
while (fill !== false && visited.indexOf(fill) === -1) {
if (!isFinite(fill)) {
return fill;
}
target = sources[fill];
if (!... | Plugin based on discussion from the following Chart.js issues:
@see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
@see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897 | resolveTarget | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function createMapper(source) {
var fill = source.fill;
var type = 'dataset';
if (fill === false) {
return null;
}
if (!isFinite(fill)) {
type = 'boundary';
}
return mappers[type](source);
} | Plugin based on discussion from the following Chart.js issues:
@see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
@see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897 | createMapper | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function isDrawable(point) {
return point && !point.skip;
} | Plugin based on discussion from the following Chart.js issues:
@see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
@see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897 | isDrawable | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function drawArea(ctx, curve0, curve1, len0, len1) {
var i;
if (!len0 || !len1) {
return;
}
// building first area curve (normal)
ctx.moveTo(curve0[0].x, curve0[0].y);
for (i = 1; i < len0; ++i) {
helpers.canvas.lineTo(ctx, curve0[i - 1], curve0[i]);
}
// joining the two area curves
ctx.lineTo(curve1[le... | Plugin based on discussion from the following Chart.js issues:
@see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
@see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897 | drawArea | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function doFill(ctx, points, mapper, view, color, loop) {
var count = points.length;
var span = view.spanGaps;
var curve0 = [];
var curve1 = [];
var len0 = 0;
var len1 = 0;
var i, ilen, index, p0, p1, d0, d1;
ctx.beginPath();
for (i = 0, ilen = (count + !!loop); i < ilen; ++i) {
index = i % count;
p0 = p... | Plugin based on discussion from the following Chart.js issues:
@see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
@see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897 | doFill | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getBoxWidth(labelOpts, fontSize) {
return labelOpts.usePointStyle ?
fontSize * Math.SQRT2 :
labelOpts.boxWidth;
} | Helper function to get the box width based on the usePointStyle option
@param labelopts {Object} the label options on the legend
@param fontSize {Number} the label font size
@return {Number} width of the color box area | getBoxWidth | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
drawLegendBox = function(x, y, legendItem) {
if (isNaN(boxWidth) || boxWidth <= 0) {
return;
}
// Set the ctx for the box
ctx.save();
ctx.fillStyle = valueOrDefault(legendItem.fillStyle, globalDefault.defaultColor);
ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapSty... | IMPORTANT: this class is exposed publicly as Chart.Legend, backward compatibility required! | drawLegendBox | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
fillText = function(x, y, legendItem, textWidth) {
var halfFontSize = fontSize / 2;
var xLeft = boxWidth + halfFontSize + x;
var yMiddle = y + halfFontSize;
ctx.fillText(legendItem.text, xLeft, yMiddle);
if (legendItem.hidden) {
// Strikethrough the text if hidden
ctx.beginPath();
c... | IMPORTANT: this class is exposed publicly as Chart.Legend, backward compatibility required! | fillText | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function createNewLegendAndAttach(chart, legendOpts) {
var legend = new Legend({
ctx: chart.ctx,
options: legendOpts,
chart: chart
});
layouts.configure(chart, legend, legendOpts);
layouts.addBox(chart, legend);
chart.legend = legend;
} | Handle an event
@private
@param {IEvent} event - The event to handle
@return {Boolean} true if a change occured | createNewLegendAndAttach | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function createNewTitleBlockAndAttach(chart, titleOpts) {
var title = new Title({
ctx: chart.ctx,
options: titleOpts,
chart: chart
});
layouts.configure(chart, title, titleOpts);
layouts.addBox(chart, title);
chart.titleBlock = title;
} | IMPORTANT: this class is exposed publicly as Chart.Legend, backward compatibility required! | createNewTitleBlockAndAttach | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function IDMatches(meta) {
return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
} | Internal function to get the correct labels. If data.xLabels or data.yLabels are defined, use those
else fall back to data.labels
@private | IDMatches | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function generateTicks(generationOptions, dataRange) {
var ticks = [];
// To get a "nice" value for the tick spacing, we will use the appropriately named
// "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
// for details.
var factor;
var p... | Generate a set of linear ticks
@param generationOptions the options used to generate the ticks
@param dataRange the range of the data
@returns {Array<Number>} array of tick values | generateTicks | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function generateTicks(generationOptions, dataRange) {
var ticks = [];
var valueOrDefault = helpers.valueOrDefault;
// Figure out what the max number of ticks we can support it is based on the size of
// the axis area. For now, we say that the minimum tick spacing in pixels must be 50
// We also limit the maximum... | Generate a set of logarithmic ticks
@param generationOptions the options used to generate the ticks
@param dataRange the range of the data
@returns {Array<Number>} array of tick values | generateTicks | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function IDMatches(meta) {
return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
} | Generate a set of logarithmic ticks
@param generationOptions the options used to generate the ticks
@param dataRange the range of the data
@returns {Array<Number>} array of tick values | IDMatches | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getValueCount(scale) {
var opts = scale.options;
return opts.angleLines.display || opts.pointLabels.display ? scale.chart.data.labels.length : 0;
} | Returns the value of the first tick.
@param {Number} value - The minimum not zero value.
@return {Number} The first tick value.
@private | getValueCount | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getPointLabelFontOptions(scale) {
var pointLabelOptions = scale.options.pointLabels;
var fontSize = helpers.valueOrDefault(pointLabelOptions.fontSize, globalDefaults.defaultFontSize);
var fontStyle = helpers.valueOrDefault(pointLabelOptions.fontStyle, globalDefaults.defaultFontStyle);
var fontFamily = ... | Returns the value of the first tick.
@param {Number} value - The minimum not zero value.
@return {Number} The first tick value.
@private | getPointLabelFontOptions | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function measureLabelSize(ctx, fontSize, label) {
if (helpers.isArray(label)) {
return {
w: helpers.longestText(ctx, ctx.font, label),
h: (label.length * fontSize) + ((label.length - 1) * 1.5 * fontSize)
};
}
return {
w: ctx.measureText(label).width,
h: fontSize
};
} | Returns the value of the first tick.
@param {Number} value - The minimum not zero value.
@return {Number} The first tick value.
@private | measureLabelSize | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function determineLimits(angle, pos, size, min, max) {
if (angle === min || angle === max) {
return {
start: pos - (size / 2),
end: pos + (size / 2)
};
} else if (angle < min || angle > max) {
return {
start: pos - size - 5,
end: pos
};
}
return {
start: pos,
end: pos + size +... | Returns the value of the first tick.
@param {Number} value - The minimum not zero value.
@return {Number} The first tick value.
@private | determineLimits | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function fitWithPointLabels(scale) {
/*
* Right, this is really confusing and there is a lot of maths going on here
* The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
*
* Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
*
* Solution:
*
... | Helper function to fit a radial linear scale with point labels | fitWithPointLabels | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function fit(scale) {
var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
scale.drawingArea = Math.round(largestPossibleRadius);
scale.setCenterPoint(0, 0, 0, 0);
} | Helper function to fit a radial linear scale with no point labels | fit | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function getTextAlignForAngle(angle) {
if (angle === 0 || angle === 180) {
return 'center';
} else if (angle < 180) {
return 'left';
}
return 'right';
} | Helper function to fit a radial linear scale with no point labels | getTextAlignForAngle | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function fillText(ctx, text, position, fontSize) {
if (helpers.isArray(text)) {
var y = position.y;
var spacing = 1.5 * fontSize;
for (var i = 0; i < text.length; ++i) {
ctx.fillText(text[i], position.x, y);
y += spacing;
}
} else {
ctx.fillText(text, position.x, position.y);
}
} | Helper function to fit a radial linear scale with no point labels | fillText | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function adjustPointPositionForLabelHeight(angle, textSize, position) {
if (angle === 90 || angle === 270) {
position.y -= (textSize.h / 2);
} else if (angle > 270 || angle < 90) {
position.y -= textSize.h;
}
} | Helper function to fit a radial linear scale with no point labels | adjustPointPositionForLabelHeight | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function drawPointLabels(scale) {
var ctx = scale.ctx;
var opts = scale.options;
var angleLineOpts = opts.angleLines;
var pointLabelOpts = opts.pointLabels;
ctx.lineWidth = angleLineOpts.lineWidth;
ctx.strokeStyle = angleLineOpts.color;
var outerDistance = scale.getDistanceFromCenterForValue(opts.ticks.... | Helper function to fit a radial linear scale with no point labels | drawPointLabels | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function drawRadiusLine(scale, gridLineOpts, radius, index) {
var ctx = scale.ctx;
ctx.strokeStyle = helpers.valueAtIndexOrDefault(gridLineOpts.color, index - 1);
ctx.lineWidth = helpers.valueAtIndexOrDefault(gridLineOpts.lineWidth, index - 1);
if (scale.options.gridLines.circular) {
// Draw circular arcs b... | Helper function to fit a radial linear scale with no point labels | drawRadiusLine | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function numberOrZero(param) {
return helpers.isNumber(param) ? param : 0;
} | Helper function to fit a radial linear scale with no point labels | numberOrZero | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function sorter(a, b) {
return a - b;
} | Set radius reductions and determine new radius and center point
@private | sorter | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function arrayUnique(items) {
var hash = {};
var out = [];
var i, ilen, item;
for (i = 0, ilen = items.length; i < ilen; ++i) {
item = items[i];
if (!hash[item]) {
hash[item] = true;
out.push(item);
}
}
return out;
} | Set radius reductions and determine new radius and center point
@private | arrayUnique | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function interpolate(table, skey, sval, tkey) {
var range = lookup(table, skey, sval);
// Note: the lookup table ALWAYS contains at least 2 items (min and max)
var prev = !range.lo ? table[0] : !range.hi ? table[table.length - 2] : range.lo;
var next = !range.lo ? table[1] : !range.hi ? table[table.length - 1] : r... | Linearly interpolates the given source `value` using the table items `skey` values and
returns the associated `tkey` value. For example, interpolate(table, 'time', 42, 'pos')
returns the position for a timestamp equal to 42. If value is out of bounds, values at
index [0, 1] or [n - 1, n] are used for the interpolation. | interpolate | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function momentify(value, options) {
var parser = options.parser;
var format = options.parser || options.format;
if (typeof parser === 'function') {
return parser(value);
}
if (typeof value === 'string' && typeof format === 'string') {
return moment(value, format);
}
if (!(value instanceof moment)) {
va... | Convert the given value to a moment object using the given time options.
@see http://momentjs.com/docs/#/parsing/ | momentify | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function parse(input, scale) {
if (helpers.isNullOrUndef(input)) {
return null;
}
var options = scale.options.time;
var value = momentify(scale.getRightValue(input), options);
if (!value.isValid()) {
return null;
}
if (options.round) {
value.startOf(options.round);
}
return value.valueOf();
} | Convert the given value to a moment object using the given time options.
@see http://momentjs.com/docs/#/parsing/ | parse | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function determineStepSize(min, max, unit, capacity) {
var range = max - min;
var interval = INTERVALS[unit];
var milliseconds = interval.size;
var steps = interval.steps;
var i, ilen, factor;
if (!steps) {
return Math.ceil(range / (capacity * milliseconds));
}
for (i = 0, ilen = steps.length; i < ilen; ++i... | Returns the number of unit to skip to be able to display up to `capacity` number of ticks
in `unit` for the given `min` / `max` range and respecting the interval steps constraints. | determineStepSize | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function determineUnitForAutoTicks(minUnit, min, max, capacity) {
var ilen = UNITS.length;
var i, interval, factor;
for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
interval = INTERVALS[UNITS[i]];
factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
if (interval.common && M... | Figures out what unit results in an appropriate number of auto-generated ticks | determineUnitForAutoTicks | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function determineUnitForFormatting(ticks, minUnit, min, max) {
var duration = moment.duration(moment(max).diff(moment(min)));
var ilen = UNITS.length;
var i, unit;
for (i = ilen - 1; i >= UNITS.indexOf(minUnit); i--) {
unit = UNITS[i];
if (INTERVALS[unit].common && duration.as(unit) >= ticks.length) {
retu... | Figures out what unit to format a set of ticks with | determineUnitForFormatting | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function determineMajorUnit(unit) {
for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {
if (INTERVALS[UNITS[i]].common) {
return UNITS[i];
}
}
} | Figures out what unit to format a set of ticks with | determineMajorUnit | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function generate(min, max, capacity, options) {
var timeOpts = options.time;
var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, capacity);
var major = determineMajorUnit(minor);
var stepSize = helpers.valueOrDefault(timeOpts.stepSize, timeOpts.unitStepSize);
var weekday = minor ===... | Generates a maximum of `capacity` timestamps between min and max, rounded to the
`minor` unit, aligned on the `major` unit and using the given scale time `options`.
Important: this method can return ticks outside the min and max range, it's the
responsibility of the calling code to clamp values if needed. | generate | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function computeOffsets(table, ticks, min, max, options) {
var left = 0;
var right = 0;
var upper, lower;
if (options.offset && ticks.length) {
if (!options.time.min) {
upper = ticks.length > 1 ? ticks[1] : max;
lower = ticks[0];
left = (
interpolate(table, 'time', upper, 'pos') -
interpolate(ta... | Returns the right and left offsets from edges in the form of {left, right}.
Offsets are added when the `offset` option is true. | computeOffsets | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function ticksFromTimestamps(values, majorUnit) {
var ticks = [];
var i, ilen, value, major;
for (i = 0, ilen = values.length; i < ilen; ++i) {
value = values[i];
major = majorUnit ? value === +moment(value).startOf(majorUnit) : false;
ticks.push({
value: value,
major: major
});
}
return ticks;
} | Returns the right and left offsets from edges in the form of {left, right}.
Offsets are added when the `offset` option is true. | ticksFromTimestamps | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function determineLabelFormat(data, timeOpts) {
var i, momentDate, hasTime;
var ilen = data.length;
// find the label with the most parts (milliseconds, minutes, etc.)
// format all labels with the same level of detail as the most specific label
for (i = 0; i < ilen; i++) {
momentDate = momentify(data[i], timeO... | Returns the right and left offsets from edges in the form of {left, right}.
Offsets are added when the `offset` option is true. | determineLabelFormat | javascript | syzoj/syzoj | static/cdnjs/Chart.js/2.7.3/Chart.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/Chart.js/2.7.3/Chart.js | MIT |
function markFunction( fn ) {
fn[ expando ] = true;
return fn;
} | Mark a function for special use by Sizzle
@param {Function} fn The function to mark | markFunction | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function assert( fn ) {
var el = document.createElement("fieldset");
try {
return !!fn( el );
} catch (e) {
return false;
} finally {
// Remove from its parent by default
if ( el.parentNode ) {
el.parentNode.removeChild( el );
}
// release memory in IE
el = null;
}
} | Support testing using an element
@param {Function} fn Passed the created element and returns a boolean result | assert | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function addHandle( attrs, handler ) {
var arr = attrs.split("|"),
i = arr.length;
while ( i-- ) {
Expr.attrHandle[ arr[i] ] = handler;
}
} | Adds the same handler for all of the specified attrs
@param {String} attrs Pipe-separated list of attributes
@param {Function} handler The method that will be applied | addHandle | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function siblingCheck( a, b ) {
var cur = b && a,
diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
a.sourceIndex - b.sourceIndex;
// Use IE sourceIndex if available on both nodes
if ( diff ) {
return diff;
}
// Check if b follows a
if ( cur ) {
while ( (cur = cur.nextSibling) ) {
if ( cur === b... | Checks document order of two siblings
@param {Element} a
@param {Element} b
@returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b | siblingCheck | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function createInputPseudo( type ) {
return function( elem ) {
var name = elem.nodeName.toLowerCase();
return name === "input" && elem.type === type;
};
} | Returns a function to use in pseudos for input types
@param {String} type | createInputPseudo | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function createButtonPseudo( type ) {
return function( elem ) {
var name = elem.nodeName.toLowerCase();
return (name === "input" || name === "button") && elem.type === type;
};
} | Returns a function to use in pseudos for buttons
@param {String} type | createButtonPseudo | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function createDisabledPseudo( disabled ) {
// Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
return function( elem ) {
// Only certain elements can match :enabled or :disabled
// https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
// https://html... | Returns a function to use in pseudos for :enabled/:disabled
@param {Boolean} disabled true for :disabled; false for :enabled | createDisabledPseudo | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function createPositionalPseudo( fn ) {
return markFunction(function( argument ) {
argument = +argument;
return markFunction(function( seed, matches ) {
var j,
matchIndexes = fn( [], seed.length, argument ),
i = matchIndexes.length;
// Match elements found at the specified indexes
while ( i-- ) {... | Returns a function to use in pseudos for positionals
@param {Function} fn | createPositionalPseudo | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function testContext( context ) {
return context && typeof context.getElementsByTagName !== "undefined" && context;
} | Checks a node for validity as a Sizzle context
@param {Element|Object=} context
@returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value | testContext | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function toSelector( tokens ) {
var i = 0,
len = tokens.length,
selector = "";
for ( ; i < len; i++ ) {
selector += tokens[i].value;
}
return selector;
} | Utility function for retrieving the text value of an array of DOM nodes
@param {Array|Element} elem | toSelector | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function addCombinator( matcher, combinator, base ) {
var dir = combinator.dir,
skip = combinator.next,
key = skip || dir,
checkNonElements = base && key === "parentNode",
doneName = done++;
return combinator.first ?
// Check against closest ancestor/preceding element
function( elem, context, xml ) {
... | Utility function for retrieving the text value of an array of DOM nodes
@param {Array|Element} elem | addCombinator | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function elementMatcher( matchers ) {
return matchers.length > 1 ?
function( elem, context, xml ) {
var i = matchers.length;
while ( i-- ) {
if ( !matchers[i]( elem, context, xml ) ) {
return false;
}
}
return true;
} :
matchers[0];
} | Utility function for retrieving the text value of an array of DOM nodes
@param {Array|Element} elem | elementMatcher | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function multipleContexts( selector, contexts, results ) {
var i = 0,
len = contexts.length;
for ( ; i < len; i++ ) {
Sizzle( selector, contexts[i], results );
}
return results;
} | Utility function for retrieving the text value of an array of DOM nodes
@param {Array|Element} elem | multipleContexts | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
function condense( unmatched, map, filter, context, xml ) {
var elem,
newUnmatched = [],
i = 0,
len = unmatched.length,
mapped = map != null;
for ( ; i < len; i++ ) {
if ( (elem = unmatched[i]) ) {
if ( !filter || filter( elem, context, xml ) ) {
newUnmatched.push( elem );
if ( mapped ) {
m... | Utility function for retrieving the text value of an array of DOM nodes
@param {Array|Element} elem | condense | javascript | syzoj/syzoj | static/cdnjs/jquery/3.3.1/jquery.js | https://github.com/syzoj/syzoj/blob/master/static/cdnjs/jquery/3.3.1/jquery.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.