},
update: function(changed) {
-
- var ctx = this._chart.ctx;
-
- if(this._active.length){
+ if (this._active.length){
this._model.opacity = 1;
var element = this._active[0],
}
});
- helpers.each(this._active, function(active, i) {
+ helpers.each(this._active, function(active) {
if (active) {
labelColors.push({
borderColor: active._view.borderColor,
// Width
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);
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);
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width + (this._options.tooltips.mode != 'single' ? (vm.bodyFontSize + 2) : 0));
}, this);
- helpers.each(vm.footer, function(line, i) {
+ helpers.each(vm.footer, function(line) {
ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
tooltipWidth = Math.max(tooltipWidth, ctx.measureText(line).width);
});
var tooltipX = vm.x,
tooltipY = vm.y;
- if (vm.yAlign == 'top') {
+ if (vm.yAlign === 'top') {
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;
} else {
tooltipY = vm.y - (tooltipHeight / 2);
}
- if (vm.xAlign == 'left') {
+ if (vm.xAlign === 'left') {
tooltipX = vm.x - tooltipTotalWidth;
- } else if (vm.xAlign == 'right') {
+ } else if (vm.xAlign === 'right') {
tooltipX = vm.x + caretPadding + vm.caretSize;
} else {
tooltipX = vm.x + (tooltipTotalWidth / 2);
if (this._options.tooltips.enabled) {
ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(opacity).rgbString();
- if (vm.xAlign == 'left') {
+ if (vm.xAlign === 'left') {
ctx.beginPath();
ctx.moveTo(vm.x - caretPadding, vm.y);
helpers.each(vm.title, function(title, i) {
ctx.fillText(title, xBase, yBase);
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
}
}, this);
ctx.font = helpers.fontString(vm.bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
// Before Body
- helpers.each(vm.beforeBody, function(beforeBody, i) {
+ helpers.each(vm.beforeBody, function(beforeBody) {
ctx.fillText(vm.beforeBody, xBase, yBase);
yBase += vm.bodyFontSize + vm.bodySpacing;
});
// 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
ctx.fillStyle = helpers.color(vm.legendColorBackground).alpha(opacity).rgbaString();
ctx.fillRect(xBase, yBase, vm.bodyFontSize, vm.bodyFontSize);
}
// 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;
}, this);
// After Body
- helpers.each(vm.afterBody, function(afterBody, i) {
+ helpers.each(vm.afterBody, function(afterBody) {
ctx.fillText(vm.afterBody, xBase, yBase);
yBase += vm.bodyFontSize;
});
ctx.fillStyle = helpers.color(vm.footerColor).alpha(opacity).rgbString();
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);
yBase += vm.footerFontSize + vm.footerSpacing;
}, this);
ctx.lineTo(previousPoint._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
ctx.lineTo(point._view.x, point._view.y);
});
} else {
this.lineToNextPoint(previous, point, next, function(previousPoint, point, nextPoint) {
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
ctx.moveTo(point._view.x, point._view.y);
});