flot-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 854741497e7baa12b564432c785a81928abfc8f9
4
+ data.tar.gz: a59ccf685ed4b437e76139ebe84d85b28e2429eb
5
+ SHA512:
6
+ metadata.gz: e8fddd3f69226e58cff2faf1ea1e150e0be07ef4b5b670115c765ac28adf7b2aa78feda9949705432cb2852de9f3fe56c54051a0f2d78c7067468ac23a5631ed
7
+ data.tar.gz: b59be6ffde468f138fddce39bfb70e8bc06c0dc893559c24f5455847b22243b6abe5ba59ff6ac6e4595260677e6da718cf98fd5ea56f7b4ce4826477be9b6ab4
@@ -1,6 +1,6 @@
1
1
  module Flot
2
2
  module Rails
3
- VERSION = "0.0.4"
4
- FLOT_VERSION = "0.8.1"
3
+ VERSION = "0.0.5"
4
+ FLOT_VERSION = "0.8.2"
5
5
  end
6
6
  end
@@ -74,14 +74,15 @@
74
74
  // if it's "transparent"
75
75
  $.color.extract = function (elem, css) {
76
76
  var c;
77
+
77
78
  do {
78
79
  c = elem.css(css).toLowerCase();
79
80
  // keep going until we find an element that has color, or
80
- // we hit the body
81
+ // we hit the body or root (have no parent)
81
82
  if (c != '' && c != 'transparent')
82
83
  break;
83
84
  elem = elem.parent();
84
- } while (!$.nodeName(elem.get(0), "body"));
85
+ } while (elem.length && !$.nodeName(elem.get(0), "body"));
85
86
 
86
87
  // catch Safari's way of signalling transparent
87
88
  if (c == "rgba(0, 0, 0, 0)")
