|
1 (function(b){var a={tooltip:false,tooltipOpts:{content:"%s | X: %x | Y: %y.2",dateFormat:"%y-%0m-%0d",shifts:{x:10,y:20},defaultTheme:true}};var c=function(i){var d={x:0,y:0};var h=i.getOptions();var g=function(l){d.x=l.x;d.y=l.y};var k=function(l){var m={x:0,y:0};m.x=l.pageX;m.y=l.pageY;g(m)};var f=function(l){var m=new Date(l);return b.plot.formatDate(m,h.tooltipOpts.dateFormat)};i.hooks.bindEvents.push(function(m,l){var p=h.tooltipOpts;var o=m.getPlaceholder();var n;if(h.tooltip===false){return}if(b("#flotTip").length>0){n=b("#flotTip")}else{n=b("<div />").attr("id","flotTip");n.appendTo("body").hide().css({position:"absolute"});if(p.defaultTheme){n.css({background:"#fff","z-index":"100",padding:"0.4em 0.6em","border-radius":"0.5em","font-size":"0.8em",border:"1px solid #111"})}}b(o).bind("plothover",function(s,t,r){if(r){var q;if(h.xaxis.mode==="time"||h.xaxes[0].mode==="time"){q=e(p.content,r,f)}else{q=e(p.content,r)}n.html(q).css({left:d.x+p.shifts.x,top:d.y+p.shifts.y}).show()}else{n.hide().html("")}});l.mousemove(k)});var e=function(p,o,n){var r=/%p\.{0,1}(\d{0,})/;var q=/%s/;var m=/%x\.{0,1}(\d{0,})/;var l=/%y\.{0,1}(\d{0,})/;if(typeof(o.series.percent)!=="undefined"){p=j(r,p,o.series.percent)}if(typeof(o.series.label)!=="undefined"){p=p.replace(q,o.series.label)}if(typeof(n)==="function"){p=p.replace(m,n(o.series.data[o.dataIndex][0]))}else{if(typeof o.series.data[o.dataIndex][0]==="number"){p=j(m,p,o.series.data[o.dataIndex][0])}}if(typeof o.series.data[o.dataIndex][1]==="number"){p=j(l,p,o.series.data[o.dataIndex][1])}return p};var j=function(o,m,n){var l;if(m.match(o)!=="null"){if(RegExp.$1!==""){l=RegExp.$1;n=n.toFixed(l)}m=m.replace(o,n)}return m}};b.plot.plugins.push({init:c,options:a,name:"tooltip",version:"0.4.4"})})(jQuery); |