Clean up code climate style issues and formatting.

This commit is contained in:
etimberg 2016-02-14 17:06:00 -05:00
parent 756208413b
commit 01b88f19df
32 changed files with 5700 additions and 5694 deletions

View File

@ -5,7 +5,7 @@ module.exports = function(Chart) {
var helpers = Chart.helpers;
var defaultConfig = {
aspectRatio: 1,
aspectRatio: 1
};
Chart.Radar = function(context, config) {

View File

@ -4,20 +4,20 @@ module.exports = function(Chart) {
var defaultConfig = {
hover: {
mode: 'single',
mode: 'single'
},
scales: {
xAxes: [{
type: "linear", // scatter should not use a category axis
position: "bottom",
id: "x-axis-1", // need an ID so datasets can reference the scale
id: "x-axis-1" // need an ID so datasets can reference the scale
}],
yAxes: [{
type: "linear",
position: "left",
id: "y-axis-1",
}],
id: "y-axis-1"
}]
},
tooltips: {
@ -30,7 +30,7 @@ module.exports = function(Chart) {
return '(' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ')';
}
}
},
}
};
// Register the default config for this type

View File

@ -19,13 +19,13 @@ module.exports = function(Chart) {
// grid line settings
gridLines: {
offsetGridLines: true,
},
offsetGridLines: true
}
}],
yAxes: [{
type: "linear",
}],
},
type: "linear"
}]
}
};
Chart.controllers.bar = Chart.DatasetController.extend({
@ -52,7 +52,7 @@ module.exports = function(Chart) {
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Rectangle({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
}, this);
},
@ -61,7 +61,7 @@ module.exports = function(Chart) {
var rectangle = new Chart.elements.Rectangle({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
var numBars = this.getBarCount();
@ -117,8 +117,8 @@ module.exports = function(Chart) {
width: this.calculateBarWidth(numBars),
backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor),
borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor),
borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth),
},
borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth)
}
});
rectangle.pivot();
},
@ -193,7 +193,7 @@ module.exports = function(Chart) {
categorySpacing: categorySpacing,
fullBarWidth: fullBarWidth,
barWidth: barWidth,
barSpacing: barSpacing,
barSpacing: barSpacing
};
},

View File

@ -13,13 +13,13 @@ module.exports = function(Chart) {
xAxes: [{
type: "linear", // bubble should probably use a linear scale by default
position: "bottom",
id: "x-axis-0", // need an ID so datasets can reference the scale
id: "x-axis-0" // need an ID so datasets can reference the scale
}],
yAxes: [{
type: "linear",
position: "left",
id: "y-axis-0",
}],
id: "y-axis-0"
}]
},
tooltips: {
@ -34,7 +34,7 @@ module.exports = function(Chart) {
return datasetLabel + ': (' + dataPoint.x + ', ' + dataPoint.y + ', ' + dataPoint.r + ')';
}
}
},
}
};
@ -47,7 +47,7 @@ module.exports = function(Chart) {
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
}, this);
},
@ -56,7 +56,7 @@ module.exports = function(Chart) {
var point = new Chart.elements.Point({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
// Reset the point
@ -120,8 +120,8 @@ module.exports = function(Chart) {
borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.point.borderWidth),
// Tooltip
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius),
},
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius)
}
});
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));

View File

@ -9,7 +9,7 @@ module.exports = function(Chart) {
//Boolean - Whether we animate the rotation of the Doughnut
animateRotate: true,
//Boolean - Whether we animate scaling the Doughnut from the centre
animateScale: false,
animateScale: false
},
aspectRatio: 1,
hover: {
@ -70,7 +70,9 @@ module.exports = function(Chart) {
// Need to override these to give a nice default
tooltips: {
callbacks: {
title: function() { return '';},
title: function() {
return '';
},
label: function(tooltipItem, data) {
return data.labels[tooltipItem.index] + ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
}
@ -95,7 +97,7 @@ module.exports = function(Chart) {
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
}, this);
},
@ -104,7 +106,7 @@ module.exports = function(Chart) {
var arc = new Chart.elements.Arc({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
if (colorForNewElement && helpers.isArray(this.getDataset().backgroundColor)) {
@ -119,7 +121,9 @@ module.exports = function(Chart) {
},
getVisibleDatasetCount: function getVisibleDatasetCount() {
return helpers.where(this.chart.data.datasets, function(ds) { return helpers.isDatasetVisible(ds); }).length;
return helpers.where(this.chart.data.datasets, function(ds) {
return helpers.isDatasetVisible(ds);
}).length;
},
// Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly
@ -190,7 +194,7 @@ module.exports = function(Chart) {
borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor),
label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index])
},
}
});
if (!reset) {
@ -244,7 +248,6 @@ module.exports = function(Chart) {
} else {
return 0;
}
},
}
});
};

