]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix #2734 Cleanup unused variables
authorSimon Brunel <simonbrunel@users.noreply.github.com>
Sat, 18 Jun 2016 09:00:11 +0000 (11:00 +0200)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Sat, 18 Jun 2016 09:00:11 +0000 (11:00 +0200)
23 files changed:
config.jshintrc
src/charts/Chart.Scatter.js
src/controllers/controller.bar.js
src/controllers/controller.bubble.js
src/controllers/controller.doughnut.js
src/controllers/controller.line.js
src/controllers/controller.polarArea.js
src/controllers/controller.radar.js
src/core/core.controller.js
src/core/core.datasetController.js
src/core/core.layoutService.js
src/core/core.legend.js
src/core/core.scale.js
src/core/core.title.js
src/core/core.tooltip.js
src/elements/element.arc.js
src/elements/element.rectangle.js
src/scales/scale.category.js
src/scales/scale.linear.js
src/scales/scale.linearbase.js
src/scales/scale.logarithmic.js
src/scales/scale.radialLinear.js
src/scales/scale.time.js

index 978cc985ae0b5d05e122df75a75c8a386b50bf6d..00b42024f097f69e037db5faf6eaf6a91a961e09 100644 (file)
@@ -1,4 +1,5 @@
 {
        "node": true,
+       "unused": true,
        "predef": [ "require", "module" ]
 }
