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