mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 20:29:12 +02:00
Start fixing code climate issues
This commit is contained in:
parent
20b9395585
commit
1cb7dde0d5
@ -222,9 +222,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
update: function(changed) {
|
update: function(changed) {
|
||||||
|
|
||||||
var ctx = this._chart.ctx;
|
|
||||||
|
|
||||||
if (this._active.length){
|
if (this._active.length){
|
||||||
this._model.opacity = 1;
|
this._model.opacity = 1;
|
||||||
|
|
||||||
@ -261,7 +258,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
helpers.each(this._active, function(active, i) {
|
helpers.each(this._active, function(active) {
|
||||||
if (active) {
|
if (active) {
|
||||||
labelColors.push({
|
labelColors.push({
|
||||||
borderColor: active._view.borderColor,
|
borderColor: active._view.borderColor,
|
||||||
@ -334,15 +331,15 @@
|
|||||||
|
|
||||||
// Width
|
// Width
|
||||||
var tooltipWidth = 0;
|
var tooltipWidth = 0;
|
||||||
helpers.each(vm.title, function(line, i) {
|
helpers.each(vm.title, function(line) {
|
||||||
ctx.font = helpers.fontString(vm.titleFontSize, vm._titleFontStyle, vm._titleFontFamily);
|
ctx.font = helpers.fontString(vm.titleFontSize, vm._titleFontStyle, vm._titleFontFamily);
|
||||||
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width);
|
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width);
|
||||||
});
|
});
|
||||||
helpers.each(vm.body, function(line, i) {
|
helpers.each(vm.body, function(line) {
|
||||||
ctx.font = helpers.fontString(vm.bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
|
ctx.font = helpers.fontString(vm.bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
|
||||||
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width + (this._options.tooltips.mode != 'single' ? (vm.bodyFontSize + 2) : 0));
|
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width + (this._options.tooltips.mode != 'single' ? (vm.bodyFontSize + 2) : 0));
|
||||||
}, this);
|
}, this);
|
||||||
helpers.each(vm.footer, function(line, i) {
|
helpers.each(vm.footer, function(line) {
|
||||||
ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
|
ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
|
||||||
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width);
|
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width);
|
||||||
});
|
});
|
||||||
@ -372,17 +369,17 @@
|
|||||||
var tooltipX = vm.x,
|
var tooltipX = vm.x,
|
||||||
tooltipY = vm.y;
|
tooltipY = vm.y;
|
||||||
|
|
||||||
if (vm.yAlign == 'top') {
|
if (vm.yAlign === 'top') {
|
||||||
tooltipY = vm.y - vm.caretSize - vm.cornerRadius;
|
tooltipY = vm.y - vm.caretSize - vm.cornerRadius;
|
||||||
} else if (vm.yAlign == 'bottom') {
|
} else if (vm.yAlign === 'bottom') {
|
||||||
tooltipY = vm.y - tooltipHeight + vm.caretSize + vm.cornerRadius;
|
tooltipY = vm.y - tooltipHeight + vm.caretSize + vm.cornerRadius;
|
||||||
} else {
|
} else {
|
||||||
tooltipY = vm.y - (tooltipHeight / 2);
|
tooltipY = vm.y - (tooltipHeight / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.xAlign == 'left') {
|
if (vm.xAlign === 'left') {
|
||||||
tooltipX = vm.x - tooltipTotalWidth;
|
tooltipX = vm.x - tooltipTotalWidth;
|
||||||
} else if (vm.xAlign == 'right') {
|
} else if (vm.xAlign === 'right') {
|
||||||
tooltipX = vm.x + caretPadding + vm.caretSize;
|
tooltipX = vm.x + caretPadding + vm.caretSize;
|
||||||
} else {
|
} else {
|
||||||
tooltipX = vm.x + (tooltipTotalWidth / 2);
|
tooltipX = vm.x + (tooltipTotalWidth / 2);
|
||||||
@ -404,7 +401,7 @@
|
|||||||
if (this._options.tooltips.enabled) {
|
if (this._options.tooltips.enabled) {
|
||||||
ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(opacity).rgbString();
|
ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(opacity).rgbString();
|
||||||
|
|
||||||
if (vm.xAlign == 'left') {
|
if (vm.xAlign === 'left') {
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(vm.x - caretPadding, vm.y);
|
ctx.moveTo(vm.x - caretPadding, vm.y);
|
||||||
@ -440,7 +437,7 @@
|
|||||||
helpers.each(vm.title, function(title, i) {
|
helpers.each(vm.title, function(title, i) {
|
||||||
ctx.fillText(title, xBase, yBase);
|
ctx.fillText(title, xBase, yBase);
|
||||||
yBase += vm.titleFontSize + vm.titleSpacing; // Line Height and spacing
|
yBase += vm.titleFontSize + vm.titleSpacing; // Line Height and spacing
|
||||||
if (i + 1 == vm.title.length) {
|
if (i + 1 === vm.title.length) {
|
||||||
yBase += vm.titleMarginBottom - vm.titleSpacing; // If Last, add margin, remove spacing
|
yBase += vm.titleMarginBottom - vm.titleSpacing; // If Last, add margin, remove spacing
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
@ -454,7 +451,7 @@
|
|||||||
ctx.font = helpers.fontString(vm.bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
|
ctx.font = helpers.fontString(vm.bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
|
||||||
|
|
||||||
// Before Body
|
// Before Body
|
||||||
helpers.each(vm.beforeBody, function(beforeBody, i) {
|
helpers.each(vm.beforeBody, function(beforeBody) {
|
||||||
ctx.fillText(vm.beforeBody, xBase, yBase);
|
ctx.fillText(vm.beforeBody, xBase, yBase);
|
||||||
yBase += vm.bodyFontSize + vm.bodySpacing;
|
yBase += vm.bodyFontSize + vm.bodySpacing;
|
||||||
});
|
});
|
||||||
@ -463,7 +460,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// Draw Legend-like boxes if needed
|
// Draw Legend-like boxes if needed
|
||||||
if (this._options.tooltips.mode != 'single') {
|
if (this._options.tooltips.mode !== 'single') {
|
||||||
// Fill a white rect so that colours merge nicely if the opacity is < 1
|
// Fill a white rect so that colours merge nicely if the opacity is < 1
|
||||||
ctx.fillStyle = helpers.color(vm.legendColorBackground).alpha(opacity).rgbaString();
|
ctx.fillStyle = helpers.color(vm.legendColorBackground).alpha(opacity).rgbaString();
|
||||||
ctx.fillRect(xBase, yBase, vm.bodyFontSize, vm.bodyFontSize);
|
ctx.fillRect(xBase, yBase, vm.bodyFontSize, vm.bodyFontSize);
|
||||||
@ -480,14 +477,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Body Line
|
// Body Line
|
||||||
ctx.fillText(body, xBase + (this._options.tooltips.mode != 'single' ? (vm.bodyFontSize + 2) : 0), yBase);
|
ctx.fillText(body, xBase + (this._options.tooltips.mode !== 'single' ? (vm.bodyFontSize + 2) : 0), yBase);
|
||||||
|
|
||||||
yBase += vm.bodyFontSize + vm.bodySpacing;
|
yBase += vm.bodyFontSize + vm.bodySpacing;
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// After Body
|
// After Body
|
||||||
helpers.each(vm.afterBody, function(afterBody, i) {
|
helpers.each(vm.afterBody, function(afterBody) {
|
||||||
ctx.fillText(vm.afterBody, xBase, yBase);
|
ctx.fillText(vm.afterBody, xBase, yBase);
|
||||||
yBase += vm.bodyFontSize;
|
yBase += vm.bodyFontSize;
|
||||||
});
|
});
|
||||||
@ -505,7 +502,7 @@
|
|||||||
ctx.fillStyle = helpers.color(vm.footerColor).alpha(opacity).rgbString();
|
ctx.fillStyle = helpers.color(vm.footerColor).alpha(opacity).rgbString();
|
||||||
ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
|
ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
|
||||||
|
|
||||||
helpers.each(vm.footer, function(footer, i) {
|
helpers.each(vm.footer, function(footer) {
|
||||||
ctx.fillText(footer, xBase, yBase);
|
ctx.fillText(footer, xBase, yBase);
|
||||||
yBase += vm.footerFontSize + vm.footerSpacing;
|
yBase += vm.footerFontSize + vm.footerSpacing;
|
||||||
}, this);
|
}, this);
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
ctx.lineTo(previousPoint._view.x, this._view.scaleZero);
|
ctx.lineTo(previousPoint._view.x, this._view.scaleZero);
|
||||||
ctx.moveTo(nextPoint._view.x, this._view.scaleZero);
|
ctx.moveTo(nextPoint._view.x, this._view.scaleZero);
|
||||||
}
|
}
|
||||||
}, function(previousPoint, point, nextPoint) {
|
}, function(previousPoint, point) {
|
||||||
// If we skipped the last point, draw a line to ourselves so that the fill is nice
|
// If we skipped the last point, draw a line to ourselves so that the fill is nice
|
||||||
ctx.lineTo(point._view.x, point._view.y);
|
ctx.lineTo(point._view.x, point._view.y);
|
||||||
});
|
});
|
||||||
@ -154,7 +154,7 @@
|
|||||||
} else {
|
} else {
|
||||||
this.lineToNextPoint(previous, point, next, function(previousPoint, point, nextPoint) {
|
this.lineToNextPoint(previous, point, next, function(previousPoint, point, nextPoint) {
|
||||||
ctx.moveTo(nextPoint._view.x, nextPoint._view.y);
|
ctx.moveTo(nextPoint._view.x, nextPoint._view.y);
|
||||||
}, function(previousPoint, point, nextPoint) {
|
}, function(previousPoint, point) {
|
||||||
// If we skipped the last point, move up to our point preventing a line from being drawn
|
// If we skipped the last point, move up to our point preventing a line from being drawn
|
||||||
ctx.moveTo(point._view.x, point._view.y);
|
ctx.moveTo(point._view.x, point._view.y);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user