]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Enforce consistent tab indentation
authorSimon Brunel <simonbrunel@users.noreply.github.com>
Sat, 3 Sep 2016 08:53:32 +0000 (10:53 +0200)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Sat, 3 Sep 2016 16:42:26 +0000 (18:42 +0200)
indent: [error, tab] (http://eslint.org/docs/rules/indent)

12 files changed:
.eslintrc
src/controllers/controller.bar.js
src/controllers/controller.doughnut.js
src/core/core.controller.js
src/core/core.datasetController.js
src/core/core.element.js
src/core/core.legend.js
src/core/core.scale.js
src/elements/element.arc.js
src/scales/scale.category.js
src/scales/scale.logarithmic.js
src/scales/scale.time.js

index cb5b0d49e3965f72b37db4d2f155fe8c9417bd77..b02b49bfe6c7c4a8aa5a8d6a9b4001ec0dc1b68f 100644 (file)
--- a/.eslintrc
+++ b/.eslintrc
@@ -139,7 +139,7 @@ rules:
   func-style: 0
   id-length: 0
   id-match: 0
-  indent: 0
+  indent: [2, tab]
   jsx-quotes: 0
   key-spacing: 0
   linebreak-style: 0
index 46d44fe16951b1273ae70c12ffd68d1d5e3907b2..1621274d3d5ebec166b45476f233ca243bb8f075 100644 (file)
@@ -142,8 +142,8 @@ module.exports = function(Chart) {
                        var fullBarWidth = categoryWidth / datasetCount;
 
                        if (xScale.ticks.length !== me.chart.data.labels.length) {
-                           var perc = xScale.ticks.length / me.chart.data.labels.length;
-                           fullBarWidth = fullBarWidth * perc;
+                               var perc = xScale.ticks.length / me.chart.data.labels.length;
+                               fullBarWidth = fullBarWidth * perc;
                        }
 
                        var barWidth = fullBarWidth * xScale.options.barPercentage;
@@ -326,7 +326,7 @@ module.exports = function(Chart) {
                                },
                                label: function(tooltipItem, data) {
                                        var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
-                               return datasetLabel + ': ' + tooltipItem.xLabel;
+                                       return datasetLabel + ': ' + tooltipItem.xLabel;
                                }
                        }
                }
index 637caea3769168e28a1df19bbb316f93395cd855..096f3085a41aefa8ac08d100e7279855e8d3914f 100644 (file)
@@ -166,8 +166,8 @@ module.exports = function(Chart) {
                                minSize = Math.min(availableWidth / size.width, availableHeight / size.height);
                                offset = {x: (max.x + min.x) * -0.5, y: (max.y + min.y) * -0.5};
                        }
-            chart.borderWidth = me.getMaxBorderWidth(meta.data);
 
+                       chart.borderWidth = me.getMaxBorderWidth(meta.data);
                        chart.outerRadius = Math.max((minSize - chart.borderWidth) / 2, 0);
                        chart.innerRadius = Math.max(cutoutPercentage ? (chart.outerRadius / 100) * (cutoutPercentage) : 1, 0);
                        chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
@@ -268,23 +268,23 @@ module.exports = function(Chart) {
                                return 0;
                        }
                },
-               
+
                //gets the max border or hover width to properly scale pie charts
-        getMaxBorderWidth: function (elements) {
-            var max = 0,
+               getMaxBorderWidth: function (elements) {
+                       var max = 0,
                                index = this.index,
                                length = elements.length,
                                borderWidth,
                                hoverWidth;
 
-            for (var i = 0; i < length; i++) {
-                       borderWidth = elements[i]._model ? elements[i]._model.borderWidth : 0;
-                hoverWidth = elements[i]._chart ? elements[i]._chart.config.data.datasets[index].hoverBorderWidth : 0;
-                               
-                max = borderWidth > max ? borderWidth : max;
-                max = hoverWidth > max ? hoverWidth : max;
-            }
-            return max;
-        }
+                       for (var i = 0; i < length; i++) {
+                               borderWidth = elements[i]._model ? elements[i]._model.borderWidth : 0;
+                               hoverWidth = elements[i]._chart ? elements[i]._chart.config.data.datasets[index].hoverBorderWidth : 0;
+
+                               max = borderWidth > max ? borderWidth : max;
+                               max = hoverWidth > max ? hoverWidth : max;
+                       }
+                       return max;
+               }
        });
 };
