diff --git a/samples/tooltips/custom-line.html b/samples/tooltips/custom-line.html
index 97f543b2653..801b12df680 100644
--- a/samples/tooltips/custom-line.html
+++ b/samples/tooltips/custom-line.html
@@ -48,7 +48,7 @@
tooltipEl = document.createElement('div');
tooltipEl.id = 'chartjs-tooltip';
tooltipEl.innerHTML = "
"
- document.body.appendChild(tooltipEl);
+ this._chart.canvas.parentNode.appendChild(tooltipEl);
}
// Hide if no tooltip
@@ -95,12 +95,13 @@
tableRoot.innerHTML = innerHtml;
}
- var position = this._chart.canvas.getBoundingClientRect();
+ var positionY = this._chart.canvas.offsetTop;
+ var positionX = this._chart.canvas.offsetLeft;
// Display, position, and set styles for font
tooltipEl.style.opacity = 1;
- tooltipEl.style.left = position.left + tooltip.caretX + 'px';
- tooltipEl.style.top = position.top + tooltip.caretY + 'px';
+ tooltipEl.style.left = positionX + tooltip.caretX + 'px';
+ tooltipEl.style.top = positionY + tooltip.caretY + 'px';
tooltipEl.style.fontFamily = tooltip._fontFamily;
tooltipEl.style.fontSize = tooltip.fontSize;
tooltipEl.style.fontStyle = tooltip._fontStyle;
diff --git a/samples/tooltips/custom-pie.html b/samples/tooltips/custom-pie.html
index 4eedd6a3a7a..9c3cd0aa608 100644
--- a/samples/tooltips/custom-pie.html
+++ b/samples/tooltips/custom-pie.html
@@ -36,11 +36,10 @@
-
-
-
-