View File

@ -19,8 +19,8 @@ module.exports = function(Chart) {
yAxes: [{
type: "linear",
id: 'y-axis-0'
}],
},
}]
}
};
@ -32,14 +32,14 @@ module.exports = function(Chart) {
this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({
_chart: this.chart.chart,
_datasetIndex: this.index,
_points: this.getDataset().metaData,
_points: this.getDataset().metaData
});
helpers.each(this.getDataset().data, function(value, index) {
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
}, this);
},
@ -48,7 +48,7 @@ module.exports = function(Chart) {
var point = new Chart.elements.Point({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
// Reset the point

View File

@ -8,7 +8,7 @@ module.exports = function(Chart) {
scale: {
type: "radialLinear",
lineArc: true, // so that lines are circular
lineArc: true // so that lines are circular
},
//Boolean - Whether to animate the rotation of the chart
@ -68,7 +68,9 @@ module.exports = function(Chart) {
// Need to override these to give a nice default
tooltips: {
callbacks: {
title: function() { return ''; },
title: function() {
return '';
},
label: function(tooltipItem, data) {
return data.labels[tooltipItem.index] + ': ' + tooltipItem.yLabel;
}
@ -86,7 +88,7 @@ module.exports = function(Chart) {
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
}, this);
},
@ -95,7 +97,7 @@ module.exports = function(Chart) {
var arc = new Chart.elements.Arc({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
// Reset the point
@ -105,7 +107,9 @@ module.exports = function(Chart) {
this.getDataset().metaData.splice(index, 0, arc);
},
getVisibleDatasetCount: function getVisibleDatasetCount() {
return helpers.where(this.chart.data.datasets, function(ds) { return helpers.isDatasetVisible(ds); }).length;
return helpers.where(this.chart.data.datasets, function(ds) {
return helpers.isDatasetVisible(ds);
}).length;
},
update: function update(reset) {
@ -180,7 +184,7 @@ module.exports = function(Chart) {
borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor),
label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index])
},
}
});
arc.pivot();

View File

@ -7,13 +7,13 @@ module.exports = function(Chart) {
Chart.defaults.radar = {
scale: {
type: "radialLinear",
type: "radialLinear"
},
elements: {
line: {
tension: 0, // no bezier in radar
tension: 0 // no bezier in radar
}
}
},
};
Chart.controllers.radar = Chart.DatasetController.extend({
@ -39,8 +39,8 @@ module.exports = function(Chart) {
_index: index,
_model: {
x: 0, //xScale.getPixelForValue(null, index, true),
y: 0, //this.chartArea.bottom,
},
y: 0 //this.chartArea.bottom,
}
});
}, this);
},
@ -49,7 +49,7 @@ module.exports = function(Chart) {
var point = new Chart.elements.Point({
_chart: this.chart.chart,
_datasetIndex: this.index,
_index: index,
_index: index
});
// Reset the point
@ -99,8 +99,8 @@ module.exports = function(Chart) {
// Scale
scaleTop: scale.top,
scaleBottom: scale.bottom,
scaleZero: scaleBase,
},
scaleZero: scaleBase
}
});
this.getDataset().metaDataset.pivot();
@ -137,8 +137,8 @@ module.exports = function(Chart) {
pointStyle: point.custom && point.custom.pointStyle ? point.custom.pointStyle : helpers.getValueAtIndexOrDefault(this.getDataset().pointStyle, index, this.chart.options.elements.point.pointStyle),
// Tooltip
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius),
},
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius)
}
});
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));