index 6eb74a7c4ea23c312e9a3a5c3dcfe4c1736b594f..2ee3712baf6bf74338712d3e35b2358f9923f17a 100644 (file)
@@ -461,7 +461,7 @@ module.exports = function(Chart) {
                        }, me);
 
                        return elementsArray;
-               },              
+               },
 
                getElementsAtEventForMode: function(e, mode) {
                        var me = this;
@@ -472,8 +472,8 @@ module.exports = function(Chart) {
                                return me.getElementsAtEvent(e);
                        case 'dataset':
                                return me.getDatasetAtEvent(e);
-            case 'x-axis':
-                return me.getElementsAtXAxis(e);
+                       case 'x-axis':
+                               return me.getElementsAtXAxis(e);
                        default:
                                return e;
                        }
@@ -499,14 +499,14 @@ module.exports = function(Chart) {
                        var meta = dataset._meta[me.id];
                        if (!meta) {
                                meta = dataset._meta[me.id] = {
-                               type: null,
-                               data: [],
-                               dataset: null,
-                               controller: null,
-                               hidden: null,                   // See isDatasetVisible() comment
-                               xAxisID: null,
-                               yAxisID: null
-                       };
+                                       type: null,
+                                       data: [],
+                                       dataset: null,
+                                       controller: null,
+                                       hidden: null,                   // See isDatasetVisible() comment
+                                       xAxisID: null,
+                                       yAxisID: null
+                               };
                        }
 
                        return meta;
@@ -591,7 +591,7 @@ module.exports = function(Chart) {
                                break;
                        case 'label':
                        case 'dataset':
-            case 'x-axis':
+                       case 'x-axis':
                                // elements = elements;
                                break;
                        default:
index 4318a9c951d48b9eaf07992c575f9305535ea17d..bc140800d824f3ab1862432c322b01107a838f3a 100644 (file)
@@ -158,8 +158,7 @@ module.exports = function(Chart) {
                        model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : valueOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
                }
 
-    });
-
+       });
 
        Chart.DatasetController.extend = helpers.inherits;
 };
