I am using http://www.chartjs.org/ to display a pie chart but can't seem to figure out how to display the tooltips on page load.
$(document).on('ready page:load', function() {
Chart.defaults.global.tooltipEvents = ['click', 'mousemove', 'window.onload'];
Chart.defaults.global.customTooltips = function(tooltip) {
var text = tooltip.text;
var tooltipEl = $('#chartjs-tooltip');
if(!tooltip) {
tooltipEl.css({
opacity: 0
});
return;
}
if(text) {
var id = text.split(":")[0].replace(/ /g, '-').toLowerCase();
$('.tip-text').addClass('hide');
$('#'+id+'-tip').removeClass('hide').show();
}
// Set caret Position
tooltipEl.removeClass('above below');
tooltipEl.addClass(tooltip.yAlign);
// Set Text
tooltipEl.html(tooltip.text.split(":")[0]);
// Find Y Location on page
var top;
if (tooltip.yAlign == 'above') {
top = tooltip.y - tooltip.caretHeight - tooltip.caretPadding;
} else {
top = tooltip.y + tooltip.caretHeight + tooltip.caretPadding;
}
// Display, position, and set styles for font
tooltipEl.css({
opacity: 1,
left: tooltip.chart.canvas.offsetLeft + tooltip.x + 'px',
top: tooltip.chart.canvas.offsetTop + top + 'px',
fontFamily: tooltip.fontFamily,
fontSize: tooltip.fontSize,
fontStyle: tooltip.fontStyle,
});
}
var body = $('body');
if(body.is(".home")) {
var ctx1 = $("#custom-research-chart").get(0).getContext("2d");
var data = [
{
value: 250,
color:"#7ad3f7",
highlight: "#7ad3f7",
label: "GROWTH OVER TIME",
labelColor: "white",
labelFontSize: "16"
},
{
value: 250,
color:"#9e062e",
highlight: "#9e062e",
label: "INNOVATION",
labelColor: "white",
labelFontSize: "16"
},
{
value: 250,
color:"#577e7e",
highlight: "#577e7e",
label: "DEVELOPMENT",
labelColor: "white",
labelFontSize: "16"
},
{
value: 250,
color:"#f28d1e",
highlight: "#f28d1e",
label: "MARKET RESEARCH",
labelColor: "white",
labelFontSize: "16"
},
];
var customResearch = new Chart(ctx1).Doughnut(data);
$('.various').fancybox({
maxWidth : 800,
maxHeight : 600,
width : '70%',
height : '70%',
openEffect : 'none'
});
$.force_appear();
$(document.body).on('appear', '#alicia', function(e, $affected) {
console.log("HEY")
});
}
});