@@ -1,21 +1 @@
1
- /* Plugin for jQuery for working with colors.
2
- *
3
- * Version 1.1.
4
- *
5
- * Inspiration from jQuery color animation plugin by John Resig.
6
- *
7
- * Released under the MIT license by Ole Laursen, October 2009.
8
- *
9
- * Examples:
10
- *
11
- * $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
12
- * var c = $.color.extract($("#mydiv"), 'background-color');
13
- * console.log(c.r, c.g, c.b, c.a);
14
- * $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
15
- *
16
- * Note that .scale() and .add() return the same modified object
17
- * instead of making a new one.
18
- *
19
- * V. 1.1: Fix error handling so e.g. parsing an empty string does
20
- * produce a color rather than just crashing.
21
- */(function(e){e.color={},e.color.make=function(t,n,r,i){var s={};return s.r=t||0,s.g=n||0,s.b=r||0,s.a=i!=null?i:1,s.add=function(e,t){for(var n=0;n<e.length;++n)s[e.charAt(n)]+=t;return s.normalize()},s.scale=function(e,t){for(var n=0;n<e.length;++n)s[e.charAt(n)]*=t;return s.normalize()},s.toString=function(){return s.a>=1?"rgb("+[s.r,s.g,s.b].join(",")+")":"rgba("+[s.r,s.g,s.b,s.a].join(",")+")"},s.normalize=function(){function e(e,t,n){return t<e?e:t>n?n:t}return s.r=e(0,parseInt(s.r),255),s.g=e(0,parseInt(s.g),255),s.b=e(0,parseInt(s.b),255),s.a=e(0,s.a,1),s},s.clone=function(){return e.color.make(s.r,s.b,s.g,s.a)},s.normalize()},e.color.extract=function(t,n){var r;do{r=t.css(n).toLowerCase();if(r!=""&&r!="transparent")break;t=t.parent()}while(!e.nodeName(t.get(0),"body"));return r=="rgba(0, 0, 0, 0)"&&(r="transparent"),e.color.parse(r)},e.color.parse=function(n){var r,i=e.color.make;if(r=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(n))return i(parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10));if(r=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(n))return i(parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4]));if(r=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(n))return i(parseFloat(r[1])*2.55,parseFloat(r[2])*2.55,parseFloat(r[3])*2.55);if(r=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(n))return i(parseFloat(r[1])*2.55,parseFloat(r[2])*2.55,parseFloat(r[3])*2.55,parseFloat(r[4]));if(r=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(n))return i(parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16));if(r=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(n))return i(parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16));var s=e.trim(n).toLowerCase();return s=="transparent"?i(255,255,255,0):(r=t[s]||[0,0,0],i(r[0],r[1],r[2]))};var t={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
1
+ (function($){$.color={};$.color.make=function(r,g,b,a){var o={};o.r=r||0;o.g=g||0;o.b=b||0;o.a=a!=null?a:1;o.add=function(c,d){for(var i=0;i<c.length;++i)o[c.charAt(i)]+=d;return o.normalize()};o.scale=function(c,f){for(var i=0;i<c.length;++i)o[c.charAt(i)]*=f;return o.normalize()};o.toString=function(){if(o.a>=1){return"rgb("+[o.r,o.g,o.b].join(",")+")"}else{return"rgba("+[o.r,o.g,o.b,o.a].join(",")+")"}};o.normalize=function(){function clamp(min,value,max){return value<min?min:value>max?max:value}o.r=clamp(0,parseInt(o.r),255);o.g=clamp(0,parseInt(o.g),255);o.b=clamp(0,parseInt(o.b),255);o.a=clamp(0,o.a,1);return o};o.clone=function(){return $.color.make(o.r,o.b,o.g,o.a)};return o.normalize()};$.color.extract=function(elem,css){var c;do{c=elem.css(css).toLowerCase();if(c!=""&&c!="transparent")break;elem=elem.parent()}while(elem.length&&!$.nodeName(elem.get(0),"body"));if(c=="rgba(0, 0, 0, 0)")c="transparent";return $.color.parse(c)};$.color.parse=function(str){var res,m=$.color.make;if(res=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10));if(res=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10),parseFloat(res[4]));if(res=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55);if(res=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55,parseFloat(res[4]));if(res=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))return m(parseInt(res[1],16),parseInt(res[2],16),parseInt(res[3],16));if(res=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))return m(parseInt(res[1]+res[1],16),parseInt(res[2]+res[2],16),parseInt(res[3]+res[3],16));var name=$.trim(str).toLowerCase();if(name=="transparent")return m(255,255,255,0);else{res=lookupColors[name]||[0,0,0];return m(res[0],res[1],res[2])}};var lookupColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
@@ -1,28 +1 @@
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.getTextInfo,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(var 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.fillText(p[m].text,g[0],g[1]);else h.splice(d--,1);h.length==0&&delete a[l]}}}e.restore()},u.prototype.getTextInfo=function(n,i,s,o,u){if(!t.getOptions().canvas)return 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==null&&(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.measureText(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.addText=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.round(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:"canvas",version:"1.0"})})(jQuery);
1
+ (function($){var options={canvas:true};var render,getTextInfo,addText;var hasOwnProperty=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=this.context,cache=this._textCache;context.save();context.textBaseline="middle";for(var layerKey in cache){if(hasOwnProperty.call(cache,layerKey)){var layerCache=cache[layerKey];for(var styleKey in layerCache){if(hasOwnProperty.call(layerCache,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=info.font.color;context.font=info.font.definition;updateStyles=false}for(var i=0,position;position=positions[i];i++){if(position.active){for(var j=0,line;line=position.lines[j];j++){context.fillText(lines[j].text,line[0],line[1])}}else{positions.splice(i--,1)}}if(positions.length==0){delete styleCache[key]}}}}}}}context.restore()};Canvas.prototype.getTextInfo=function(layer,text,font,angle,width){if(!plot.getOptions().canvas){return getTextInfo.call(this,layer,text,font,angle,width)}var textStyle,layerCache,styleCache,info;text=""+text;if(typeof font==="object"){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(info==null){var context=this.context;if(typeof font!=="object"){var element=$("<div>&nbsp;</div>").css("position","absolute").addClass(typeof font==="string"?font:null).appendTo(this.getTextLayer(layer));font={lineHeight:element.height(),style: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=styleCache[text]={width:0,height:0,positions:[],lines:[],font:{definition:textStyle,color:font.color}};context.save();context.font=textStyle;var lines=(text+"").replace(/<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(measured.width,info.width);info.height+=font.lineHeight;info.lines.push({text:lineText,width:measured.width,height:font.lineHeight})}context.restore()}return info};Canvas.prototype.addText=function(layer,x,y,text,font,angle,width,halign,valign){if(!plot.getOptions().canvas){return addText.call(this,layer,x,y,text,font,angle,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(valign=="middle"){y=Math.round(y-info.height/2)}else if(valign=="bottom"){y=Math.round(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(position.x==x&&position.y==y){position.active=true;return}}position={active:true,lines:[],x:x,y:y};positions.push(position);for(var i=0,line;line=lines[i];i++){if(halign=="center"){position.lines.push([Math.round(x-line.width/2),y])}else if(halign=="right"){position.lines.push([Math.round(x-line.width),y])}else{position.lines.push([Math.round(x),y])}y+=line.height}}}$.plot.plugins.push({init:init,options:options,name:"canvas",version:"1.0"})})(jQuery);
@@ -1,44 +1 @@
1
- /* Flot plugin for plotting textual data or categories.
2
-
3
- Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
- Licensed under the MIT license.
5
-
6
- Consider a dataset like [["February", 34], ["March", 20], ...]. This plugin
7
- allows you to plot such a dataset directly.
8
-
9
- To enable it, you must specify mode: "categories" on the axis with the textual
10
- labels, e.g.
11
-
12
- $.plot("#placeholder", data, { xaxis: { mode: "categories" } });
13
-
14
- By default, the labels are ordered as they are met in the data series. If you
15
- need a different ordering, you can specify "categories" on the axis options
16
- and list the categories there:
17
-
18
- xaxis: {
19
- mode: "categories",
20
- categories: ["February", "March", "April"]
21
- }
22
-
23
- If you need to customize the distances between the categories, you can specify
24
- "categories" as an object mapping labels to values
25
-
26
- xaxis: {
27
- mode: "categories",
28
- categories: { "February": 1, "March": 3, "April": 4 }
29
- }
30
-
31
- If you don't specify all categories, the remaining categories will be numbered
32
- from the max value plus 1 (with a spacing of 1 between each).
33
-
34
- Internally, the plugin works by transforming the input data through an auto-
35
- generated mapping where the first category becomes 0, the second 1, etc.
36
- Hence, a point like ["February", 34] becomes [0, 34] internally in Flot (this
37
- is visible in hover and click events that return numbers rather than the
38
- category labels). The plugin also overrides the tick generator to spit out the
39
- categories as ticks instead of the values.
40
-
41
- If you need to map a value back to its label, the mapping is always accessible
42
- as "categories" on the axis object, e.g. plot.getAxes().xaxis.categories.
43
-
44
- */(function(e){function n(e,t,n,r){var i=t.xaxis.options.mode=="categories",s=t.yaxis.options.mode=="categories";if(!i&&!s)return;var o=r.format;if(!o){var u=t;o=[],o.push({x:!0,number:!0,required:!0}),o.push({y:!0,number:!0,required:!0});if(u.bars.show||u.lines.show&&u.lines.fill){var a=!!(u.bars.show&&u.bars.zero||u.lines.show&&u.lines.zero);o.push({y:!0,number:!0,required:!1,defaultValue:0,autoscale:a}),u.bars.horizontal&&(delete o[o.length-1].y,o[o.length-1].x=!0)}r.format=o}for(var f=0;f<o.length;++f)o[f].x&&i&&(o[f].number=!1),o[f].y&&s&&(o[f].number=!1)}function r(e){var t=-1;for(var n in e)e[n]>t&&(t=e[n]);return t+1}function i(e){var t=[];for(var n in e.categories){var r=e.categories[n];r>=e.min&&r<=e.max&&t.push([r,n])}return t.sort(function(e,t){return e[0]-t[0]}),t}function s(t,n,r){if(t[n].options.mode!="categories")return;if(!t[n].categories){var s={},u=t[n].options.categories||{};if(e.isArray(u))for(var a=0;a<u.length;++a)s[u[a]]=a;else for(var f in u)s[f]=u[f];t[n].categories=s}t[n].options.ticks||(t[n].options.ticks=i),o(r,n,t[n].categories)}function o(e,t,n){var i=e.points,s=e.pointsize,o=e.format,u=t.charAt(0),a=r(n);for(var f=0;f<i.length;f+=s){if(i[f]==null)continue;for(var l=0;l<s;++l){var c=i[f+l];if(c==null||!o[l][u])continue;c in n||(n[c]=a,++a),i[f+l]=n[c]}}}function u(e,t,n){s(t,"xaxis",n),s(t,"yaxis",n)}function a(e){e.hooks.processRawData.push(n),e.hooks.processDatapoints.push(u)}var t={xaxis:{categories:null},yaxis:{categories:null}};e.plot.plugins.push({init:a,options:t,name:"categories",version:"1.0"})})(jQuery);
1
+ (function($){var options={xaxis:{categories:null},yaxis:{categories:null}};function processRawData(plot,series,data,datapoints){var xCategories=series.xaxis.options.mode=="categories",yCategories=series.yaxis.options.mode=="categories";if(!(xCategories||yCategories))return;var format=datapoints.format;if(!format){var s=series;format=[];format.push({x:true,number:true,required:true});format.push({y:true,number:true,required:true});if(s.bars.show||s.lines.show&&s.lines.fill){var autoscale=!!(s.bars.show&&s.bars.zero||s.lines.show&&s.lines.zero);format.push({y:true,number:true,required:false,defaultValue:0,autoscale:autoscale});if(s.bars.horizontal){delete format[format.length-1].y;format[format.length-1].x=true}}datapoints.format=format}for(var m=0;m<format.length;++m){if(format[m].x&&xCategories)format[m].number=false;if(format[m].y&&yCategories)format[m].number=false}}function getNextIndex(categories){var index=-1;for(var v in categories)if(categories[v]>index)index=categories[v];return index+1}function categoriesTickGenerator(axis){var res=[];for(var label in axis.categories){var v=axis.categories[label];if(v>=axis.min&&v<=axis.max)res.push([v,label])}res.sort(function(a,b){return a[0]-b[0]});return res}function setupCategoriesForAxis(series,axis,datapoints){if(series[axis].options.mode!="categories")return;if(!series[axis].categories){var c={},o=series[axis].options.categories||{};if($.isArray(o)){for(var i=0;i<o.length;++i)c[o[i]]=i}else{for(var v in o)c[v]=o[v]}series[axis].categories=c}if(!series[axis].options.ticks)series[axis].options.ticks=categoriesTickGenerator;transformPointsOnAxis(datapoints,axis,series[axis].categories)}function transformPointsOnAxis(datapoints,axis,categories){var points=datapoints.points,ps=datapoints.pointsize,format=datapoints.format,formatColumn=axis.charAt(0),index=getNextIndex(categories);for(var i=0;i<points.length;i+=ps){if(points[i]==null)continue;for(var m=0;m<ps;++m){var val=points[i+m];if(val==null||!format[m][formatColumn])continue;if(!(val in categories)){categories[val]=index;++index}points[i+m]=categories[val]}}}function processDatapoints(plot,series,datapoints){setupCategoriesForAxis(series,"xaxis",datapoints);setupCategoriesForAxis(series,"yaxis",datapoints)}function init(plot){plot.hooks.processRawData.push(processRawData);plot.hooks.processDatapoints.push(processDatapoints)}$.plot.plugins.push({init:init,options:options,name:"categories",version:"1.0"})})(jQuery);
@@ -1,59 +1 @@
1
- /* Flot plugin for showing crosshairs when the mouse hovers over the plot.
2
-
3
- Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
- Licensed under the MIT license.
5
-
6
- The plugin supports these options:
7
-
8
- crosshair: {
9
- mode: null or "x" or "y" or "xy"
10
- color: color
11
- lineWidth: number
12
- }
13
-
14
- Set the mode to one of "x", "y" or "xy". The "x" mode enables a vertical
15
- crosshair that lets you trace the values on the x axis, "y" enables a
16
- horizontal crosshair and "xy" enables them both. "color" is the color of the
17
- crosshair (default is "rgba(170, 0, 0, 0.80)"), "lineWidth" is the width of
18
- the drawn lines (default is 1).
19
-
20
- The plugin also adds four public methods:
21
-
22
- - setCrosshair( pos )
23
-
24
- Set the position of the crosshair. Note that this is cleared if the user
25
- moves the mouse. "pos" is in coordinates of the plot and should be on the
26
- form { x: xpos, y: ypos } (you can use x2/x3/... if you're using multiple
27
- axes), which is coincidentally the same format as what you get from a
28
- "plothover" event. If "pos" is null, the crosshair is cleared.
29
-
30
- - clearCrosshair()
31
-
32
- Clear the crosshair.
33
-
34
- - lockCrosshair(pos)
35
-
36
- Cause the crosshair to lock to the current location, no longer updating if
37
- the user moves the mouse. Optionally supply a position (passed on to
38
- setCrosshair()) to move it to.
39
-
40
- Example usage:
41
-
42
- var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
43
- $("#graph").bind( "plothover", function ( evt, position, item ) {
44
- if ( item ) {
45
- // Lock the crosshair to the data point being hovered
46
- myFlot.lockCrosshair({
47
- x: item.datapoint[ 0 ],
48
- y: item.datapoint[ 1 ]
49
- });
50
- } else {
51
- // Return normal crosshair operation
52
- myFlot.unlockCrosshair();
53
- }
54
- });
55
-
56
- - unlockCrosshair()
57
-
58
- Free the crosshair to move again after locking it.
59
- */(function(e){function n(e){function n(n){if(t.locked)return;t.x!=-1&&(t.x=-1,e.triggerRedrawOverlay())}function r(n){if(t.locked)return;if(e.getSelection&&e.getSelection()){t.x=-1;return}var r=e.offset();t.x=Math.max(0,Math.min(n.pageX-r.left,e.width())),t.y=Math.max(0,Math.min(n.pageY-r.top,e.height())),e.triggerRedrawOverlay()}var t={x:-1,y:-1,locked:!1};e.setCrosshair=function(r){if(!r)t.x=-1;else{var i=e.p2c(r);t.x=Math.max(0,Math.min(i.left,e.width())),t.y=Math.max(0,Math.min(i.top,e.height()))}e.triggerRedrawOverlay()},e.clearCrosshair=e.setCrosshair,e.lockCrosshair=function(r){r&&e.setCrosshair(r),t.locked=!0},e.unlockCrosshair=function(){t.locked=!1},e.hooks.bindEvents.push(function(e,t){if(!e.getOptions().crosshair.mode)return;t.mouseout(n),t.mousemove(r)}),e.hooks.drawOverlay.push(function(e,n){var r=e.getOptions().crosshair;if(!r.mode)return;var i=e.getPlotOffset();n.save(),n.translate(i.left,i.top);if(t.x!=-1){var s=e.getOptions().crosshair.lineWidth%2===0?0:.5;n.strokeStyle=r.color,n.lineWidth=r.lineWidth,n.lineJoin="round",n.beginPath();if(r.mode.indexOf("x")!=-1){var o=Math.round(t.x)+s;n.moveTo(o,0),n.lineTo(o,e.height())}if(r.mode.indexOf("y")!=-1){var u=Math.round(t.y)+s;n.moveTo(0,u),n.lineTo(e.width(),u)}n.stroke()}n.restore()}),e.hooks.shutdown.push(function(e,t){t.unbind("mouseout",n),t.unbind("mousemove",r)})}var t={crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}};e.plot.plugins.push({init:n,options:t,name:"crosshair",version:"1.0"})})(jQuery);
1
+ (function($){var options={crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}};function init(plot){var crosshair={x:-1,y:-1,locked:false};plot.setCrosshair=function setCrosshair(pos){if(!pos)crosshair.x=-1;else{var o=plot.p2c(pos);crosshair.x=Math.max(0,Math.min(o.left,plot.width()));crosshair.y=Math.max(0,Math.min(o.top,plot.height()))}plot.triggerRedrawOverlay()};plot.clearCrosshair=plot.setCrosshair;plot.lockCrosshair=function lockCrosshair(pos){if(pos)plot.setCrosshair(pos);crosshair.locked=true};plot.unlockCrosshair=function unlockCrosshair(){crosshair.locked=false};function onMouseOut(e){if(crosshair.locked)return;if(crosshair.x!=-1){crosshair.x=-1;plot.triggerRedrawOverlay()}}function onMouseMove(e){if(crosshair.locked)return;if(plot.getSelection&&plot.getSelection()){crosshair.x=-1;return}var offset=plot.offset();crosshair.x=Math.max(0,Math.min(e.pageX-offset.left,plot.width()));crosshair.y=Math.max(0,Math.min(e.pageY-offset.top,plot.height()));plot.triggerRedrawOverlay()}plot.hooks.bindEvents.push(function(plot,eventHolder){if(!plot.getOptions().crosshair.mode)return;eventHolder.mouseout(onMouseOut);eventHolder.mousemove(onMouseMove)});plot.hooks.drawOverlay.push(function(plot,ctx){var c=plot.getOptions().crosshair;if(!c.mode)return;var plotOffset=plot.getPlotOffset();ctx.save();ctx.translate(plotOffset.left,plotOffset.top);if(crosshair.x!=-1){var adj=plot.getOptions().crosshair.lineWidth%2===0?0:.5;ctx.strokeStyle=c.color;ctx.lineWidth=c.lineWidth;ctx.lineJoin="round";ctx.beginPath();if(c.mode.indexOf("x")!=-1){var drawX=Math.round(crosshair.x)+adj;ctx.moveTo(drawX,0);ctx.lineTo(drawX,plot.height())}if(c.mode.indexOf("y")!=-1){var drawY=Math.round(crosshair.y)+adj;ctx.moveTo(0,drawY);ctx.lineTo(plot.width(),drawY)}ctx.stroke()}ctx.restore()});plot.hooks.shutdown.push(function(plot,eventHolder){eventHolder.unbind("mouseout",onMouseOut);eventHolder.unbind("mousemove",onMouseMove)})}$.plot.plugins.push({init:init,options:options,name:"crosshair",version:"1.0"})})(jQuery);
@@ -1,63 +1 @@
1
- /* Flot plugin for plotting error bars.
2
-
3
- Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
- Licensed under the MIT license.
5
-
6
- Error bars are used to show standard deviation and other statistical
7
- properties in a plot.
8
-
9
- * Created by Rui Pereira - rui (dot) pereira (at) gmail (dot) com
10
-
11
- This plugin allows you to plot error-bars over points. Set "errorbars" inside
12
- the points series to the axis name over which there will be error values in
13
- your data array (*even* if you do not intend to plot them later, by setting
14
- "show: null" on xerr/yerr).
15
-
16
- The plugin supports these options:
17
-
18
- series: {
19
- points: {
20
- errorbars: "x" or "y" or "xy",
21
- xerr: {
22
- show: null/false or true,
23
- asymmetric: null/false or true,
24
- upperCap: null or "-" or function,
25
- lowerCap: null or "-" or function,
26
- color: null or color,
27
- radius: null or number
28
- },
29
- yerr: { same options as xerr }
30
- }
31
- }
32
-
33
- Each data point array is expected to be of the type:
34
-
35
- "x" [ x, y, xerr ]
36
- "y" [ x, y, yerr ]
37
- "xy" [ x, y, xerr, yerr ]
38
-
39
- Where xerr becomes xerr_lower,xerr_upper for the asymmetric error case, and
40
- equivalently for yerr. Eg., a datapoint for the "xy" case with symmetric
41
- error-bars on X and asymmetric on Y would be:
42
-
43
- [ x, y, xerr, yerr_lower, yerr_upper ]
44
-
45
- By default no end caps are drawn. Setting upperCap and/or lowerCap to "-" will
46
- draw a small cap perpendicular to the error bar. They can also be set to a
47
- user-defined drawing function, with (ctx, x, y, radius) as parameters, as eg.
48
-
49
- function drawSemiCircle( ctx, x, y, radius ) {
50
- ctx.beginPath();
51
- ctx.arc( x, y, radius, 0, Math.PI, false );
52
- ctx.moveTo( x - radius, y );
53
- ctx.lineTo( x + radius, y );
54
- ctx.stroke();
55
- }
56
-
57
- Color and radius both default to the same ones of the points series if not
58
- set. The independent radius parameter on xerr/yerr is useful for the case when
59
- we may want to add error-bars to a line, without showing the interconnecting
60
- points (with radius: 0), and still showing end caps on the error-bars.
61
- shadowSize and lineWidth are derived as well from the points series.
62
-
63
- */(function(e){function n(e,t,n,r){if(!t.points.errorbars)return;var i=[{x:!0,number:!0,required:!0},{y:!0,number:!0,required:!0}],s=t.points.errorbars;if(s=="x"||s=="xy")t.points.xerr.asymmetric?(i.push({x:!0,number:!0,required:!0}),i.push({x:!0,number:!0,required:!0})):i.push({x:!0,number:!0,required:!0});if(s=="y"||s=="xy")t.points.yerr.asymmetric?(i.push({y:!0,number:!0,required:!0}),i.push({y:!0,number:!0,required:!0})):i.push({y:!0,number:!0,required:!0});r.format=i}function r(e,t){var n=e.datapoints.points,r=null,i=null,s=null,o=null,u=e.points.xerr,a=e.points.yerr,f=e.points.errorbars;f=="x"||f=="xy"?u.asymmetric?(r=n[t+2],i=n[t+3],f=="xy"&&(a.asymmetric?(s=n[t+4],o=n[t+5]):s=n[t+4])):(r=n[t+2],f=="xy"&&(a.asymmetric?(s=n[t+3],o=n[t+4]):s=n[t+3])):f=="y"&&(a.asymmetric?(s=n[t+2],o=n[t+3]):s=n[t+2]),i==null&&(i=r),o==null&&(o=s);var l=[r,i,s,o];return u.show||(l[0]=null,l[1]=null),a.show||(l[2]=null,l[3]=null),l}function i(e,t,n){var i=n.datapoints.points,o=n.datapoints.pointsize,u=[n.xaxis,n.yaxis],a=n.points.radius,f=[n.points.xerr,n.points.yerr],l=!1;if(u[0].p2c(u[0].max)<u[0].p2c(u[0].min)){l=!0;var c=f[0].lowerCap;f[0].lowerCap=f[0].upperCap,f[0].upperCap=c}var h=!1;if(u[1].p2c(u[1].min)<u[1].p2c(u[1].max)){h=!0;var c=f[1].lowerCap;f[1].lowerCap=f[1].upperCap,f[1].upperCap=c}for(var p=0;p<n.datapoints.points.length;p+=o){var d=r(n,p);for(var v=0;v<f.length;v++){var m=[u[v].min,u[v].max];if(d[v*f.length]){var g=i[p],y=i[p+1],b=[g,y][v]+d[v*f.length+1],w=[g,y][v]-d[v*f.length];if(f[v].err=="x")if(y>u[1].max||y<u[1].min||b<u[0].min||w>u[0].max)continue;if(f[v].err=="y")if(g>u[0].max||g<u[0].min||b<u[1].min||w>u[1].max)continue;var E=!0,S=!0;b>m[1]&&(E=!1,b=m[1]),w<m[0]&&(S=!1,w=m[0]);if(f[v].err=="x"&&l||f[v].err=="y"&&h){var c=w;w=b,b=c,c=S,S=E,E=c,c=m[0],m[0]=m[1],m[1]=c}g=u[0].p2c(g),y=u[1].p2c(y),b=u[v].p2c(b),w=u[v].p2c(w),m[0]=u[v].p2c(m[0]),m[1]=u[v].p2c(m[1]);var x=f[v].lineWidth?f[v].lineWidth:n.points.lineWidth,T=n.points.shadowSize!=null?n.points.shadowSize:n.shadowSize;if(x>0&&T>0){var N=T/2;t.lineWidth=N,t.strokeStyle="rgba(0,0,0,0.1)",s(t,f[v],g,y,b,w,E,S,a,N+N/2,m),t.strokeStyle="rgba(0,0,0,0.2)",s(t,f[v],g,y,b,w,E,S,a,N/2,m)}t.strokeStyle=f[v].color?f[v].color:n.color,t.lineWidth=x,s(t,f[v],g,y,b,w,E,S,a,0,m)}}}}function s(t,n,r,i,s,u,a,f,l,c,h){i+=c,s+=c,u+=c,n.err=="x"?(s>r+l?o(t,[[s,i],[Math.max(r+l,h[0]),i]]):a=!1,u<r-l?o(t,[[Math.min(r-l,h[1]),i],[u,i]]):f=!1):(s<i-l?o(t,[[r,s],[r,Math.min(i-l,h[0])]]):a=!1,u>i+l?o(t,[[r,Math.max(i+l,h[1])],[r,u]]):f=!1),l=n.radius!=null?n.radius:l,a&&(n.upperCap=="-"?n.err=="x"?o(t,[[s,i-l],[s,i+l]]):o(t,[[r-l,s],[r+l,s]]):e.isFunction(n.upperCap)&&(n.err=="x"?n.upperCap(t,s,i,l):n.upperCap(t,r,s,l))),f&&(n.lowerCap=="-"?n.err=="x"?o(t,[[u,i-l],[u,i+l]]):o(t,[[r-l,u],[r+l,u]]):e.isFunction(n.lowerCap)&&(n.err=="x"?n.lowerCap(t,u,i,l):n.lowerCap(t,r,u,l)))}function o(e,t){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(var n=1;n<t.length;n++)e.lineTo(t[n][0],t[n][1]);e.stroke()}function u(t,n){var r=t.getPlotOffset();n.save(),n.translate(r.left,r.top),e.each(t.getData(),function(e,r){r.points.errorbars&&(r.points.xerr.show||r.points.yerr.show)&&i(t,n,r)}),n.restore()}function a(e){e.hooks.processRawData.push(n),e.hooks.draw.push(u)}var t={series:{points:{errorbars:null,xerr:{err:"x",show:null,asymmetric:null,upperCap:null,lowerCap:null,color:null,radius:null},yerr:{err:"y",show:null,asymmetric:null,upperCap:null,lowerCap:null,color:null,radius:null}}}};e.plot.plugins.push({init:a,options:t,name:"errorbars",version:"1.0"})})(jQuery);
1
+ (function($){var options={series:{points:{errorbars:null,xerr:{err:"x",show:null,asymmetric:null,upperCap:null,lowerCap:null,color:null,radius:null},yerr:{err:"y",show:null,asymmetric:null,upperCap:null,lowerCap:null,color:null,radius:null}}}};function processRawData(plot,series,data,datapoints){if(!series.points.errorbars)return;var format=[{x:true,number:true,required:true},{y:true,number:true,required:true}];var errors=series.points.errorbars;if(errors=="x"||errors=="xy"){if(series.points.xerr.asymmetric){format.push({x:true,number:true,required:true});format.push({x:true,number:true,required:true})}else format.push({x:true,number:true,required:true})}if(errors=="y"||errors=="xy"){if(series.points.yerr.asymmetric){format.push({y:true,number:true,required:true});format.push({y:true,number:true,required:true})}else format.push({y:true,number:true,required:true})}datapoints.format=format}function parseErrors(series,i){var points=series.datapoints.points;var exl=null,exu=null,eyl=null,eyu=null;var xerr=series.points.xerr,yerr=series.points.yerr;var eb=series.points.errorbars;if(eb=="x"||eb=="xy"){if(xerr.asymmetric){exl=points[i+2];exu=points[i+3];if(eb=="xy")if(yerr.asymmetric){eyl=points[i+4];eyu=points[i+5]}else eyl=points[i+4]}else{exl=points[i+2];if(eb=="xy")if(yerr.asymmetric){eyl=points[i+3];eyu=points[i+4]}else eyl=points[i+3]}}else if(eb=="y")if(yerr.asymmetric){eyl=points[i+2];eyu=points[i+3]}else eyl=points[i+2];if(exu==null)exu=exl;if(eyu==null)eyu=eyl;var errRanges=[exl,exu,eyl,eyu];if(!xerr.show){errRanges[0]=null;errRanges[1]=null}if(!yerr.show){errRanges[2]=null;errRanges[3]=null}return errRanges}function drawSeriesErrors(plot,ctx,s){var points=s.datapoints.points,ps=s.datapoints.pointsize,ax=[s.xaxis,s.yaxis],radius=s.points.radius,err=[s.points.xerr,s.points.yerr];var invertX=false;if(ax[0].p2c(ax[0].max)<ax[0].p2c(ax[0].min)){invertX=true;var tmp=err[0].lowerCap;err[0].lowerCap=err[0].upperCap;err[0].upperCap=tmp}var invertY=false;if(ax[1].p2c(ax[1].min)<ax[1].p2c(ax[1].max)){invertY=true;var tmp=err[1].lowerCap;err[1].lowerCap=err[1].upperCap;err[1].upperCap=tmp}for(var i=0;i<s.datapoints.points.length;i+=ps){var errRanges=parseErrors(s,i);for(var e=0;e<err.length;e++){var minmax=[ax[e].min,ax[e].max];if(errRanges[e*err.length]){var x=points[i],y=points[i+1];var upper=[x,y][e]+errRanges[e*err.length+1],lower=[x,y][e]-errRanges[e*err.length];if(err[e].err=="x")if(y>ax[1].max||y<ax[1].min||upper<ax[0].min||lower>ax[0].max)continue;if(err[e].err=="y")if(x>ax[0].max||x<ax[0].min||upper<ax[1].min||lower>ax[1].max)continue;var drawUpper=true,drawLower=true;if(upper>minmax[1]){drawUpper=false;upper=minmax[1]}if(lower<minmax[0]){drawLower=false;lower=minmax[0]}if(err[e].err=="x"&&invertX||err[e].err=="y"&&invertY){var tmp=lower;lower=upper;upper=tmp;tmp=drawLower;drawLower=drawUpper;drawUpper=tmp;tmp=minmax[0];minmax[0]=minmax[1];minmax[1]=tmp}x=ax[0].p2c(x),y=ax[1].p2c(y),upper=ax[e].p2c(upper);lower=ax[e].p2c(lower);minmax[0]=ax[e].p2c(minmax[0]);minmax[1]=ax[e].p2c(minmax[1]);var lw=err[e].lineWidth?err[e].lineWidth:s.points.lineWidth,sw=s.points.shadowSize!=null?s.points.shadowSize:s.shadowSize;if(lw>0&&sw>0){var w=sw/2;ctx.lineWidth=w;ctx.strokeStyle="rgba(0,0,0,0.1)";drawError(ctx,err[e],x,y,upper,lower,drawUpper,drawLower,radius,w+w/2,minmax);ctx.strokeStyle="rgba(0,0,0,0.2)";drawError(ctx,err[e],x,y,upper,lower,drawUpper,drawLower,radius,w/2,minmax)}ctx.strokeStyle=err[e].color?err[e].color:s.color;ctx.lineWidth=lw;drawError(ctx,err[e],x,y,upper,lower,drawUpper,drawLower,radius,0,minmax)}}}}function drawError(ctx,err,x,y,upper,lower,drawUpper,drawLower,radius,offset,minmax){y+=offset;upper+=offset;lower+=offset;if(err.err=="x"){if(upper>x+radius)drawPath(ctx,[[upper,y],[Math.max(x+radius,minmax[0]),y]]);else drawUpper=false;if(lower<x-radius)drawPath(ctx,[[Math.min(x-radius,minmax[1]),y],[lower,y]]);else drawLower=false}else{if(upper<y-radius)drawPath(ctx,[[x,upper],[x,Math.min(y-radius,minmax[0])]]);else drawUpper=false;if(lower>y+radius)drawPath(ctx,[[x,Math.max(y+radius,minmax[1])],[x,lower]]);else drawLower=false}radius=err.radius!=null?err.radius:radius;if(drawUpper){if(err.upperCap=="-"){if(err.err=="x")drawPath(ctx,[[upper,y-radius],[upper,y+radius]]);else drawPath(ctx,[[x-radius,upper],[x+radius,upper]])}else if($.isFunction(err.upperCap)){if(err.err=="x")err.upperCap(ctx,upper,y,radius);else err.upperCap(ctx,x,upper,radius)}}if(drawLower){if(err.lowerCap=="-"){if(err.err=="x")drawPath(ctx,[[lower,y-radius],[lower,y+radius]]);else drawPath(ctx,[[x-radius,lower],[x+radius,lower]])}else if($.isFunction(err.lowerCap)){if(err.err=="x")err.lowerCap(ctx,lower,y,radius);else err.lowerCap(ctx,x,lower,radius)}}}function drawPath(ctx,pts){ctx.beginPath();ctx.moveTo(pts[0][0],pts[0][1]);for(var p=1;p<pts.length;p++)ctx.lineTo(pts[p][0],pts[p][1]);ctx.stroke()}function draw(plot,ctx){var plotOffset=plot.getPlotOffset();ctx.save();ctx.translate(plotOffset.left,plotOffset.top);$.each(plot.getData(),function(i,s){if(s.points.errorbars&&(s.points.xerr.show||s.points.yerr.show))drawSeriesErrors(plot,ctx,s)});ctx.restore()}function init(plot){plot.hooks.processRawData.push(processRawData);plot.hooks.draw.push(draw)}$.plot.plugins.push({init:init,options:options,name:"errorbars",version:"1.0"})})(jQuery);
@@ -1,30 +1 @@
1
- /* Flot plugin for computing bottoms for filled line and bar charts.
2
-
3
- Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
- Licensed under the MIT license.
5
-
6
- The case: you've got two series that you want to fill the area between. In Flot
7
- terms, you need to use one as the fill bottom of the other. You can specify the
8
- bottom of each data point as the third coordinate manually, or you can use this
9
- plugin to compute it for you.
10
-
11
- In order to name the other series, you need to give it an id, like this:
12
-
13
- var dataset = [
14
- { data: [ ... ], id: "foo" } , // use default bottom
15
- { data: [ ... ], fillBetween: "foo" }, // use first dataset as bottom
16
- ];
17
-
18
- $.plot($("#placeholder"), dataset, { lines: { show: true, fill: true }});
19
-
20
- As a convenience, if the id given is a number that doesn't appear as an id in
21
- the series, it is interpreted as the index in the array instead (so fillBetween:
22
- 0 can also mean the first series).
23
-
24
- Internally, the plugin modifies the datapoints in each series. For line series,
25
- extra data points might be inserted through interpolation. Note that at points
26
- where the bottom line is not defined (due to a null point or start/end of line),
27
- the current line will show a gap too. The algorithm comes from the
28
- jquery.flot.stack.js plugin, possibly some code could be shared.
29
-
30
- */(function(e){function n(e){function t(e,t){var n;for(n=0;n<t.length;++n)if(t[n].id===e.fillBetween)return t[n];return typeof e.fillBetween=="number"?e.fillBetween<0||e.fillBetween>=t.length?null:t[e.fillBetween]:null}function n(e,n,r){if(n.fillBetween==null)return;var i=t(n,e.getData());if(!i)return;var s=r.pointsize,o=r.points,u=i.datapoints.pointsize,a=i.datapoints.points,f=[],l,c,h,p,d,v,m=n.lines.show,g=s>2&&r.format[2].y,y=m&&n.lines.steps,b=!0,w=0,E=0,S,x;for(;;){if(w>=o.length)break;S=f.length;if(o[w]==null){for(x=0;x<s;++x)f.push(o[w+x]);w+=s}else if(E>=a.length){if(!m)for(x=0;x<s;++x)f.push(o[w+x]);w+=s}else if(a[E]==null){for(x=0;x<s;++x)f.push(null);b=!0,E+=u}else{l=o[w],c=o[w+1],p=a[E],d=a[E+1],v=0;if(l===p){for(x=0;x<s;++x)f.push(o[w+x]);v=d,w+=s,E+=u}else if(l>p){if(m&&w>0&&o[w-s]!=null){h=c+(o[w-s+1]-c)*(p-l)/(o[w-s]-l),f.push(p),f.push(h);for(x=2;x<s;++x)f.push(o[w+x]);v=d}E+=u}else{if(b&&m){w+=s;continue}for(x=0;x<s;++x)f.push(o[w+x]);m&&E>0&&a[E-u]!=null&&(v=d+(a[E-u+1]-d)*(l-p)/(a[E-u]-p)),w+=s}b=!1,S!==f.length&&g&&(f[S+2]=v)}if(y&&S!==f.length&&S>0&&f[S]!==null&&f[S]!==f[S-s]&&f[S+1]!==f[S-s+1]){for(x=0;x<s;++x)f[S+s+x]=f[S+x];f[S+1]=f[S-s+1]}}r.points=f}e.hooks.processDatapoints.push(n)}var t={series:{fillBetween:null}};e.plot.plugins.push({init:n,options:t,name:"fillbetween",version:"1.0"})})(jQuery);
1
+ (function($){var options={series:{fillBetween:null}};function init(plot){function findBottomSeries(s,allseries){var i;for(i=0;i<allseries.length;++i){if(allseries[i].id===s.fillBetween){return allseries[i]}}if(typeof s.fillBetween==="number"){if(s.fillBetween<0||s.fillBetween>=allseries.length){return null}return allseries[s.fillBetween]}return null}function computeFillBottoms(plot,s,datapoints){if(s.fillBetween==null){return}var other=findBottomSeries(s,plot.getData());if(!other){return}var ps=datapoints.pointsize,points=datapoints.points,otherps=other.datapoints.pointsize,otherpoints=other.datapoints.points,newpoints=[],px,py,intery,qx,qy,bottom,withlines=s.lines.show,withbottom=ps>2&&datapoints.format[2].y,withsteps=withlines&&s.lines.steps,fromgap=true,i=0,j=0,l,m;while(true){if(i>=points.length){break}l=newpoints.length;if(points[i]==null){for(m=0;m<ps;++m){newpoints.push(points[i+m])}i+=ps}else if(j>=otherpoints.length){if(!withlines){for(m=0;m<ps;++m){newpoints.push(points[i+m])}}i+=ps}else if(otherpoints[j]==null){for(m=0;m<ps;++m){newpoints.push(null)}fromgap=true;j+=otherps}else{px=points[i];py=points[i+1];qx=otherpoints[j];qy=otherpoints[j+1];bottom=0;if(px===qx){for(m=0;m<ps;++m){newpoints.push(points[i+m])}bottom=qy;i+=ps;j+=otherps}else if(px>qx){if(withlines&&i>0&&points[i-ps]!=null){intery=py+(points[i-ps+1]-py)*(qx-px)/(points[i-ps]-px);newpoints.push(qx);newpoints.push(intery);for(m=2;m<ps;++m){newpoints.push(points[i+m])}bottom=qy}j+=otherps}else{if(fromgap&&withlines){i+=ps;continue}for(m=0;m<ps;++m){newpoints.push(points[i+m])}if(withlines&&j>0&&otherpoints[j-otherps]!=null){bottom=qy+(otherpoints[j-otherps+1]-qy)*(px-qx)/(otherpoints[j-otherps]-qx)}i+=ps}fromgap=false;if(l!==newpoints.length&&withbottom){newpoints[l+2]=bottom}}if(withsteps&&l!==newpoints.length&&l>0&&newpoints[l]!==null&&newpoints[l]!==newpoints[l-ps]&&newpoints[l+1]!==newpoints[l-ps+1]){for(m=0;m<ps;++m){newpoints[l+ps+m]=newpoints[l+m]}newpoints[l+1]=newpoints[l-ps+1]}}datapoints.points=newpoints}plot.hooks.processDatapoints.push(computeFillBottoms)}$.plot.plugins.push({init:init,options:options,name:"fillbetween",version:"1.0"})})(jQuery);
@@ -1,53 +1 @@
1
- /* Flot plugin for plotting images.
2
-
3
- Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
- Licensed under the MIT license.
5
-
6
- The data syntax is [ [ image, x1, y1, x2, y2 ], ... ] where (x1, y1) and
7
- (x2, y2) are where you intend the two opposite corners of the image to end up
8
- in the plot. Image must be a fully loaded Javascript image (you can make one
9
- with new Image()). If the image is not complete, it's skipped when plotting.
10
-
11
- There are two helpers included for retrieving images. The easiest work the way
12
- that you put in URLs instead of images in the data, like this:
13
-
14
- [ "myimage.png", 0, 0, 10, 10 ]
15
-
16
- Then call $.plot.image.loadData( data, options, callback ) where data and
17
- options are the same as you pass in to $.plot. This loads the images, replaces
18
- the URLs in the data with the corresponding images and calls "callback" when
19
- all images are loaded (or failed loading). In the callback, you can then call
20
- $.plot with the data set. See the included example.
21
-
22
- A more low-level helper, $.plot.image.load(urls, callback) is also included.
23
- Given a list of URLs, it calls callback with an object mapping from URL to
24
- Image object when all images are loaded or have failed loading.
25
-
26
- The plugin supports these options:
27
-
28
- series: {
29
- images: {
30
- show: boolean
31
- anchor: "corner" or "center"
32
- alpha: [ 0, 1 ]
33
- }
34
- }
35
-
36
- They can be specified for a specific series:
37
-
38
- $.plot( $("#placeholder"), [{
39
- data: [ ... ],
40
- images: { ... }
41
- ])
42
-
43
- Note that because the data format is different from usual data points, you
44
- can't use images with anything else in a specific data series.
45
-
46
- Setting "anchor" to "center" causes the pixels in the image to be anchored at
47
- the corner pixel centers inside of at the pixel corners, effectively letting
48
- half a pixel stick out to each side in the plot.
49
-
50
- A possible future direction could be support for tiling for large images (like
51
- Google Maps).
52
-
53
- */(function(e){function n(e,t,n){var r=e.getPlotOffset();if(!n.images||!n.images.show)return;var i=n.datapoints.points,s=n.datapoints.pointsize;for(var o=0;o<i.length;o+=s){var u=i[o],a=i[o+1],f=i[o+2],l=i[o+3],c=i[o+4],h=n.xaxis,p=n.yaxis,d;if(!u||u.width<=0||u.height<=0)continue;a>l&&(d=l,l=a,a=d),f>c&&(d=c,c=f,f=d),n.images.anchor=="center"&&(d=.5*(l-a)/(u.width-1),a-=d,l+=d,d=.5*(c-f)/(u.height-1),f-=d,c+=d);if(a==l||f==c||a>=h.max||l<=h.min||f>=p.max||c<=p.min)continue;var v=0,m=0,g=u.width,y=u.height;a<h.min&&(v+=(g-v)*(h.min-a)/(l-a),a=h.min),l>h.max&&(g+=(g-v)*(h.max-l)/(l-a),l=h.max),f<p.min&&(y+=(m-y)*(p.min-f)/(c-f),f=p.min),c>p.max&&(m+=(m-y)*(p.max-c)/(c-f),c=p.max),a=h.p2c(a),l=h.p2c(l),f=p.p2c(f),c=p.p2c(c),a>l&&(d=l,l=a,a=d),f>c&&(d=c,c=f,f=d),d=t.globalAlpha,t.globalAlpha*=n.images.alpha,t.drawImage(u,v,m,g-v,y-m,a+r.left,f+r.top,l-a,c-f),t.globalAlpha=d}}function r(e,t,n,r){if(!t.images.show)return;r.format=[{required:!0},{x:!0,number:!0,required:!0},{y:!0,number:!0,required:!0},{x:!0,number:!0,required:!0},{y:!0,number:!0,required:!0}]}function i(e){e.hooks.processRawData.push(r),e.hooks.drawSeries.push(n)}var t={series:{images:{show:!1,alpha:1,anchor:"corner"}}};e.plot.image={},e.plot.image.loadDataImages=function(t,n,r){var i=[],s=[],o=n.series.images.show;e.each(t,function(t,n){if(!o&&!n.images.show)return;n.data&&(n=n.data),e.each(n,function(e,t){typeof t[0]=="string"&&(i.push(t[0]),s.push(t))})}),e.plot.image.load(i,function(t){e.each(s,function(e,n){var r=n[0];t[r]&&(n[0]=t[r])}),r()})},e.plot.image.load=function(t,n){var r=t.length,i={};r==0&&n({}),e.each(t,function(t,s){var o=function(){--r,i[s]=this,r==0&&n(i)};e("<img />").load(o).error(o).attr("src",s)})},e.plot.plugins.push({init:i,options:t,name:"image",version:"1.1"})})(jQuery);
1
+ (function($){var options={series:{images:{show:false,alpha:1,anchor:"corner"}}};$.plot.image={};$.plot.image.loadDataImages=function(series,options,callback){var urls=[],points=[];var defaultShow=options.series.images.show;$.each(series,function(i,s){if(!(defaultShow||s.images.show))return;if(s.data)s=s.data;$.each(s,function(i,p){if(typeof p[0]=="string"){urls.push(p[0]);points.push(p)}})});$.plot.image.load(urls,function(loadedImages){$.each(points,function(i,p){var url=p[0];if(loadedImages[url])p[0]=loadedImages[url]});callback()})};$.plot.image.load=function(urls,callback){var missing=urls.length,loaded={};if(missing==0)callback({});$.each(urls,function(i,url){var handler=function(){--missing;loaded[url]=this;if(missing==0)callback(loaded)};$("<img />").load(handler).error(handler).attr("src",url)})};function drawSeries(plot,ctx,series){var plotOffset=plot.getPlotOffset();if(!series.images||!series.images.show)return;var points=series.datapoints.points,ps=series.datapoints.pointsize;for(var i=0;i<points.length;i+=ps){var img=points[i],x1=points[i+1],y1=points[i+2],x2=points[i+3],y2=points[i+4],xaxis=series.xaxis,yaxis=series.yaxis,tmp;if(!img||img.width<=0||img.height<=0)continue;if(x1>x2){tmp=x2;x2=x1;x1=tmp}if(y1>y2){tmp=y2;y2=y1;y1=tmp}if(series.images.anchor=="center"){tmp=.5*(x2-x1)/(img.width-1);x1-=tmp;x2+=tmp;tmp=.5*(y2-y1)/(img.height-1);y1-=tmp;y2+=tmp}if(x1==x2||y1==y2||x1>=xaxis.max||x2<=xaxis.min||y1>=yaxis.max||y2<=yaxis.min)continue;var sx1=0,sy1=0,sx2=img.width,sy2=img.height;if(x1<xaxis.min){sx1+=(sx2-sx1)*(xaxis.min-x1)/(x2-x1);x1=xaxis.min}if(x2>xaxis.max){sx2+=(sx2-sx1)*(xaxis.max-x2)/(x2-x1);x2=xaxis.max}if(y1<yaxis.min){sy2+=(sy1-sy2)*(yaxis.min-y1)/(y2-y1);y1=yaxis.min}if(y2>yaxis.max){sy1+=(sy1-sy2)*(yaxis.max-y2)/(y2-y1);y2=yaxis.max}x1=xaxis.p2c(x1);x2=xaxis.p2c(x2);y1=yaxis.p2c(y1);y2=yaxis.p2c(y2);if(x1>x2){tmp=x2;x2=x1;x1=tmp}if(y1>y2){tmp=y2;y2=y1;y1=tmp}tmp=ctx.globalAlpha;ctx.globalAlpha*=series.images.alpha;ctx.drawImage(img,sx1,sy1,sx2-sx1,sy2-sy1,x1+plotOffset.left,y1+plotOffset.top,x2-x1,y2-y1);ctx.globalAlpha=tmp}}function processRawData(plot,series,data,datapoints){if(!series.images.show)return;datapoints.format=[{required:true},{x:true,number:true,required:true},{y:true,number:true,required:true},{x:true,number:true,required:true},{y:true,number:true,required:true}]}function init(plot){plot.hooks.processRawData.push(processRawData);plot.hooks.drawSeries.push(drawSeries)}$.plot.plugins.push({init:init,options:options,name:"image",version:"1.1"})})(jQuery);
@@ -1,4 +1,4 @@
1
- /* Javascript plotting library for jQuery, version 0.8.1.
1
+ /* Javascript plotting library for jQuery, version 0.8.2.
2
2
 
3
3
  Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
4
  Licensed under the MIT license.
@@ -29,7 +29,7 @@ Licensed under the MIT license.
29
29
  * V. 1.1: Fix error handling so e.g. parsing an empty string does
30
30
  * produce a color rather than just crashing.
31
31
  */
32
- (function(B){B.color={};B.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]+=I}return G.normalize()};G.scale=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]*=I}return G.normalize()};G.toString=function(){if(G.a>=1){return"rgb("+[G.r,G.g,G.b].join(",")+")"}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")"}};G.normalize=function(){function H(J,K,I){return K<J?J:(K>I?I:K)}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G};G.clone=function(){return B.color.make(G.r,G.b,G.g,G.a)};return G.normalize()};B.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break}D=D.parent()}while(!B.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent"}return B.color.parse(E)};B.color.parse=function(F){var E,C=B.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10))}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]))}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55)}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]))}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16))}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16))}var D=B.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0)}else{E=A[D]||[0,0,0];return C(E[0],E[1],E[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
32
+ (function($){$.color={};$.color.make=function(r,g,b,a){var o={};o.r=r||0;o.g=g||0;o.b=b||0;o.a=a!=null?a:1;o.add=function(c,d){for(var i=0;i<c.length;++i)o[c.charAt(i)]+=d;return o.normalize()};o.scale=function(c,f){for(var i=0;i<c.length;++i)o[c.charAt(i)]*=f;return o.normalize()};o.toString=function(){if(o.a>=1){return"rgb("+[o.r,o.g,o.b].join(",")+")"}else{return"rgba("+[o.r,o.g,o.b,o.a].join(",")+")"}};o.normalize=function(){function clamp(min,value,max){return value<min?min:value>max?max:value}o.r=clamp(0,parseInt(o.r),255);o.g=clamp(0,parseInt(o.g),255);o.b=clamp(0,parseInt(o.b),255);o.a=clamp(0,o.a,1);return o};o.clone=function(){return $.color.make(o.r,o.b,o.g,o.a)};return o.normalize()};$.color.extract=function(elem,css){var c;do{c=elem.css(css).toLowerCase();if(c!=""&&c!="transparent")break;elem=elem.parent()}while(elem.length&&!$.nodeName(elem.get(0),"body"));if(c=="rgba(0, 0, 0, 0)")c="transparent";return $.color.parse(c)};$.color.parse=function(str){var res,m=$.color.make;if(res=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10));if(res=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10),parseFloat(res[4]));if(res=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55);if(res=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55,parseFloat(res[4]));if(res=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))return m(parseInt(res[1],16),parseInt(res[2],16),parseInt(res[3],16));if(res=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))return m(parseInt(res[1]+res[1],16),parseInt(res[2]+res[2],16),parseInt(res[3]+res[3],16));var name=$.trim(str).toLowerCase();if(name=="transparent")return m(255,255,255,0);else{res=lookupColors[name]||[0,0,0];return m(res[0],res[1],res[2])}};var lookupColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
33
33
 
