var lbl = new Array(); jQuery(document).ready(function(){ jQuery('#wpta_trend').hide(); jQuery('#wpta_powered').hide(); var data = [3,2,2,5,1]; lbl = ['10-December-2017','11-December-2017','12-December-2017','13-December-2017','14-December-2017']; var datapoint = new Array(); for(var i=0;i0){ if(jQuery('#trenddiv').length>0){ plot = jQuery.plot( jQuery('#trenddiv'), [ datapoint ] , plot_options ); } }else{ jQuery('#trenddiv').html("No Data Found"); } jQuery("#trenddiv").bind("plothover", function (event, pos, item) { if (item){ jQuery('#tooltip').remove(); showTooltip(pos.pageX,pos.pageY,item); }else{ jQuery('#tooltip').remove(); } } ); } ); function showTooltip(x, y, item) { var x_point = item.datapoint[0]; // => x-axis var y_point = item.datapoint[1]; // => y-axis var x_lbl = lbl[item.datapoint[0]] //=> X-Axis Label jQuery('
Date:'+x_lbl+'
Count:' + y_point + '
').css( { position: 'absolute', top: y + 5, left: x + 5, border: '1px solid #000', padding: '2px', 'background-color': '#fee', opacity: 0.80 }).appendTo("body"); var total_x_points = lbl.length; var current_x_point = x_point; var width = parseFloat(jQuery('#tooltip').css('width')); if(current_x_point >= total_x_points/2) jQuery('#tooltip').css('left', x-width ) ; }