View File

@ -9,7 +9,7 @@ module.exports = function(Chart) {
duration: 1000,
easing: "easeOutQuart",
onProgress: helpers.noop,
onComplete: helpers.noop,
onComplete: helpers.noop
};
Chart.Animation = Chart.Element.extend({
@ -19,7 +19,7 @@ module.exports = function(Chart) {
render: null, // render function used by the animation service
onAnimationProgress: null, // user specified callback to fire on each step of the animation
onAnimationComplete: null, // user specified callback to fire when the animation finishes
onAnimationComplete: null // user specified callback to fire when the animation finishes
});
Chart.animationService = {
@ -46,7 +46,7 @@ module.exports = function(Chart) {
});
// If there are no animations queued, manually kickstart a digest, for lack of a better word
if (this.animations.length == 1) {
if (this.animations.length === 1) {
helpers.requestAnimFrame.call(window, this.digestWrapper);
}
},
@ -91,7 +91,7 @@ module.exports = function(Chart) {
this.animations[i].animationObject.onAnimationProgress.call(this.animations[i].chartInstance, this.animations[i]);
}
if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) {
if (this.animations[i].animationObject.currentStep === this.animations[i].animationObject.numSteps) {
if (this.animations[i].animationObject.onAnimationComplete && this.animations[i].animationObject.onAnimationComplete.call) {
this.animations[i].animationObject.onAnimationComplete.call(this.animations[i].chartInstance, this.animations[i]);
}

View File

@ -24,7 +24,7 @@ module.exports = function(Chart) {
Object.defineProperty(this, 'data', {
get: function() {
return this.config.data;
},
}
});
//Add the chart instance to the global namespace
@ -35,7 +35,7 @@ module.exports = function(Chart) {
this.resize(true);
}
this.initialize.call(this);
this.initialize();
return this;
};
@ -133,7 +133,7 @@ module.exports = function(Chart) {
ctx: this.chart.ctx,
options: xAxisOptions,
chart: this,
id: xAxisOptions.id,
id: xAxisOptions.id
});
this.scales[scale.id] = scale;
@ -150,7 +150,7 @@ module.exports = function(Chart) {
ctx: this.chart.ctx,
options: yAxisOptions,
chart: this,
id: yAxisOptions.id,
id: yAxisOptions.id
});
this.scales[scale.id] = scale;
@ -165,7 +165,7 @@ module.exports = function(Chart) {
var scale = new ScaleClass({
ctx: this.chart.ctx,
options: this.options.scale,
chart: this,
chart: this
});
this.scale = scale;
@ -192,7 +192,7 @@ module.exports = function(Chart) {
this.legend = new Chart.Legend({
ctx: this.chart.ctx,
options: this.options.legend,
chart: this,
chart: this
});
Chart.layoutService.addBox(this, this.legend);
@ -225,7 +225,7 @@ module.exports = function(Chart) {
if (types.length > 1) {
for (var i = 1; i < types.length; i++) {
if (types[i] != types[i - 1]) {
if (types[i] !== types[i - 1]) {
this.isCombo = true;
break;
}
@ -269,7 +269,7 @@ module.exports = function(Chart) {
render: function render(duration, lazy) {
if (this.options.animation && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration == 'undefined' && this.options.animation.duration !== 0))) {
if (this.options.animation && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && this.options.animation.duration !== 0))) {
var animation = new Chart.Animation();
animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps
animation.easing = this.options.animation.easing;
@ -415,7 +415,7 @@ module.exports = function(Chart) {
_chart: this.chart,
_chartInstance: this,
_data: this.data,
_options: this.options,
_options: this.options
}, this);
},
@ -429,7 +429,7 @@ module.exports = function(Chart) {
this.lastTooltipActive = this.lastTooltipActive || [];
// Find Active Elements for hover and tooltips
if (e.type == 'mouseout') {
if (e.type === 'mouseout') {
this.active = [];
this.tooltipActive = [];
} else {
@ -457,7 +457,7 @@ module.exports = function(Chart) {
this.options.hover.onHover.call(this, this.active);
}
if (e.type == 'mouseup' || e.type == 'click') {
if (e.type === 'mouseup' || e.type === 'click') {
if (this.options.onClick) {
this.options.onClick.call(this, e, this.active);
}
@ -555,6 +555,6 @@ module.exports = function(Chart) {
this.lastActive = this.active;
this.lastTooltipActive = this.tooltipActive;
return this;
},
}
});
};

View File

@ -65,7 +65,7 @@ module.exports = function(Chart) {
draw: helpers.noop,
removeHoverStyle: helpers.noop,
setHoverStyle: helpers.noop,
update: helpers.noop,
update: helpers.noop
});
Chart.DatasetController.extend = helpers.inherits;

View File

@ -83,7 +83,7 @@ module.exports = function(Chart) {
helpers.each(value, function(valueObj, index) {
if (index < baseArray.length) {
if (typeof baseArray[index] == 'object' && baseArray[index] !== null && typeof valueObj == 'object' && valueObj !== null) {
if (typeof baseArray[index] === 'object' && baseArray[index] !== null && typeof valueObj === 'object' && valueObj !== null) {
// Two objects are coming together. Do a merge of them.
baseArray[index] = helpers.configMerge(baseArray[index], valueObj);
} else {
@ -95,7 +95,7 @@ module.exports = function(Chart) {
}
});
} else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") {
} else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
// If we are overwriting an object with an object, do a merge of the properties.
base[key] = helpers.configMerge(base[key], value);
@ -152,7 +152,7 @@ module.exports = function(Chart) {
base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj));
});
}
} else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") {
} else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
// If we are overwriting an object with an object, do a merge of the properties.
base[key] = helpers.configMerge(base[key], value);
@ -510,7 +510,7 @@ module.exports = function(Chart) {
if (t === 0) {
return 0;
}
if ((t /= 1) == 1) {
if ((t /= 1) === 1) {
return 1;
}
if (!p) {
@ -531,7 +531,7 @@ module.exports = function(Chart) {
if (t === 0) {
return 0;
}
if ((t /= 1) == 1) {
if ((t /= 1) === 1) {
return 1;
}
if (!p) {
@ -552,7 +552,7 @@ module.exports = function(Chart) {
if (t === 0) {
return 0;
}
if ((t /= 1 / 2) == 2) {
if ((t /= 1 / 2) === 2) {
return 1;
}
if (!p) {
@ -874,7 +874,7 @@ module.exports = function(Chart) {
return Array.isArray(obj);
};
helpers.pushAllIfDefined = function(element, array) {
if (typeof element == "undefined") {
if (typeof element === "undefined") {
return;
}

View File

@ -68,7 +68,7 @@ module.exports = function() {
hover: {
onHover: null,
mode: 'single',
animationDuration: 400,
animationDuration: 400
},
onClick: null,
defaultColor: 'rgba(0,0,0,0.1)',
@ -96,7 +96,7 @@ module.exports = function() {
return text.join("");
}
},
}
};
return Chart;

View File

@ -36,21 +36,21 @@ module.exports = function(Chart) {
var yPadding = height > 30 ? 5 : 2;
var leftBoxes = helpers.where(chartInstance.boxes, function(box) {
return box.options.position == "left";
return box.options.position === "left";
});
var rightBoxes = helpers.where(chartInstance.boxes, function(box) {
return box.options.position == "right";
return box.options.position === "right";
});
var topBoxes = helpers.where(chartInstance.boxes, function(box) {
return box.options.position == "top";
return box.options.position === "top";
});
var bottomBoxes = helpers.where(chartInstance.boxes, function(box) {
return box.options.position == "bottom";
return box.options.position === "bottom";
});
// Boxes that overlay the chartarea such as the radialLinear scale
var chartAreaBoxes = helpers.where(chartInstance.boxes, function(box) {
return box.options.position == "chartArea";
return box.options.position === "chartArea";
});
function fullWidthSorter(a, b) {
@ -136,7 +136,7 @@ module.exports = function(Chart) {
minBoxSizes.push({
horizontal: isHorizontal,
minSize: minSize,
box: box,
box: box
});
}
@ -175,7 +175,7 @@ module.exports = function(Chart) {
left: totalLeftBoxesWidth,
right: totalRightBoxesWidth,
top: 0,
bottom: 0,
bottom: 0
};
// Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends
@ -306,7 +306,7 @@ module.exports = function(Chart) {
left: totalLeftBoxesWidth,
top: totalTopBoxesHeight,
right: totalLeftBoxesWidth + maxChartAreaWidth,
bottom: totalTopBoxesHeight + maxChartAreaHeight,
bottom: totalTopBoxesHeight + maxChartAreaHeight
};
// Step 9

View File

@ -55,7 +55,7 @@ module.exports = function(Chart) {
};
}, this);
}
},
}
};
Chart.Legend = Chart.Element.extend({
@ -133,7 +133,7 @@ module.exports = function(Chart) {
// Reset minSize
this.minSize = {
width: 0,
height: 0,
height: 0
};
},
afterSetDimensions: helpers.noop,
@ -196,7 +196,7 @@ module.exports = function(Chart) {
left: 0,
top: 0,
width: width,
height: this.options.labels.fontSize,
height: this.options.labels.fontSize
};
this.lineWidths[this.lineWidths.length - 1] += width + this.options.labels.padding;
@ -217,7 +217,7 @@ module.exports = function(Chart) {
// Shared Methods
isHorizontal: function() {
return this.options.position == "top" || this.options.position == "bottom";
return this.options.position === "top" || this.options.position === "bottom";
},
// Actualy draw the legend on the canvas
@ -227,7 +227,7 @@ module.exports = function(Chart) {
var cursor = {
x: this.left + ((this.width - this.lineWidths[0]) / 2),
y: this.top + this.options.labels.padding,
line: 0,
line: 0
};
var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily);

View File

@ -16,7 +16,7 @@ module.exports = function(Chart) {
drawTicks: true,
zeroLineWidth: 1,
zeroLineColor: "rgba(0,0,0,0.25)",
offsetGridLines: false,
offsetGridLines: false
},
// scale label
@ -30,7 +30,7 @@ module.exports = function(Chart) {
labelString: '',
// display property
display: false,
display: false
},
// label settings
@ -49,8 +49,8 @@ module.exports = function(Chart) {
autoSkipPadding: 20,
callback: function(value) {
return '' + value;
},
},
}
}
};
Chart.Scale = Chart.Element.extend({
@ -259,7 +259,7 @@ module.exports = function(Chart) {
this.minSize = {
width: 0,
height: 0,
height: 0
};
// Width
@ -483,7 +483,7 @@ module.exports = function(Chart) {
helpers.each(this.ticks, function(label, index) {
// Blank ticks
var isLastTick = this.ticks.length == index + 1;
var isLastTick = this.ticks.length === index + 1;
var shouldSkip = skipRatio > 1 && index % skipRatio > 0;
if (shouldSkip && !isLastTick || (label === undefined || label === null)) {
return;

View File

@ -29,6 +29,6 @@ module.exports = function(Chart) {
helpers.each(chartInstance.scales, function(scale) {
Chart.layoutService.addBox(chartInstance, scale);
});
},
}
};
};

View File

@ -16,7 +16,7 @@ module.exports = function(Chart) {
padding: 10,
// actual title
text: '',
text: ''
};
Chart.Title = Chart.Element.extend({
@ -90,7 +90,7 @@ module.exports = function(Chart) {
// Reset minSize
this.minSize = {
width: 0,
height: 0,
height: 0
};
},
afterSetDimensions: helpers.noop,
@ -142,7 +142,7 @@ module.exports = function(Chart) {
// Shared Methods
isHorizontal: function() {
return this.options.position == "top" || this.options.position == "bottom";
return this.options.position === "top" || this.options.position === "bottom";
},
// Actualy draw the title block on the canvas
@ -170,9 +170,9 @@ module.exports = function(Chart) {
// Title
if (this.options.display) {
titleX = this.options.position == 'left' ? this.left + (this.options.fontSize / 2) : this.right - (this.options.fontSize / 2);
titleX = this.options.position === 'left' ? this.left + (this.options.fontSize / 2) : this.right - (this.options.fontSize / 2);
titleY = this.top + ((this.bottom - this.top) / 2);
var rotation = this.options.position == 'left' ? -0.5 * Math.PI : 0.5 * Math.PI;
var rotation = this.options.position === 'left' ? -0.5 * Math.PI : 0.5 * Math.PI;
ctx.save();
ctx.translate(titleX, titleY);

View File

@ -70,8 +70,8 @@ module.exports = function(Chart) {
// Args are: (tooltipItems, data)
beforeFooter: helpers.noop,
footer: helpers.noop,
afterFooter: helpers.noop,
},
afterFooter: helpers.noop
}
};
// Helper to push or concat based on if the 2nd parameter is an array or not
@ -127,8 +127,8 @@ module.exports = function(Chart) {
cornerRadius: options.tooltips.cornerRadius,
backgroundColor: options.tooltips.backgroundColor,
opacity: 0,
legendColorBackground: options.tooltips.multiKeyBackground,
},
legendColorBackground: options.tooltips.multiKeyBackground
}
});
},
@ -234,7 +234,7 @@ module.exports = function(Chart) {
xLabel: element._xScale ? element._xScale.getLabelForIndex(element._index, element._datasetIndex) : '',
yLabel: yScale ? yScale.getLabelForIndex(element._index, element._datasetIndex) : '',
index: element._index,
datasetIndex: element._datasetIndex,
datasetIndex: element._datasetIndex
});
tooltipPosition = this.getAveragePosition(this._active);
} else {
@ -250,7 +250,7 @@ module.exports = function(Chart) {
xLabel: currentElement._xScale ? currentElement._xScale.getLabelForIndex(currentElement._index, currentElement._datasetIndex) : '',
yLabel: yScale ? yScale.getLabelForIndex(currentElement._index, currentElement._datasetIndex) : '',
index: element._index,
datasetIndex: datasetIndex,
datasetIndex: datasetIndex
});
}
});
@ -274,14 +274,14 @@ module.exports = function(Chart) {
beforeBody: this.getBeforeBody(tooltipItems, this._data),
body: this.getBody(tooltipItems, this._data),
afterBody: this.getAfterBody(tooltipItems, this._data),
footer: this.getFooter(tooltipItems, this._data),
footer: this.getFooter(tooltipItems, this._data)
});
helpers.extend(this._model, {
x: Math.round(tooltipPosition.x),
y: Math.round(tooltipPosition.y),
caretPadding: helpers.getValueOrDefault(tooltipPosition.padding, 2),
labelColors: labelColors,
labelColors: labelColors
});
// We need to determine alignment of
@ -420,7 +420,7 @@ module.exports = function(Chart) {
pt.y -= (size.height / 2);
}
if (vm.yAlign == 'center') {
if (vm.yAlign === 'center') {
if (vm.xAlign === 'left') {
pt.x += vm.caretPadding + vm.caretSize;
} else if (vm.xAlign === 'right') {

View File

@ -13,7 +13,7 @@ module.exports = function(Chart) {
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
fill: true, // do we fill in the area between the line and its base axis
fill: true // do we fill in the area between the line and its base axis
};
Chart.elements.Line = Chart.Element.extend({
@ -156,6 +156,6 @@ module.exports = function(Chart) {
ctx.stroke();
ctx.restore();
},
}
});
};

View File

@ -13,7 +13,7 @@ module.exports = function(Chart) {
// Hover
hitRadius: 1,
hoverRadius: 4,
hoverBorderWidth: 1,
hoverBorderWidth: 1
};
@ -69,8 +69,7 @@ module.exports = function(Chart) {
switch (vm.pointStyle) {
// Default includes circle
default:
ctx.beginPath();
default: ctx.beginPath();
ctx.arc(vm.x, vm.y, radius, 0, Math.PI * 2);
ctx.closePath();
ctx.fill();

View File

@ -7,7 +7,7 @@ module.exports = function(Chart) {
Chart.defaults.global.elements.rectangle = {
backgroundColor: Chart.defaults.global.defaultColor,
borderWidth: 0,
borderColor: Chart.defaults.global.defaultColor,
borderColor: Chart.defaults.global.defaultColor
};
Chart.elements.Rectangle = Chart.Element.extend({
@ -80,7 +80,7 @@ module.exports = function(Chart) {
x: vm.x,
y: vm.y
};
},
}
});
};

View File

@ -5,7 +5,7 @@ module.exports = function(Chart) {
var helpers = Chart.helpers;
// Default config for a category scale
var defaultConfig = {
position: "bottom",
position: "bottom"
};
var DatasetScale = Chart.Scale.extend({
@ -40,7 +40,7 @@ module.exports = function(Chart) {
return this.top + Math.round(heightOffset);
}
},
}
});
Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig);

View File

@ -49,7 +49,7 @@ module.exports = function(Chart) {
if (valuesPerType[dataset.type] === undefined) {
valuesPerType[dataset.type] = {
positiveValues: [],
negativeValues: [],
negativeValues: []
};
}
@ -203,7 +203,7 @@ module.exports = function(Chart) {
}
this.ticks.push(this.options.ticks.max !== undefined ? this.options.ticks.max : niceMax);
if (this.options.position == "left" || this.options.position == "right") {
if (this.options.position === "left" || this.options.position === "right") {
// We are in a vertical orientation. The top value is the highest. So reverse the array
this.ticks.reverse();
}
@ -249,7 +249,7 @@ module.exports = function(Chart) {
},
getPixelForTick: function(index, includeOffset) {
return this.getPixelForValue(this.ticksAsNumbers[index], null, null, includeOffset);
},
}
});
Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig);