34
34
  // the actual Flot code
35
35
  (function($) {
@@ -425,7 +425,7 @@ Licensed under the MIT license.
425
425
  element: positions.length ? info.element.clone() : info.element,
426
426
  x: x,
427
427
  y: y
428
- }
428
+ };
429
429
 
430
430
  positions.push(position);
431
431
 
@@ -658,6 +658,23 @@ Licensed under the MIT license.
658
658
  };
659
659
  };
660
660
  plot.shutdown = shutdown;
661
+ plot.destroy = function () {
662
+ shutdown();
663
+ placeholder.removeData("plot").empty();
664
+
665
+ series = [];
666
+ options = null;
667
+ surface = null;
668
+ overlay = null;
669
+ eventHolder = null;
670
+ ctx = null;
671
+ octx = null;
672
+ xaxes = [];
673
+ yaxes = [];
674
+ hooks = null;
675
+ highlights = [];
676
+ plot = null;
677
+ };
661
678
  plot.resize = function () {
662
679
  var width = placeholder.width(),
663
680
  height = placeholder.height();
@@ -735,16 +752,16 @@ Licensed under the MIT license.
735
752
  // since the rest of the code assumes that they exist.
736
753
 
737
754
  var i, axisOptions, axisCount,
755
+ fontSize = placeholder.css("font-size"),
756
+ fontSizeDefault = fontSize ? +fontSize.replace("px", "") : 13,
738
757
  fontDefaults = {
739
758
  style: placeholder.css("font-style"),
740
- size: Math.round(0.8 * (+placeholder.css("font-size").replace("px", "") || 13)),
759
+ size: Math.round(0.8 * fontSizeDefault),
741
760
  variant: placeholder.css("font-variant"),
742
761
  weight: placeholder.css("font-weight"),
743
762
  family: placeholder.css("font-family")
744
763
  };
745
764
 
746
- fontDefaults.lineHeight = fontDefaults.size * 1.15;
747
-
748
765
  axisCount = options.xaxes.length || 1;
749
766
  for (i = 0; i < axisCount; ++i) {
750
767
 
@@ -761,6 +778,9 @@ Licensed under the MIT license.
761
778
  if (!axisOptions.font.color) {
762
779
  axisOptions.font.color = axisOptions.color;
763
780
  }
781
+ if (!axisOptions.font.lineHeight) {
782
+ axisOptions.font.lineHeight = Math.round(axisOptions.font.size * 1.15);
783
+ }
764
784
  }
765
785
  }
