File chart.js
has 10124 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* Chart.js
* http://chartjs.org/
* Version: 2.7.2
*
Function 35
has 702 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"45":45}],35:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function 32
has 668 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"45":45}],32:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function exports
has 620 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
/**
* Helper method to merge the opacity into a color
*/
Function 23
has 604 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"45":45}],23:[function(require,module,exports){
'use strict';
var defaults = require(25);
var helpers = require(45);
Function exports
has 598 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
function computeTextSize(context, tick, font) {
return helpers.isArray(tick) ?
helpers.longestText(context, font, tick) :
Function exports
has 596 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
// Create a dictionary of chart types, to allow for extension of existing types
Chart.types = {};
Function 4
has 580 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"2":2,"5":5}],4:[function(require,module,exports){
/* MIT license */
module.exports = {
rgb2hsl: rgb2hsl,
Function 58
has 545 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"34":34,"45":45}],58:[function(require,module,exports){
/* global window: false */
'use strict';
var moment = require(1);
Function 27
has 489 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"3":3,"45":45}],27:[function(require,module,exports){
/* global window: false */
/* global document: false */
'use strict';
Function exports
has 484 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
// -- Basic js utility methods
helpers.configMerge = function(/* objects ... */) {
Function 3
has 400 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"6":6}],3:[function(require,module,exports){
/* MIT license */
var convert = require(5);
var string = require(2);
Function 51
has 399 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"40":40,"45":45}],51:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function 57
has 381 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"34":34,"45":45}],57:[function(require,module,exports){
'use strict';
var defaults = require(25);
var helpers = require(45);
Function exports
has 376 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
var globalDefaults = defaults.global;
var defaultConfig = {
Function 15
has 347 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],15:[function(require,module,exports){
'use strict';
var defaults = require(25);
var elements = require(40);
Function 47
has 294 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],47:[function(require,module,exports){
/**
* Chart.Platform implementation for targeting a web browser
*/
Function 56
has 282 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"45":45}],56:[function(require,module,exports){
'use strict';
var helpers = require(45);
var Ticks = require(34);
Function 18
has 262 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"40":40,"45":45}],18:[function(require,module,exports){
'use strict';
var defaults = require(25);
var elements = require(40);
Function 50
has 247 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"50":50,"51":51,"52":52}],50:[function(require,module,exports){
/**
* 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
Function exports
has 247 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
var defaultConfig = {
position: 'left',
Function exports
has 247 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
var defaultConfig = {
position: 'bottom',
Function 30
has 246 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25}],30:[function(require,module,exports){
'use strict';
var helpers = require(45);
Function exports
has 240 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
function lineEnabled(dataset, options) {
return helpers.valueOrDefault(dataset.showLine, options.showLines);
}
Function 17
has 232 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"40":40,"45":45}],17:[function(require,module,exports){
'use strict';
var defaults = require(25);
var elements = require(40);
Function 24
has 224 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"28":28,"30":30,"31":31,"45":45,"48":48}],24:[function(require,module,exports){
'use strict';
var helpers = require(45);
Function exports
has 222 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
Chart.controllers.bar = Chart.DatasetController.extend({
dataElementType: elements.Rectangle,
Function exports
has 221 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];
/**
Function draw
has 211 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function(chartArea) {
var me = this;
var options = me.options;
if (!options.display) {
return;
Function 43
has 202 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],43:[function(require,module,exports){
'use strict';
var helpers = require(42);
Function update
has 192 lines of code (exceeds 25 allowed). Consider refactoring. Open
update: function(chart, width, height) {
if (!chart) {
return;
}
Function 2
has 191 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],2:[function(require,module,exports){
/* MIT license */
var colorNames = require(6);
module.exports = {
Function 52
has 180 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"30":30,"45":45}],52:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function 19
has 177 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"40":40,"45":45}],19:[function(require,module,exports){
'use strict';
var defaults = require(25);
var elements = require(40);
Function 28
has 168 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"3":3,"45":45}],28:[function(require,module,exports){
'use strict';
var helpers = require(45);
Function 39
has 165 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"45":45}],39:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function 41
has 162 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"36":36,"37":37,"38":38,"39":39}],41:[function(require,module,exports){
'use strict';
var helpers = require(42);
Function 42
has 159 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"42":42}],42:[function(require,module,exports){
'use strict';
/**
* @namespace Chart.helpers
Function 54
has 153 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],54:[function(require,module,exports){
'use strict';
var defaults = require(25);
var helpers = require(45);
Function 6
has 150 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"4":4}],6:[function(require,module,exports){
'use strict'
module.exports = {
"aliceblue": [240, 248, 255],
Function exports
has 148 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
var defaultConfig = {
position: 'left',
ticks: {
Function exports
has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
Chart.controllers.doughnut = Chart.controllers.pie = Chart.DatasetController.extend({
dataElementType: elements.Arc,
Function 16
has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"40":40,"45":45}],16:[function(require,module,exports){
'use strict';
var defaults = require(25);
var elements = require(40);
Function 55
has 130 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"34":34,"45":45}],55:[function(require,module,exports){
'use strict';
var helpers = require(45);
Function 20
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"40":40,"45":45}],20:[function(require,module,exports){
'use strict';
var defaults = require(25);
var elements = require(40);
Function 22
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25}],22:[function(require,module,exports){
/* global window: false */
'use strict';
var defaults = require(25);
Function exports
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
Chart.controllers.radar = Chart.DatasetController.extend({
datasetElementType: elements.Line,
Function draw
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function() {
var me = this;
var opts = me.options;
var labelOpts = opts.labels;
var globalDefault = defaults.global;
Function exports
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
Chart.controllers.bubble = Chart.DatasetController.extend({
/**
* @protected
Function drawPoint
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawPoint: function(ctx, style, radius, x, y) {
var type, edgeLength, xOffset, yOffset, height, size;
if (style && typeof style === 'object') {
type = style.toString();
Function exports
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
Chart.Animation = Element.extend({
chart: null, // the animation associated chart instance
currentStep: 0, // the current animation step
Function 53
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"30":30,"45":45}],53:[function(require,module,exports){
'use strict';
module.exports = function(Chart) {
Function determineDataLimits
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
determineDataLimits: function() {
var me = this;
var opts = me.options;
var chart = me.chart;
var data = chart.data;
Function exports
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
// Default config for a category scale
var defaultConfig = {
position: 'bottom'
Function exports
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
var noop = helpers.noop;
Chart.LinearScaleBase = Chart.Scale.extend({
Function 31
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"45":45}],31:[function(require,module,exports){
'use strict';
var defaults = require(25);
var helpers = require(45);
Function 38
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"45":45}],38:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function 26
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"45":45}],26:[function(require,module,exports){
'use strict';
var color = require(3);
var helpers = require(45);
Function 36
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"45":45}],36:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function determineDataLimits
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
determineDataLimits: function() {
var me = this;
var opts = me.options;
var chart = me.chart;
var data = chart.data;
Function exports
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
Chart.controllers.polarArea = Chart.DatasetController.extend({
dataElementType: elements.Arc,
Function update
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
update: function(changed) {
var me = this;
var opts = me._options;
// Need to regenerate the model because its faster than using extend and it is necessary due to the optimization in Chart.Element.transition
Function fit
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
fit: function() {
var me = this;
var opts = me.options;
var labelOpts = opts.labels;
var display = opts.display;
Consider simplifying this complex logical expression. Open
if (circumference < Math.PI * 2.0) {
var startAngle = opts.rotation % (Math.PI * 2.0);
startAngle += Math.PI * 2.0 * (startAngle >= Math.PI ? -1 : startAngle < -Math.PI ? 1 : 0);
var endAngle = startAngle + circumference;
var start = {x: Math.cos(startAngle), y: Math.sin(startAngle)};
Function fit
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
fit: function() {
var me = this;
// Reset
var minSize = me.minSize = {
width: 0,
Function splineCurveMonotone
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
helpers.splineCurveMonotone = function(points) {
// This function calculates Bézier control points in a similar way than |splineCurve|,
// but preserves monotonicity of the provided data and ensures no local extremums are added
// between the dataset discrete points due to the interpolation.
// See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
Function 37
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"45":45}],37:[function(require,module,exports){
'use strict';
var defaults = require(25);
var Element = require(26);
Function draw
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function() {
var ctx = this._chart.ctx;
var vm = this._view;
var left, right, top, bottom, signX, signY, borderSkipped;
var borderWidth = vm.borderWidth;
Function buildOrUpdateScales
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildOrUpdateScales: function() {
var me = this;
var options = me.options;
var scales = me.scales || {};
var items = [];
Function 5
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],5:[function(require,module,exports){
var conversions = require(4);
var convert = function() {
return new Converter();
Function determineAlignment
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
function determineAlignment(tooltip, size) {
var model = tooltip._model;
var chart = tooltip._chart;
var chartArea = tooltip._chart.chartArea;
var xAlign = 'center';
Function 44
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"42":42}],44:[function(require,module,exports){
'use strict';
var helpers = require(42);
Function getRgba
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getRgba(string) {
if (!string) {
return;
}
var abbr = /^#([a-fA-F0-9]{3})$/i,
Function 7
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{}],7:[function(require,module,exports){
/**
* @namespace Chart
*/
var Chart = require(29)();
Function determineDataLimits
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
determineDataLimits: function() {
var me = this;
var chart = me.chart;
var timeOpts = me.options.time;
var unit = timeOpts.unit || 'day';
Function getCaretPosition
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
getCaretPosition: function(tooltipPoint, size, vm) {
var x1, x2, x3, y1, y2, y3;
var caretSize = vm.caretSize;
var cornerRadius = vm.cornerRadius;
var xAlign = vm.xAlign;
Function createResizer
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createResizer(handler) {
var resizer = document.createElement('div');
var cls = CSS_PREFIX + 'size-monitor';
var maxSize = 1000000;
var style =
Function handleTickRangeOptions
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleTickRangeOptions: function() {
var me = this;
var opts = me.options;
var tickOpts = opts.ticks;
Function draw
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function() {
var me = this;
var ctx = me.ctx;
var valueOrDefault = helpers.valueOrDefault;
var opts = me.options;
Function draw
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function() {
var me = this;
var opts = me.options;
var gridLineOpts = opts.gridLines;
var tickOpts = opts.ticks;
Function update
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
update: function(maxWidth, maxHeight, margins) {
var me = this;
var i, ilen, labels, label, ticks, tick;
// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
Function draw
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function() {
var me = this;
var vm = me._view;
var ctx = me._chart.ctx;
var spanGaps = vm.spanGaps;
Function getTooltipSize
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getTooltipSize(tooltip, model) {
var ctx = tooltip._chart.ctx;
var height = model.yPadding * 2; // Tooltip Padding
var width = 0;
Function update
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
update: function(reset) {
var me = this;
var meta = me.getMeta();
var line = meta.dataset;
var points = meta.data || [];
Function getBackgroundPoint
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getBackgroundPoint(vm, size, alignment, chart) {
// Background Position
var x = vm.x;
var y = vm.y;
Function _resolveElementOptions
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
_resolveElementOptions: function(point, index) {
var me = this;
var chart = me.chart;
var datasets = chart.data.datasets;
var dataset = datasets[me.index];
Consider simplifying this complex logical expression. Open
if (showLine) {
custom = line.custom || {};
// Compatibility: If the properties are defined with only the old name, use those values
if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
Function update
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
update: function(reset) {
var me = this;
var chart = me.chart;
var chartArea = chart.chartArea;
var opts = chart.options;
Function updateBezierControlPoints
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateBezierControlPoints: function() {
var me = this;
var meta = me.getMeta();
var area = me.chart.chartArea;
var points = (meta.data || []);
Function fitWithPointLabels
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
*
Function buildTicks
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildTicks: function() {
var me = this;
var min = me.min;
var max = me.max;
var options = me.options;
Function updateElement
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateElement: function(arc, index, reset) {
var me = this;
var chart = me.chart;
var chartArea = chart.chartArea;
var opts = chart.options;
Function Color
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Color = function (obj) {
if (obj instanceof Color) {
return obj;
}
if (!(this instanceof Color)) {
Function getPixelForValue
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPixelForValue: function(value) {
var me = this;
var reverse = me.options.ticks.reverse;
var log10 = helpers.log10;
var firstTickValue = me._getFirstTickValue(me.minNotZero);
Function setValues
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Color.prototype.setValues = function (space, vals) {
var values = this.values;
var spaces = this.spaces;
var maxes = this.maxes;
var alpha = 1;
Function updateElement
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateElement: function(arc, index, reset) {
var me = this;
var chart = me.chart;
var dataset = me.getDataset();
var opts = chart.options;
Function doFill
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function doFill(ctx, points, mapper, view, color, loop) {
var count = points.length;
var span = view.spanGaps;
var curve0 = [];
var curve1 = [];
Function drawBody
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawBody: function(pt, vm, ctx, opacity) {
var bodyFontSize = vm.bodyFontSize;
var bodySpacing = vm.bodySpacing;
var body = vm.body;
Function drawBackground
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawBackground: function(pt, vm, ctx, tooltipSize, opacity) {
ctx.fillStyle = mergeOpacity(vm.backgroundColor, opacity);
ctx.strokeStyle = mergeOpacity(vm.borderColor, opacity);
ctx.lineWidth = vm.borderWidth;
var xAlign = vm.xAlign;
Function 29
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"45":45}],29:[function(require,module,exports){
'use strict';
var defaults = require(25);
Function getBaseModel
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getBaseModel(tooltipOpts) {
var globalDefaults = defaults.global;
var valueOrDefault = helpers.valueOrDefault;
return {
Function decodeFill
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function decodeFill(el, index, count) {
var model = el._model || {};
var fill = model.fill;
var target;
Function update
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
update: function(config) {
var me = this;
if (!config || typeof config !== 'object') {
// backwards compatibility
Function render
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
render: function(config) {
var me = this;
if (!config || typeof config !== 'object') {
// backwards compatibility
Function 34
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"30":30,"45":45}],34:[function(require,module,exports){
'use strict';
var helpers = require(45);
Function handleEvent
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleEvent: function(e) {
var me = this;
var opts = me.options;
var type = e.type === 'mouseup' ? 'click' : e.type;
var changed = false;
Function updateElement
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateElement: function(point, index, reset) {
var me = this;
var meta = me.getMeta();
var custom = point.custom || {};
var dataset = me.getDataset();
Function interpolate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function interpolate(start, view, model, ease) {
var keys = Object.keys(model);
var i, ilen, key, actual, origin, target, type, c0, c1;
for (i = 0, ilen = keys.length; i < ilen; ++i) {
Function handleTickRangeOptions
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleTickRangeOptions: function() {
var me = this;
var opts = me.options;
var tickOpts = opts.ticks;
var valueOrDefault = helpers.valueOrDefault;
Function generateTicks
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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.
Function getValueForPixel
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
getValueForPixel: function(pixel) {
var me = this;
var reverse = me.options.ticks.reverse;
var log10 = helpers.log10;
var firstTickValue = me._getFirstTickValue(me.minNotZero);
Consider simplifying this complex logical expression. Open
if (meta.bar && chart.isDatasetVisible(i) &&
(stacked === false ||
(stacked === true && stacks.indexOf(meta.stack) === -1) ||
(stacked === undefined && (meta.stack === undefined || stacks.indexOf(meta.stack) === -1)))) {
stacks.push(meta.stack);
Function 33
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"26":26,"34":34,"45":45}],33:[function(require,module,exports){
'use strict';
var defaults = require(25);
var helpers = require(45);
Function generate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Function update
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
update: function(reset) {
var me = this;
var meta = me.getMeta();
var line = meta.dataset;
var points = meta.data;
Function calculateBarValuePixels
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateBarValuePixels: function(datasetIndex, index) {
var me = this;
var chart = me.chart;
var meta = me.getMeta();
var scale = me.getValueScale();
Function 21
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"25":25,"40":40,"45":45}],21:[function(require,module,exports){
'use strict';
var defaults = require(25);
Function construct
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
construct: function(item, config) {
var me = this;
config = initConfig(config);
Function initCanvas
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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.
Function computeBoundary
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function computeBoundary(source) {
var model = source.el._model || {};
var scale = source.el._scale || {};
var fill = source.fill;
var target = null;
Function _autoSkip
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_autoSkip: function(ticks) {
var skipRatio;
var me = this;
var isHorizontal = me.isHorizontal();
var optionTicks = me.options.ticks.minor;
Function draw
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
draw: function(chartArea) {
var vm = this._view;
var model = this._model;
var ctx = this._chart.ctx;
var pointStyle = vm.pointStyle;
Function descriptors
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
descriptors: function(chart) {
var cache = chart.$plugins || (chart.$plugins = {});
if (cache.id === this._cacheId) {
return cache.descriptors;
}
Function drawPointLabels
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function drawPointLabels(scale) {
var ctx = scale.ctx;
var opts = scale.options;
var angleLineOpts = opts.angleLines;
var pointLabelOpts = opts.pointLabels;
Function hsl2rgb
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function hsl2rgb(hsl) {
var h = hsl[0] / 360,
s = hsl[1] / 100,
l = hsl[2] / 100,
t1, t2, t3, rgb, val;
Function longestText
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
helpers.longestText = function(ctx, font, arrayOfThings, cache) {
cache = cache || {};
var data = cache.data = cache.data || {};
var gc = cache.garbageCollect = cache.garbageCollect || [];
Function updateElement
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateElement: function(point, index, reset) {
var me = this;
var custom = point.custom || {};
var dataset = me.getDataset();
var scale = me.chart.scale;
Function listenArrayEvents
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function listenArrayEvents(array, listener) {
if (array._chartjs) {
array._chartjs.listeners.push(listener);
return;
}
Function generateTicks
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function afterDatasetsUpdate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
afterDatasetsUpdate: function(chart, options) {
var count = (chart.data.datasets || []).length;
var propagate = options.propagate;
var sources = [];
var meta, i, el, source;
Function exports
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(Chart) {
Chart.scaleService = {
// Scale registration object. Extensions can register new scale types (such as log or DB scales) and then
// use the new chart options to grab the correct scale
Function hwb2rgb
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function hwb2rgb(hwb) {
var h = hwb[0] / 360,
wh = hwb[1] / 100,
bl = hwb[2] / 100,
ratio = wh + bl,
Function getPixelForValue
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPixelForValue: function(value, index) {
var me = this;
var offset = me.options.offset;
// 1 is added because we need the length but we have the indexes
var offsetAmt = Math.max((me.maxIndex + 1 - me.minIndex - (offset ? 0 : 1)), 1);
Function drawLegendBox
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
var drawLegendBox = function(x, y, legendItem) {
if (isNaN(boxWidth) || boxWidth <= 0) {
return;
}
Function updateElement
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateElement: function(point, index, reset) {
var me = this;
var meta = me.getMeta();
var custom = point.custom || {};
var xScale = me.getScaleForId(meta.xAxisID);
Function calculatePointY
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculatePointY: function(value, index, datasetIndex) {
var me = this;
var chart = me.chart;
var meta = me.getMeta();
var yScale = me.getScaleForId(meta.yAxisID);
Function rgb2hsl
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function rgb2hsl(rgb) {
var r = rgb[0]/255,
g = rgb[1]/255,
b = rgb[2]/255,
min = Math.min(r, g, b),
Consider simplifying this complex logical expression. Open
if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
var animation = new Chart.Animation({
numSteps: (duration || animationOptions.duration) / 16.66, // 60 fps
easing: config.easing || animationOptions.easing,
Avoid deeply nested control flow statements. Open
for (var i = 0; i < rgb.length; i++) {
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
}
Function roundedRect
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
roundedRect: function(ctx, x, y, width, height, radius) {
Function doFill
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function doFill(ctx, points, mapper, view, color, loop) {
Avoid deeply nested control flow statements. Open
else if (match = string.match(keyword)) {
if (match[1] == "transparent") {
return [0, 0, 0, 0];
}
rgb = colorNames[match[1]];
Avoid deeply nested control flow statements. Open
if (c1.valid) {
view[key] = c1.mix(c0, ease).rgbString();
continue;
}
Consider simplifying this complex logical expression. Open
if (helpers.isObject(value)) {
t = +value.top || 0;
r = +value.right || 0;
b = +value.bottom || 0;
l = +value.left || 0;
Function drawBackground
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
drawBackground: function(pt, vm, ctx, tooltipSize, opacity) {
Function drawPoint
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
drawPoint: function(ctx, style, radius, x, y) {
Function computeOffsets
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function computeOffsets(table, ticks, min, max, options) {
Function measureText
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
helpers.measureText = function(ctx, data, gc, longest, string) {
Function drawArea
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function drawArea(ctx, curve0, curve1, len0, len1) {
Function determineLimits
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function determineLimits(angle, pos, size, min, max) {
Function createEvent
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function createEvent(type, chart, x, y, nativeEvent) {
Avoid too many return
statements within this function. Open
return value;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return rawValue;
Similar blocks of code found in 4 locations. Consider refactoring. Open
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Chart = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
},{}],2:[function(require,module,exports){
/* MIT license */
var colorNames = require(6);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 115324.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76