View File

@ -129,7 +129,7 @@ module.exports = function(Chart) {
var lastTick = this.options.ticks.max !== undefined ? this.options.ticks.max : tickVal;
this.tickValues.push(lastTick);
if (this.options.position == "left" || this.options.position == "right") {
if (this.options.position === "left" || this.options.position === "right") {
// We are in a vertical orientation. The top value is the highest. So reverse the array
this.tickValues.reverse();
}
@ -184,7 +184,7 @@ module.exports = function(Chart) {
}
return pixel;
},
}
});
Chart.scaleService.registerScaleType("logarithmic", LogarithmicScale, defaultConfig);

View File

@ -30,7 +30,7 @@ module.exports = function(Chart) {
backdropPaddingY: 2,
//Number - The backdrop padding to the side of the label in pixels
backdropPaddingX: 2,
backdropPaddingX: 2
},
pointLabels: {
@ -50,7 +50,7 @@ module.exports = function(Chart) {
callback: function(label) {
return label;
}
},
}
};
var LinearRadialScale = Chart.Scale.extend({

View File

@ -37,11 +37,11 @@ module.exports = function(Chart) {
maxStep: 3
}, {
name: 'quarter',
maxStep: 4,
maxStep: 4
}, {
name: 'year',
maxStep: false
}, ],
}]
};
var defaultConfig = {
@ -63,9 +63,9 @@ module.exports = function(Chart) {
'week': 'll', // Week 46, or maybe "[W]WW - YYYY" ?
'month': 'MMM YYYY', // Sept 2015
'quarter': '[Q]Q - YYYY', // Q3
'year': 'YYYY', // 2015
},
},
'year': 'YYYY' // 2015
}
}
};
var TimeScale = Chart.Scale.extend({
@ -287,7 +287,7 @@ module.exports = function(Chart) {
},
parseTime: function(label) {
// Date objects
if (typeof label.getMonth === 'function' || typeof label == 'number') {
if (typeof label.getMonth === 'function' || typeof label === 'number') {
return moment(label);
}
// Moment support
@ -300,7 +300,7 @@ module.exports = function(Chart) {
}
// Moment format parsing
return moment(label, this.options.time.format);
},
}
});
Chart.scaleService.registerScaleType("time", TimeScale, defaultConfig);