\ No newline at end of file
index 5bab6d49cd0c15c7024ac74d94c19a2a30b4813b..e385074ae9c4a2d1661257a00c89c23941f0f655 100644 (file)
 
 module.exports = function(Chart) {
 
-  var helpers = Chart.helpers;
-
-  Chart.elements = {};
-
-  Chart.Element = function(configuration) {
-    helpers.extend(this, configuration);
-    this.initialize.apply(this, arguments);
-  };
-
-  helpers.extend(Chart.Element.prototype, {
-
-    initialize: function() {
-      this.hidden = false;
-    },
-
-    pivot: function() {
-      var me = this;
-      if (!me._view) {
-        me._view = helpers.clone(me._model);
-      }
-      me._start = helpers.clone(me._view);
-      return me;
-    },
-
-    transition: function(ease) {
-      var me = this;
-      
-      if (!me._view) {
-        me._view = helpers.clone(me._model);
-      }
-
-      // No animation -> No Transition
-      if (ease === 1) {
-        me._view = me._model;
-        me._start = null;
-        return me;
-      }
-
-      if (!me._start) {
-        me.pivot();
-      }
-
-      helpers.each(me._model, function(value, key) {
-
-        if (key[0] === '_') {
-          // Only non-underscored properties
-        }
-
-        // Init if doesn't exist
-        else if (!me._view.hasOwnProperty(key)) {
-          if (typeof value === 'number' && !isNaN(me._view[key])) {
-            me._view[key] = value * ease;
-          } else {
-            me._view[key] = value;
-          }
-        }
-
-        // No unnecessary computations
-        else if (value === me._view[key]) {
-          // It's the same! Woohoo!
-        }
-
-        // Color transitions if possible
-        else if (typeof value === 'string') {
-          try {
-            var color = helpers.color(me._model[key]).mix(helpers.color(me._start[key]), ease);
-            me._view[key] = color.rgbString();
-          } catch (err) {
-            me._view[key] = value;
-          }
-        }
-        // Number transitions
-        else if (typeof value === 'number') {
-          var startVal = me._start[key] !== undefined && isNaN(me._start[key]) === false ? me._start[key] : 0;
-          me._view[key] = ((me._model[key] - startVal) * ease) + startVal;
-        }
-        // Everything else
-        else {
-          me._view[key] = value;
-        }
-      }, me);
-
-      return me;
-    },
-
-    tooltipPosition: function() {
-      return {
-        x: this._model.x,
-        y: this._model.y
-      };
-    },
-
-    hasValue: function() {
-      return helpers.isNumber(this._model.x) && helpers.isNumber(this._model.y);
-    }
-  });
-
-  Chart.Element.extend = helpers.inherits;
+       var helpers = Chart.helpers;
+
+       Chart.elements = {};
+
+       Chart.Element = function(configuration) {
+               helpers.extend(this, configuration);
+               this.initialize.apply(this, arguments);
+       };
+
+       helpers.extend(Chart.Element.prototype, {
+
+               initialize: function() {
+                       this.hidden = false;
+               },
+
+               pivot: function() {
+                       var me = this;
+                       if (!me._view) {
+                               me._view = helpers.clone(me._model);
+                       }
+                       me._start = helpers.clone(me._view);
+                       return me;
+               },
+
+               transition: function(ease) {
+                       var me = this;
+
+                       if (!me._view) {
+                               me._view = helpers.clone(me._model);
+                       }
+
+                       // No animation -> No Transition
+                       if (ease === 1) {
+                               me._view = me._model;
+                               me._start = null;
+                               return me;
+                       }
+
+                       if (!me._start) {
+                               me.pivot();
+                       }
+
+                       helpers.each(me._model, function(value, key) {
+
+                               if (key[0] === '_') {
+                                       // Only non-underscored properties
+                               }
+
+                               // Init if doesn't exist
+                               else if (!me._view.hasOwnProperty(key)) {
+                                       if (typeof value === 'number' && !isNaN(me._view[key])) {
+                                               me._view[key] = value * ease;
+                                       } else {
+                                               me._view[key] = value;
+                                       }
+                               }
+
+                               // No unnecessary computations
+                               else if (value === me._view[key]) {
+                                       // It's the same! Woohoo!
+                               }
+
+                               // Color transitions if possible
+                               else if (typeof value === 'string') {
+                                       try {
+                                               var color = helpers.color(me._model[key]).mix(helpers.color(me._start[key]), ease);
+                                               me._view[key] = color.rgbString();
+                                       } catch (err) {
+                                               me._view[key] = value;
+                                       }
+                               }
+                               // Number transitions
+                               else if (typeof value === 'number') {
+                                       var startVal = me._start[key] !== undefined && isNaN(me._start[key]) === false ? me._start[key] : 0;
+                                       me._view[key] = ((me._model[key] - startVal) * ease) + startVal;
+                               }
+                               // Everything else
+                               else {
+                                       me._view[key] = value;
+                               }
+                       }, me);
+
+                       return me;
+               },
+
+               tooltipPosition: function() {
+                       return {
+                               x: this._model.x,
+                               y: this._model.y
+                       };
+               },
+
+               hasValue: function() {
+                       return helpers.isNumber(this._model.x) && helpers.isNumber(this._model.y);
+               }
+       });
+
+       Chart.Element.extend = helpers.inherits;
 
 };
index ffe42c9047e5b88a1055dddf46fd9e6f63b1eef4..fe5b47f8035859e654d0bdbdf66159473f07573d 100644 (file)
@@ -346,7 +346,7 @@ module.exports = function(Chart) {
                                                // Draw box as legend symbol
                                                if (!isLineWidthZero)
                                                {
-                                                               ctx.strokeRect(x, y, boxWidth, fontSize);
+                                                       ctx.strokeRect(x, y, boxWidth, fontSize);
                                                }
                                                ctx.fillRect(x, y, boxWidth, fontSize);
                                        }
