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

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

Issue 22357004: Roll the Flot JavaScript plotting library to 0.8.1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /* Flot plugin for drawing all elements of a plot on the canvas.
2
3 Copyright (c) 2007-2013 IOLA and Ole Laursen.
4 Licensed under the MIT license.
5
6 Flot normally produces certain elements, like axis labels and the legend, using
7 HTML elements. This permits greater interactivity and customization, and often
8 looks better, due to cross-browser canvas text inconsistencies and limitations.
9
10 It can also be desirable to render the plot entirely in canvas, particularly
11 if the goal is to save it as an image, or if Flot is being used in a context
12 where the HTML DOM does not exist, as is the case within Node.js. This plugin
13 switches out Flot's standard drawing operations for canvas-only replacements.
14
15 Currently the plugin supports only axis labels, but it will eventually allow
16 every element of the plot to be rendered directly to canvas.
17
18 The plugin supports these options:
19
20 {
21 canvas: boolean
22 }
23
24 The "canvas" option controls whether full canvas drawing is enabled, making it
25 possible to toggle on and off. This is useful when a plot uses HTML text in the
26 browser, but needs to redraw with canvas text when exporting as an image.
27
28 */(function(e){function o(t,o){var u=o.Canvas;n==null&&(r=u.prototype.getTextInf o,i=u.prototype.addText,n=u.prototype.render),u.prototype.render=function(){if(! t.getOptions().canvas)return n.call(this);var e=this.context,r=this._textCache;e .save(),e.textBaseline="middle";for(var i in r)if(s.call(r,i)){var o=r[i];for(va r u in o)if(s.call(o,u)){var a=o[u],f=!0;for(var l in a)if(s.call(a,l)){var c=a[ l],h=c.positions,p=c.lines;f&&(e.fillStyle=c.font.color,e.font=c.font.definition ,f=!1);for(var d=0,v;v=h[d];d++)if(v.active)for(var m=0,g;g=v.lines[m];m++)e.fil lText(p[m].text,g[0],g[1]);else h.splice(d--,1);h.length==0&&delete a[l]}}}e.res tore()},u.prototype.getTextInfo=function(n,i,s,o,u){if(!t.getOptions().canvas)re turn r.call(this,n,i,s,o,u);var a,f,l,c;i=""+i,typeof s=="object"?a=s.style+" "+ s.variant+" "+s.weight+" "+s.size+"px "+s.family:a=s,f=this._textCache[n],f==nul l&&(f=this._textCache[n]={}),l=f[a],l==null&&(l=f[a]={}),c=l[i];if(c==null){var h=this.context;if(typeof s!="object"){var p=e("<div>&nbsp;</div>").css("position ","absolute").addClass(typeof s=="string"?s:null).appendTo(this.getTextLayer(n)) ;s={lineHeight:p.height(),style:p.css("font-style"),variant:p.css("font-variant" ),weight:p.css("font-weight"),family:p.css("font-family"),color:p.css("color")}, s.size=p.css("line-height",1).height(),p.remove()}a=s.style+" "+s.variant+" "+s. weight+" "+s.size+"px "+s.family,c=l[i]={width:0,height:0,positions:[],lines:[], font:{definition:a,color:s.color}},h.save(),h.font=a;var d=(i+"").replace(/<br ? \/?>|\r\n|\r/g,"\n").split("\n");for(var v=0;v<d.length;++v){var m=d[v],g=h.meas ureText(m);c.width=Math.max(g.width,c.width),c.height+=s.lineHeight,c.lines.push ({text:m,width:g.width,height:s.lineHeight})}h.restore()}return c},u.prototype.a ddText=function(e,n,r,s,o,u,a,f,l){if(!t.getOptions().canvas)return i.call(this, e,n,r,s,o,u,a,f,l);var c=this.getTextInfo(e,s,o,u,a),h=c.positions,p=c.lines;r+= c.height/p.length/2,l=="middle"?r=Math.round(r-c.height/2):l=="bottom"?r=Math.ro und(r-c.height):r=Math.round(r),!(window.opera&&window.opera.version().split("." )[0]<12)||(r-=2);for(var d=0,v;v=h[d];d++)if(v.x==n&&v.y==r){v.active=!0;return} v={active:!0,lines:[],x:n,y:r},h.push(v);for(var d=0,m;m=p[d];d++)f=="center"?v. lines.push([Math.round(n-m.width/2),r]):f=="right"?v.lines.push([Math.round(n-m. width),r]):v.lines.push([Math.round(n),r]),r+=m.height}}var t={canvas:!0},n,r,i, s=Object.prototype.hasOwnProperty;e.plot.plugins.push({init:o,options:t,name:"ca nvas",version:"1.0"})})(jQuery);
OLDNEW
« no previous file with comments | « third_party/flot/jquery.colorhelpers.min.js ('k') | third_party/flot/jquery.flot.categories.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698