web/data/cubicweb.flot.js
author Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 28 Jul 2009 21:11:10 +0200
branchstable
changeset 2537 73c83c14dd2c
parent 1888 f36d43f00f32
child 2564 5f38f5eaff86
permissions -rw-r--r--
[javascript] fix IFRAME implementation and make it work in IE 6/7 + FF3 with text/html served pages For more information : - http://groups.google.com/group/comp.lang.javascript/msg/510f639e1fdebcc8 - http://msdn.microsoft.com/en-us/library/ms536389%28VS.85%29.aspx

function showTooltip(x, y, contents) {
    $('<div id="tooltip">' + contents + '</div>').css( {
            position: 'absolute',
	    display: 'none',
	    top: y + 5,
            left: x + 5,
            border: '1px solid #fdd',
            padding: '2px',
            'background-color': '#fee',
            opacity: 0.80
		}).appendTo("body").fadeIn(200);
}

var previousPoint = null;
function onPlotHover(event, pos, item) {
    if (item) {
        if (previousPoint != item.datapoint) {
    	previousPoint = item.datapoint;
    	
    	$("#tooltip").remove();
    	var x = item.datapoint[0].toFixed(2),
    	    y = item.datapoint[1].toFixed(2);
	if (item.datapoint.length == 3) {
	    var x = new Date(item.datapoint[2]);
	    x = x.toLocaleDateString() + ' ' + x.toLocaleTimeString();
	}
    	showTooltip(item.pageX, item.pageY,
    		    item.series.label + ': (' + x + ' ; ' + y + ')');
            }
    } else {
        $("#tooltip").remove();
        previousPoint = null;
    }
}