text: function Timeline(f,e,a){if(a.sortLines){sortLines(e,a)}var g=makeFlotData(e,a);var j=makeFlotConfig(a);var h=$.plot(f,g.flotData,j);$(f).bind("plotselected",function(k,d){h.clearSelection();h.getOptions().xaxes[0].min=d.xaxis.from;h.getOptions().xaxes[0].max=d.xaxis.to;h.setupGrid();h.draw()});function c(){h.getOptions().xaxes[0].min=null;h.getOptions().xaxes[0].max=null;h.setupGrid();h.draw()}$(f).dblclick(c);var b=null;$(f).bind("plothover",function(l,m,k){if(k){if(b!=k.dataIndex){b=k.dataIndex;$("#timelineTooltip").remove();var d=g.tooltips[k.seriesIndex][k.dataIndex];if(d){showTooltip(k.pageX,k.pageY,d)}}}else{$("#timelineTooltip").fadeOut(400,function(){this.remove()});b=null}});return h}function sortLines(d,b){if(b.lines===undefined){b.lines=[]}else{b.lines=b.lines.slice(0)}var f=[];for(i=0;i<b.lines.length;++i){f[i]=0}for(i=0;i<d.length;++i){if(b.lines.indexOf(d[i].line)<0){b.lines.push(d[i].line);f.push(0)}if(b.sortLines.categories){s=b.sortLines.categories.indexOf(d[i].category);if(s>=0){lineIndex=b.lines.indexOf(d[i].line);f[lineIndex]+=Math.pow(d.length,(b.sortLines.categories.length-s-1))}}else{lineIndex=b.lines.indexOf(d[i].line);f[lineIndex]++}}var a=[];for(i=0;i<f.length;++i){a[i]=i}if(b.sortLines.direction=="ascending"){a.sort(function(h,g){return f[g]-f[h]})}else{a.sort(function(h,g){return f[h]-f[g]})}var e=b.lines.slice(0);for(i=0;i<b.lines.length;++i){b.lines[i]=e[a[i]]}if(b.lineLabels){var c=b.lineLabels.slice(0);for(i=0;i<b.lineLabels.length;++i){b.lineLabels[i]=c[a[i]]}}}function makeFlotData(d,g){var e=[];if(g.lines===undefined){g.lines=[]}var j=[];var h=[];function c(k){var l=e.indexOf(k);if(l>=0){return l}else{jQuery.extend(g.categories[k],{data:[]});j.push(g.categories[k]);h.push([]);return e.push(k)-1}}function f(k){var l=g.lines.indexOf(k);if(l>=0){return l}else{return g.lines.push(k)-1}}for(i=0;i<d.length;++i){var a=c(d[i].category);var b=f(d[i].line);j[a].data.push([d[i].time,b]);if(d[i].endTime!==undefined){h[a].push(d[i].label+" started");j[a].data.push([d[i].endTime,b]);h[a].push(d[i].label+" ended")}else{h[a].push(d[i].label)}j[a].data.push(null);h[a].push(null)}return{flotData:j,tooltips:h}}function makeFlotConfig(a){var c="browser";if(a.timezone!==undefined){c=a.timezone}var b={xaxis:{mode:"time",timezone:c,tickLength:5,position:"top"},yaxis:{max:a.lines.length},selection:{mode:"x",color:"green"},lines:{show:true,lineWidth:3},points:{show:true,fillColor:false},shadowSize:0,grid:{borderWidth:{top:1,bottom:0,left:0,right:0},labelMargin:10,hoverable:true,clickable:true}};if(a.lineLabels){b.yaxis.ticks=[];for(iLine=0;iLine<a.lines.length;iLine++){if(iLine<a.lineLabels.length&&a.lineLabels[iLine]!==undefined){b.yaxis.ticks.push([iLine,a.lineLabels[iLine]])}else{b.yaxis.ticks.push([iLine,""+a.lines[iLine]])}}}else{b.yaxis.tickSize=1;b.yaxis.tickFormatter=function(e,d){return""}}return b}function showTooltip(a,c,b){$('<div id="timelineTooltip">'+b+"</div>").css({position:"absolute",display:"none",top:c+5,left:a+5,border:"1px solid #ddf",padding:"10px","background-color":"#efd",margin:0,"font-size":"smaller"}).appendTo("body").fadeIn(200)};