Add simple measure to prevent compression of the tooltip at the right edge of the screen (may be improved, not tested on mobile screens)

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2018-03-20 00:50:53 +01:00
parent b6be5629ac
commit e3cd76ad7d

View File

@@ -1088,12 +1088,17 @@ var customTooltips = function(tooltip) {
// Display, position, and set styles for font
var position = this._chart.canvas.getBoundingClientRect();
var width = tooltip.caretX;
// Prevent compression of the tooltip at the right edge of the screen
if($(document).width() - tooltip.caretX < 400)
{
width = $(document).width()-400;
}
tooltipEl.style.opacity = 1;
tooltipEl.style.left = position.left + tooltip.caretX + "px";
tooltipEl.style.left = position.left + width + "px";
tooltipEl.style.top = position.top + tooltip.caretY + 'px';
tooltipEl.style.fontFamily = tooltip._bodyFontFamily;
tooltipEl.style.fontSize = tooltip.bodyFontSize + 'px';
tooltipEl.style.fontStyle = tooltip._bodyFontStyle;
tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px';
};