Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: third_party/flot/jquery.flot.canvas.min.js

Issue 1235773002: Add jquery and flot to catapult/third_party. (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Rebased Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/flot/jquery.flot.canvas.js ('k') | third_party/flot/jquery.flot.categories.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Javascript plotting library for jQuery, version 0.8.3.
2
3 Copyright (c) 2007-2014 IOLA and Ole Laursen.
4 Licensed under the MIT license.
5
6 */
7 (function($){var options={canvas:true};var render,getTextInfo,addText;var hasOwn Property=Object.prototype.hasOwnProperty;function init(plot,classes){var Canvas= classes.Canvas;if(render==null){getTextInfo=Canvas.prototype.getTextInfo,addText =Canvas.prototype.addText,render=Canvas.prototype.render}Canvas.prototype.render =function(){if(!plot.getOptions().canvas){return render.call(this)}var context=t his.context,cache=this._textCache;context.save();context.textBaseline="middle";f or(var layerKey in cache){if(hasOwnProperty.call(cache,layerKey)){var layerCache =cache[layerKey];for(var styleKey in layerCache){if(hasOwnProperty.call(layerCac he,styleKey)){var styleCache=layerCache[styleKey],updateStyles=true;for(var key in styleCache){if(hasOwnProperty.call(styleCache,key)){var info=styleCache[key], positions=info.positions,lines=info.lines;if(updateStyles){context.fillStyle=inf o.font.color;context.font=info.font.definition;updateStyles=false}for(var i=0,po sition;position=positions[i];i++){if(position.active){for(var j=0,line;line=posi tion.lines[j];j++){context.fillText(lines[j].text,line[0],line[1])}}else{positio ns.splice(i--,1)}}if(positions.length==0){delete styleCache[key]}}}}}}}context.r estore()};Canvas.prototype.getTextInfo=function(layer,text,font,angle,width){if( !plot.getOptions().canvas){return getTextInfo.call(this,layer,text,font,angle,wi dth)}var textStyle,layerCache,styleCache,info;text=""+text;if(typeof font==="obj ect"){textStyle=font.style+" "+font.variant+" "+font.weight+" "+font.size+"px "+ font.family}else{textStyle=font}layerCache=this._textCache[layer];if(layerCache= =null){layerCache=this._textCache[layer]={}}styleCache=layerCache[textStyle];if( styleCache==null){styleCache=layerCache[textStyle]={}}info=styleCache[text];if(i nfo==null){var context=this.context;if(typeof font!=="object"){var element=$("<d iv>&nbsp;</div>").css("position","absolute").addClass(typeof font==="string"?fon t:null).appendTo(this.getTextLayer(layer));font={lineHeight:element.height(),sty le:element.css("font-style"),variant:element.css("font-variant"),weight:element. css("font-weight"),family:element.css("font-family"),color:element.css("color")} ;font.size=element.css("line-height",1).height();element.remove()}textStyle=font .style+" "+font.variant+" "+font.weight+" "+font.size+"px "+font.family;info=sty leCache[text]={width:0,height:0,positions:[],lines:[],font:{definition:textStyle ,color:font.color}};context.save();context.font=textStyle;var lines=(text+"").re place(/<br ?\/?>|\r\n|\r/g,"\n").split("\n");for(var i=0;i<lines.length;++i){var lineText=lines[i],measured=context.measureText(lineText);info.width=Math.max(me asured.width,info.width);info.height+=font.lineHeight;info.lines.push({text:line Text,width:measured.width,height:font.lineHeight})}context.restore()}return info };Canvas.prototype.addText=function(layer,x,y,text,font,angle,width,halign,valig n){if(!plot.getOptions().canvas){return addText.call(this,layer,x,y,text,font,an gle,width,halign,valign)}var info=this.getTextInfo(layer,text,font,angle,width), positions=info.positions,lines=info.lines;y+=info.height/lines.length/2;if(valig n=="middle"){y=Math.round(y-info.height/2)}else if(valign=="bottom"){y=Math.roun d(y-info.height)}else{y=Math.round(y)}if(!!(window.opera&&window.opera.version() .split(".")[0]<12)){y-=2}for(var i=0,position;position=positions[i];i++){if(posi tion.x==x&&position.y==y){position.active=true;return}}position={active:true,lin es:[],x:x,y:y};positions.push(position);for(var i=0,line;line=lines[i];i++){if(h align=="center"){position.lines.push([Math.round(x-line.width/2),y])}else if(hal ign=="right"){position.lines.push([Math.round(x-line.width),y])}else{position.li nes.push([Math.round(x),y])}y+=line.height}}}$.plot.plugins.push({init:init,opti ons:options,name:"canvas",version:"1.0"})})(jQuery);
OLDNEW
« no previous file with comments | « third_party/flot/jquery.flot.canvas.js ('k') | third_party/flot/jquery.flot.categories.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698