this.canvasWidth||y>this.canvasHeight||x<0||y<0){return null;}newRegion=this.getRegion(el,x,y);if(currentRegion!==newRegion){if(currentRegion!==undefined&&highlightEnabled){this.removeHighlight();}this.currentRegion=newRegion;if(newRegion!==undefined&&highlightEnabled){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(highlight){},getCurrentRegionTooltip:function(){var options=this.options,header='',entries=[],fields,formats,formatlen,fclass,text,i,showFields,showFieldsKey,newFields,fv,formatter,format,fieldlen,j;if(this.currentRegion===undefined){return'';}fields=this.getCurrentRegionFields();formatter=options.get('tooltipFormatter');if(formatter){return formatter(this,options,fields);}if(options.get('tooltipChartTitle')){header+=''+options.get('tooltipChartTitle')+'
\n';}formats=this.options.get('tooltipFormat');if(!formats){return'';}if(!$.isArray(formats)){formats=[formats];}if(!$.isArray(fields)){fields=[fields];}showFields=this.options.get('tooltipFormatFieldlist');showFieldsKey=this.options.get('tooltipFormatFieldlistKey');if(showFields&&showFieldsKey){newFields=[];for(i=fields.length;i--;){fv=fields[i][showFieldsKey];if((j=$.inArray(fv,showFields))!=-1){newFields[j]=fields[i];}}fields=newFields;}formatlen=formats.length;fieldlen=fields.length;for(i=0;i'+text+'');}}}if(entries.length){return header+entries.join('\n');}return'';},getCurrentRegionFields:function(){},calcHighlightColor:function(color,options){var highlightColor=options.get('highlightColor'),lighten=options.get('highlightLighten'),parse,mult,rgbnew,i;if(highlightColor){return highlightColor;}if(lighten){parse=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(color)||/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);if(parse){rgbnew=[];mult=color.length===4?16:1;for(i=0;i<3;i++){rgbnew[i]=clipval(Math.round(parseInt(parse[i+1],16)*mult*lighten),0,255);}return'rgb('+rgbnew.join(',')+')';}}return color;}});barHighlightMixin={changeHighlight:function(highlight){var currentRegion=this.currentRegion,target=this.target,shapeids=this.regionShapes[currentRegion],newShapes;if(shapeids){newShapes=this.renderRegion(currentRegion,highlight);if($.isArray(newShapes)||$.isArray(shapeids)){target.replaceWithShapes(shapeids,newShapes);this.regionShapes[currentRegion]=$.map(newShapes,function(newShape){return newShape.id;});}else{target.replaceWithShape(shapeids,newShapes);this.regionShapes[currentRegion]=newShapes.id;}}},render:function(){var values=this.values,target=this.target,regionShapes=this.regionShapes,shapes,ids,i,j;if(!this.cls._super.render.call(this)){return;}for(i=values.length;i--;){shapes=this.renderRegion(i);if(shapes){if($.isArray(shapes)){ids=[];for(j=shapes.length;j--;){shapes[j].append();ids.push(shapes[j].id);}regionShapes[i]=ids;}else{shapes.append();regionShapes[i]=shapes.id;}}else{regionShapes[i]=null;}}target.render();}};$.fn.sparkline.line=line=createClass($.fn.sparkline._base,{type:'line',init:function(el,values,options,width,height){line._super.init.call(this,el,values,options,width,height);this.vertices=[];this.regionMap=[];this.xvalues=[];this.yvalues=[];this.yminmax=[];this.hightlightSpotId=null;this.lastShapeId=null;this.initTarget();},getRegion:function(el,x,y){var i,regionMap=this.regionMap;for(i=regionMap.length;i--;){if(regionMap[i]!==null&&x>=regionMap[i][0]&&x<=regionMap[i][1]){return regionMap[i][2];}}return undefined;},getCurrentRegionFields:function(){var currentRegion=this.currentRegion;return{isNull:this.yvalues[currentRegion]===null,x:this.xvalues[currentRegion],y:this.yvalues[currentRegion],color:this.options.get('lineColor'),fillColor:this.options.get('fillColor'),offset:currentRegion};},renderHighlight:function(){var currentRegion=this.currentRegion,target=this.target,vertex=this.vertices[currentRegion],options=this.options,spotRadius=options.get('spotRadius'),highlightSpotColor=options.get('highlightSpotColor'),highlightLineColor=options.get('highlightLineColor'),highlightSpot,highlightLine;if(!vertex){return;}if(spotRadius&&highlightSpotColor){highlightSpot=target.drawCircle(vertex[0],vertex[1],spotRadius,undefined,highlightSpotColor);this.highlightSpotId=highlightSpot.id;target.insertAfterShape(this.lastShapeId,highlightSpot);}if(highlightLineColor){highlightLine=target.drawLine(vertex[0],this.canvasTop,vertex[0],this.canvasTop+this.canvasHeight,highlightLineColor);this.highlightLineId=highlightLine.id;target.insertAfterShape(this.lastShapeId,highlightLine);}},removeHighlight:function(){var target=this.target;if(this.highlightSpotId){target.removeShapeId(this.highlightSpotId);this.highlightSpotId=null;}if(this.highlightLineId){target.removeShapeId(this.highlightLineId);this.highlightLineId=null;}},scanValues:function(){var values=this.values,valcount=values.length,xvalues=this.xvalues,yvalues=this.yvalues,yminmax=this.yminmax,i,val,isStr,isArray,sp;for(i=0;ithis.maxy){this.maxy=normalRangeMax;}}if(options.get('chartRangeMin')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMin')this.maxy)){this.maxy=options.get('chartRangeMax');}if(options.get('chartRangeMinX')!==undefined&&(options.get('chartRangeClipX')||options.get('chartRangeMinX')this.maxx)){this.maxx=options.get('chartRangeMaxX');}},drawNormalRange:function(canvasLeft,canvasTop,canvasHeight,canvasWidth,rangey){var normalRangeMin=this.options.get('normalRangeMin'),normalRangeMax=this.options.get('normalRangeMax'),ytop=canvasTop+Math.round(canvasHeight-(canvasHeight*((normalRangeMax-this.miny)/rangey))),height=Math.round((canvasHeight*(normalRangeMax-normalRangeMin))/rangey);this.target.drawRect(canvasLeft,ytop,canvasWidth,height,undefined,this.options.get('normalRangeColor')).append();},render:function(){var options=this.options,target=this.target,canvasWidth=this.canvasWidth,canvasHeight=this.canvasHeight,vertices=this.vertices,spotRadius=options.get('spotRadius'),regionMap=this.regionMap,rangex,rangey,yvallast,canvasTop,canvasLeft,vertex,path,paths,x,y,xnext,xpos,xposnext,last,next,yvalcount,lineShapes,fillShapes,plen,valueSpots,hlSpotsEnabled,color,xvalues,yvalues,i;if(!line._super.render.call(this)){return;}this.scanValues();this.processRangeOptions();xvalues=this.xvalues;yvalues=this.yvalues;if(!this.yminmax.length||this.yvalues.length<2){return;}canvasTop=canvasLeft=0;rangex=this.maxx-this.minx===0?1:this.maxx-this.minx;rangey=this.maxy-this.miny===0?1:this.maxy-this.miny;yvallast=this.yvalues.length-1;if(spotRadius&&(canvasWidth<(spotRadius*4)||canvasHeight<(spotRadius*4))){spotRadius=0;}if(spotRadius){hlSpotsEnabled=options.get('highlightSpotColor')&&!options.get('disableInteraction');if(hlSpotsEnabled||options.get('minSpotColor')||(options.get('spotColor')&&yvalues[yvallast]===this.miny)){canvasHeight-=Math.ceil(spotRadius);}if(hlSpotsEnabled||options.get('maxSpotColor')||(options.get('spotColor')&&yvalues[yvallast]===this.maxy)){canvasHeight-=Math.ceil(spotRadius);canvasTop+=Math.ceil(spotRadius);}if(hlSpotsEnabled||((options.get('minSpotColor')||options.get('maxSpotColor'))&&(yvalues[0]===this.miny||yvalues[0]===this.maxy))){canvasLeft+=Math.ceil(spotRadius);canvasWidth-=Math.ceil(spotRadius);}if(hlSpotsEnabled||options.get('spotColor')||(options.get('minSpotColor')||options.get('maxSpotColor')&&(yvalues[yvallast]===this.miny||yvalues[yvallast]===this.maxy))){canvasWidth-=Math.ceil(spotRadius);}}canvasHeight--;if(options.get('normalRangeMin')!==undefined&&!options.get('drawNormalOnTop')){this.drawNormalRange(canvasLeft,canvasTop,canvasHeight,canvasWidth,rangey);}path=[];paths=[path];last=next=null;yvalcount=yvalues.length;for(i=0;ithis.maxy){y=this.maxy;}if(!path.length){path.push([xpos,canvasTop+canvasHeight]);}vertex=[xpos,canvasTop+Math.round(canvasHeight-(canvasHeight*((y-this.miny)/rangey)))];path.push(vertex);vertices.push(vertex);}}lineShapes=[];fillShapes=[];plen=paths.length;for(i=0;i2){path[0]=[path[0][0],path[1][1]];}lineShapes.push(path);}}plen=fillShapes.length;for(i=0;i-1;if(isStackString||$.isArray(val)){stacked=true;if(isStackString){val=values[i]=normalizeValues(val.split(':'));}val=remove(val,null);groupMin=Math.min.apply(Math,val);groupMax=Math.max.apply(Math,val);if(groupMinstackMax){stackMax=groupMax;}}}this.stacked=stacked;this.regionShapes={};this.barWidth=barWidth;this.barSpacing=barSpacing;this.totalBarWidth=barWidth+barSpacing;this.width=width=(values.length*barWidth)+((values.length-1)*barSpacing);this.initTarget();if(chartRangeClip){clipMin=chartRangeMin===undefined?-Infinity:chartRangeMin;clipMax=chartRangeMax===undefined?Infinity:chartRangeMax;}numValues=[];stackRanges=stacked?[]:numValues;var stackTotals=[];var stackRangesNeg=[];for(i=0,vlen=values.length;i0){stackTotals[i]+=val;}if(stackMin<0&&stackMax>0){if(val<0){stackRangesNeg[i]+=Math.abs(val);}else{stackRanges[i]+=val;}}else{stackRanges[i]+=Math.abs(val-(val<0?stackMax:stackMin));}numValues.push(val);}}}else{val=chartRangeClip?clipval(values[i],clipMin,clipMax):values[i];val=values[i]=normalizeValue(val);if(val!==null){numValues.push(val);}}}this.max=max=Math.max.apply(Math,numValues);this.min=min=Math.min.apply(Math,numValues);this.stackMax=stackMax=stacked?Math.max.apply(Math,stackTotals):max;this.stackMin=stackMin=stacked?Math.min.apply(Math,numValues):min;if(options.get('chartRangeMin')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMin')max)){max=options.get('chartRangeMax');}this.zeroAxis=zeroAxis=options.get('zeroAxis',true);if(min<=0&&max>=0&&zeroAxis){xaxisOffset=0;}else if(zeroAxis==false){xaxisOffset=min;}else if(min>0){xaxisOffset=min;}else{xaxisOffset=max;}this.xaxisOffset=xaxisOffset;range=stacked?(Math.max.apply(Math,stackRanges)+Math.max.apply(Math,stackRangesNeg)):max-min;this.canvasHeightEf=(zeroAxis&&min<0)?this.canvasHeight-2:this.canvasHeight-1;if(min=0)?stackMax:max;yoffset=(yMaxCalc-xaxisOffset)/range*this.canvasHeight;if(yoffset!==Math.ceil(yoffset)){this.canvasHeightEf-=2;yoffset=Math.ceil(yoffset);}}else{yoffset=this.canvasHeight;}this.yoffset=yoffset;if($.isArray(options.get('colorMap'))){this.colorMapByIndex=options.get('colorMap');this.colorMapByValue=null;}else{this.colorMapByIndex=null;this.colorMapByValue=options.get('colorMap');if(this.colorMapByValue&&this.colorMapByValue.get===undefined){this.colorMapByValue=new RangeMap(this.colorMapByValue);}}this.range=range;},getRegion:function(el,x,y){var result=Math.floor(x/this.totalBarWidth);return(result<0||result>=this.values.length)?undefined:result;},getCurrentRegionFields:function(){var currentRegion=this.currentRegion,values=ensureArray(this.values[currentRegion]),result=[],value,i;for(i=values.length;i--;){value=values[i];result.push({isNull:value===null,value:value,color:this.calcColor(i,value,currentRegion),offset:currentRegion});}return result;},calcColor:function(stacknum,value,valuenum){var colorMapByIndex=this.colorMapByIndex,colorMapByValue=this.colorMapByValue,options=this.options,color,newColor;if(this.stacked){color=options.get('stackedBarColor');}else{color=(value<0)?options.get('negBarColor'):options.get('barColor');}if(value===0&&options.get('zeroColor')!==undefined){color=options.get('zeroColor');}if(colorMapByValue&&(newColor=colorMapByValue.get(value))){color=newColor;}else if(colorMapByIndex&&colorMapByIndex.length>valuenum){color=colorMapByIndex[valuenum];}return $.isArray(color)?color[stacknum%color.length]:color;},renderRegion:function(valuenum,highlight){var vals=this.values[valuenum],options=this.options,xaxisOffset=this.xaxisOffset,result=[],range=this.range,stacked=this.stacked,target=this.target,x=valuenum*this.totalBarWidth,canvasHeightEf=this.canvasHeightEf,yoffset=this.yoffset,y,height,color,isNull,yoffsetNeg,i,valcount,val,minPlotted,allMin;vals=$.isArray(vals)?vals:[vals];valcount=vals.length;val=vals[0];isNull=all(null,vals);allMin=all(xaxisOffset,vals,true);if(isNull){if(options.get('nullColor')){color=highlight?options.get('nullColor'):this.calcHighlightColor(options.get('nullColor'),options);y=(yoffset>0)?yoffset-1:yoffset;return target.drawRect(x,y,this.barWidth-1,0,color,color);}else{return undefined;}}yoffsetNeg=yoffset;for(i=0;i0){height=Math.floor(canvasHeightEf*((Math.abs(val-xaxisOffset)/range)))+1;}else{height=1;}if(valvaluenum){color=colorMapByIndex[valuenum];}else if(values[valuenum]<0){color=options.get('negBarColor');}else if(values[valuenum]>0){color=options.get('posBarColor');}else{color=options.get('zeroBarColor');}return color;},renderRegion:function(valuenum,highlight){var values=this.values,options=this.options,target=this.target,canvasHeight,height,halfHeight,x,y,color;canvasHeight=target.pixelHeight;halfHeight=Math.round(canvasHeight/2);x=valuenum*this.totalBarWidth;if(values[valuenum]<0){y=halfHeight;height=halfHeight-1;}else if(values[valuenum]>0){y=0;height=halfHeight-1;}else{y=halfHeight-1;height=2;}color=this.calcColor(values[valuenum],valuenum);if(color===null){return;}if(highlight){color=this.calcHighlightColor(color,options);}return target.drawRect(x,y,this.barWidth-1,height-1,color,color);}});$.fn.sparkline.discrete=discrete=createClass($.fn.sparkline._base,barHighlightMixin,{type:'discrete',init:function(el,values,options,width,height){discrete._super.init.call(this,el,values,options,width,height);this.regionShapes={};this.values=values=$.map(values,Number);this.min=Math.min.apply(Math,values);this.max=Math.max.apply(Math,values);this.range=this.max-this.min;this.width=width=options.get('width')==='auto'?values.length*2:this.width;this.interval=Math.floor(width/values.length);this.itemWidth=width/values.length;if(options.get('chartRangeMin')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMin')this.max)){this.max=options.get('chartRangeMax');}this.initTarget();if(this.target){this.lineHeight=options.get('lineHeight')==='auto'?Math.round(this.canvasHeight*0.3):options.get('lineHeight');}},getRegion:function(el,x,y){return Math.floor(x/this.itemWidth);},getCurrentRegionFields:function(){var currentRegion=this.currentRegion;return{isNull:this.values[currentRegion]===undefined,value:this.values[currentRegion],offset:currentRegion};},renderRegion:function(valuenum,highlight){var values=this.values,options=this.options,min=this.min,max=this.max,range=this.range,interval=this.interval,target=this.target,canvasHeight=this.canvasHeight,lineHeight=this.lineHeight,pheight=canvasHeight-lineHeight,ytop,val,color,x;val=clipval(values[valuenum],min,max);x=valuenum*interval;ytop=Math.round(pheight-pheight*((val-min)/range));color=(options.get('thresholdColor')&&val0){for(i=values.length;i--;){total+=values[i];}}this.total=total;this.initTarget();this.radius=Math.floor(Math.min(this.canvasWidth,this.canvasHeight)/2);},getRegion:function(el,x,y){var shapeid=this.target.getShapeAt(el,x,y);return(shapeid!==undefined&&this.shapes[shapeid]!==undefined)?this.shapes[shapeid]:undefined;},getCurrentRegionFields:function(){var currentRegion=this.currentRegion;return{isNull:this.values[currentRegion]===undefined,value:this.values[currentRegion],percent:this.values[currentRegion]/this.total*100,color:this.options.get('sliceColors')[currentRegion%this.options.get('sliceColors').length],offset:currentRegion};},changeHighlight:function(highlight){var currentRegion=this.currentRegion,newslice=this.renderSlice(currentRegion,highlight),shapeid=this.valueShapes[currentRegion];delete this.shapes[shapeid];this.target.replaceWithShape(shapeid,newslice);this.valueShapes[currentRegion]=newslice.id;this.shapes[newslice.id]=currentRegion;},renderSlice:function(valuenum,highlight){var target=this.target,options=this.options,radius=this.radius,borderWidth=options.get('borderWidth'),offset=options.get('offset'),circle=2*Math.PI,values=this.values,total=this.total,next=offset?(2*Math.PI)*(offset/360):0,start,end,i,vlen,color;vlen=values.length;for(i=0;i0){end=next+(circle*(values[i]/total));}if(valuenum===i){color=options.get('sliceColors')[i%options.get('sliceColors').length];if(highlight){color=this.calcHighlightColor(color,options);}return target.drawPieSlice(radius,radius,radius-borderWidth,start,end,undefined,color);}next=end;}},render:function(){var target=this.target,values=this.values,options=this.options,radius=this.radius,borderWidth=options.get('borderWidth'),shape,i;if(!pie._super.render.call(this)){return;}if(borderWidth){target.drawCircle(radius,radius,Math.floor(radius-(borderWidth/2)),options.get('borderColor'),undefined,borderWidth).append();}for(i=values.length;i--;){if(values[i]){shape=this.renderSlice(i).append();this.valueShapes[i]=shape.id;this.shapes[shape.id]=i;}}target.render();}});$.fn.sparkline.box=box=createClass($.fn.sparkline._base,{type:'box',init:function(el,values,options,width,height){box._super.init.call(this,el,values,options,width,height);this.values=$.map(values,Number);this.width=options.get('width')==='auto'?'4.0em':width;this.initTarget();if(!this.values.length){this.disabled=1;}},getRegion:function(){return 1;},getCurrentRegionFields:function(){var result=[{field:'lq',value:this.quartiles[0]},{field:'med',value:this.quartiles[1]},{field:'uq',value:this.quartiles[2]}];if(this.loutlier!==undefined){result.push({field:'lo',value:this.loutlier});}if(this.routlier!==undefined){result.push({field:'ro',value:this.routlier});}if(this.lwhisker!==undefined){result.push({field:'lw',value:this.lwhisker});}if(this.rwhisker!==undefined){result.push({field:'rw',value:this.rwhisker});}return result;},render:function(){var target=this.target,values=this.values,vlen=values.length,options=this.options,canvasWidth=this.canvasWidth,canvasHeight=this.canvasHeight,minValue=options.get('chartRangeMin')===undefined?Math.min.apply(Math,values):options.get('chartRangeMin'),maxValue=options.get('chartRangeMax')===undefined?Math.max.apply(Math,values):options.get('chartRangeMax'),canvasLeft=0,lwhisker,loutlier,iqr,q1,q2,q3,rwhisker,routlier,i,size,unitSize;if(!box._super.render.call(this)){return;}if(options.get('raw')){if(options.get('showOutliers')&&values.length>5){loutlier=values[0];lwhisker=values[1];q1=values[2];q2=values[3];q3=values[4];rwhisker=values[5];routlier=values[6];}else{lwhisker=values[0];q1=values[1];q2=values[2];q3=values[3];rwhisker=values[4];}}else{values.sort(function(a,b){return a-b;});q1=quartile(values,1);q2=quartile(values,2);q3=quartile(values,3);iqr=q3-q1;if(options.get('showOutliers')){lwhisker=rwhisker=undefined;for(i=0;iq1-(iqr*options.get('outlierIQR'))){lwhisker=values[i];}if(values[i]rwhisker){target.drawCircle((routlier-minValue)*unitSize+canvasLeft,canvasHeight/2,options.get('spotRadius'),options.get('outlierLineColor'),options.get('outlierFillColor')).append();}}target.drawRect(Math.round((q1-minValue)*unitSize+canvasLeft),Math.round(canvasHeight*0.1),Math.round((q3-q1)*unitSize),Math.round(canvasHeight*0.8),options.get('boxLineColor'),options.get('boxFillColor')).append();target.drawLine(Math.round((lwhisker-minValue)*unitSize+canvasLeft),Math.round(canvasHeight/2),Math.round((q1-minValue)*unitSize+canvasLeft),Math.round(canvasHeight/2),options.get('lineColor')).append();target.drawLine(Math.round((lwhisker-minValue)*unitSize+canvasLeft),Math.round(canvasHeight/4),Math.round((lwhisker-minValue)*unitSize+canvasLeft),Math.round(canvasHeight-canvasHeight/4),options.get('whiskerColor')).append();target.drawLine(Math.round((rwhisker-minValue)*unitSize+canvasLeft),Math.round(canvasHeight/2),Math.round((q3-minValue)*unitSize+canvasLeft),Math.round(canvasHeight/2),options.get('lineColor')).append();target.drawLine(Math.round((rwhisker-minValue)*unitSize+canvasLeft),Math.round(canvasHeight/4),Math.round((rwhisker-minValue)*unitSize+canvasLeft),Math.round(canvasHeight-canvasHeight/4),options.get('whiskerColor')).append();target.drawLine(Math.round((q2-minValue)*unitSize+canvasLeft),Math.round(canvasHeight*0.1),Math.round((q2-minValue)*unitSize+canvasLeft),Math.round(canvasHeight*0.9),options.get('medianColor')).append();if(options.get('target')){size=Math.ceil(options.get('spotRadius'));target.drawLine(Math.round((options.get('target')-minValue)*unitSize+canvasLeft),Math.round((canvasHeight/2)-size),Math.round((options.get('target')-minValue)*unitSize+canvasLeft),Math.round((canvasHeight/2)+size),options.get('targetColor')).append();target.drawLine(Math.round((options.get('target')-minValue)*unitSize+canvasLeft-size),Math.round(canvasHeight/2),Math.round((options.get('target')-minValue)*unitSize+canvasLeft+size),Math.round(canvasHeight/2),options.get('targetColor')).append();}target.render();}});VShape=createClass({init:function(target,id,type,args){this.target=target;this.id=id;this.type=type;this.args=args;},append:function(){this.target.appendShape(this);return this;}});VCanvas_base=createClass({_pxregex:/(\d+)(px)?\s*$/i,init:function(width,height,target){if(!width){return;}this.width=width;this.height=height;this.target=target;this.lastShapeId=null;if(target[0]){target=target[0];}$.data(target,'_jqs_vcanvas',this);},drawLine:function(x1,y1,x2,y2,lineColor,lineWidth){return this.drawShape([[x1,y1],[x2,y2]],lineColor,lineWidth);},drawShape:function(path,lineColor,fillColor,lineWidth){return this._genShape('Shape',[path,lineColor,fillColor,lineWidth]);},drawCircle:function(x,y,radius,lineColor,fillColor,lineWidth){return this._genShape('Circle',[x,y,radius,lineColor,fillColor,lineWidth]);},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){return this._genShape('PieSlice',[x,y,radius,startAngle,endAngle,lineColor,fillColor]);},drawRect:function(x,y,width,height,lineColor,fillColor){return this._genShape('Rect',[x,y,width,height,lineColor,fillColor]);},getElement:function(){return this.canvas;},getLastShapeId:function(){return this.lastShapeId;},reset:function(){alert('reset not implemented');},_insert:function(el,target){$(target).html(el);},_calculatePixelDims:function(width,height,canvas){var match;match=this._pxregex.exec(height);if(match){this.pixelHeight=match[1];}else{this.pixelHeight=$(canvas).height();}match=this._pxregex.exec(width);if(match){this.pixelWidth=match[1];}else{this.pixelWidth=$(canvas).width();}},_genShape:function(shapetype,shapeargs){var id=shapeCount++;shapeargs.unshift(id);return new VShape(this,id,shapetype,shapeargs);},appendShape:function(shape){alert('appendShape not implemented');},replaceWithShape:function(shapeid,shape){alert('replaceWithShape not implemented');},insertAfterShape:function(shapeid,shape){alert('insertAfterShape not implemented');},removeShapeId:function(shapeid){alert('removeShapeId not implemented');},getShapeAt:function(el,x,y){alert('getShapeAt not implemented');},render:function(){alert('render not implemented');}});VCanvas_canvas=createClass(VCanvas_base,{init:function(width,height,target,interact){VCanvas_canvas._super.init.call(this,width,height,target);this.canvas=document.createElement('canvas');if(target[0]){target=target[0];}$.data(target,'_jqs_vcanvas',this);$(this.canvas).css({display:'inline-block',width:width,height:height,verticalAlign:'top'});this._insert(this.canvas,target);this._calculatePixelDims(width,height,this.canvas);this.canvas.width=this.pixelWidth;this.canvas.height=this.pixelHeight;this.interact=interact;this.shapes={};this.shapeseq=[];this.currentTargetShapeId=undefined;$(this.canvas).css({width:this.pixelWidth,height:this.pixelHeight});},_getContext:function(lineColor,fillColor,lineWidth){var context=this.canvas.getContext('2d');if(lineColor!==undefined){context.strokeStyle=lineColor;}context.lineWidth=lineWidth===undefined?1:lineWidth;if(fillColor!==undefined){context.fillStyle=fillColor;}return context;},reset:function(){var context=this._getContext();context.clearRect(0,0,this.pixelWidth,this.pixelHeight);this.shapes={};this.shapeseq=[];this.currentTargetShapeId=undefined;},_drawShape:function(shapeid,path,lineColor,fillColor,lineWidth){var context=this._getContext(lineColor,fillColor,lineWidth),i,plen;context.beginPath();context.moveTo(path[0][0]+0.5,path[0][1]+0.5);for(i=1,plen=path.length;i';this.canvas.insertAdjacentHTML('beforeEnd',groupel);this.group=$(this.canvas).children()[0];this.rendered=false;this.prerender='';},_drawShape:function(shapeid,path,lineColor,fillColor,lineWidth){var vpath=[],initial,stroke,fill,closed,vel,plen,i;for(i=0,plen=path.length;i'+' ';return vel;},_drawCircle:function(shapeid,x,y,radius,lineColor,fillColor,lineWidth){var stroke,fill,vel;x-=radius;y-=radius;stroke=lineColor===undefined?' stroked="false" ':' strokeWeight="'+lineWidth+'px" strokeColor="'+lineColor+'" ';fill=fillColor===undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';vel='';return vel;},_drawPieSlice:function(shapeid,x,y,radius,startAngle,endAngle,lineColor,fillColor){var vpath,startx,starty,endx,endy,stroke,fill,vel;if(startAngle===endAngle){return'';}if((endAngle-startAngle)===(2*Math.PI)){startAngle=0.0;endAngle=(2*Math.PI);}startx=x+Math.round(Math.cos(startAngle)*radius);starty=y+Math.round(Math.sin(startAngle)*radius);endx=x+Math.round(Math.cos(endAngle)*radius);endy=y+Math.round(Math.sin(endAngle)*radius);if(startx===endx&&starty===endy){if((endAngle-startAngle)'+' ';return vel;},_drawRect:function(shapeid,x,y,width,height,lineColor,fillColor){return this._drawShape(shapeid,[[x,y],[x,y+height],[x+width,y+height],[x+width,y],[x,y]],lineColor,fillColor);},reset:function(){this.group.innerHTML='';},appendShape:function(shape){var vel=this['_draw'+shape.type].apply(this,shape.args);if(this.rendered){this.group.insertAdjacentHTML('beforeEnd',vel);}else{this.prerender+=vel;}this.lastShapeId=shape.id;return shape.id;},replaceWithShape:function(shapeid,shape){var existing=$('#jqsshape'+shapeid),vel=this['_draw'+shape.type].apply(this,shape.args);existing[0].outerHTML=vel;},replaceWithShapes:function(shapeids,shapes){var existing=$('#jqsshape'+shapeids[0]),replace='',slen=shapes.length,i;for(i=0;i