forked from sergachev/flot-downsample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.flot.downsample.min.js
More file actions
3 lines (3 loc) · 1.05 KB
/
Copy pathjquery.flot.downsample.min.js
File metadata and controls
3 lines (3 loc) · 1.05 KB
1
2
3
/*! flot-downsample - v0.0.0 - 2014-12-16
* Copyright (c) 2014 ; Licensed */
!function(a){"use strict";function b(a){for(var b=[],c=[],d=0;d<a.length;d++){var e=a[d];e?c.push(e):(b.push(c),b.push([null]),c=[])}return b.push(c),b}function c(a,b){var c=a.length;if(b>=c||0===b)return a;var d,e,h,i,j=[],k=0,l=(c-2)/(b-2),m=0;j[k++]=a[m];for(var n=0;b-2>n;n++){var o=0,p=0,q=f((n+1)*l)+1,r=f((n+2)*l)+1;r=c>r?r:c;for(var s=r-q;r>q;q++)o+=1*a[q][0],p+=1*a[q][1];o/=s,p/=s;var t=f((n+0)*l)+1,u=Math.min(f((n+1)*l)+1,a.length),v=1*a[m][0],w=1*a[m][1];for(e=h=-1;u>t;t++)h=.5*g((v-o)*(a[t][1]-w)-(v-a[t][0])*(p-w)),h>e&&(e=h,d=a[t],i=t);j[k++]=d,m=i}return j[k++]=a[c-1],j}function d(a,d){if(!(d.downsample.pixelsPerPoint<=1)){for(var e=b(d.data),f=[],g=0;g<e.length;g++){var h=e[g];if(h&&null!==h[0]){var i=Math.max(3,Math.ceil(h.length/d.downsample.ratio));h=c(h,i)}f=f.concat(h)}d.data=f}}function e(a){a.hooks.processRawData.push(d)}var f=Math.floor,g=Math.abs,h={series:{downsample:{ratio:0}}};a.plot.plugins.push({init:e,options:h,name:"downsample",version:"1.0"})}(jQuery);