web/data/cubicweb.flot.js
changeset 1888 f36d43f00f32
child 2564 5f38f5eaff86
equal deleted inserted replaced
1887:7e19c94ce0d7 1888:f36d43f00f32
       
     1 function showTooltip(x, y, contents) {
       
     2     $('<div id="tooltip">' + contents + '</div>').css( {
       
     3             position: 'absolute',
       
     4 	    display: 'none',
       
     5 	    top: y + 5,
       
     6             left: x + 5,
       
     7             border: '1px solid #fdd',
       
     8             padding: '2px',
       
     9             'background-color': '#fee',
       
    10             opacity: 0.80
       
    11 		}).appendTo("body").fadeIn(200);
       
    12 }
       
    13 
       
    14 var previousPoint = null;
       
    15 function onPlotHover(event, pos, item) {
       
    16     if (item) {
       
    17         if (previousPoint != item.datapoint) {
       
    18     	previousPoint = item.datapoint;
       
    19     	
       
    20     	$("#tooltip").remove();
       
    21     	var x = item.datapoint[0].toFixed(2),
       
    22     	    y = item.datapoint[1].toFixed(2);
       
    23 	if (item.datapoint.length == 3) {
       
    24 	    var x = new Date(item.datapoint[2]);
       
    25 	    x = x.toLocaleDateString() + ' ' + x.toLocaleTimeString();
       
    26 	}
       
    27     	showTooltip(item.pageX, item.pageY,
       
    28     		    item.series.label + ': (' + x + ' ; ' + y + ')');
       
    29             }
       
    30     } else {
       
    31         $("#tooltip").remove();
       
    32         previousPoint = null;
       
    33     }
       
    34 }