index ca2546b26a3b8d24209b347d90dfb7b510da71aa..8faa49ef50f418277c541f06a5733d5eaadf47bb 100644 (file)
@@ -170,12 +170,12 @@ module.exports = function(Chart) {
                        var me = this;
                        // Convert ticks to strings
                        me.ticks = me.ticks.map(function(numericalTick, index, ticks) {
-                                       if (me.options.ticks.userCallback) {
-                                               return me.options.ticks.userCallback(numericalTick, index, ticks);
-                                       }
-                                       return me.options.ticks.callback(numericalTick, index, ticks);
-                               },
-                               me);
+                               if (me.options.ticks.userCallback) {
+                                       return me.options.ticks.userCallback(numericalTick, index, ticks);
+                               }
+                               return me.options.ticks.callback(numericalTick, index, ticks);
+                       },
+                       me);
                },
                afterTickToLabelConversion: function() {
                        helpers.callCallback(this.options.afterTickToLabelConversion, [this]);
index e91b9c2c899e6a14e6a2dbf0ad355a6e20f61edd..64d9604836520a5f8edaa440c7e1d0f00316b113 100644 (file)
@@ -2,92 +2,92 @@
 
 module.exports = function(Chart) {
 
-  var helpers = Chart.helpers,
-    globalOpts = Chart.defaults.global;
-
-  globalOpts.elements.arc = {
-    backgroundColor: globalOpts.defaultColor,
-    borderColor: "#fff",
-    borderWidth: 2
-  };
-
-  Chart.elements.Arc = Chart.Element.extend({
-    inLabelRange: function(mouseX) {
-      var vm = this._view;
-
-      if (vm) {
-        return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2));
-      } else {
-        return false;
-      }
-    },
-    inRange: function(chartX, chartY) {
-      var vm = this._view;
-
-      if (vm) {
-        var pointRelativePosition = helpers.getAngleFromPoint(vm, {
-            x: chartX,
-            y: chartY
-          }),
-          angle = pointRelativePosition.angle,
-          distance = pointRelativePosition.distance;
-
-        //Sanitise angle range
-        var startAngle = vm.startAngle;
-        var endAngle = vm.endAngle;
-        while (endAngle < startAngle) {
-          endAngle += 2.0 * Math.PI;
-        }
-        while (angle > endAngle) {
-          angle -= 2.0 * Math.PI;
-        }
-        while (angle < startAngle) {
-          angle += 2.0 * Math.PI;
-        }
-
-        //Check if within the range of the open/close angle
-        var betweenAngles = (angle >= startAngle && angle <= endAngle),
-          withinRadius = (distance >= vm.innerRadius && distance <= vm.outerRadius);
-
-        return (betweenAngles && withinRadius);
-      } else {
-        return false;
-      }
-    },
-    tooltipPosition: function() {
-      var vm = this._view;
-
-      var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2),
-        rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius;
-      return {
-        x: vm.x + (Math.cos(centreAngle) * rangeFromCentre),
-        y: vm.y + (Math.sin(centreAngle) * rangeFromCentre)
-      };
-    },
-    draw: function() {
-
-      var ctx = this._chart.ctx,
-        vm = this._view,
-        sA = vm.startAngle,
-        eA = vm.endAngle;
-
-      ctx.beginPath();
-
-      ctx.arc(vm.x, vm.y, vm.outerRadius, sA, eA);
-      ctx.arc(vm.x, vm.y, vm.innerRadius, eA, sA, true);
-
-      ctx.closePath();
-      ctx.strokeStyle = vm.borderColor;
-      ctx.lineWidth = vm.borderWidth;
-
-      ctx.fillStyle = vm.backgroundColor;
-
-      ctx.fill();
-      ctx.lineJoin = 'bevel';
-
-      if (vm.borderWidth) {
-        ctx.stroke();
-      }
-    }
-  });
+       var helpers = Chart.helpers,
+               globalOpts = Chart.defaults.global;
+
+       globalOpts.elements.arc = {
+               backgroundColor: globalOpts.defaultColor,
+               borderColor: "#fff",
+               borderWidth: 2
+       };
+
+       Chart.elements.Arc = Chart.Element.extend({
+               inLabelRange: function(mouseX) {
+                       var vm = this._view;
+
+                       if (vm) {
+                               return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2));
+                       } else {
+                               return false;
+                       }
+               },
+               inRange: function(chartX, chartY) {
+                       var vm = this._view;
+
+                       if (vm) {
+                               var pointRelativePosition = helpers.getAngleFromPoint(vm, {
+                                               x: chartX,
+                                               y: chartY
+                                       }),
+                                       angle = pointRelativePosition.angle,
+                                       distance = pointRelativePosition.distance;
+
+                               //Sanitise angle range
+                               var startAngle = vm.startAngle;
+                               var endAngle = vm.endAngle;
+                               while (endAngle < startAngle) {
+                                       endAngle += 2.0 * Math.PI;
+                               }
+                               while (angle > endAngle) {
+                                       angle -= 2.0 * Math.PI;
+                               }
+                               while (angle < startAngle) {
+                                       angle += 2.0 * Math.PI;
+                               }
+
+                               //Check if within the range of the open/close angle
+                               var betweenAngles = (angle >= startAngle && angle <= endAngle),
+                                       withinRadius = (distance >= vm.innerRadius && distance <= vm.outerRadius);
+
+                               return (betweenAngles && withinRadius);
+                       } else {
+                               return false;
+                       }
+               },
+               tooltipPosition: function() {
+                       var vm = this._view;
+
+                       var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2),
+                               rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius;
+                       return {
+                               x: vm.x + (Math.cos(centreAngle) * rangeFromCentre),
+                               y: vm.y + (Math.sin(centreAngle) * rangeFromCentre)
+                       };
+               },
+               draw: function() {
+
+                       var ctx = this._chart.ctx,
+                               vm = this._view,
+                               sA = vm.startAngle,
+                               eA = vm.endAngle;
+
+                       ctx.beginPath();
+
+                       ctx.arc(vm.x, vm.y, vm.outerRadius, sA, eA);
+                       ctx.arc(vm.x, vm.y, vm.innerRadius, eA, sA, true);
+
+                       ctx.closePath();
+                       ctx.strokeStyle = vm.borderColor;
+                       ctx.lineWidth = vm.borderWidth;
+
+                       ctx.fillStyle = vm.backgroundColor;
+
+                       ctx.fill();
+                       ctx.lineJoin = 'bevel';
+
+                       if (vm.borderWidth) {
+                               ctx.stroke();
+                       }
+               }
+       });
 };