766
786
 
@@ -780,6 +800,9 @@ Licensed under the MIT license.
780
800
  if (!axisOptions.font.color) {
781
801
  axisOptions.font.color = axisOptions.color;
782
802
  }
803
+ if (!axisOptions.font.lineHeight) {
804
+ axisOptions.font.lineHeight = Math.round(axisOptions.font.size * 1.15);
805
+ }
783
806
  }
784
807
  }
785
808
 
@@ -1131,7 +1154,7 @@ Licensed under the MIT license.
1131
1154
  if (val != null) {
1132
1155
  f = format[m];
1133
1156
  // extract min/max info
1134
- if (f.autoscale) {
1157
+ if (f.autoscale !== false) {
1135
1158
  if (f.x) {
1136
1159
  updateAxis(s.xaxis, val, val);
1137
1160
  }
@@ -1218,11 +1241,8 @@ Licensed under the MIT license.
1218
1241
  case "right":
1219
1242
  delta = -s.bars.barWidth;
1220
1243
  break;
1221
- case "center":
1222
- delta = -s.bars.barWidth / 2;
1223
- break;
1224
1244
  default:
1225
- throw new Error("Invalid bar alignment: " + s.bars.align);
1245
+ delta = -s.bars.barWidth / 2;
1226
1246
  }
1227
1247
 
1228
1248
  if (s.bars.horizontal) {
@@ -1253,7 +1273,9 @@ Licensed under the MIT license.
1253
1273
  // from a previous plot in this container that we'll try to re-use.
1254
1274
 
1255
1275
  placeholder.css("padding", 0) // padding messes up the positioning
1256
- .children(":not(.flot-base,.flot-overlay)").remove();
1276
+ .children().filter(function(){
1277
+ return !$(this).hasClass("flot-overlay") && !$(this).hasClass('flot-base');
1278
+ }).remove();
1257
1279
 
1258
1280
  if (placeholder.css("position") == 'static')
1259
1281
  placeholder.css("position", "relative"); // for positioning labels and overlay
@@ -1350,7 +1372,7 @@ Licensed under the MIT license.
1350
1372
  ticks = axis.ticks || [],
1351
1373
  labelWidth = opts.labelWidth || 0,
1352
1374
  labelHeight = opts.labelHeight || 0,
1353
- maxWidth = labelWidth || axis.direction == "x" ? Math.floor(surface.width / (ticks.length || 1)) : null;
1375
+ maxWidth = labelWidth || (axis.direction == "x" ? Math.floor(surface.width / (ticks.length || 1)) : null),
1354
1376
  legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
1355
1377
  layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles,
1356
1378
  font = opts.font || "flot-tick-label tickLabel";
@@ -1382,37 +1404,50 @@ Licensed under the MIT license.
1382
1404
  var lw = axis.labelWidth,
1383
1405
  lh = axis.labelHeight,
1384
1406
  pos = axis.options.position,
1407
+ isXAxis = axis.direction === "x",
1385
1408
  tickLength = axis.options.tickLength,
1386
1409
  axisMargin = options.grid.axisMargin,
1387
1410
  padding = options.grid.labelMargin,
1388
- all = axis.direction == "x" ? xaxes : yaxes,
1389
- index, innermost;
1390
-
1391
- // determine axis margin
1392
- var samePosition = $.grep(all, function (a) {
1393
- return a && a.options.position == pos && a.reserveSpace;
1411
+ innermost = true,
1412
+ outermost = true,
1413
+ first = true,
1414
+ found = false;
1415
+
1416
+ // Determine the axis's position in its direction and on its side
1417
+
1418
+ $.each(isXAxis ? xaxes : yaxes, function(i, a) {
1419
+ if (a && a.reserveSpace) {
1420
+ if (a === axis) {
1421
+ found = true;
1422
+ } else if (a.options.position === pos) {
1423
+ if (found) {
1424
+ outermost = false;
1425
+ } else {
1426
+ innermost = false;
1427
+ }
1428
+ }
1429
+ if (!found) {
1430
+ first = false;
1431
+ }
1432
+ }
1394
1433
  });
1395
- if ($.inArray(axis, samePosition) == samePosition.length - 1)
1396
- axisMargin = 0; // outermost
1397
1434
 
1398
- // determine tick length - if we're innermost, we can use "full"
1399
- if (tickLength == null) {
1400
- var sameDirection = $.grep(all, function (a) {
1401
- return a && a.reserveSpace;
1402
- });
1435
+ // The outermost axis on each side has no margin
1403
1436
 
1404
- innermost = $.inArray(axis, sameDirection) == 0;
1405
- if (innermost)
1406
- tickLength = "full";
1407
- else
1408
- tickLength = 5;
1437
+ if (outermost) {
1438
+ axisMargin = 0;
1439
+ }
1440
+
1441
+ // The ticks for the first axis in each direction stretch across
1442
+
1443
+ if (tickLength == null) {
1444
+ tickLength = first ? "full" : 5;
1409
1445
  }
1410
1446
 
1411
1447
  if (!isNaN(+tickLength))
1412
1448
  padding += +tickLength;
1413
1449
 
1414
- // compute box
1415
- if (axis.direction == "x") {
1450
+ if (isXAxis) {
1416
1451
  lh += padding;
1417
1452
 
1418
1453
  if (pos == "bottom") {
@@ -1462,7 +1497,7 @@ Licensed under the MIT license.
1462
1497
  // inside the canvas and isn't clipped off
1463
1498
 
1464
1499
  var minMargin = options.grid.minBorderMargin,
1465
- margins = { x: 0, y: 0 }, i, axis;
1500
+ axis, i;
1466
1501
 
1467
1502
  // check stuff from the plot (FIXME: this should just read
1468
1503
  // a value from the series, otherwise it's impossible to
@@ -1473,21 +1508,37 @@ Licensed under the MIT license.
1473
1508
  minMargin = Math.max(minMargin, 2 * (series[i].points.radius + series[i].points.lineWidth/2));
1474
1509
  }
1475
1510
 
1476
- margins.x = margins.y = Math.ceil(minMargin);
1511
+ var margins = {
1512
+ left: minMargin,
1513
+ right: minMargin,
1514
+ top: minMargin,
1515
+ bottom: minMargin
1516
+ };
1477
1517
 
1478
1518
  // check axis labels, note we don't check the actual
1479
1519
  // labels but instead use the overall width/height to not
1480
1520
  // jump as much around with replots
1481
1521
  $.each(allAxes(), function (_, axis) {
1482
- var dir = axis.direction;
1483
- if (axis.reserveSpace)
1484
- margins[dir] = Math.ceil(Math.max(margins[dir], (dir == "x" ? axis.labelWidth : axis.labelHeight) / 2));
1522
+ if (axis.reserveSpace && axis.ticks && axis.ticks.length) {
1523
+ var lastTick = axis.ticks[axis.ticks.length - 1];
1524
+ if (axis.direction === "x") {
1525
+ margins.left = Math.max(margins.left, axis.labelWidth / 2);
1526
+ if (lastTick.v <= axis.max) {
1527
+ margins.right = Math.max(margins.right, axis.labelWidth / 2);
1528
+ }
1529
+ } else {
1530
+ margins.bottom = Math.max(margins.bottom, axis.labelHeight / 2);
1531
+ if (lastTick.v <= axis.max) {
1532
+ margins.top = Math.max(margins.top, axis.labelHeight / 2);
1533
+ }
1534
+ }
1535
+ }
1485
1536
  });
1486
1537
 
1487
- plotOffset.left = Math.max(margins.x, plotOffset.left);
1488
- plotOffset.right = Math.max(margins.x, plotOffset.right);
1489
- plotOffset.top = Math.max(margins.y, plotOffset.top);
1490
- plotOffset.bottom = Math.max(margins.y, plotOffset.bottom);
1538
+ plotOffset.left = Math.ceil(Math.max(margins.left, plotOffset.left));
1539
+ plotOffset.right = Math.ceil(Math.max(margins.right, plotOffset.right));
1540
+ plotOffset.top = Math.ceil(Math.max(margins.top, plotOffset.top));
1541
+ plotOffset.bottom = Math.ceil(Math.max(margins.bottom, plotOffset.bottom));
1491
1542
  }
1492
1543
 
1493
1544
  function setupGrid() {
@@ -2100,17 +2151,21 @@ Licensed under the MIT license.
2100
2151
  function drawAxisLabels() {
2101
2152
 
2102
2153
  $.each(allAxes(), function (_, axis) {
2103
- if (!axis.show || axis.ticks.length == 0)
2104
- return;
2105
-
2106
2154
  var box = axis.box,
2107
2155
  legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
2108
2156
  layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles,
2109
2157
  font = axis.options.font || "flot-tick-label tickLabel",
2110
2158
  tick, x, y, halign, valign;
2111
2159
 
2160
+ // Remove text before checking for axis.show and ticks.length;
2161
+ // otherwise plugins, like flot-tickrotor, that draw their own
2162
+ // tick labels will end up with both theirs and the defaults.
2163
+
2112
2164
  surface.removeText(layer);
2113
2165
 
2166
+ if (!axis.show || axis.ticks.length == 0)
2167
+ return;
2168
+
2114
2169
  for (var i = 0; i < axis.ticks.length; ++i) {
2115
2170
 
2116
2171
  tick = axis.ticks[i];
@@ -2468,7 +2523,7 @@ Licensed under the MIT license.
2468
2523
  ctx.restore();
2469
2524
  }
2470
2525
 
2471
- function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
2526
+ function drawBar(x, y, b, barLeft, barRight, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
2472
2527
  var left, right, bottom, top,
2473
2528
  drawLeft, drawRight, drawTop, drawBottom,
2474
2529
  tmp;
@@ -2543,13 +2598,8 @@ Licensed under the MIT license.
2543
2598
 
2544
2599
  // fill the bar
2545
2600
  if (fillStyleCallback) {
2546
- c.beginPath();
2547
- c.moveTo(left, bottom);
2548
- c.lineTo(left, top);
2549
- c.lineTo(right, top);
2550
- c.lineTo(right, bottom);
2551
2601
  c.fillStyle = fillStyleCallback(bottom, top);
2552
- c.fill();
2602
+ c.fillRect(left, top, right - left, bottom - top)
2553
2603
  }
2554
2604
 
2555
2605
  // draw outline
@@ -2557,35 +2607,35 @@ Licensed under the MIT license.
2557
2607
  c.beginPath();
2558
2608
 
2559
2609
  // FIXME: inline moveTo is buggy with excanvas
2560
- c.moveTo(left, bottom + offset);
2610
+ c.moveTo(left, bottom);
2561
2611
  if (drawLeft)
2562
- c.lineTo(left, top + offset);
2612
+ c.lineTo(left, top);
2563
2613
  else
2564
- c.moveTo(left, top + offset);
2614
+ c.moveTo(left, top);
2565
2615
  if (drawTop)
2566
- c.lineTo(right, top + offset);
2616
+ c.lineTo(right, top);
2567
2617
  else
2568
- c.moveTo(right, top + offset);
2618
+ c.moveTo(right, top);
2569
2619
  if (drawRight)
2570
- c.lineTo(right, bottom + offset);
2620
+ c.lineTo(right, bottom);
2571
2621
  else
2572
- c.moveTo(right, bottom + offset);
2622
+ c.moveTo(right, bottom);
2573
2623
  if (drawBottom)
2574
- c.lineTo(left, bottom + offset);
2624
+ c.lineTo(left, bottom);
2575
2625
  else
2576
- c.moveTo(left, bottom + offset);
2626
+ c.moveTo(left, bottom);
2577
2627
  c.stroke();
2578
2628
  }
2579
2629
  }
2580
2630
 
2581
2631
  function drawSeriesBars(series) {
2582
- function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) {
2632
+ function plotBars(datapoints, barLeft, barRight, fillStyleCallback, axisx, axisy) {
2583
2633
  var points = datapoints.points, ps = datapoints.pointsize;
2584
2634
 
2585
2635
  for (var i = 0; i < points.length; i += ps) {
2586
2636
  if (points[i] == null)
2587
2637
  continue;
2588
- drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth);
2638
+ drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth);
2589
2639
  }
2590
2640
  }
2591
2641
 
@@ -2605,15 +2655,12 @@ Licensed under the MIT license.
2605
2655
  case "right":
2606
2656
  barLeft = -series.bars.barWidth;
2607
2657
  break;
2608
- case "center":
2609
- barLeft = -series.bars.barWidth / 2;
2610
- break;
2611
2658
  default:
2612
- throw new Error("Invalid bar alignment: " + series.bars.align);
2659
+ barLeft = -series.bars.barWidth / 2;
2613
2660
  }
2614
2661
 
2615
2662
  var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null;
2616
- plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis);
2663
+ plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, fillStyleCallback, series.xaxis, series.yaxis);
2617
2664
  ctx.restore();
2618
2665
  }
2619
2666
 
@@ -2633,10 +2680,15 @@ Licensed under the MIT license.
2633
2680
 
2634
2681
  function insertLegend() {
2635
2682
 
2636
- placeholder.find(".legend").remove();
2683
+ if (options.legend.container != null) {
2684
+ $(options.legend.container).html("");
2685
+ } else {
2686
+ placeholder.find(".legend").remove();
2687
+ }
2637
2688
 
2638
- if (!options.legend.show)
2689
+ if (!options.legend.show) {
2639
2690
  return;
2691
+ }
2640
2692
 
2641
2693
  var fragments = [], entries = [], rowStarted = false,
2642
2694
  lf = options.legend.labelFormatter, s, label;
@@ -2797,8 +2849,21 @@ Licensed under the MIT license.
2797
2849
  }
2798
2850
 
2799
2851
  if (s.bars.show && !item) { // no other point can be nearby
2800
- var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2,
2801
- barRight = barLeft + s.bars.barWidth;
2852
+
2853
+ var barLeft, barRight;
2854
+
2855
+ switch (s.bars.align) {
2856
+ case "left":
2857
+ barLeft = 0;
2858
+ break;
2859
+ case "right":
2860
+ barLeft = -s.bars.barWidth;
2861
+ break;
2862
+ default:
2863
+ barLeft = -s.bars.barWidth / 2;
2864
+ }
2865
+
2866
+ barRight = barLeft + s.bars.barWidth;
2802
2867
 
2803
2868
  for (j = 0; j < points.length; j += ps) {
2804
2869
  var x = points[j], y = points[j + 1], b = points[j + 2];
@@ -2996,13 +3061,24 @@ Licensed under the MIT license.
2996
3061
  function drawBarHighlight(series, point) {
2997
3062
  var highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString(),
2998
3063
  fillStyle = highlightColor,
2999
- barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
3064
+ barLeft;
3065
+
3066
+ switch (series.bars.align) {
3067
+ case "left":
3068
+ barLeft = 0;
3069
+ break;
3070
+ case "right":
3071
+ barLeft = -series.bars.barWidth;
3072
+ break;
3073
+ default:
3074
+ barLeft = -series.bars.barWidth / 2;
3075
+ }
3000
3076
 
3001
3077
  octx.lineWidth = series.bars.lineWidth;
3002
3078
  octx.strokeStyle = highlightColor;
3003
3079
 
3004
3080
  drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth,
3005
- 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
3081
+ function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
3006
3082
  }
3007
3083
 
3008
3084
  function getColorOrGradient(spec, bottom, top, defaultColor) {
@@ -3041,7 +3117,7 @@ Licensed under the MIT license.
3041
3117
  return plot;
3042
3118
  };
3043
3119
 
3044
- $.plot.version = "0.8.1";
3120
+ $.plot.version = "0.8.2";
3045
3121
 
3046
3122
  $.plot.plugins = [];
3047
3123