0&&(z[m]+=I),B<0&&$>0?I<0?V[m]+=o.abs(I):c[m]+=I:c[m]+=o.abs(I-(I<0?$:B)),f.push(I));else I=F?n(i[m],_,k):i[m],null!==(I=i[m]=h(I))&&f.push(I);this.max=R=o.max.apply(o,f),this.min=S=o.min.apply(o,f),this.stackMax=$=M?o.max.apply(o,z):R,this.stackMin=B=M?o.min.apply(o,f):S,void 0!==s.get("chartRangeMin")&&(s.get("chartRangeClip")||s.get("chartRangeMin")R)&&(R=s.get("chartRangeMax")),this.zeroAxis=w=s.get("zeroAxis",!0),b=S<=0&&R>=0&&w?0:0==w?S:S>0?S:R,this.xaxisOffset=b,y=M?o.max.apply(o,c)+o.max.apply(o,V):R-S,this.canvasHeightEf=w&&S<0?this.canvasHeight-2:this.canvasHeight-1,S=0?$:R)-b)/y*this.canvasHeight)!==o.ceil(q)&&(this.canvasHeightEf-=2,q=o.ceil(q)):q=this.canvasHeight,this.yoffset=q,t.isArray(s.get("colorMap"))?(this.colorMapByIndex=s.get("colorMap"),this.colorMapByValue=null):(this.colorMapByIndex=null,this.colorMapByValue=s.get("colorMap"),this.colorMapByValue&&void 0===this.colorMapByValue.get&&(this.colorMapByValue=new v(this.colorMapByValue))),this.range=y},getRegion:function(t,e,i){var s=o.floor(e/this.totalBarWidth);return s<0||s>=this.values.length?void 0:s},getCurrentRegionFields:function(){var t,e,i=this.currentRegion,s=c(this.values[i]),n=[];for(e=s.length;e--;)t=s[e],n.push({isNull:null===t,value:t,color:this.calcColor(e,t,i),offset:i});return n},calcColor:function(e,i,s){var n,r,a=this.colorMapByIndex,o=this.colorMapByValue,h=this.options;return n=this.stacked?h.get("stackedBarColor"):i<0?h.get("negBarColor"):h.get("barColor"),0===i&&void 0!==h.get("zeroColor")&&(n=h.get("zeroColor")),o&&(r=o.get(i))?n=r:a&&a.length>s&&(n=a[s]),t.isArray(n)?n[e%n.length]:n},renderRegion:function(e,i){var s,n,r,a,h,l,p,g,d,c,f=this.values[e],v=this.options,m=this.xaxisOffset,x=[],y=this.range,w=this.stacked,C=this.target,b=e*this.totalBarWidth,S=this.canvasHeightEf,R=this.yoffset;if(f=t.isArray(f)?f:[f],p=f.length,g=f[0],a=u(null,f),c=u(m,f,!0),a)return v.get("nullColor")?(r=i?v.get("nullColor"):this.calcHighlightColor(v.get("nullColor"),v),s=R>0?R-1:R,C.drawRect(b,s,this.barWidth-1,0,r,r)):void 0;for(h=R,l=0;l0?o.floor(S*(o.abs(g-m)/y))+1:1,ge?r[e]:s[e]<0?n.get("negBarColor"):s[e]>0?n.get("posBarColor"):n.get("zeroBarColor")},renderRegion:function(t,e){var i,s,n,r,a,h,l=this.values,p=this.options,g=this.target;if(i=g.pixelHeight,n=o.round(i/2),r=t*this.totalBarWidth,l[t]<0?(a=n,s=n-1):l[t]>0?(a=0,s=n-1):(a=n-1,s=2),null!==(h=this.calcColor(l[t],t)))return e&&(h=this.calcHighlightColor(h,p)),g.drawRect(r,a,this.barWidth-1,s-1,h,h)}}),t.fn.sparkline.discrete=S=i(t.fn.sparkline._base,y,{type:"discrete",init:function(e,i,s,n,r){S._super.init.call(this,e,i,s,n,r),this.regionShapes={},this.values=i=t.map(i,Number),this.min=o.min.apply(o,i),this.max=o.max.apply(o,i),this.range=this.max-this.min,this.width=n="auto"===s.get("width")?2*i.length:this.width,this.interval=o.floor(n/i.length),this.itemWidth=n/i.length,void 0!==s.get("chartRangeMin")&&(s.get("chartRangeClip")||s.get("chartRangeMin")this.max)&&(this.max=s.get("chartRangeMax")),this.initTarget(),this.target&&(this.lineHeight="auto"===s.get("lineHeight")?o.round(.3*this.canvasHeight):s.get("lineHeight"))},getRegion:function(t,e,i){return o.floor(e/this.itemWidth)},getCurrentRegionFields:function(){var t=this.currentRegion;return{isNull:void 0===this.values[t],value:this.values[t],offset:t}},renderRegion:function(t,e){var i,s,r,a,h=this.values,l=this.options,p=this.min,g=this.max,u=this.range,d=this.interval,c=this.target,f=this.canvasHeight,v=this.lineHeight,m=f-v;return s=n(h[t],p,g),a=t*d,i=o.round(m-m*((s-p)/u)),r=l.get("thresholdColor")&&s0)for(a=i.length;a--;)h+=i[a];this.total=h,this.initTarget(),this.radius=o.floor(o.min(this.canvasWidth,this.canvasHeight)/2)},getRegion:function(t,e,i){var s=this.target.getShapeAt(t,e,i);return void 0!==s&&void 0!==this.shapes[s]?this.shapes[s]:void 0},getCurrentRegionFields:function(){var t=this.currentRegion;return{isNull:void 0===this.values[t],value:this.values[t],percent:this.values[t]/this.total*100,color:this.options.get("sliceColors")[t%this.options.get("sliceColors").length],offset:t}},changeHighlight:function(t){var e=this.currentRegion,i=this.renderSlice(e,t),s=this.valueShapes[e];delete this.shapes[s],this.target.replaceWithShape(s,i),this.valueShapes[e]=i.id,this.shapes[i.id]=e},renderSlice:function(t,e){var i,s,n,r,a,h=this.target,l=this.options,p=this.radius,g=l.get("borderWidth"),u=l.get("offset"),d=2*o.PI,c=this.values,f=this.total,v=u?2*o.PI*(u/360):0;for(r=c.length,n=0;n0&&(s=v+d*(c[n]/f)),t===n)return a=l.get("sliceColors")[n%l.get("sliceColors").length],e&&(a=this.calcHighlightColor(a,l)),h.drawPieSlice(p,p,p-g,i,s,void 0,a);v=s}},render:function(){var t,e,i=this.target,s=this.values,n=this.options,r=this.radius,a=n.get("borderWidth"),h=n.get("donutWidth");if(_._super.render.call(this)){for(a&&i.drawCircle(r,r,o.floor(r-a/2),n.get("borderColor"),void 0,a).append(),e=s.length;e--;)s[e]&&(t=this.renderSlice(e).append(),this.valueShapes[e]=t.id,this.shapes[t.id]=e);h&&i.drawCircle(r,r,r-h,n.get("donutColor"),n.get("donutColor"),0).append(),i.render()}}}),t.fn.sparkline.box=k=i(t.fn.sparkline._base,{type:"box",init:function(e,i,s,n,r){k._super.init.call(this,e,i,s,n,r),this.values=t.map(i,Number),this.width="auto"===s.get("width")?"4.0em":n,this.initTarget(),this.values.length||(this.disabled=1)},getRegion:function(){return 1},getCurrentRegionFields:function(){var t=[{field:"lq",value:this.quartiles[0]},{field:"med",value:this.quartiles[1]},{field:"uq",value:this.quartiles[2]}];return void 0!==this.loutlier&&t.push({field:"lo",value:this.loutlier}),void 0!==this.routlier&&t.push({field:"ro",value:this.routlier}),void 0!==this.lwhisker&&t.push({field:"lw",value:this.lwhisker}),void 0!==this.rwhisker&&t.push({field:"rw",value:this.rwhisker}),t},render:function(){var t,e,i,s,n,a,h,l,p,g,u,d=this.target,c=this.values,f=c.length,v=this.options,m=this.canvasWidth,x=this.canvasHeight,y=void 0===v.get("chartRangeMin")?o.min.apply(o,c):v.get("chartRangeMin"),w=void 0===v.get("chartRangeMax")?o.max.apply(o,c):v.get("chartRangeMax"),C=0;if(k._super.render.call(this)){if(v.get("raw"))v.get("showOutliers")&&c.length>5?(e=c[0],t=c[1],s=c[2],n=c[3],a=c[4],h=c[5],l=c[6]):(t=c[0],s=c[1],n=c[2],a=c[3],h=c[4]);else if(c.sort(function(t,e){return t-e}),s=r(c,1),n=r(c,2),a=r(c,3),i=a-s,v.get("showOutliers")){for(t=h=void 0,p=0;ps-i*v.get("outlierIQR")&&(t=c[p]),c[p]h&&d.drawCircle((l-y)*u+C,x/2,v.get("spotRadius"),v.get("outlierLineColor"),v.get("outlierFillColor")).append()),d.drawRect(o.round((s-y)*u+C),o.round(.1*x),o.round((a-s)*u),o.round(.8*x),v.get("boxLineColor"),v.get("boxFillColor")).append(),d.drawLine(o.round((t-y)*u+C),o.round(x/2),o.round((s-y)*u+C),o.round(x/2),v.get("lineColor")).append(),d.drawLine(o.round((t-y)*u+C),o.round(x/4),o.round((t-y)*u+C),o.round(x-x/4),v.get("whiskerColor")).append(),d.drawLine(o.round((h-y)*u+C),o.round(x/2),o.round((a-y)*u+C),o.round(x/2),v.get("lineColor")).append(),d.drawLine(o.round((h-y)*u+C),o.round(x/4),o.round((h-y)*u+C),o.round(x-x/4),v.get("whiskerColor")).append(),d.drawLine(o.round((n-y)*u+C),o.round(.1*x),o.round((n-y)*u+C),o.round(.9*x),v.get("medianColor")).append(),v.get("target")&&(g=o.ceil(v.get("spotRadius")),d.drawLine(o.round((v.get("target")-y)*u+C),o.round(x/2-g),o.round((v.get("target")-y)*u+C),o.round(x/2+g),v.get("targetColor")).append(),d.drawLine(o.round((v.get("target")-y)*u+C-g),o.round(x/2),o.round((v.get("target")-y)*u+C+g),o.round(x/2),v.get("targetColor")).append()),d.render()}}}),M=i({init:function(t,e,i,s){this.target=t,this.id=e,this.type=i,this.args=s},append:function(){return this.target.appendShape(this),this}}),H=i({_pxregex:/(\d+)(px)?\s*$/i,init:function(e,i,s){e&&(this.width=e,this.height=i,this.target=s,this.lastShapeId=null,s[0]&&(s=s[0]),t.data(s,"_jqs_vcanvas",this))},drawLine:function(t,e,i,s,n,r){return this.drawShape([[t,e],[i,s]],n,r)},drawShape:function(t,e,i,s){return this._genShape("Shape",[t,e,i,s])},drawCircle:function(t,e,i,s,n,r){return this._genShape("Circle",[t,e,i,s,n,r])},drawPieSlice:function(t,e,i,s,n,r,a){return this._genShape("PieSlice",[t,e,i,s,n,r,a])},drawRect:function(t,e,i,s,n,r){return this._genShape("Rect",[t,e,i,s,n,r])},getElement:function(){return this.canvas},getLastShapeId:function(){return this.lastShapeId},reset:function(){alert("reset not implemented")},_insert:function(e,i){t(i).html(e)},_calculatePixelDims:function(e,i,s){var n;n=this._pxregex.exec(i),this.pixelHeight=n?n[1]:t(s).height(),n=this._pxregex.exec(e),this.pixelWidth=n?n[1]:t(s).width()},_genShape:function(t,e){var i=q++;return e.unshift(i),new M(this,i,t,e)},appendShape:function(t){alert("appendShape not implemented")},replaceWithShape:function(t,e){alert("replaceWithShape not implemented")},insertAfterShape:function(t,e){alert("insertAfterShape not implemented")},removeShapeId:function(t){alert("removeShapeId not implemented")},getShapeAt:function(t,e,i){alert("getShapeAt not implemented")},render:function(){alert("render not implemented")}}),j=i(H,{init:function(e,i,s,n){j._super.init.call(this,e,i,s),this.canvas=a.createElement("canvas"),s[0]&&(s=s[0]),t.data(s,"_jqs_vcanvas",this),t(this.canvas).css({display:"inline-block",width:e,height:i,verticalAlign:"top"}),this._insert(this.canvas,s),this._calculatePixelDims(e,i,this.canvas),this.canvas.width=this.pixelWidth,this.canvas.height=this.pixelHeight,this.interact=n,this.shapes={},this.shapeseq=[],this.currentTargetShapeId=void 0,t(this.canvas).css({width:this.pixelWidth,height:this.pixelHeight})},_getContext:function(t,e,i){var s=this.canvas.getContext("2d");return void 0!==t&&(s.strokeStyle=t),s.lineWidth=void 0===i?1:i,void 0!==e&&(s.fillStyle=e),s},reset:function(){var t=this._getContext();t.clearRect(0,0,this.pixelWidth,this.pixelHeight),this.shapes={},this.shapeseq=[],this.currentTargetShapeId=void 0},_drawShape:function(t,e,i,s,n){var r,a,o=this._getContext(i,s,n);for(o.beginPath(),o.moveTo(e[0][0]+.5,e[0][1]+.5),r=1,a=e.length;r',this.canvas.insertAdjacentHTML("beforeEnd",n),this.group=t(this.canvas).children()[0],this.rendered=!1,this.prerender=""},_drawShape:function(t,e,i,s,n){var r,a,o,h,l,p,g=[];for(p=0,l=e.length;p '},_drawCircle:function(t,e,i,s,n,r,a){return''},_drawPieSlice:function(t,e,i,s,n,r,a,h){var l,p,g,u,d,c,f;if(n===r)return"";if(r-n==2*o.PI&&(n=0,r=2*o.PI),p=e+o.round(o.cos(n)*s),g=i+o.round(o.sin(n)*s),u=e+o.round(o.cos(r)*s),d=i+o.round(o.sin(r)*s),p===u&&g===d){if(r-n ')},_drawRect:function(t,e,i,s,n,r,a){return this._drawShape(t,[[e,i],[e,i+n],[e+s,i+n],[e+s,i],[e,i]],r,a)},reset:function(){this.group.innerHTML=""},appendShape:function(t){var e=this["_draw"+t.type].apply(this,t.args);return this.rendered?this.group.insertAdjacentHTML("beforeEnd",e):this.prerender+=e,this.lastShapeId=t.id,t.id},replaceWithShape:function(e,i){var s=t("#jqsshape"+e),n=this["_draw"+i.type].apply(this,i.args);s[0].outerHTML=n},replaceWithShapes:function(e,i){var s,n=t("#jqsshape"+e[0]),r="",a=i.length;for(s=0;s\s*$)|\s+/g,"").split(",")),i&&"[object Array]"===Object.prototype.toString.call(i)&&0!==i.length||(i=null),{values:i,config:s}}},{key:"_jQueryInterface",value:function(){for(var e=arguments.length,i=new Array(e),s=0;s