index 7e7d552fc71bb1c5b0b0ba098fb2501b927bbfe9..7767ef58df78b6ace01a712c536a3e638d11a46a 100644 (file)
@@ -70,9 +70,9 @@ module.exports = function(Chart) {
                                var valueWidth = innerWidth / offsetAmt;
                                var widthOffset = (valueWidth * (index - me.minIndex)) + me.paddingLeft;
 
-                       if (me.options.gridLines.offsetGridLines && includeOffset || me.maxIndex === me.minIndex && includeOffset) {
+                               if (me.options.gridLines.offsetGridLines && includeOffset || me.maxIndex === me.minIndex && includeOffset) {
                                        widthOffset += (valueWidth / 2);
-                       }
+                               }
 
                                return me.left + Math.round(widthOffset);
                        } else {
index 86cc516afec6b71f601d964a08e432d8597c3cc3..fe3e44c4f18f253a0ee000975903ed989ef8a5c6 100644 (file)
@@ -243,7 +243,7 @@ module.exports = function(Chart) {
                                        range = helpers.log10(me.end) - helpers.log10(start);
                                        innerDimension = me.height - (paddingTop + paddingBottom);
                                        pixel = (me.bottom - paddingBottom) - (innerDimension / range * (helpers.log10(newVal) - helpers.log10(start)));
-                          }
+                               }
                        }
                        return pixel;
                },
index c7b64cbd3b9c5e33b43d8275d6583d66625eb9f4..50d3c3bec417253e93bc07767ded272abe808a92 100755 (executable)
@@ -78,8 +78,8 @@ module.exports = function(Chart) {
                getLabelMoment: function(datasetIndex, index) {
                        if (datasetIndex === null || index === null) {
                                return null;
-            }
-            
+                       }
+
                        if (typeof this.labelMoments[datasetIndex] !== 'undefined') {
                                return this.labelMoments[datasetIndex][index];
                        }