Untitled
unknown
actionscript
2 years ago
5.1 kB
2
Indexable
Never
{ key: "handleTooltips", value: function handleTooltips() { // line and bar $('<div id="flot-tooltip" class="flot-tooltip"></div>').appendTo('body'); $(document).on('plothover', '#flot-line, #flot-bar', function(event, pos, item) { if (item) { var x = item.datapoint[0].toFixed(2); var y = item.datapoint[1].toFixed(2); var series = item.series.label === undefined ? item.series.data[item.dataIndex][0] : item.series.label + ' of ' + x; $('#flot-tooltip').html(series + ' = ' + y).css({ top: item.pageY + 5, left: item.pageX + 5 }).fadeIn(300); } else { $('#flot-tooltip').hide(); } }); // flot area $('<div id="flot-tooltip2" class="flot-tooltip"></div>').appendTo('body'); $(document).on('plothover', '#flot-area', function(event, pos, item) { if (item) { var x = item.datapoint[0]; var y = item.datapoint[1]; var color = item.series.color; $('#flot-tooltip2').html("<strong>".concat(item.series.label, "</strong><br>").concat(new Date(x).getFullYear(), " : <strong>Population : ").concat(y, "</strong> <br> <em>(multiply by 10,000)</em>")).css({ top: item.pageY + 5, left: item.pageX + 5, borderColor: color, color: Looper.getDarkColor(), backgroundColor: Looper.getLightColor() }).fadeIn(300); } else { $('#flot-tooltip2').hide(); } }); // barhor $('<div id="flot-tooltip3" class="flot-tooltip"></div>').appendTo('body'); $(document).on('plothover', '#flot-barhor', function(event, pos, item) { if (item) { var x = item.datapoint[0]; var y = item.datapoint[1]; var color = item.series.color; $('#flot-tooltip3').html("<strong>".concat(item.series.label, " :</strong> ").concat(x)).css({ top: item.pageY + 9, left: item.pageX - 100, borderColor: color, color: Looper.getDarkColor(), backgroundColor: Looper.getLightColor() }).fadeIn(300); } else { $('#flot-tooltip3').hide(); } }); // combine $('<div id="flot-tooltip4" class="flot-tooltip"></div>').appendTo('body'); $(document).on('plothover', '#flot-combine', function(event, pos, item) { if (item) { var x = item.datapoint[0]; var y = item.datapoint[1]; var color = item.series.color; var date = 'Jan ' + new Date(x).getDate(); var unit = ''; if (item.series.label == 'Sea Level Pressure') { unit = 'hPa'; } else if (item.series.label == 'Wind Speed') { unit = 'km/hr'; } else if (item.series.label == 'Temperature') { unit = '°C'; } $('#flot-tooltip4').html("'<strong>".concat(item.series.label, "'</strong><br>").concat(date, "' : <strong>").concat(y, "'</strong> ").concat(unit)).css({ top: item.pageY + 5, left: item.pageX + 5, borderColor: color, color: Looper.getDarkColor(), backgroundColor: Looper.getLightColor() }).fadeIn(300); } else { $('#flot-tooltip4').hide(); } }); } }