4 lines
45 KiB
JavaScript
4 lines
45 KiB
JavaScript
/* jquery.sparkline 2.1.2 - http://omnipotent.net/jquery.sparkline/
|
|
** Licensed under the New BSD License - see above site for details */
|
|
|
|
(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(e){"use strict";var t={},n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P=0;n=function(){return{common:{type:"line",lineColor:"#00f",fillColor:"#cdf",defaultPixelsPerValue:3,width:"auto",height:"auto",composite:false,tagValuesAttribute:"values",tagOptionsPrefix:"spark",enableTagOptions:false,enableHighlight:true,highlightLighten:1.4,tooltipSkipNull:true,tooltipPrefix:"",tooltipSuffix:"",disableHiddenCheck:false,numberFormatter:false,numberDigitGroupCount:3,numberDigitGroupSep:",",numberDecimalMark:".",disableTooltips:false,disableInteraction:false},line:{spotColor:"#f80",highlightSpotColor:"#5f5",highlightLineColor:"#f22",spotRadius:1.5,minSpotColor:"#f80",maxSpotColor:"#f80",lineWidth:1,normalRangeMin:undefined,normalRangeMax:undefined,normalRangeColor:"#ccc",drawNormalOnTop:false,chartRangeMin:undefined,chartRangeMax:undefined,chartRangeMinX:undefined,chartRangeMaxX:undefined,tooltipFormat:new i('<span style="color: {{color}}">●</span> {{prefix}}{{y}}{{suffix}}')},bar:{barColor:"#3366cc",negBarColor:"#f44",stackedBarColor:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"],zeroColor:undefined,nullColor:undefined,zeroAxis:true,barWidth:4,barSpacing:1,chartRangeMax:undefined,chartRangeMin:undefined,chartRangeClip:false,colorMap:undefined,tooltipFormat:new i('<span style="color: {{color}}">●</span> {{prefix}}{{value}}{{suffix}}')},tristate:{barWidth:4,barSpacing:1,posBarColor:"#6f6",negBarColor:"#f44",zeroBarColor:"#999",colorMap:{},tooltipFormat:new i('<span style="color: {{color}}">●</span> {{value:map}}'),tooltipValueLookups:{map:{"-1":"Loss",0:"Draw",1:"Win"}}},discrete:{lineHeight:"auto",thresholdColor:undefined,thresholdValue:0,chartRangeMax:undefined,chartRangeMin:undefined,chartRangeClip:false,tooltipFormat:new i("{{prefix}}{{value}}{{suffix}}")},bullet:{targetColor:"#f33",targetWidth:3,performanceColor:"#33f",rangeColors:["#d3dafe","#a8b6ff","#7f94ff"],base:undefined,tooltipFormat:new i("{{fieldkey:fields}} - {{value}}"),tooltipValueLookups:{fields:{r:"Range",p:"Performance",t:"Target"}}},pie:{offset:0,sliceColors:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"],borderWidth:0,borderColor:"#000",tooltipFormat:new i('<span style="color: {{color}}">●</span> {{value}} ({{percent.1}}%)')},box:{raw:false,boxLineColor:"#000",boxFillColor:"#cdf",whiskerColor:"#000",outlierLineColor:"#333",outlierFillColor:"#fff",medianColor:"#f00",showOutliers:true,outlierIQR:1.5,spotRadius:1.5,target:undefined,targetColor:"#4a2",chartRangeMax:undefined,chartRangeMin:undefined,tooltipFormat:new i("{{field:fields}}: {{value}}"),tooltipFormatFieldlistKey:"field",tooltipValueLookups:{fields:{lq:"Lower Quartile",med:"Median",uq:"Upper Quartile",lo:"Left Outlier",ro:"Right Outlier",lw:"Left Whisker",rw:"Right Whisker"}}}}};k=".jqstooltip { "+"position: absolute;"+"left: 0px;"+"top: 0px;"+"visibility: hidden;"+"background: rgb(0, 0, 0) transparent;"+"background-color: rgba(0,0,0,0.6);"+"filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);"+'-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";'+"color: white;"+"font: 10px arial, san serif;"+"text-align: left;"+"white-space: nowrap;"+"padding: 5px;"+"border: 1px solid white;"+"z-index: 10000;"+"}"+".jqsfield { "+"color: white;"+"font: 10px arial, san serif;"+"text-align: left;"+"}";r=function(){var t,n;t=function(){this.init.apply(this,arguments)};if(arguments.length>1){if(arguments[0]){t.prototype=e.extend(new arguments[0],arguments[arguments.length-1]);t._super=arguments[0].prototype}else{t.prototype=arguments[arguments.length-1]}if(arguments.length>2){n=Array.prototype.slice.call(arguments,1,-1);n.unshift(t.prototype);e.extend.apply(e,n)}}else{t.prototype=arguments[0]}t.prototype.cls=t;return t};e.SPFormatClass=i=r({fre:/\{\{([\w.]+?)(:(.+?))?\}\}/g,precre:/(\w+)\.(\d+)/,init:function(e,t){this.format=e;this.fclass=t},render:function(e,t,n){var r=this,i=e,s,o,u,a,f;return this.format.replace(this.fre,function(){var e;o=arguments[1];u=arguments[3];s=r.precre.exec(o);if(s){f=s[2];o=s[1]}else{f=false}a=i[o];if(a===undefined){return""}if(u&&t&&t[u]){e=t[u];if(e.get){return t[u].get(a)||a}else{return t[u][a]||a}}if(l(a)){if(n.get("numberFormatter")){a=n.get("numberFormatter")(a)}else{a=v(a,f,n.get("numberDigitGroupCount"),n.get("numberDigitGroupSep"),n.get("numberDecimalMark"))}}return a})}});e.spformat=function(e,t){return new i(e,t)};s=function(e,t,n){if(e<t){return t}if(e>n){return n}return e};o=function(e,t){var n;if(t===2){n=Math.floor(e.length/2);return e.length%2?e[n]:(e[n-1]+e[n])/2}else{if(e.length%2){n=(e.length*t+t)/4;return n%1?(e[Math.floor(n)]+e[Math.floor(n)-1])/2:e[n-1]}else{n=(e.length*t+2)/4;return n%1?(e[Math.floor(n)]+e[Math.floor(n)-1])/2:e[n-1]}}};u=function(e){var t;switch(e){case"undefined":e=undefined;break;case"null":e=null;break;case"true":e=true;break;case"false":e=false;break;default:t=parseFloat(e);if(e==t){e=t}}return e};a=function(e){var t,n=[];for(t=e.length;t--;){n[t]=u(e[t])}return n};f=function(e,t){var n,r,i=[];for(n=0,r=e.length;n<r;n++){if(e[n]!==t){i.push(e[n])}}return i};l=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};v=function(t,n,r,i,s){var o,u;t=(n===false?parseFloat(t).toString():t.toFixed(n)).split("");o=(o=e.inArray(".",t))<0?t.length:o;if(o<t.length){t[o]=s}for(u=o-r;u>0;u-=r){t.splice(u,0,i)}return t.join("")};c=function(e,t,n){var r;for(r=t.length;r--;){if(n&&t[r]===null)continue;if(t[r]!==e){return false}}return true};h=function(e){var t=0,n;for(n=e.length;n--;){t+=typeof e[n]==="number"?e[n]:0}return t};d=function(t){return e.isArray(t)?t:[t]};p=function(e){var t;if(document.createStyleSheet){document.createStyleSheet().cssText=e}else{t=document.createElement("style");t.type="text/css";document.getElementsByTagName("head")[0].appendChild(t);t[typeof document.body.style.WebkitAppearance=="string"?"innerText":"innerHTML"]=e}};e.fn.simpledraw=function(t,n,r,i){var s,o;if(r&&(s=this.data("_jqs_vcanvas"))){return s}if(t===undefined){t=e(this).innerWidth()}if(n===undefined){n=e(this).innerHeight()}if(e.fn.sparkline.hasCanvas){s=new M(t,n,this,i)}else if(e.fn.sparkline.hasVML){s=new _(t,n,this)}else{return false}o=e(this).data("_jqs_mhandler");if(o){o.registerCanvas(s)}return s};e.fn.cleardraw=function(){var e=this.data("_jqs_vcanvas");if(e){e.reset()}};e.RangeMapClass=m=r({init:function(e){var t,n,r=[];for(t in e){if(e.hasOwnProperty(t)&&typeof t==="string"&&t.indexOf(":")>-1){n=t.split(":");n[0]=n[0].length===0?-Infinity:parseFloat(n[0]);n[1]=n[1].length===0?Infinity:parseFloat(n[1]);n[2]=e[t];r.push(n)}}this.map=e;this.rangelist=r||false},get:function(e){var t=this.rangelist,n,r,i;if((i=this.map[e])!==undefined){return i}if(t){for(n=t.length;n--;){r=t[n];if(r[0]<=e&&r[1]>=e){return r[2]}}}return undefined}});e.range_map=function(e){return new m(e)};g=r({init:function(t,n){var r=e(t);this.$el=r;this.options=n;this.currentPageX=0;this.currentPageY=0;this.el=t;this.splist=[];this.tooltip=null;this.over=false;this.displayTooltips=!n.get("disableTooltips");this.highlightEnabled=!n.get("disableHighlight")},registerSparkline:function(e){this.splist.push(e);if(this.over){this.updateDisplay()}},registerCanvas:function(t){var n=e(t.canvas);this.canvas=t;this.$canvas=n;n.mouseenter(e.proxy(this.mouseenter,this));n.mouseleave(e.proxy(this.mouseleave,this));n.click(e.proxy(this.mouseclick,this))},reset:function(e){this.splist=[];if(this.tooltip&&e){this.tooltip.remove();this.tooltip=undefined}},mouseclick:function(t){var n=e.Event("sparklineClick");n.originalEvent=t;n.sparklines=this.splist;this.$el.trigger(n)},mouseenter:function(t){e(document.body).unbind("mousemove.jqs");e(document.body).bind("mousemove.jqs",e.proxy(this.mousemove,this));this.over=true;this.currentPageX=t.pageX;this.currentPageY=t.pageY;this.currentEl=t.target;if(!this.tooltip&&this.displayTooltips){this.tooltip=new y(this.options);this.tooltip.updatePosition(t.pageX,t.pageY)}this.updateDisplay()},mouseleave:function(){e(document.body).unbind("mousemove.jqs");var t=this.splist,n=t.length,r=false,i,s;this.over=false;this.currentEl=null;if(this.tooltip){this.tooltip.remove();this.tooltip=null}for(s=0;s<n;s++){i=t[s];if(i.clearRegionHighlight()){r=true}}if(r){this.canvas.render()}},mousemove:function(e){this.currentPageX=e.pageX;this.currentPageY=e.pageY;this.currentEl=e.target;if(this.tooltip){this.tooltip.updatePosition(e.pageX,e.pageY)}this.updateDisplay()},updateDisplay:function(){var t=this.splist,n=t.length,r=false,i=this.$canvas.offset(),s=this.currentPageX-i.left,o=this.currentPageY-i.top,u,a,f,l,c;if(!this.over){return}for(f=0;f<n;f++){a=t[f];l=a.setRegionHighlight(this.currentEl,s,o);if(l){r=true}}if(r){c=e.Event("sparklineRegionChange");c.sparklines=this.splist;this.$el.trigger(c);if(this.tooltip){u="";for(f=0;f<n;f++){a=t[f];u+=a.getCurrentRegionTooltip()}this.tooltip.setContent(u)}if(!this.disableHighlight){this.canvas.render()}}if(l===null){this.mouseleave()}}});y=r({sizeStyle:"position: static !important;"+"display: block !important;"+"visibility: hidden !important;"+"float: left !important;",init:function(t){var n=t.get("tooltipClassname","jqstooltip"),r=this.sizeStyle,i;this.container=t.get("tooltipContainer")||document.body;this.tooltipOffsetX=t.get("tooltipOffsetX",10);this.tooltipOffsetY=t.get("tooltipOffsetY",12);e("#jqssizetip").remove();e("#jqstooltip").remove();this.sizetip=e("<div/>",{id:"jqssizetip",style:r,"class":n});this.tooltip=e("<div/>",{id:"jqstooltip","class":n}).appendTo(this.container);i=this.tooltip.offset();this.offsetLeft=i.left;this.offsetTop=i.top;this.hidden=true;e(window).unbind("resize.jqs scroll.jqs");e(window).bind("resize.jqs scroll.jqs",e.proxy(this.updateWindowDims,this));this.updateWindowDims()},updateWindowDims:function(){this.scrollTop=e(window).scrollTop();this.scrollLeft=e(window).scrollLeft();this.scrollRight=this.scrollLeft+e(window).width();this.updatePosition()},getSize:function(e){this.sizetip.html(e).appendTo(this.container);this.width=this.sizetip.width()+12;this.height=this.sizetip.height()+12;this.sizetip.remove()},setContent:function(e){if(!e){this.tooltip.css("visibility","hidden");this.hidden=true;return}this.getSize(e);this.tooltip.html(e).css({width:this.width,height:this.height,visibility:"visible"});if(this.hidden){this.hidden=false;this.updatePosition()}},updatePosition:function(e,t){if(e===undefined){if(this.mousex===undefined){return}e=this.mousex-this.offsetLeft;t=this.mousey-this.offsetTop}else{this.mousex=e=e-this.offsetLeft;this.mousey=t=t-this.offsetTop}if(!this.height||!this.width||this.hidden){return}t-=this.height+this.tooltipOffsetY;e+=this.tooltipOffsetX;if(t<this.scrollTop){t=this.scrollTop}if(e<this.scrollLeft){e=this.scrollLeft}else if(e+this.width>this.scrollRight){e=this.scrollRight-this.width}this.tooltip.css({left:e,top:t})},remove:function(){this.tooltip.remove();this.sizetip.remove();this.sizetip=this.tooltip=undefined;e(window).unbind("resize.jqs scroll.jqs")}});L=function(){p(k)};e(L);D=[];e.fn.sparkline=function(t,n){return this.each(function(){var r=new e.fn.sparkline.options(this,n),i=e(this),s,o;s=function(){var n,s,o,u,a,f,l;if(t==="html"||t===undefined){l=this.getAttribute(r.get("tagValuesAttribute"));if(l===undefined||l===null){l=i.html()}n=l.replace(/(^\s*<!--)|(-->\s*$)|\s+/g,"").split(",")}else{n=t}s=r.get("width")==="auto"?n.length*r.get("defaultPixelsPerValue"):r.get("width");if(r.get("height")==="auto"){if(!r.get("composite")||!e.data(this,"_jqs_vcanvas")){u=document.createElement("span");u.innerHTML="a";i.html(u);o=e(u).innerHeight()||e(u).height();e(u).remove();u=null}}else{o=r.get("height")}if(!r.get("disableInteraction")){a=e.data(this,"_jqs_mhandler");if(!a){a=new g(this,r);e.data(this,"_jqs_mhandler",a)}else if(!r.get("composite")){a.reset()}}else{a=false}if(r.get("composite")&&!e.data(this,"_jqs_vcanvas")){if(!e.data(this,"_jqs_errnotify")){alert("Attempted to attach a composite sparkline to an element with no existing sparkline");e.data(this,"_jqs_errnotify",true)}return}f=new(e.fn.sparkline[r.get("type")])(this,n,r,s,o);f.render();if(a){a.registerSparkline(f)}};if(e(this).html()&&!r.get("disableHiddenCheck")&&e(this).is(":hidden")||e.fn.jquery<"1.3.0"&&e(this).parents().is(":hidden")||!e(this).parents("body").length){if(!r.get("composite")&&e.data(this,"_jqs_pending")){for(o=D.length;o;o--){if(D[o-1][0]==this){D.splice(o-1,1)}}}D.push([this,s]);e.data(this,"_jqs_pending",true)}else{s.call(this)}})};e.fn.sparkline.defaults=n();e.sparkline_display_visible=function(){var t,n,r;var i=[];for(n=0,r=D.length;n<r;n++){t=D[n][0];if(e(t).is(":visible")&&!e(t).parents().is(":hidden")){D[n][1].call(t);e.data(D[n][0],"_jqs_pending",false);i.push(n)}else if(!e(t).closest("html").length&&!e.data(t,"_jqs_pending")){e.data(D[n][0],"_jqs_pending",false);i.push(n)}}for(n=i.length;n;n--){D.splice(i[n-1],1)}};e.fn.sparkline.options=r({init:function(n,r){var i,s,o,u;this.userOptions=r=r||{};this.tag=n;this.tagValCache={};s=e.fn.sparkline.defaults;o=s.common;this.tagOptionsPrefix=r.enableTagOptions&&(r.tagOptionsPrefix||o.tagOptionsPrefix);u=this.getTagSetting("type");if(u===t){i=s[r.type||o.type]}else{i=s[u]}this.mergedOptions=e.extend({},o,i,r)},getTagSetting:function(e){var n=this.tagOptionsPrefix,r,i,s,o;if(n===false||n===undefined){return t}if(this.tagValCache.hasOwnProperty(e)){r=this.tagValCache.key}else{r=this.tag.getAttribute(n+e);if(r===undefined||r===null){r=t}else if(r.substr(0,1)==="["){r=r.substr(1,r.length-2).split(",");for(i=r.length;i--;){r[i]=u(r[i].replace(/(^\s*)|(\s*$)/g,""))}}else if(r.substr(0,1)==="{"){s=r.substr(1,r.length-2).split(",");r={};for(i=s.length;i--;){o=s[i].split(":",2);r[o[0].replace(/(^\s*)|(\s*$)/g,"")]=u(o[1].replace(/(^\s*)|(\s*$)/g,""))}}else{r=u(r)}this.tagValCache.key=r}return r},get:function(e,n){var r=this.getTagSetting(e),i;if(r!==t){return r}return(i=this.mergedOptions[e])===undefined?n:i}});e.fn.sparkline._base=r({disabled:false,init:function(t,n,r,i,s){this.el=t;this.$el=e(t);this.values=n;this.options=r;this.width=i;this.height=s;this.currentRegion=undefined},initTarget:function(){var e=!this.options.get("disableInteraction");if(!(this.target=this.$el.simpledraw(this.width,this.height,this.options.get("composite"),e))){this.disabled=true}else{this.canvasWidth=this.target.pixelWidth;this.canvasHeight=this.target.pixelHeight}},render:function(){if(this.disabled){this.el.innerHTML="";return false}return true},getRegion:function(e,t){},setRegionHighlight:function(e,t,n){var r=this.currentRegion,i=!this.options.get("disableHighlight"),s;if(t>this.canvasWidth||n>this.canvasHeight||t<0||n<0){return null}s=this.getRegion(e,t,n);if(r!==s){if(r!==undefined&&i){this.removeHighlight()}this.currentRegion=s;if(s!==undefined&&i){this.renderHighlight()}return true}return false},clearRegionHighlight:function(){if(this.currentRegion!==undefined){this.removeHighlight();this.currentRegion=undefined;return true}return false},renderHighlight:function(){this.changeHighlight(true)},removeHighlight:function(){this.changeHighlight(false)},changeHighlight:function(e){},getCurrentRegionTooltip:function(){var t=this.options,n="",r=[],s,o,u,a,f,l,c,h,p,d,v,m,g,y;if(this.currentRegion===undefined){return""}s=this.getCurrentRegionFields();v=t.get("tooltipFormatter");if(v){return v(this,t,s)}if(t.get("tooltipChartTitle")){n+='<div class="jqs jqstitle">'+t.get("tooltipChartTitle")+"</div>\n"}o=this.options.get("tooltipFormat");if(!o){return""}if(!e.isArray(o)){o=[o]}if(!e.isArray(s)){s=[s]}c=this.options.get("tooltipFormatFieldlist");h=this.options.get("tooltipFormatFieldlistKey");if(c&&h){p=[];for(l=s.length;l--;){d=s[l][h];if((y=e.inArray(d,c))!=-1){p[y]=s[l]}}s=p}u=o.length;g=s.length;for(l=0;l<u;l++){m=o[l];if(typeof m==="string"){m=new i(m)}a=m.fclass||"jqsfield";for(y=0;y<g;y++){if(!s[y].isNull||!t.get("tooltipSkipNull")){e.extend(s[y],{prefix:t.get("tooltipPrefix"),suffix:t.get("tooltipSuffix")});f=m.render(s[y],t.get("tooltipValueLookups"),t);r.push('<div class="'+a+'">'+f+"</div>")}}}if(r.length){return n+r.join("\n")}return""},getCurrentRegionFields:function(){},calcHighlightColor:function(e,t){var n=t.get("highlightColor"),r=t.get("highlightLighten"),i,o,u,a;if(n){return n}if(r){i=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e)||/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(i){u=[];o=e.length===4?16:1;for(a=0;a<3;a++){u[a]=s(Math.round(parseInt(i[a+1],16)*o*r),0,255)}return"rgb("+u.join(",")+")"}}return e}});b={changeHighlight:function(t){var n=this.currentRegion,r=this.target,i=this.regionShapes[n],s;if(i){s=this.renderRegion(n,t);if(e.isArray(s)||e.isArray(i)){r.replaceWithShapes(i,s);this.regionShapes[n]=e.map(s,function(e){return e.id})}else{r.replaceWithShape(i,s);this.regionShapes[n]=s.id}}},render:function(){var t=this.values,n=this.target,r=this.regionShapes,i,s,o,u;if(!this.cls._super.render.call(this)){return}for(o=t.length;o--;){i=this.renderRegion(o);if(i){if(e.isArray(i)){s=[];for(u=i.length;u--;){i[u].append();s.push(i[u].id)}r[o]=s}else{i.append();r[o]=i.id}}else{r[o]=null}}n.render()}};e.fn.sparkline.line=w=r(e.fn.sparkline._base,{type:"line",init:function(e,t,n,r,i){w._super.init.call(this,e,t,n,r,i);this.vertices=[];this.regionMap=[];this.xvalues=[];this.yvalues=[];this.yminmax=[];this.hightlightSpotId=null;this.lastShapeId=null;this.initTarget()},getRegion:function(e,t,n){var r,i=this.regionMap;for(r=i.length;r--;){if(i[r]!==null&&t>=i[r][0]&&t<=i[r][1]){return i[r][2]}}return undefined},getCurrentRegionFields:function(){var e=this.currentRegion;return{isNull:this.yvalues[e]===null,x:this.xvalues[e],y:this.yvalues[e],color:this.options.get("lineColor"),fillColor:this.options.get("fillColor"),offset:e}},renderHighlight:function(){var e=this.currentRegion,t=this.target,n=this.vertices[e],r=this.options,i=r.get("spotRadius"),s=r.get("highlightSpotColor"),o=r.get("highlightLineColor"),u,a;if(!n){return}if(i&&s){u=t.drawCircle(n[0],n[1],i,undefined,s);this.highlightSpotId=u.id;t.insertAfterShape(this.lastShapeId,u)}if(o){a=t.drawLine(n[0],this.canvasTop,n[0],this.canvasTop+this.canvasHeight,o);this.highlightLineId=a.id;t.insertAfterShape(this.lastShapeId,a)}},removeHighlight:function(){var e=this.target;if(this.highlightSpotId){e.removeShapeId(this.highlightSpotId);this.highlightSpotId=null}if(this.highlightLineId){e.removeShapeId(this.highlightLineId);this.highlightLineId=null}},scanValues:function(){var e=this.values,t=e.length,n=this.xvalues,r=this.yvalues,i=this.yminmax,s,o,u,a,f;for(s=0;s<t;s++){o=e[s];u=typeof e[s]==="string";a=typeof e[s]==="object"&&e[s]instanceof Array;f=u&&e[s].split(":");if(u&&f.length===2){n.push(Number(f[0]));r.push(Number(f[1]));i.push(Number(f[1]))}else if(a){n.push(o[0]);r.push(o[1]);i.push(o[1])}else{n.push(s);if(e[s]===null||e[s]==="null"){r.push(null)}else{r.push(Number(o));i.push(Number(o))}}}if(this.options.get("xvalues")){n=this.options.get("xvalues")}this.maxy=this.maxyorg=Math.max.apply(Math,i);this.miny=this.minyorg=Math.min.apply(Math,i);this.maxx=Math.max.apply(Math,n);this.minx=Math.min.apply(Math,n);this.xvalues=n;this.yvalues=r;this.yminmax=i},processRangeOptions:function(){var e=this.options,t=e.get("normalRangeMin"),n=e.get("normalRangeMax");if(t!==undefined){if(t<this.miny){this.miny=t}if(n>this.maxy){this.maxy=n}}if(e.get("chartRangeMin")!==undefined&&(e.get("chartRangeClip")||e.get("chartRangeMin")<this.miny)){this.miny=e.get("chartRangeMin")}if(e.get("chartRangeMax")!==undefined&&(e.get("chartRangeClip")||e.get("chartRangeMax")>this.maxy)){this.maxy=e.get("chartRangeMax")}if(e.get("chartRangeMinX")!==undefined&&(e.get("chartRangeClipX")||e.get("chartRangeMinX")<this.minx)){this.minx=e.get("chartRangeMinX")}if(e.get("chartRangeMaxX")!==undefined&&(e.get("chartRangeClipX")||e.get("chartRangeMaxX")>this.maxx)){this.maxx=e.get("chartRangeMaxX")}},drawNormalRange:function(e,t,n,r,i){var s=this.options.get("normalRangeMin"),o=this.options.get("normalRangeMax"),u=t+Math.round(n-n*((o-this.miny)/i)),a=Math.round(n*(o-s)/i);this.target.drawRect(e,u,r,a,undefined,this.options.get("normalRangeColor")).append()},render:function(){var t=this.options,n=this.target,r=this.canvasWidth,i=this.canvasHeight,s=this.vertices,o=t.get("spotRadius"),u=this.regionMap,a,f,l,c,h,p,d,v,g,y,b,E,S,x,T,N,C,k,L,A,O,M,_,D,P;if(!w._super.render.call(this)){return}this.scanValues();this.processRangeOptions();_=this.xvalues;D=this.yvalues;if(!this.yminmax.length||this.yvalues.length<2){return}c=h=0;a=this.maxx-this.minx===0?1:this.maxx-this.minx;f=this.maxy-this.miny===0?1:this.maxy-this.miny;l=this.yvalues.length-1;if(o&&(r<o*4||i<o*4)){o=0}if(o){O=t.get("highlightSpotColor")&&!t.get("disableInteraction");if(O||t.get("minSpotColor")||t.get("spotColor")&&D[l]===this.miny){i-=Math.ceil(o)}if(O||t.get("maxSpotColor")||t.get("spotColor")&&D[l]===this.maxy){i-=Math.ceil(o);c+=Math.ceil(o)}if(O||(t.get("minSpotColor")||t.get("maxSpotColor"))&&(D[0]===this.miny||D[0]===this.maxy)){h+=Math.ceil(o);r-=Math.ceil(o)}if(O||t.get("spotColor")||t.get("minSpotColor")||t.get("maxSpotColor")&&(D[l]===this.miny||D[l]===this.maxy)){r-=Math.ceil(o)}}i--;if(t.get("normalRangeMin")!==undefined&&!t.get("drawNormalOnTop")){this.drawNormalRange(h,c,i,r,f)}d=[];v=[d];x=T=null;N=D.length;for(P=0;P<N;P++){g=_[P];b=_[P+1];y=D[P];E=h+Math.round((g-this.minx)*(r/a));S=P<N-1?h+Math.round((b-this.minx)*(r/a)):r;T=E+(S-E)/2;u[P]=[x||0,T,P];x=T;if(y===null){if(P){if(D[P-1]!==null){d=[];v.push(d)}s.push(null)}}else{if(y<this.miny){y=this.miny}if(y>this.maxy){y=this.maxy}if(!d.length){d.push([E,c+i])}p=[E,c+Math.round(i-i*((y-this.miny)/f))];d.push(p);s.push(p)}}C=[];k=[];L=v.length;for(P=0;P<L;P++){d=v[P];if(d.length){if(t.get("fillColor")){d.push([d[d.length-1][0],c+i]);k.push(d.slice(0));d.pop()}if(d.length>2){d[0]=[d[0][0],d[1][1]]}C.push(d)}}L=k.length;for(P=0;P<L;P++){n.drawShape(k[P],t.get("fillColor"),t.get("fillColor")).append()}if(t.get("normalRangeMin")!==undefined&&t.get("drawNormalOnTop")){this.drawNormalRange(h,c,i,r,f)}L=C.length;for(P=0;P<L;P++){n.drawShape(C[P],t.get("lineColor"),undefined,t.get("lineWidth")).append()}if(o&&t.get("valueSpots")){A=t.get("valueSpots");if(A.get===undefined){A=new m(A)}for(P=0;P<N;P++){M=A.get(D[P]);if(M){n.drawCircle(h+Math.round((_[P]-this.minx)*(r/a)),c+Math.round(i-i*((D[P]-this.miny)/f)),o,undefined,M).append()}}}if(o&&t.get("spotColor")&&D[l]!==null){n.drawCircle(h+Math.round((_[_.length-1]-this.minx)*(r/a)),c+Math.round(i-i*((D[l]-this.miny)/f)),o,undefined,t.get("spotColor")).append()}if(this.maxy!==this.minyorg){if(o&&t.get("minSpotColor")){g=_[e.inArray(this.minyorg,D)];n.drawCircle(h+Math.round((g-this.minx)*(r/a)),c+Math.round(i-i*((this.minyorg-this.miny)/f)),o,undefined,t.get("minSpotColor")).append()}if(o&&t.get("maxSpotColor")){g=_[e.inArray(this.maxyorg,D)];n.drawCircle(h+Math.round((g-this.minx)*(r/a)),c+Math.round(i-i*((this.maxyorg-this.miny)/f)),o,undefined,t.get("maxSpotColor")).append()}}this.lastShapeId=n.getLastShapeId();this.canvasTop=c;n.render()}});e.fn.sparkline.bar=E=r(e.fn.sparkline._base,b,{type:"bar",init:function(t,n,r,i,o){var l=parseInt(r.get("barWidth"),10),c=parseInt(r.get("barSpacing"),10),h=r.get("chartRangeMin"),p=r.get("chartRangeMax"),d=r.get("chartRangeClip"),v=Infinity,g=-Infinity,y,b,w,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j,F,I,q,R;E._super.init.call(this,t,n,r,i,o);for(T=0,N=n.length;T<N;T++){F=n[T];y=typeof F==="string"&&F.indexOf(":")>-1;if(y||e.isArray(F)){D=true;if(y){F=n[T]=a(F.split(":"))}F=f(F,null);b=Math.min.apply(Math,F);w=Math.max.apply(Math,F);if(b<v){v=b}if(w>g){g=w}}}this.stacked=D;this.regionShapes={};this.barWidth=l;this.barSpacing=c;this.totalBarWidth=l+c;this.width=i=n.length*l+(n.length-1)*c;this.initTarget();if(d){M=h===undefined?-Infinity:h;_=p===undefined?Infinity:p}x=[];S=D?[]:x;var U=[];var z=[];for(T=0,N=n.length;T<N;T++){if(D){P=n[T];n[T]=j=[];U[T]=0;S[T]=z[T]=0;for(H=0,B=P.length;H<B;H++){F=j[H]=d?s(P[H],M,_):P[H];if(F!==null){if(F>0){U[T]+=F}if(v<0&&g>0){if(F<0){z[T]+=Math.abs(F)}else{S[T]+=F}}else{S[T]+=Math.abs(F-(F<0?g:v))}x.push(F)}}}else{F=d?s(n[T],M,_):n[T];F=n[T]=u(F);if(F!==null){x.push(F)}}}this.max=O=Math.max.apply(Math,x);this.min=A=Math.min.apply(Math,x);this.stackMax=g=D?Math.max.apply(Math,U):O;this.stackMin=v=D?Math.min.apply(Math,x):A;if(r.get("chartRangeMin")!==undefined&&(r.get("chartRangeClip")||r.get("chartRangeMin")<A)){A=r.get("chartRangeMin")}if(r.get("chartRangeMax")!==undefined&&(r.get("chartRangeClip")||r.get("chartRangeMax")>O)){O=r.get("chartRangeMax")}this.zeroAxis=k=r.get("zeroAxis",true);if(A<=0&&O>=0&&k){L=0}else if(k==false){L=A}else if(A>0){L=A}else{L=O}this.xaxisOffset=L;C=D?Math.max.apply(Math,S)+Math.max.apply(Math,z):O-A;this.canvasHeightEf=k&&A<0?this.canvasHeight-2:this.canvasHeight-1;if(A<L){q=D&&O>=0?g:O;I=(q-L)/C*this.canvasHeight;if(I!==Math.ceil(I)){this.canvasHeightEf-=2;I=Math.ceil(I)}}else{I=this.canvasHeight}this.yoffset=I;if(e.isArray(r.get("colorMap"))){this.colorMapByIndex=r.get("colorMap");this.colorMapByValue=null}else{this.colorMapByIndex=null;this.colorMapByValue=r.get("colorMap");if(this.colorMapByValue&&this.colorMapByValue.get===undefined){this.colorMapByValue=new m(this.colorMapByValue)}}this.range=C},getRegion:function(e,t,n){var r=Math.floor(t/this.totalBarWidth);return r<0||r>=this.values.length?undefined:r},getCurrentRegionFields:function(){var e=this.currentRegion,t=d(this.values[e]),n=[],r,i;for(i=t.length;i--;){r=t[i];n.push({isNull:r===null,value:r,color:this.calcColor(i,r,e),offset:e})}return n},calcColor:function(t,n,r){var i=this.colorMapByIndex,s=this.colorMapByValue,o=this.options,u,a;if(this.stacked){u=o.get("stackedBarColor")}else{u=n<0?o.get("negBarColor"):o.get("barColor")}if(n===0&&o.get("zeroColor")!==undefined){u=o.get("zeroColor")}if(s&&(a=s.get(n))){u=a}else if(i&&i.length>r){u=i[r]}return e.isArray(u)?u[t%u.length]:u},renderRegion:function(t,n){var r=this.values[t],i=this.options,s=this.xaxisOffset,o=[],u=this.range,a=this.stacked,f=this.target,l=t*this.totalBarWidth,h=this.canvasHeightEf,p=this.yoffset,d,v,m,g,y,b,w,E,S,x;r=e.isArray(r)?r:[r];w=r.length;E=r[0];g=c(null,r);x=c(s,r,true);if(g){if(i.get("nullColor")){m=n?i.get("nullColor"):this.calcHighlightColor(i.get("nullColor"),i);d=p>0?p-1:p;return f.drawRect(l,d,this.barWidth-1,0,m,m)}else{return undefined}}y=p;for(b=0;b<w;b++){E=r[b];if(a&&E===s){if(!x||S){continue}S=true}if(u>0){v=Math.floor(h*(Math.abs(E-s)/u))+1}else{v=1}if(E<s||E===s&&p===0){d=y;y+=v}else{d=p-v;p-=v}m=this.calcColor(b,E,t);if(n){m=this.calcHighlightColor(m,i)}o.push(f.drawRect(l,d,this.barWidth-1,v-1,m,m))}if(o.length===1){return o[0]}return o}});e.fn.sparkline.tristate=S=r(e.fn.sparkline._base,b,{type:"tristate",init:function(t,n,r,i,s){var o=parseInt(r.get("barWidth"),10),u=parseInt(r.get("barSpacing"),10);S._super.init.call(this,t,n,r,i,s);this.regionShapes={};this.barWidth=o;this.barSpacing=u;this.totalBarWidth=o+u;this.values=e.map(n,Number);this.width=i=n.length*o+(n.length-1)*u;if(e.isArray(r.get("colorMap"))){this.colorMapByIndex=r.get("colorMap");this.colorMapByValue=null}else{this.colorMapByIndex=null;this.colorMapByValue=r.get("colorMap");if(this.colorMapByValue&&this.colorMapByValue.get===undefined){this.colorMapByValue=new m(this.colorMapByValue)}}this.initTarget()},getRegion:function(e,t,n){return Math.floor(t/this.totalBarWidth)},getCurrentRegionFields:function(){var e=this.currentRegion;return{isNull:this.values[e]===undefined,value:this.values[e],color:this.calcColor(this.values[e],e),offset:e}},calcColor:function(e,t){var n=this.values,r=this.options,i=this.colorMapByIndex,s=this.colorMapByValue,o,u;if(s&&(u=s.get(e))){o=u}else if(i&&i.length>t){o=i[t]}else if(n[t]<0){o=r.get("negBarColor")}else if(n[t]>0){o=r.get("posBarColor")}else{o=r.get("zeroBarColor")}return o},renderRegion:function(e,t){var n=this.values,r=this.options,i=this.target,s,o,u,a,f,l;s=i.pixelHeight;u=Math.round(s/2);a=e*this.totalBarWidth;if(n[e]<0){f=u;o=u-1}else if(n[e]>0){f=0;o=u-1}else{f=u-1;o=2}l=this.calcColor(n[e],e);if(l===null){return}if(t){l=this.calcHighlightColor(l,r)}return i.drawRect(a,f,this.barWidth-1,o-1,l,l)}});e.fn.sparkline.discrete=x=r(e.fn.sparkline._base,b,{type:"discrete",init:function(t,n,r,i,s){x._super.init.call(this,t,n,r,i,s);this.regionShapes={};this.values=n=e.map(n,Number);this.min=Math.min.apply(Math,n);this.max=Math.max.apply(Math,n);this.range=this.max-this.min;this.width=i=r.get("width")==="auto"?n.length*2:this.width;this.interval=Math.floor(i/n.length);this.itemWidth=i/n.length;if(r.get("chartRangeMin")!==undefined&&(r.get("chartRangeClip")||r.get("chartRangeMin")<this.min)){this.min=r.get("chartRangeMin")}if(r.get("chartRangeMax")!==undefined&&(r.get("chartRangeClip")||r.get("chartRangeMax")>this.max)){this.max=r.get("chartRangeMax")}this.initTarget();if(this.target){this.lineHeight=r.get("lineHeight")==="auto"?Math.round(this.canvasHeight*.3):r.get("lineHeight")}},getRegion:function(e,t,n){return Math.floor(t/this.itemWidth)},getCurrentRegionFields:function(){var e=this.currentRegion;return{isNull:this.values[e]===undefined,value:this.values[e],offset:e}},renderRegion:function(e,t){var n=this.values,r=this.options,i=this.min,o=this.max,u=this.range,a=this.interval,f=this.target,l=this.canvasHeight,c=this.lineHeight,h=l-c,p,d,v,m;d=s(n[e],i,o);m=e*a;p=Math.round(h-h*((d-i)/u));v=r.get("thresholdColor")&&d<r.get("thresholdValue")?r.get("thresholdColor"):r.get("lineColor");if(t){v=this.calcHighlightColor(v,r)}return f.drawLine(m,p,m,p+c,v)}});e.fn.sparkline.bullet=T=r(e.fn.sparkline._base,{type:"bullet",init:function(e,t,n,r,i){var s,o,u;T._super.init.call(this,e,t,n,r,i);this.values=t=a(t);u=t.slice();u[0]=u[0]===null?u[2]:u[0];u[1]=t[1]===null?u[2]:u[1];s=Math.min.apply(Math,t);o=Math.max.apply(Math,t);if(n.get("base")===undefined){s=s<0?s:0}else{s=n.get("base")}this.min=s;this.max=o;this.range=o-s;this.shapes={};this.valueShapes={};this.regiondata={};this.width=r=n.get("width")==="auto"?"4.0em":r;this.target=this.$el.simpledraw(r,i,n.get("composite"));if(!t.length){this.disabled=true}this.initTarget()},getRegion:function(e,t,n){var r=this.target.getShapeAt(e,t,n);return r!==undefined&&this.shapes[r]!==undefined?this.shapes[r]:undefined},getCurrentRegionFields:function(){var e=this.currentRegion;return{fieldkey:e.substr(0,1),value:this.values[e.substr(1)],region:e}},changeHighlight:function(e){var t=this.currentRegion,n=this.valueShapes[t],r;delete this.shapes[n];switch(t.substr(0,1)){case"r":r=this.renderRange(t.substr(1),e);break;case"p":r=this.renderPerformance(e);break;case"t":r=this.renderTarget(e);break}this.valueShapes[t]=r.id;this.shapes[r.id]=t;this.target.replaceWithShape(n,r)},renderRange:function(e,t){var n=this.values[e],r=Math.round(this.canvasWidth*((n-this.min)/this.range)),i=this.options.get("rangeColors")[e-2];if(t){i=this.calcHighlightColor(i,this.options)}return this.target.drawRect(0,0,r-1,this.canvasHeight-1,i,i)},renderPerformance:function(e){var t=this.values[1],n=Math.round(this.canvasWidth*((t-this.min)/this.range)),r=this.options.get("performanceColor");if(e){r=this.calcHighlightColor(r,this.options)}return this.target.drawRect(0,Math.round(this.canvasHeight*.3),n-1,Math.round(this.canvasHeight*.4)-1,r,r)},renderTarget:function(e){var t=this.values[0],n=Math.round(this.canvasWidth*((t-this.min)/this.range)-this.options.get("targetWidth")/2),r=Math.round(this.canvasHeight*.1),i=this.canvasHeight-r*2,s=this.options.get("targetColor");if(e){s=this.calcHighlightColor(s,this.options)}return this.target.drawRect(n,r,this.options.get("targetWidth")-1,i-1,s,s)},render:function(){var e=this.values.length,t=this.target,n,r;if(!T._super.render.call(this)){return}for(n=2;n<e;n++){r=this.renderRange(n).append();this.shapes[r.id]="r"+n;this.valueShapes["r"+n]=r.id}if(this.values[1]!==null){r=this.renderPerformance().append();this.shapes[r.id]="p1";this.valueShapes.p1=r.id}if(this.values[0]!==null){r=this.renderTarget().append();this.shapes[r.id]="t0";this.valueShapes.t0=r.id}t.render()}});e.fn.sparkline.pie=N=r(e.fn.sparkline._base,{type:"pie",init:function(t,n,r,i,s){var o=0,u;N._super.init.call(this,t,n,r,i,s);this.shapes={};this.valueShapes={};this.values=n=e.map(n,Number);if(r.get("width")==="auto"){this.width=this.height}if(n.length>0){for(u=n.length;u--;){o+=n[u]}}this.total=o;this.initTarget();this.radius=Math.floor(Math.min(this.canvasWidth,this.canvasHeight)/2)},getRegion:function(e,t,n){var r=this.target.getShapeAt(e,t,n);return r!==undefined&&this.shapes[r]!==undefined?this.shapes[r]:undefined},getCurrentRegionFields:function(){var e=this.currentRegion;return{isNull:this.values[e]===undefined,value:this.values[e],percent:this.values[e]/this.total*100,color:this.options.get("sliceColors")[e%this.options.get("sliceColors").length],offset:e}},changeHighlight:function(e){var t=this.currentRegion,n=this.renderSlice(t,e),r=this.valueShapes[t];delete this.shapes[r];this.target.replaceWithShape(r,n);this.valueShapes[t]=n.id;this.shapes[n.id]=t},renderSlice:function(e,t){var n=this.target,r=this.options,i=this.radius,s=r.get("borderWidth"),o=r.get("offset"),u=2*Math.PI,a=this.values,f=this.total,l=o?2*Math.PI*(o/360):0,c,h,p,d,v;d=a.length;for(p=0;p<d;p++){c=l;h=l;if(f>0){h=l+u*(a[p]/f)}if(e===p){v=r.get("sliceColors")[p%r.get("sliceColors").length];if(t){v=this.calcHighlightColor(v,r)}return n.drawPieSlice(i,i,i-s,c,h,undefined,v)}l=h}},render:function(){var e=this.target,t=this.values,n=this.options,r=this.radius,i=n.get("borderWidth"),s,o;if(!N._super.render.call(this)){return}if(i){e.drawCircle(r,r,Math.floor(r-i/2),n.get("borderColor"),undefined,i).append()}for(o=t.length;o--;){if(t[o]){s=this.renderSlice(o).append();this.valueShapes[o]=s.id;this.shapes[s.id]=o}}e.render()}});e.fn.sparkline.box=C=r(e.fn.sparkline._base,{type:"box",init:function(t,n,r,i,s){C._super.init.call(this,t,n,r,i,s);this.values=e.map(n,Number);this.width=r.get("width")==="auto"?"4.0em":i;this.initTarget();if(!this.values.length){this.disabled=1}},getRegion:function(){return 1},getCurrentRegionFields:function(){var e=[{field:"lq",value:this.quartiles[0]},{field:"med",value:this.quartiles[1]},{field:"uq",value:this.quartiles[2]}];if(this.loutlier!==undefined){e.push({field:"lo",value:this.loutlier})}if(this.routlier!==undefined){e.push({field:"ro",value:this.routlier})}if(this.lwhisker!==undefined){e.push({field:"lw",value:this.lwhisker})}if(this.rwhisker!==undefined){e.push({field:"rw",value:this.rwhisker})}return e},render:function(){var e=this.target,t=this.values,n=t.length,r=this.options,i=this.canvasWidth,s=this.canvasHeight,u=r.get("chartRangeMin")===undefined?Math.min.apply(Math,t):r.get("chartRangeMin"),a=r.get("chartRangeMax")===undefined?Math.max.apply(Math,t):r.get("chartRangeMax"),f=0,l,c,h,p,d,v,m,g,y,b,w;if(!C._super.render.call(this)){return}if(r.get("raw")){if(r.get("showOutliers")&&t.length>5){c=t[0];l=t[1];p=t[2];d=t[3];v=t[4];m=t[5];g=t[6]}else{l=t[0];p=t[1];d=t[2];v=t[3];m=t[4]}}else{t.sort(function(e,t){return e-t});p=o(t,1);d=o(t,2);v=o(t,3);h=v-p;if(r.get("showOutliers")){l=m=undefined;for(y=0;y<n;y++){if(l===undefined&&t[y]>p-h*r.get("outlierIQR")){l=t[y]}if(t[y]<v+h*r.get("outlierIQR")){m=t[y]}}c=t[0];g=t[n-1]}else{l=t[0];m=t[n-1]}}this.quartiles=[p,d,v];this.lwhisker=l;this.rwhisker=m;this.loutlier=c;this.routlier=g;w=i/(a-u+1);if(r.get("showOutliers")){f=Math.ceil(r.get("spotRadius"));i-=2*Math.ceil(r.get("spotRadius"));w=i/(a-u+1);if(c<l){e.drawCircle((c-u)*w+f,s/2,r.get("spotRadius"),r.get("outlierLineColor"),r.get("outlierFillColor")).append()}if(g>m){e.drawCircle((g-u)*w+f,s/2,r.get("spotRadius"),r.get("outlierLineColor"),r.get("outlierFillColor")).append()}}e.drawRect(Math.round((p-u)*w+f),Math.round(s*.1),Math.round((v-p)*w),Math.round(s*.8),r.get("boxLineColor"),r.get("boxFillColor")).append();e.drawLine(Math.round((l-u)*w+f),Math.round(s/2),Math.round((p-u)*w+f),Math.round(s/2),r.get("lineColor")).append();e.drawLine(Math.round((l-u)*w+f),Math.round(s/4),Math.round((l-u)*w+f),Math.round(s-s/4),r.get("whiskerColor")).append();e.drawLine(Math.round((m-u)*w+f),Math.round(s/2),Math.round((v-u)*w+f),Math.round(s/2),r.get("lineColor")).append();e.drawLine(Math.round((m-u)*w+f),Math.round(s/4),Math.round((m-u)*w+f),Math.round(s-s/4),r.get("whiskerColor")).append();e.drawLine(Math.round((d-u)*w+f),Math.round(s*.1),Math.round((d-u)*w+f),Math.round(s*.9),r.get("medianColor")).append();if(r.get("target")){b=Math.ceil(r.get("spotRadius"));e.drawLine(Math.round((r.get("target")-u)*w+f),Math.round(s/2-b),Math.round((r.get("target")-u)*w+f),Math.round(s/2+b),r.get("targetColor")).append();e.drawLine(Math.round((r.get("target")-u)*w+f-b),Math.round(s/2),Math.round((r.get("target")-u)*w+f+b),Math.round(s/2),r.get("targetColor")).append()}e.render()}});(function(){if(document.namespaces&&!document.namespaces.v){e.fn.sparkline.hasVML=true;document.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML")}else{e.fn.sparkline.hasVML=false}var t=document.createElement("canvas");e.fn.sparkline.hasCanvas=!!(t.getContext&&t.getContext("2d"))})();A=r({init:function(e,t,n,r){this.target=e;this.id=t;this.type=n;this.args=r},append:function(){this.target.appendShape(this);return this}});O=r({_pxregex:/(\d+)(px)?\s*$/i,init:function(t,n,r){if(!t){return}this.width=t;this.height=n;this.target=r;this.lastShapeId=null;if(r[0]){r=r[0]}e.data(r,"_jqs_vcanvas",this)},drawLine:function(e,t,n,r,i,s){return this.drawShape([[e,t],[n,r]],i,s)},drawShape:function(e,t,n,r){return this._genShape("Shape",[e,t,n,r])},drawCircle:function(e,t,n,r,i,s){return this._genShape("Circle",[e,t,n,r,i,s])},drawPieSlice:function(e,t,n,r,i,s,o){return this._genShape("PieSlice",[e,t,n,r,i,s,o])},drawRect:function(e,t,n,r,i,s){return this._genShape("Rect",[e,t,n,r,i,s])},getElement:function(){return this.canvas},getLastShapeId:function(){return this.lastShapeId},reset:function(){alert("reset not implemented")},_insert:function(t,n){e(n).html(t)},_calculatePixelDims:function(t,n,r){var i;i=this._pxregex.exec(n);if(i){this.pixelHeight=i[1]}else{this.pixelHeight=e(r).height()}i=this._pxregex.exec(t);if(i){this.pixelWidth=i[1]}else{this.pixelWidth=e(r).width()}},_genShape:function(e,t){var n=P++;t.unshift(n);return new A(this,n,e,t)},appendShape:function(e){alert("appendShape not implemented")},replaceWithShape:function(e,t){alert("replaceWithShape not implemented")},insertAfterShape:function(e,t){alert("insertAfterShape not implemented")},removeShapeId:function(e){alert("removeShapeId not implemented")},getShapeAt:function(e,t,n){alert("getShapeAt not implemented")},render:function(){alert("render not implemented")}});M=r(O,{init:function(t,n,r,i){M._super.init.call(this,t,n,r);this.canvas=document.createElement("canvas");if(r[0]){r=r[0]}e.data(r,"_jqs_vcanvas",this);e(this.canvas).css({display:"inline-block",width:t,height:n,verticalAlign:"top"});this._insert(this.canvas,r);this._calculatePixelDims(t,n,this.canvas);this.canvas.width=this.pixelWidth;this.canvas.height=this.pixelHeight;this.interact=i;this.shapes={};this.shapeseq=[];this.currentTargetShapeId=undefined;e(this.canvas).css({width:this.pixelWidth,height:this.pixelHeight})},_getContext:function(e,t,n){var r=this.canvas.getContext("2d");if(e!==undefined){r.strokeStyle=e}r.lineWidth=n===undefined?1:n;if(t!==undefined){r.fillStyle=t}return r},reset:function(){var e=this._getContext();e.clearRect(0,0,this.pixelWidth,this.pixelHeight);this.shapes={};this.shapeseq=[];this.currentTargetShapeId=undefined},_drawShape:function(e,t,n,r,i){var s=this._getContext(n,r,i),o,u;s.beginPath();s.moveTo(t[0][0]+.5,t[0][1]+.5);for(o=1,u=t.length;o<u;o++){s.lineTo(t[o][0]+.5,t[o][1]+.5)}if(n!==undefined){s.stroke()}if(r!==undefined){s.fill()}if(this.targetX!==undefined&&this.targetY!==undefined&&s.isPointInPath(this.targetX,this.targetY)){this.currentTargetShapeId=e}},_drawCircle:function(e,t,n,r,i,s,o){var u=this._getContext(i,s,o);u.beginPath();u.arc(t,n,r,0,2*Math.PI,false);if(this.targetX!==undefined&&this.targetY!==undefined&&u.isPointInPath(this.targetX,this.targetY)){this.currentTargetShapeId=e}if(i!==undefined){u.stroke()}if(s!==undefined){u.fill()}},_drawPieSlice:function(e,t,n,r,i,s,o,u){var a=this._getContext(o,u);a.beginPath();a.moveTo(t,n);a.arc(t,n,r,i,s,false);a.lineTo(t,n);a.closePath();if(o!==undefined){a.stroke()}if(u){a.fill()}if(this.targetX!==undefined&&this.targetY!==undefined&&a.isPointInPath(this.targetX,this.targetY)){this.currentTargetShapeId=e}},_drawRect:function(e,t,n,r,i,s,o){return this._drawShape(e,[[t,n],[t+r,n],[t+r,n+i],[t,n+i],[t,n]],s,o)},appendShape:function(e){this.shapes[e.id]=e;this.shapeseq.push(e.id);this.lastShapeId=e.id;return e.id},replaceWithShape:function(e,t){var n=this.shapeseq,r;this.shapes[t.id]=t;for(r=n.length;r--;){if(n[r]==e){n[r]=t.id}}delete this.shapes[e]},replaceWithShapes:function(e,t){var n=this.shapeseq,r={},i,s,o;for(s=e.length;s--;){r[e[s]]=true}for(s=n.length;s--;){i=n[s];if(r[i]){n.splice(s,1);delete this.shapes[i];o=s}}for(s=t.length;s--;){n.splice(o,0,t[s].id);this.shapes[t[s].id]=t[s]}},insertAfterShape:function(e,t){var n=this.shapeseq,r;for(r=n.length;r--;){if(n[r]===e){n.splice(r+1,0,t.id);this.shapes[t.id]=t;return}}},removeShapeId:function(e){var t=this.shapeseq,n;for(n=t.length;n--;){if(t[n]===e){t.splice(n,1);break}}delete this.shapes[e]},getShapeAt:function(e,t,n){this.targetX=t;this.targetY=n;this.render();return this.currentTargetShapeId},render:function(){var e=this.shapeseq,t=this.shapes,n=e.length,r=this._getContext(),i,s,o;r.clearRect(0,0,this.pixelWidth,this.pixelHeight);for(o=0;o<n;o++){i=e[o];s=t[i];this["_draw"+s.type].apply(this,s.args)}if(!this.interact){this.shapes={};this.shapeseq=[]}}});_=r(O,{init:function(t,n,r){var i;_._super.init.call(this,t,n,r);if(r[0]){r=r[0]}e.data(r,"_jqs_vcanvas",this);this.canvas=document.createElement("span");e(this.canvas).css({display:"inline-block",position:"relative",overflow:"hidden",width:t,height:n,margin:"0px",padding:"0px",verticalAlign:"top"});this._insert(this.canvas,r);this._calculatePixelDims(t,n,this.canvas);this.canvas.width=this.pixelWidth;this.canvas.height=this.pixelHeight;i='<v:group coordorigin="0 0" coordsize="'+this.pixelWidth+" "+this.pixelHeight+'"'+' style="position:absolute;top:0;left:0;width:'+this.pixelWidth+"px;height="+this.pixelHeight+'px;"></v:group>';this.canvas.insertAdjacentHTML("beforeEnd",i);this.group=e(this.canvas).children()[0];this.rendered=false;this.prerender=""},_drawShape:function(e,t,n,r,i){var s=[],o,u,a,f,l,c,h;for(h=0,c=t.length;h<c;h++){s[h]=""+t[h][0]+","+t[h][1]}o=s.splice(0,1);i=i===undefined?1:i;u=n===undefined?' stroked="false" ':' strokeWeight="'+i+'px" strokeColor="'+n+'" ';a=r===undefined?' filled="false"':' fillColor="'+r+'" filled="true" ';f=s[0]===s[s.length-1]?"x ":"";l='<v:shape coordorigin="0 0" coordsize="'+this.pixelWidth+" "+this.pixelHeight+'" '+' id="jqsshape'+e+'" '+u+a+' style="position:absolute;left:0px;top:0px;height:'+this.pixelHeight+"px;width:"+this.pixelWidth+'px;padding:0px;margin:0px;" '+' path="m '+o+" l "+s.join(", ")+" "+f+'e">'+" </v:shape>";return l},_drawCircle:function(e,t,n,r,i,s,o){var u,a,f;t-=r;n-=r;u=i===undefined?' stroked="false" ':' strokeWeight="'+o+'px" strokeColor="'+i+'" ';a=s===undefined?' filled="false"':' fillColor="'+s+'" filled="true" ';f="<v:oval "+' id="jqsshape'+e+'" '+u+a+' style="position:absolute;top:'+n+"px; left:"+t+"px; width:"+r*2+"px; height:"+r*2+'px"></v:oval>';return f},_drawPieSlice:function(e,t,n,r,i,s,o,u){var a,f,l,c,h,p,d,v;if(i===s){return""}if(s-i===2*Math.PI){i=0;s=2*Math.PI}f=t+Math.round(Math.cos(i)*r);l=n+Math.round(Math.sin(i)*r);c=t+Math.round(Math.cos(s)*r);h=n+Math.round(Math.sin(s)*r);if(f===c&&l===h){if(s-i<Math.PI){return""}f=c=t+r;l=h=n}if(f===c&&l===h&&s-i<Math.PI){return""}a=[t-r,n-r,t+r,n+r,f,l,c,h];p=o===undefined?' stroked="false" ':' strokeWeight="1px" strokeColor="'+o+'" ';d=u===undefined?' filled="false"':' fillColor="'+u+'" filled="true" ';v='<v:shape coordorigin="0 0" coordsize="'+this.pixelWidth+" "+this.pixelHeight+'" '+' id="jqsshape'+e+'" '+p+d+' style="position:absolute;left:0px;top:0px;height:'+this.pixelHeight+"px;width:"+this.pixelWidth+'px;padding:0px;margin:0px;" '+' path="m '+t+","+n+" wa "+a.join(", ")+' x e">'+" </v:shape>";return v},_drawRect:function(e,t,n,r,i,s,o){return this._drawShape(e,[[t,n],[t,n+i],[t+r,n+i],[t+r,n],[t,n]],s,o)},reset:function(){this.group.innerHTML=""},appendShape:function(e){var t=this["_draw"+e.type].apply(this,e.args);if(this.rendered){this.group.insertAdjacentHTML("beforeEnd",t)}else{this.prerender+=t}this.lastShapeId=e.id;return e.id},replaceWithShape:function(t,n){var r=e("#jqsshape"+t),i=this["_draw"+n.type].apply(this,n.args);r[0].outerHTML=i},replaceWithShapes:function(t,n){var r=e("#jqsshape"+t[0]),i="",s=n.length,o;for(o=0;o<s;o++){i+=this["_draw"+n[o].type].apply(this,n[o].args)}r[0].outerHTML=i;for(o=1;o<t.length;o++){e("#jqsshape"+t[o]).remove()}},insertAfterShape:function(t,n){var r=e("#jqsshape"+t),i=this["_draw"+n.type].apply(this,n.args);r[0].insertAdjacentHTML("afterEnd",i)},removeShapeId:function(t){var n=e("#jqsshape"+t);this.group.removeChild(n[0])},getShapeAt:function(e,t,n){var r=e.id.substr(8);return r},render:function(){if(!this.rendered){this.group.innerHTML=this.prerender;this.rendered=true}}})}) |