\ No newline at end of file
index 7b504535733cab0963a6789cd2618c69bf879fe4..7ab5c5717c749efe00055bf786de2dc7c5cf154c 100644 (file)
@@ -22,11 +22,11 @@ module.exports = function(Chart) {
 
                tooltips: {
                        callbacks: {
-                               title: function(tooltipItems, data) {
+                               title: function() {
                                        // Title doesn't make sense for scatter since we format the data as a point
                                        return '';
                                },
-                               label: function(tooltipItem, data) {
+                               label: function(tooltipItem) {
                                        return '(' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ')';
                                }
                        }
index 28962db987620b6e9b1ef038013a06089cf4a1be..509ff1b2a2a3db1b05cfcbc48748854e5c5ce829 100644 (file)
@@ -338,7 +338,7 @@ module.exports = function(Chart) {
        };
 
        Chart.controllers.horizontalBar = Chart.controllers.bar.extend({
-               updateElement: function updateElement(rectangle, index, reset, numBars) {
+               updateElement: function updateElement(rectangle, index, reset) {
                        var me = this;
                        var meta = me.getMeta();
                        var xScale = me.getScaleForId(meta.xAxisID);
index 8dd9cf86e16435f001a8f68ee23f222f7a2d82e9..ee717a3dc9b37277eea4c89ee9816a9da5b64eba 100644 (file)
@@ -24,7 +24,7 @@ module.exports = function(Chart) {
 
                tooltips: {
                        callbacks: {
-                               title: function(tooltipItems, data) {
+                               title: function() {
                                        // Title doesn't make sense for scatter since we format the data as a point
                                        return '';
                                },
index ddc1b9af4e759237d5886921dbbcefa271dbab2e..c039532b4a133a9080ef3d3e13c804bda0a55177 100644 (file)
@@ -189,7 +189,6 @@ module.exports = function(Chart) {
                                chartArea = chart.chartArea,
                                opts = chart.options,
                                animationOpts = opts.animation,
-                               arcOpts = opts.elements.arc,
                                centerX = (chartArea.left + chartArea.right) / 2,
                                centerY = (chartArea.top + chartArea.bottom) / 2,
                                startAngle = opts.rotation, // non reset case handled later
@@ -198,7 +197,6 @@ module.exports = function(Chart) {
                                circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumference / (2.0 * Math.PI)),
                                innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius,
                                outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius,
-                               custom = arc.custom || {},
                                valueAtIndexOrDefault = helpers.getValueAtIndexOrDefault;
 
                        helpers.extend(arc, {
index a0138eed2c52fc656c9fe3a2b2a142afe6354edc..b5c31e161207025faee1f86c45e0fb0ef5109748 100644 (file)
@@ -181,7 +181,7 @@ module.exports = function(Chart) {
                        }
 
                        x = xScale.getPixelForValue(value, index, datasetIndex, me.chart.isCombo);
-                       y = reset ? yScale.getBasePixel() : me.calculatePointY(value, index, datasetIndex, me.chart.isCombo);
+                       y = reset ? yScale.getBasePixel() : me.calculatePointY(value, index, datasetIndex);
 
                        // Utility
                        point._xScale = xScale;
@@ -206,7 +206,7 @@ module.exports = function(Chart) {
                        };
                },
 
-               calculatePointY: function(value, index, datasetIndex, isCombo) {
+               calculatePointY: function(value, index, datasetIndex) {
                        var me = this;
                        var chart = me.chart;
                        var meta = me.getMeta();
@@ -240,7 +240,6 @@ module.exports = function(Chart) {
 
                updateBezierControlPoints: function() {
                        var meta = this.getMeta();
-                       var area = this.chart.chartArea;
                        var points = meta.data || [];
                        var i, ilen, point, model, controlPoints;
 
index ebf88b5eae1950570e0ad7ca5501950bdab437ea..23d0f4e19abfd3f57e286ea69d651919b6df7335 100644 (file)
@@ -134,8 +134,6 @@ module.exports = function(Chart) {
                        var dataset = me.getDataset();
                        var opts = chart.options;
                        var animationOpts = opts.animation;
-                       var arcOpts = opts.elements.arc;
-                       var custom = arc.custom || {};
                        var scale = chart.scale;
                        var getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault;
                        var labels = chart.data.labels;
index 102c3744aa3f16b6a9c998471395b98fc07ed522..4634add4367d6bacd0f209cecd23c5ef2bd1738c 100644 (file)
@@ -146,7 +146,7 @@ module.exports = function(Chart) {
                        var easingDecimal = ease || 1;
 
                        // Transition Point Locations
-                       helpers.each(meta.data, function(point, index) {
+                       helpers.each(meta.data, function(point) {
                                point.transition(easingDecimal);
                        });
 
index 2d0148b7749ce9b5b0b4c517b481b1f3a06175e6..9b6693900e3d546a3da9d2b06cb3a1f3ad879246 100644 (file)
@@ -154,7 +154,7 @@ module.exports = function(Chart) {
                                items.push({ options: options.scale, dtype: 'radialLinear', isDefault: true });
                        }
 
-                       helpers.each(items, function(item, index) {
+                       helpers.each(items, function(item) {
                                var scaleOptions = item.options;
                                var scaleType = helpers.getValueOrDefault(scaleOptions.type, item.dtype);
                                var scaleClass = Chart.scaleService.getScaleConstructor(scaleType);
@@ -375,7 +375,7 @@ module.exports = function(Chart) {
                        helpers.each(me.data.datasets, function(dataset, datasetIndex) {
                                if (me.isDatasetVisible(datasetIndex)) {
                                        var meta = me.getDatasetMeta(datasetIndex);
-                                       helpers.each(meta.data, function(element, index) {
+                                       helpers.each(meta.data, function(element) {
                                                if (element.inRange(eventPosition.x, eventPosition.y)) {
                                                        elementsArray.push(element);
                                                        return elementsArray;
index 07f787eaf2a57b58330b5b48b1cc0f0357385d04..7ef414f7ddf335de060a7d9b1b84d98fcd20c13a 100644 (file)
@@ -128,7 +128,7 @@ module.exports = function(Chart) {
 
                draw: function(ease) {
                        var easingDecimal = ease || 1;
-                       helpers.each(this.getMeta().data, function(element, index) {
+                       helpers.each(this.getMeta().data, function(element) {
                                element.transition(easingDecimal).draw();
                        });
                },
@@ -138,7 +138,6 @@ module.exports = function(Chart) {
                                index = element._index,
                                custom = element.custom || {},
                                valueOrDefault = helpers.getValueAtIndexOrDefault,
-                               color = helpers.color,
                                model = element._model;
 
                        model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueOrDefault(dataset.backgroundColor, index, elementOpts.backgroundColor);
@@ -151,7 +150,6 @@ module.exports = function(Chart) {
                                index = element._index,
                                custom = element.custom || {},
                                valueOrDefault = helpers.getValueAtIndexOrDefault,
-                               color = helpers.color,
                                getHoverColor = helpers.getHoverColor,
                                model = element._model;
 
index 700ecfd5315f2a11445f66da20d3c818f5ed94c6..6e649b13a7d8fa758d7958b3bdf3ebc4112308e2 100644 (file)
@@ -267,8 +267,6 @@ module.exports = function(Chart) {
                        // Step 7 - Position the boxes
                        var left = xPadding;
                        var top = yPadding;
-                       var right = 0;
-                       var bottom = 0;
 
                        helpers.each(leftBoxes.concat(topBoxes), placeBox);
 
index 78c89c55925262657d54aa3f39fc825512b81d8a..4747bbad5efad3476b4ce71fc6c0e048756b98ec 100644 (file)
@@ -274,11 +274,10 @@ module.exports = function(Chart) {
                        var me = this;
                        var opts = me.options;
                        var labelOpts = opts.labels;
-                       var globalDefault = Chart.defaults.global,
-                               lineDefault = globalDefault.elements.line,
-                               legendWidth = me.width,
-                               legendHeight = me.height,
-                               lineWidths = me.lineWidths;
+                       var globalDefault = Chart.defaults.global;
+                       var lineDefault = globalDefault.elements.line;
+                       var legendWidth = me.width;
+                       var lineWidths = me.lineWidths;
 
                        if (opts.display) {
                                var ctx = me.ctx,
@@ -373,7 +372,6 @@ module.exports = function(Chart) {
                                                        cursor.line++;
                                                }
                                        }
-                                       
 
                                        drawLegendBox(x, y, legendItem);
 
@@ -388,7 +386,7 @@ module.exports = function(Chart) {
                                        } else {
                                                cursor.y += itemHeight;
                                        }
-                                       
+
                                });
                        }
                },
index 93f07491352a1d2dfeff852161e41e26304f0be4..698d2fb5bc4f4056e6398b6dca894f548498f875 100644 (file)
@@ -284,9 +284,6 @@ module.exports = function(Chart) {
                        var tickLabelFont = helpers.fontString(tickFontSize, tickFontStyle, tickFontFamily);
 
                        var scaleLabelFontSize = helpers.getValueOrDefault(scaleLabelOpts.fontSize, globalDefaults.defaultFontSize);
-                       var scaleLabelFontStyle = helpers.getValueOrDefault(scaleLabelOpts.fontStyle, globalDefaults.defaultFontStyle);
-                       var scaleLabelFontFamily = helpers.getValueOrDefault(scaleLabelOpts.fontFamily, globalDefaults.defaultFontFamily);
-                       var scaleLabelFont = helpers.fontString(scaleLabelFontSize, scaleLabelFontStyle, scaleLabelFontFamily);
 
                        var tickMarkLength = opts.gridLines.tickMarkLength;
 
@@ -514,9 +511,7 @@ module.exports = function(Chart) {
 
                        var labelRotationRadians = helpers.toRadians(me.labelRotation);
                        var cosRotation = Math.cos(labelRotationRadians);
-                       var sinRotation = Math.sin(labelRotationRadians);
                        var longestRotatedLabel = me.longestLabelWidth * cosRotation;
-                       var rotatedLabelHeight = tickFontSize * sinRotation;
 
                        // Make sure we draw text in the correct color and font
                        context.fillStyle = tickFontColor;
@@ -526,11 +521,11 @@ module.exports = function(Chart) {
                        if (isHorizontal) {
                                skipRatio = false;
 
-                // Only calculate the skip ratio with the half width of longestRotateLabel if we got an actual rotation
-                // See #2584
-                if (isRotated) {
-                    longestRotatedLabel /= 2;
-                }
+                               // Only calculate the skip ratio with the half width of longestRotateLabel if we got an actual rotation
+                               // See #2584
+                               if (isRotated) {
+                                       longestRotatedLabel /= 2;
+                               }
 
                                if ((longestRotatedLabel + optionTicks.autoSkipPadding) * me.ticks.length > (me.width - (me.paddingLeft + me.paddingRight))) {
                                        skipRatio = 1 + Math.floor(((longestRotatedLabel + optionTicks.autoSkipPadding) * me.ticks.length) / (me.width - (me.paddingLeft + me.paddingRight)));
@@ -712,7 +707,7 @@ module.exports = function(Chart) {
                                        scaleLabelY = me.top + ((me.bottom - me.top) / 2);
                                        rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;
                                }
-                               
+
                                context.save();
                                context.translate(scaleLabelX, scaleLabelY);
                                context.rotate(rotation);
index 4e00b82b774a7458b98d87917bc21336ed8429b8..25abad2a743b2e81086047d9b097ea0a2e31970c 100644 (file)
@@ -111,9 +111,7 @@ module.exports = function(Chart) {
 
                beforeFit: noop,
                fit: function() {
-
                        var me = this,
-                               ctx = me.ctx,
                                valueOrDefault = helpers.getValueOrDefault,
                                opts = me.options,
                                globalDefaults = Chart.defaults.global,
index d55dd2be050c3cb86d892765a93b50b1b60b892d..bff3f2962fd0a7dad0856834597207b809008897 100755 (executable)
@@ -498,7 +498,7 @@ module.exports = function(Chart) {
 
                        return pt;
                },
-               drawCaret: function drawCaret(tooltipPoint, size, opacity, caretPadding) {
+               drawCaret: function drawCaret(tooltipPoint, size, opacity) {
                        var vm = this._view;
                        var ctx = this._chart.ctx;
                        var x1, x2, x3;
@@ -692,7 +692,7 @@ module.exports = function(Chart) {
                                ctx.fill();
 
                                // Draw Caret
-                               this.drawCaret(pt, tooltipSize, opacity, vm.caretPadding);
+                               this.drawCaret(pt, tooltipSize, opacity);
 
                                // Draw Title, Body, and Footer
                                pt.x += vm.xPadding;
index 7b6d96a8111f5a55391fdd4ac4937254f82cf29d..e91b9c2c899e6a14e6a2dbf0ad355a6e20f61edd 100644 (file)
@@ -1,6 +1,6 @@
 "use strict";
 
-module.exports = function(Chart, moment) {
+module.exports = function(Chart) {
 
   var helpers = Chart.helpers,
     globalOpts = Chart.defaults.global;
index 944d5e38a25a30aea164dbdd31c75ef83e53fb68..6bedca75539233c3eee915c0bf937b0e01fc4c3b 100644 (file)
@@ -2,8 +2,7 @@
 
 module.exports = function(Chart) {
 
-       var helpers = Chart.helpers,
-               globalOpts = Chart.defaults.global;
+       var globalOpts = Chart.defaults.global;
 
        globalOpts.elements.rectangle = {
                backgroundColor: globalOpts.defaultColor,
@@ -46,7 +45,7 @@ module.exports = function(Chart) {
                                [rightX, vm.base]
                        ];
 
-                       // Find first (starting) corner with fallback to 'bottom' 
+                       // Find first (starting) corner with fallback to 'bottom'
                        var borders = ['bottom', 'left', 'top', 'right'];
                        var startCorner = borders.indexOf(vm.borderSkipped, 0);
                        if (startCorner === -1)
@@ -72,8 +71,8 @@ module.exports = function(Chart) {
                },
                inRange: function(mouseX, mouseY) {
                        var vm = this._view;
-                       return vm ? 
-                                       (vm.y < vm.base ? 
+                       return vm ?
+                                       (vm.y < vm.base ?
                                                (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.y && mouseY <= vm.base) :
                                                (mouseX >= vm.x - vm.width / 2 && mouseX <= vm.x + vm.width / 2) && (mouseY >= vm.base && mouseY <= vm.y)) :
                                        false;
index efbcbcce6f75318197c5f906374f4e28ae22c9e9..fc1d69eb692bbb075d1aa531bb6198a8d07da7f3 100644 (file)
@@ -9,7 +9,7 @@ module.exports = function(Chart) {
        };
 
        var DatasetScale = Chart.Scale.extend({
-               // Implement this so that 
+               // Implement this so that
                determineDataLimits: function() {
                        var me = this;
                        me.minIndex = 0;
@@ -32,13 +32,13 @@ module.exports = function(Chart) {
                        me.max = me.chart.data.labels[me.maxIndex];
                },
 
-               buildTicks: function(index) {
+               buildTicks: function() {
                        var me = this;
                        // If we are viewing some subset of labels, slice the original array
                        me.ticks = (me.minIndex === 0 && me.maxIndex === me.chart.data.labels.length - 1) ? me.chart.data.labels : me.chart.data.labels.slice(me.minIndex, me.maxIndex + 1);
                },
 
-               getLabelForIndex: function(index, datasetIndex) {
+               getLabelForIndex: function(index) {
                        return this.ticks[index];
                },
 
index 31630c284bee3973cc4fc3a81f0b9454ddc66713..2c19f71a7b70f22cf2f4260ad510f0153649bc8d 100644 (file)
@@ -39,7 +39,6 @@ module.exports = function(Chart) {
                determineDataLimits: function() {
                        var me = this;
                        var opts = me.options;
-                       var tickOpts = opts.ticks;
                        var chart = me.chart;
                        var data = chart.data;
                        var datasets = data.datasets;
@@ -148,7 +147,7 @@ module.exports = function(Chart) {
 
                        return maxTicks;
                },
-               // Called after the ticks are built. We need 
+               // Called after the ticks are built. We need
                handleDirectionalChanges: function() {
                        if (!this.isHorizontal()) {
                                // We are in a vertical orientation. The top value is the highest. So reverse the array
@@ -159,9 +158,9 @@ module.exports = function(Chart) {
                        return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
                },
                // Utils
-               getPixelForValue: function(value, index, datasetIndex, includeOffset) {
+               getPixelForValue: function(value) {
                        // This must be called after fit has been run so that
-                       //      this.left, this.top, this.right, and this.bottom have been defined
+                       // this.left, this.top, this.right, and this.bottom have been defined
                        var me = this;
                        var paddingLeft = me.paddingLeft;
                        var paddingBottom = me.paddingBottom;
@@ -191,8 +190,8 @@ module.exports = function(Chart) {
                        var offset = (isHorizontal ? pixel - me.left - paddingLeft : me.bottom - paddingBottom - pixel) / innerDimension;
                        return me.start + ((me.end - me.start) * offset);
                },
-               getPixelForTick: function(index, includeOffset) {
-                       return this.getPixelForValue(this.ticksAsNumbers[index], null, null, includeOffset);
+               getPixelForTick: function(index) {
+                       return this.getPixelForValue(this.ticksAsNumbers[index]);
                }
        });
        Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig);
index 45292b812df620fe7a54ddc6eafbd1e3faeb1fe5..53beb4d06f98ac1c7b3375b67fb6ccf6f0973905 100644 (file)
@@ -53,11 +53,9 @@ module.exports = function(Chart) {
                buildTicks: function() {
                        var me = this;
                        var opts = me.options;
+                       var ticks = me.ticks = [];
                        var tickOpts = opts.ticks;
                        var getValueOrDefault = helpers.getValueOrDefault;
-                       var isHorizontal = me.isHorizontal();
-
-                       var ticks = me.ticks = [];
 
                        // 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
index 3d5bddc3bcbc9dc574be1e307c98f0a9f732d539..9c595b0ac425f7fdcc83e0c09e11c1a7f193a87b 100644 (file)
@@ -177,10 +177,10 @@ module.exports = function(Chart) {
                getLabelForIndex: function(index, datasetIndex) {
                        return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
                },
-               getPixelForTick: function(index, includeOffset) {
-                       return this.getPixelForValue(this.tickValues[index], null, null, includeOffset);
+               getPixelForTick: function(index) {
+                       return this.getPixelForValue(this.tickValues[index]);
                },
-               getPixelForValue: function(value, index, datasetIndex, includeOffset) {
+               getPixelForValue: function(value) {
                        var me = this;
                        var innerDimension;
                        var pixel;
@@ -215,10 +215,8 @@ module.exports = function(Chart) {
                },
                getValueForPixel: function(pixel) {
                        var me = this;
-                       var offset;
                        var range = helpers.log10(me.end) - helpers.log10(me.start);
-                       var value;
-                       var innerDimension;
+                       var value, innerDimension;
 
                        if (me.isHorizontal()) {
                                innerDimension = me.width - (me.paddingLeft + me.paddingRight);
index 241069e10cd2e550e3ff45b4b2caf80a1574db10..c69974f60aef941ceff3da8148a2a92efab39630 100644 (file)
@@ -164,8 +164,7 @@ module.exports = function(Chart) {
                                xProtrusionLeft,
                                xProtrusionRight,
                                radiusReductionRight,
-                               radiusReductionLeft,
-                               maxWidthRadius;
+                               radiusReductionLeft;
                        this.ctx.font = pointLabeFont;
 
                        for (i = 0; i < this.getValueCount(); i++) {
index 1c2ef44b95006f9ba02d1b6e28a6af0893de1cb0..0adbbf111b5ff2a4b904ae87d1e00f249f58ee7e 100644 (file)
@@ -94,7 +94,7 @@ module.exports = function(Chart) {
                        // these
                        var scaleLabelMoments = [];
                        if (me.chart.data.labels && me.chart.data.labels.length > 0) {
-                               helpers.each(me.chart.data.labels, function(label, index) {
+                               helpers.each(me.chart.data.labels, function(label) {
                                        var labelMoment = me.parseTime(label);
 
                                        if (labelMoment.isValid()) {
@@ -117,7 +117,7 @@ module.exports = function(Chart) {
                                var datasetVisible = me.chart.isDatasetVisible(datasetIndex);
 
                                if (typeof dataset.data[0] === 'object' && dataset.data[0] !== null) {
-                                       helpers.each(dataset.data, function(value, index) {
+                                       helpers.each(dataset.data, function(value) {
                                                var labelMoment = me.parseTime(me.getRightValue(value));
 
                                                if (labelMoment.isValid()) {
@@ -154,7 +154,7 @@ module.exports = function(Chart) {
                        me.firstTick = (me.firstTick || moment()).clone();
                        me.lastTick = (me.lastTick || moment()).clone();
                },
-               buildTicks: function(index) {
+               buildTicks: function() {
                        var me = this;
 
                        me.ctx.save();
@@ -325,7 +325,7 @@ module.exports = function(Chart) {
                        me.tickMoments = me.ticks;
                        me.ticks = me.ticks.map(me.tickFormatFunction, me);
                },
-               getPixelForValue: function(value, index, datasetIndex, includeOffset) {
+               getPixelForValue: function(value, index, datasetIndex) {
                        var me = this;
                        var labelMoment = value && value.isValid && value.isValid() ? value : me.getLabelMoment(datasetIndex, index);
 
@@ -336,21 +336,19 @@ module.exports = function(Chart) {
 
                                if (me.isHorizontal()) {
                                        var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
-                                       var valueWidth = innerWidth / Math.max(me.ticks.length - 1, 1);
                                        var valueOffset = (innerWidth * decimal) + me.paddingLeft;
 
                                        return me.left + Math.round(valueOffset);
                                } else {
                                        var innerHeight = me.height - (me.paddingTop + me.paddingBottom);
-                                       var valueHeight = innerHeight / Math.max(me.ticks.length - 1, 1);
                                        var heightOffset = (innerHeight * decimal) + me.paddingTop;
 
                                        return me.top + Math.round(heightOffset);
                                }
                        }
                },
-               getPixelForTick: function(index, includeOffset) {
-                       return this.getPixelForValue(this.tickMoments[index], null, null, includeOffset);
+               getPixelForTick: function(index) {
+                       return this.getPixelForValue(this.tickMoments[index], null, null);
                },
                getValueForPixel: function(pixel) {
                        var me = this;