diff options
author | sgiehl <stefan@piwik.org> | 2013-03-18 01:12:13 +0400 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2013-03-29 19:03:45 +0400 |
commit | 5e59c5948d2d28213bd29201bedeac2d8159d304 (patch) | |
tree | ae251678f95016a3630e5c188e6fa2c3b943d8b0 /libs/jqplot | |
parent | fd9a7e19bd2abe5908a83f13a4d1165e6eef5039 (diff) |
refs #3813 jquery, jqueryui & jqplot update + some fixes
Diffstat (limited to 'libs/jqplot')
20 files changed, 15157 insertions, 844 deletions
diff --git a/libs/jqplot/jqplot-custom.min.js b/libs/jqplot/jqplot-custom.min.js index 385e3b9a20..7b39f63915 100644 --- a/libs/jqplot/jqplot-custom.min.js +++ b/libs/jqplot/jqplot-custom.min.js @@ -1,28 +1,12405 @@ -/* -Following files are included below: -"jqplot.core.js"; -"jqplot.linearAxisRenderer.js"; -"jqplot.axisTickRenderer.js"; -"jqplot.axisLabelRenderer.js"; -"jqplot.tableLegendRenderer.js"; -"jqplot.lineRenderer.js"; -"jqplot.markerRenderer.js"; -"jqplot.divTitleRenderer.js"; -"jqplot.canvasGridRenderer.js"; -"jqplot.shadowRenderer.js"; -"jqplot.shapeRenderer.js"; -"jqplot.sprintf.js"; -"jqplot.themeEngine.js"; -"plugins/jqplot.pieRenderer.js"; -"plugins/jqplot.barRenderer.js"; -"plugins/jqplot.categoryAxisRenderer.js"; -"plugins/jqplot.canvasTextRenderer.js"; -"plugins/jqplot.canvasAxisTickRenderer.js"; - */ - -(function(g){var h;g.fn.emptyForce=function(){for(var j=0,k;(k=g(this)[j])!=null;j++){if(k.nodeType===1){jQuery.cleanData(k.getElementsByTagName("*"))}if(g.jqplot_use_excanvas){k.outerHTML=""}else{while(k.firstChild){k.removeChild(k.firstChild)}}k=null}return g(this)};g.fn.removeChildForce=function(i){while(i.firstChild){this.removeChildForce(i.firstChild);i.removeChild(i.firstChild)}};g.jqplot=function(o,l,j){var k,i;if(j==null){if(jQuery.isArray(l)){k=l;i=null}else{if(typeof(l)==="object"){k=null;i=l}}}else{k=l;i=j}var n=new f();g("#"+o).removeClass("jqplot-error");if(g.jqplot.config.catchErrors){try{n.init(o,k,i);n.draw();n.themeEngine.init.call(n);return n}catch(m){var p=g.jqplot.config.errorMessage||m.message;g("#"+o).append('<div class="jqplot-error-message">'+p+"</div>");g("#"+o).addClass("jqplot-error");document.getElementById(o).style.background=g.jqplot.config.errorBackground;document.getElementById(o).style.border=g.jqplot.config.errorBorder;document.getElementById(o).style.fontFamily=g.jqplot.config.errorFontFamily;document.getElementById(o).style.fontSize=g.jqplot.config.errorFontSize;document.getElementById(o).style.fontStyle=g.jqplot.config.errorFontStyle;document.getElementById(o).style.fontWeight=g.jqplot.config.errorFontWeight}}else{n.init(o,k,i);n.draw();n.themeEngine.init.call(n);return n}};g.jqplot.CanvasManager=function(){if(typeof g.jqplot.CanvasManager.canvases=="undefined"){g.jqplot.CanvasManager.canvases=[];g.jqplot.CanvasManager.free=[]}var i=[];this.getCanvas=function(){var m;var k=true;if(!g.jqplot.use_excanvas){for(var n=0,j=g.jqplot.CanvasManager.canvases.length;n<j;n++){if(g.jqplot.CanvasManager.free[n]===true){k=false;m=g.jqplot.CanvasManager.canvases[n];g.jqplot.CanvasManager.free[n]=false;i.push(n);break}}}if(k){m=document.createElement("canvas");i.push(g.jqplot.CanvasManager.canvases.length);g.jqplot.CanvasManager.canvases.push(m);g.jqplot.CanvasManager.free.push(false)}return m};this.initCanvas=function(j){if(g.jqplot.use_excanvas){return window.G_vmlCanvasManager.initElement(j)}return j};this.freeAllCanvases=function(){for(var k=0,j=i.length;k<j;k++){this.freeCanvas(i[k])}i=[]};this.freeCanvas=function(j){if(g.jqplot.use_excanvas){window.G_vmlCanvasManager.uninitElement(g.jqplot.CanvasManager.canvases[j]);g.jqplot.CanvasManager.canvases[j]=null}else{var k=g.jqplot.CanvasManager.canvases[j];k.getContext("2d").clearRect(0,0,k.width,k.height);g(k).unbind().removeAttr("class").removeAttr("style");g(k).css({left:"",top:"",position:""});k.width=0;k.height=0;g.jqplot.CanvasManager.free[j]=true}}};g.jqplot.log=function(){if(window.console){console.log.apply(console,arguments)}};g.jqplot.config={enablePlugins:false,defaultHeight:300,defaultWidth:400,UTCAdjust:false,timezoneOffset:new Date(new Date().getTimezoneOffset()*60000),errorMessage:"",errorBackground:"",errorBorder:"",errorFontFamily:"",errorFontSize:"",errorFontStyle:"",errorFontWeight:"",catchErrors:false,defaultTickFormatString:"%.1f",defaultColors:["#4bb2c5","#EAA228","#c5b47f","#579575","#839557","#958c12","#953579","#4b5de4","#d8b83f","#ff5800","#0085cc","#c747a3","#cddf54","#FBD178","#26B4E3","#bd70c7"],defaultNegativeColors:["#498991","#C08840","#9F9274","#546D61","#646C4A","#6F6621","#6E3F5F","#4F64B0","#A89050","#C45923","#187399","#945381","#959E5C","#C7AF7B","#478396","#907294"]};g.jqplot.arrayMax=function(i){return Math.max.apply(Math,i)};g.jqplot.arrayMin=function(i){return Math.min.apply(Math,i)};g.jqplot.enablePlugins=g.jqplot.config.enablePlugins;g.jqplot.support_canvas=function(){if(typeof g.jqplot.support_canvas.result=="undefined"){g.jqplot.support_canvas.result=!!document.createElement("canvas").getContext}return g.jqplot.support_canvas.result};g.jqplot.support_canvas_text=function(){if(typeof g.jqplot.support_canvas_text.result=="undefined"){g.jqplot.support_canvas_text.result=!!(document.createElement("canvas").getContext&&typeof document.createElement("canvas").getContext("2d").fillText=="function")}return g.jqplot.support_canvas_text.result};g.jqplot.use_excanvas=(g.browser.msie&&!g.jqplot.support_canvas())?true:false;g.jqplot.preInitHooks=[];g.jqplot.postInitHooks=[];g.jqplot.preParseOptionsHooks=[];g.jqplot.postParseOptionsHooks=[];g.jqplot.preDrawHooks=[];g.jqplot.postDrawHooks=[];g.jqplot.preDrawSeriesHooks=[];g.jqplot.postDrawSeriesHooks=[];g.jqplot.preDrawLegendHooks=[];g.jqplot.addLegendRowHooks=[];g.jqplot.preSeriesInitHooks=[];g.jqplot.postSeriesInitHooks=[];g.jqplot.preParseSeriesOptionsHooks=[];g.jqplot.postParseSeriesOptionsHooks=[];g.jqplot.eventListenerHooks=[];g.jqplot.preDrawSeriesShadowHooks=[];g.jqplot.postDrawSeriesShadowHooks=[];g.jqplot.ElemContainer=function(){this._elem;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null}};g.jqplot.ElemContainer.prototype.createElement=function(l,n,j,k,o){this._offsets=n;var i=j||"jqplot";var m=document.createElement(l);this._elem=g(m);this._elem.addClass(i);this._elem.css(k);this._elem.attr(o);m=null;return this._elem};g.jqplot.ElemContainer.prototype.getWidth=function(){if(this._elem){return this._elem.outerWidth(true)}else{return null}};g.jqplot.ElemContainer.prototype.getHeight=function(){if(this._elem){return this._elem.outerHeight(true)}else{return null}};g.jqplot.ElemContainer.prototype.getPosition=function(){if(this._elem){return this._elem.position()}else{return{top:null,left:null,bottom:null,right:null}}};g.jqplot.ElemContainer.prototype.getTop=function(){return this.getPosition().top};g.jqplot.ElemContainer.prototype.getLeft=function(){return this.getPosition().left};g.jqplot.ElemContainer.prototype.getBottom=function(){return this._elem.css("bottom")};g.jqplot.ElemContainer.prototype.getRight=function(){return this._elem.css("right")};function b(i){g.jqplot.ElemContainer.call(this);this.name=i;this._series=[];this.show=false;this.tickRenderer=g.jqplot.AxisTickRenderer;this.tickOptions={};this.labelRenderer=g.jqplot.AxisLabelRenderer;this.labelOptions={};this.label=null;this.showLabel=true;this.min=null;this.max=null;this.autoscale=false;this.pad=1.2;this.padMax=null;this.padMin=null;this.ticks=[];this.numberTicks;this.tickInterval;this.renderer=g.jqplot.LinearAxisRenderer;this.rendererOptions={};this.showTicks=true;this.showTickMarks=true;this.showMinorTicks=true;this.useSeriesColor=false;this.borderWidth=null;this.borderColor=null;this._dataBounds={min:null,max:null};this._intervalStats=[];this._offsets={min:null,max:null};this._ticks=[];this._label=null;this.syncTicks=null;this.tickSpacing=75;this._min=null;this._max=null;this._tickInterval=null;this._numberTicks=null;this.__ticks=null;this._options={}}b.prototype=new g.jqplot.ElemContainer();b.prototype.constructor=b;b.prototype.init=function(){this.renderer=new this.renderer();this.tickOptions.axis=this.name;if(this.tickOptions.showMark==null){this.tickOptions.showMark=this.showTicks}if(this.tickOptions.showMark==null){this.tickOptions.showMark=this.showTickMarks}if(this.tickOptions.showLabel==null){this.tickOptions.showLabel=this.showTicks}if(this.label==null||this.label==""){this.showLabel=false}else{this.labelOptions.label=this.label}if(this.showLabel==false){this.labelOptions.show=false}if(this.pad==0){this.pad=1}if(this.padMax==0){this.padMax=1}if(this.padMin==0){this.padMin=1}if(this.padMax==null){this.padMax=(this.pad-1)/2+1}if(this.padMin==null){this.padMin=(this.pad-1)/2+1}this.pad=this.padMax+this.padMin-1;if(this.min!=null||this.max!=null){this.autoscale=false}if(this.syncTicks==null&&this.name.indexOf("y")>-1){this.syncTicks=true}else{if(this.syncTicks==null){this.syncTicks=false}}this.renderer.init.call(this,this.rendererOptions)};b.prototype.draw=function(i,j){if(this.__ticks){this.__ticks=null}return this.renderer.draw.call(this,i,j)};b.prototype.set=function(){this.renderer.set.call(this)};b.prototype.pack=function(j,i){if(this.show){this.renderer.pack.call(this,j,i)}if(this._min==null){this._min=this.min;this._max=this.max;this._tickInterval=this.tickInterval;this._numberTicks=this.numberTicks;this.__ticks=this._ticks}};b.prototype.reset=function(){this.renderer.reset.call(this)};b.prototype.resetScale=function(i){g.extend(true,this,{min:null,max:null,numberTicks:null,tickInterval:null,_ticks:[],ticks:[]},i);this.resetDataBounds()};b.prototype.resetDataBounds=function(){var k=this._dataBounds;k.min=null;k.max=null;var n=(this.show)?true:false;for(var m=0;m<this._series.length;m++){var o=this._series[m];var r=o._plotData;var p=1,q=1;if(o._type!=null&&o._type=="ohlc"){p=3;q=2}for(var l=0;l<r.length;l++){if(this.name=="xaxis"||this.name=="x2axis"){if((r[l][0]!=null&&r[l][0]<k.min)||k.min==null){k.min=r[l][0]}if((r[l][0]!=null&&r[l][0]>k.max)||k.max==null){k.max=r[l][0]}}else{if((r[l][p]!=null&&r[l][p]<k.min)||k.min==null){k.min=r[l][p]}if((r[l][q]!=null&&r[l][q]>k.max)||k.max==null){k.max=r[l][q]}}}if(n&&o.renderer.constructor!==g.jqplot.BarRenderer){n=false}else{if(n&&this._options.hasOwnProperty("forceTickAt0")&&this._options.forceTickAt0==false){n=false}else{if(n&&o.renderer.constructor===g.jqplot.BarRenderer){if(o.barDirection=="vertical"&&this.name!="xaxis"&&this.name!="x2axis"){if(this._options.pad!=null||this._options.padMin!=null){n=false}}else{if(o.barDirection=="horizontal"&&(this.name=="xaxis"||this.name=="x2axis")){if(this._options.pad!=null||this._options.padMin!=null){n=false}}}}}}}if(n&&this.renderer.constructor===g.jqplot.LinearAxisRenderer&&k.min>=0){this.padMin=1;this.forceTickAt0=true}};function e(i){g.jqplot.ElemContainer.call(this);this.show=false;this.location="ne";this.labels=[];this.showLabels=true;this.showSwatches=true;this.placement="insideGrid";this.xoffset=0;this.yoffset=0;this.border;this.background;this.textColor;this.fontFamily;this.fontSize;this.rowSpacing="0.5em";this.renderer=g.jqplot.TableLegendRenderer;this.rendererOptions={};this.preDraw=false;this.marginTop=null;this.marginRight=null;this.marginBottom=null;this.marginLeft=null;this.escapeHtml=false;this._series=[];g.extend(true,this,i)}e.prototype=new g.jqplot.ElemContainer();e.prototype.constructor=e;e.prototype.setOptions=function(i){g.extend(true,this,i);if(this.placement=="inside"){this.placement="insideGrid"}if(this.xoffset>0){if(this.placement=="insideGrid"){switch(this.location){case"nw":case"w":case"sw":if(this.marginLeft==null){this.marginLeft=this.xoffset+"px"}this.marginRight="0px";break;case"ne":case"e":case"se":default:if(this.marginRight==null){this.marginRight=this.xoffset+"px"}this.marginLeft="0px";break}}else{if(this.placement=="outside"){switch(this.location){case"nw":case"w":case"sw":if(this.marginRight==null){this.marginRight=this.xoffset+"px"}this.marginLeft="0px";break;case"ne":case"e":case"se":default:if(this.marginLeft==null){this.marginLeft=this.xoffset+"px"}this.marginRight="0px";break}}}this.xoffset=0}if(this.yoffset>0){if(this.placement=="outside"){switch(this.location){case"sw":case"s":case"se":if(this.marginTop==null){this.marginTop=this.yoffset+"px"}this.marginBottom="0px";break;case"ne":case"n":case"nw":default:if(this.marginBottom==null){this.marginBottom=this.yoffset+"px"}this.marginTop="0px";break}}else{if(this.placement=="insideGrid"){switch(this.location){case"sw":case"s":case"se":if(this.marginBottom==null){this.marginBottom=this.yoffset+"px"}this.marginTop="0px";break;case"ne":case"n":case"nw":default:if(this.marginTop==null){this.marginTop=this.yoffset+"px"}this.marginBottom="0px";break}}}this.yoffset=0}};e.prototype.init=function(){this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions)};e.prototype.draw=function(k){for(var j=0;j<g.jqplot.preDrawLegendHooks.length;j++){g.jqplot.preDrawLegendHooks[j].call(this,k)}return this.renderer.draw.call(this,k)};e.prototype.pack=function(i){this.renderer.pack.call(this,i)};function d(i){g.jqplot.ElemContainer.call(this);this.text=i;this.show=true;this.fontFamily;this.fontSize;this.textAlign;this.textColor;this.renderer=g.jqplot.DivTitleRenderer;this.rendererOptions={}}d.prototype=new g.jqplot.ElemContainer();d.prototype.constructor=d;d.prototype.init=function(){this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions)};d.prototype.draw=function(i){return this.renderer.draw.call(this,i)};d.prototype.pack=function(){this.renderer.pack.call(this)};function c(){g.jqplot.ElemContainer.call(this);this.show=true;this.xaxis="xaxis";this._xaxis;this.yaxis="yaxis";this._yaxis;this.gridBorderWidth=2;this.renderer=g.jqplot.LineRenderer;this.rendererOptions={};this.data=[];this.gridData=[];this.label="";this.showLabel=true;this.color;this.lineWidth=2.5;this.lineJoin="round";this.lineCap="round";this.shadow=true;this.shadowAngle=45;this.shadowOffset=1.25;this.shadowDepth=3;this.shadowAlpha="0.1";this.breakOnNull=false;this.markerRenderer=g.jqplot.MarkerRenderer;this.markerOptions={};this.showLine=true;this.showMarker=true;this.index;this.fill=false;this.fillColor;this.fillAlpha;this.fillAndStroke=false;this.disableStack=false;this._stack=false;this.neighborThreshold=4;this.fillToZero=false;this.fillToValue=0;this.fillAxis="y";this.useNegativeColors=true;this._stackData=[];this._plotData=[];this._plotValues={x:[],y:[]};this._intervals={x:{},y:{}};this._prevPlotData=[];this._prevGridData=[];this._stackAxis="y";this._primaryAxis="_xaxis";this.canvas=new g.jqplot.GenericCanvas();this.shadowCanvas=new g.jqplot.GenericCanvas();this.plugins={};this._sumy=0;this._sumx=0;this._type=""}c.prototype=new g.jqplot.ElemContainer();c.prototype.constructor=c;c.prototype.init=function(l,p,n){this.index=l;this.gridBorderWidth=p;var o=this.data;var k=[],m;for(m=0;m<o.length;m++){if(!this.breakOnNull){if(o[m]==null||o[m][0]==null||o[m][1]==null){continue}else{k.push(o[m])}}else{k.push(o[m])}}this.data=k;if(!this.fillColor){this.fillColor=this.color}if(this.fillAlpha){var j=g.jqplot.normalize2rgb(this.fillColor);var j=g.jqplot.getColorComponents(j);this.fillColor="rgba("+j[0]+","+j[1]+","+j[2]+","+this.fillAlpha+")"}this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions,n);this.markerRenderer=new this.markerRenderer();if(!this.markerOptions.color){this.markerOptions.color=this.color}if(this.markerOptions.show==null){this.markerOptions.show=this.showMarker}this.showMarker=this.markerOptions.show;this.markerRenderer.init(this.markerOptions)};c.prototype.draw=function(p,m,o){var k=(m==h)?{}:m;p=(p==h)?this.canvas._ctx:p;var i,n,l;for(i=0;i<g.jqplot.preDrawSeriesHooks.length;i++){g.jqplot.preDrawSeriesHooks[i].call(this,p,k)}if(this.show){this.renderer.setGridData.call(this,o);if(!k.preventJqPlotSeriesDrawTrigger){g(p.canvas).trigger("jqplotSeriesDraw",[this.data,this.gridData])}n=[];if(k.data){n=k.data}else{if(!this._stack){n=this.data}else{n=this._plotData}}l=k.gridData||this.renderer.makeGridData.call(this,n,o);this.renderer.draw.call(this,p,l,k,o)}for(i=0;i<g.jqplot.postDrawSeriesHooks.length;i++){g.jqplot.postDrawSeriesHooks[i].call(this,p,k)}p=m=o=i=n=l=null};c.prototype.drawShadow=function(p,m,o){var k=(m==h)?{}:m;p=(p==h)?this.shadowCanvas._ctx:p;var i,n,l;for(i=0;i<g.jqplot.preDrawSeriesShadowHooks.length;i++){g.jqplot.preDrawSeriesShadowHooks[i].call(this,p,k)}if(this.shadow){this.renderer.setGridData.call(this,o);n=[];if(k.data){n=k.data}else{if(!this._stack){n=this.data}else{n=this._plotData}}l=k.gridData||this.renderer.makeGridData.call(this,n,o);this.renderer.drawShadow.call(this,p,l,k)}for(i=0;i<g.jqplot.postDrawSeriesShadowHooks.length;i++){g.jqplot.postDrawSeriesShadowHooks[i].call(this,p,k)}p=m=o=i=n=l=null};c.prototype.toggleDisplay=function(j){var i,k;if(j.data.series){i=j.data.series}else{i=this}if(j.data.speed){k=j.data.speed}if(k){if(i.canvas._elem.is(":hidden")){if(i.shadowCanvas._elem){i.shadowCanvas._elem.fadeIn(k)}i.canvas._elem.fadeIn(k);i.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+i.index).fadeIn(k)}else{if(i.shadowCanvas._elem){i.shadowCanvas._elem.fadeOut(k)}i.canvas._elem.fadeOut(k);i.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+i.index).fadeOut(k)}}else{if(i.canvas._elem.is(":hidden")){if(i.shadowCanvas._elem){i.shadowCanvas._elem.show()}i.canvas._elem.show();i.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+i.index).show()}else{if(i.shadowCanvas._elem){i.shadowCanvas._elem.hide()}i.canvas._elem.hide();i.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+i.index).hide()}}};function a(){g.jqplot.ElemContainer.call(this);this.drawGridlines=true;this.gridLineColor="#cccccc";this.gridLineWidth=1;this.background="#fffdf6";this.borderColor="#999999";this.borderWidth=2;this.drawBorder=true;this.shadow=true;this.shadowAngle=45;this.shadowOffset=1.5;this.shadowWidth=3;this.shadowDepth=3;this.shadowColor=null;this.shadowAlpha="0.07";this._left;this._top;this._right;this._bottom;this._width;this._height;this._axes=[];this.renderer=g.jqplot.CanvasGridRenderer;this.rendererOptions={};this._offsets={top:null,bottom:null,left:null,right:null}}a.prototype=new g.jqplot.ElemContainer();a.prototype.constructor=a;a.prototype.init=function(){this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions)};a.prototype.createElement=function(i,j){this._offsets=i;return this.renderer.createElement.call(this,j)};a.prototype.draw=function(){this.renderer.draw.call(this)};g.jqplot.GenericCanvas=function(){g.jqplot.ElemContainer.call(this);this._ctx};g.jqplot.GenericCanvas.prototype=new g.jqplot.ElemContainer();g.jqplot.GenericCanvas.prototype.constructor=g.jqplot.GenericCanvas;g.jqplot.GenericCanvas.prototype.createElement=function(m,k,j,n){this._offsets=m;var i="jqplot";if(k!=h){i=k}var l;l=n.canvasManager.getCanvas();if(j!=null){this._plotDimensions=j}l.width=this._plotDimensions.width-this._offsets.left-this._offsets.right;l.height=this._plotDimensions.height-this._offsets.top-this._offsets.bottom;this._elem=g(l);this._elem.css({position:"absolute",left:this._offsets.left,top:this._offsets.top});this._elem.addClass(i);l=n.canvasManager.initCanvas(l);l=null;return this._elem};g.jqplot.GenericCanvas.prototype.setContext=function(){this._ctx=this._elem.get(0).getContext("2d");return this._ctx};g.jqplot.GenericCanvas.prototype.resetCanvas=function(){if(this._elem){if(g.jqplot.use_excanvas){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce()}this._ctx=null};g.jqplot.HooksManager=function(){this.hooks=[]};g.jqplot.HooksManager.prototype.addOnce=function(k){var l=false,j;for(j=0;j<this.hooks.length;j++){if(this.hooks[j][0]==k){l=true}}if(!l){this.hooks.push(k)}};g.jqplot.HooksManager.prototype.add=function(i){this.hooks.push(i)};g.jqplot.EventListenerManager=function(){this.hooks=[]};g.jqplot.EventListenerManager.prototype.addOnce=function(m,l){var n=false,k,j;for(j=0;j<this.hooks.length;j++){k=this.hooks[j];if(k[0]==m&&k[1]==l){n=true}}if(!n){this.hooks.push([m,l])}};g.jqplot.EventListenerManager.prototype.add=function(j,i){this.hooks.push([j,i])};function f(){this.data=[];this.dataRenderer;this.dataRendererOptions;this.noDataIndicator={show:false,indicator:"Loading Data...",axes:{xaxis:{min:0,max:10,tickInterval:2,show:true},yaxis:{min:0,max:12,tickInterval:3,show:true}}};this.targetId=null;this.target=null;this.defaults={axesDefaults:{},axes:{xaxis:{},yaxis:{},x2axis:{},y2axis:{},y3axis:{},y4axis:{},y5axis:{},y6axis:{},y7axis:{},y8axis:{},y9axis:{}},seriesDefaults:{},series:[]};this.series=[];this.axes={xaxis:new b("xaxis"),yaxis:new b("yaxis"),x2axis:new b("x2axis"),y2axis:new b("y2axis"),y3axis:new b("y3axis"),y4axis:new b("y4axis"),y5axis:new b("y5axis"),y6axis:new b("y6axis"),y7axis:new b("y7axis"),y8axis:new b("y8axis"),y9axis:new b("y9axis")};this.grid=new a();this.legend=new e();this.baseCanvas=new g.jqplot.GenericCanvas();this.seriesStack=[];this.previousSeriesStack=[];this.eventCanvas=new g.jqplot.GenericCanvas();this._width=null;this._height=null;this._plotDimensions={height:null,width:null};this._gridPadding={top:null,right:null,bottom:null,left:null};this._defaultGridPadding={top:10,right:10,bottom:23,left:10};this.syncXTicks=true;this.syncYTicks=true;this.seriesColors=g.jqplot.config.defaultColors;this.negativeSeriesColors=g.jqplot.config.defaultNegativeColors;this.sortData=true;var k=0;this.textColor;this.fontFamily;this.fontSize;this.title=new d();this.options={};this.stackSeries=false;this.defaultAxisStart=1;this._stackData=[];this._plotData=[];this.plugins={};this._drawCount=0;this.drawIfHidden=false;this.captureRightClick=false;this.themeEngine=new g.jqplot.ThemeEngine();this._sumy=0;this._sumx=0;this.preInitHooks=new g.jqplot.HooksManager();this.postInitHooks=new g.jqplot.HooksManager();this.preParseOptionsHooks=new g.jqplot.HooksManager();this.postParseOptionsHooks=new g.jqplot.HooksManager();this.preDrawHooks=new g.jqplot.HooksManager();this.postDrawHooks=new g.jqplot.HooksManager();this.preDrawSeriesHooks=new g.jqplot.HooksManager();this.postDrawSeriesHooks=new g.jqplot.HooksManager();this.preDrawLegendHooks=new g.jqplot.HooksManager();this.addLegendRowHooks=new g.jqplot.HooksManager();this.preSeriesInitHooks=new g.jqplot.HooksManager();this.postSeriesInitHooks=new g.jqplot.HooksManager();this.preParseSeriesOptionsHooks=new g.jqplot.HooksManager();this.postParseSeriesOptionsHooks=new g.jqplot.HooksManager();this.eventListenerHooks=new g.jqplot.EventListenerManager();this.preDrawSeriesShadowHooks=new g.jqplot.HooksManager();this.postDrawSeriesShadowHooks=new g.jqplot.HooksManager();this.colorGenerator=g.jqplot.ColorGenerator;this.canvasManager=new g.jqplot.CanvasManager();this.init=function(t,q,v){v=v||{};for(var r=0;r<g.jqplot.preInitHooks.length;r++){g.jqplot.preInitHooks[r].call(this,t,q,v)}for(var r=0;r<this.preInitHooks.hooks.length;r++){this.preInitHooks.hooks[r].call(this,t,q,v)}this.targetId="#"+t;this.target=g("#"+t);this.target.removeClass("jqplot-error");if(!this.target.get(0)){throw"No plot target specified"}if(this.target.css("position")=="static"){this.target.css("position","relative")}if(!this.target.hasClass("jqplot-target")){this.target.addClass("jqplot-target")}if(!this.target.height()){var s;if(v&&v.height){s=parseInt(v.height,10)}else{if(this.target.attr("data-height")){s=parseInt(this.target.attr("data-height"),10)}else{s=parseInt(g.jqplot.config.defaultHeight,10)}}this._height=s;this.target.css("height",s+"px")}else{this._height=s=this.target.height()}if(!this.target.width()){var u;if(v&&v.width){u=parseInt(v.width,10)}else{if(this.target.attr("data-width")){u=parseInt(this.target.attr("data-width"),10)}else{u=parseInt(g.jqplot.config.defaultWidth,10)}}this._width=u;this.target.css("width",u+"px")}else{this._width=u=this.target.width()}this._plotDimensions.height=this._height;this._plotDimensions.width=this._width;this.grid._plotDimensions=this._plotDimensions;this.title._plotDimensions=this._plotDimensions;this.baseCanvas._plotDimensions=this._plotDimensions;this.eventCanvas._plotDimensions=this._plotDimensions;this.legend._plotDimensions=this._plotDimensions;if(this._height<=0||this._width<=0||!this._height||!this._width){throw"Canvas dimension not set"}if(v.dataRenderer&&jQuery.isFunction(v.dataRenderer)){if(v.dataRendererOptions){this.dataRendererOptions=v.dataRendererOptions}this.dataRenderer=v.dataRenderer;q=this.dataRenderer(q,this,this.dataRendererOptions)}if(v.noDataIndicator&&jQuery.isPlainObject(v.noDataIndicator)){g.extend(true,this.noDataIndicator,v.noDataIndicator)}if(q==null||jQuery.isArray(q)==false||q.length==0||jQuery.isArray(q[0])==false||q[0].length==0){if(this.noDataIndicator.show==false){throw {name:"DataError",message:"No data to plot."}}else{for(var m in this.noDataIndicator.axes){for(var o in this.noDataIndicator.axes[m]){this.axes[m][o]=this.noDataIndicator.axes[m][o]}}this.postDrawHooks.add(function(){var B=this.eventCanvas.getHeight();var y=this.eventCanvas.getWidth();var x=g('<div class="jqplot-noData-container" style="position:absolute;"></div>');this.target.append(x);x.height(B);x.width(y);x.css("top",this.eventCanvas._offsets.top);x.css("left",this.eventCanvas._offsets.left);var A=g('<div class="jqplot-noData-contents" style="text-align:center; position:relative; margin-left:auto; margin-right:auto;"></div>');x.append(A);A.html(this.noDataIndicator.indicator);var z=A.height();var w=A.width();A.height(z);A.width(w);A.css("top",(B-z)/2+"px")})}}this.data=q;this.parseOptions(v);if(this.textColor){this.target.css("color",this.textColor)}if(this.fontFamily){this.target.css("font-family",this.fontFamily)}if(this.fontSize){this.target.css("font-size",this.fontSize)}this.title.init();this.legend.init();this._sumy=0;this._sumx=0;for(var r=0;r<this.series.length;r++){this.seriesStack.push(r);this.previousSeriesStack.push(r);this.series[r].shadowCanvas._plotDimensions=this._plotDimensions;this.series[r].canvas._plotDimensions=this._plotDimensions;for(var p=0;p<g.jqplot.preSeriesInitHooks.length;p++){g.jqplot.preSeriesInitHooks[p].call(this.series[r],t,q,this.options.seriesDefaults,this.options.series[r],this)}for(var p=0;p<this.preSeriesInitHooks.hooks.length;p++){this.preSeriesInitHooks.hooks[p].call(this.series[r],t,q,this.options.seriesDefaults,this.options.series[r],this)}this.populatePlotData(this.series[r],r);this.series[r]._plotDimensions=this._plotDimensions;this.series[r].init(r,this.grid.borderWidth,this);for(var p=0;p<g.jqplot.postSeriesInitHooks.length;p++){g.jqplot.postSeriesInitHooks[p].call(this.series[r],t,q,this.options.seriesDefaults,this.options.series[r],this)}for(var p=0;p<this.postSeriesInitHooks.hooks.length;p++){this.postSeriesInitHooks.hooks[p].call(this.series[r],t,q,this.options.seriesDefaults,this.options.series[r],this)}this._sumy+=this.series[r]._sumy;this._sumx+=this.series[r]._sumx}for(var n in this.axes){this.axes[n]._plotDimensions=this._plotDimensions;this.axes[n].init()}if(this.sortData){i(this.series)}this.grid.init();this.grid._axes=this.axes;this.legend._series=this.series;for(var r=0;r<g.jqplot.postInitHooks.length;r++){g.jqplot.postInitHooks[r].call(this,t,q,v)}for(var r=0;r<this.postInitHooks.hooks.length;r++){this.postInitHooks.hooks[r].call(this,t,q,v)}};this.resetAxesScale=function(r,n){var p=n||{};var q=r||this.axes;if(q===true){q=this.axes}if(jQuery.isArray(q)){for(var o=0;o<q.length;o++){this.axes[q[o]].resetScale(p[q[o]])}}else{if(typeof(q)==="object"){for(var m in q){this.axes[m].resetScale(p[m])}}}};this.reInitialize=function(){this._height=this.target.height();this._width=this.target.width();if(this._height<=0||this._width<=0||!this._height||!this._width){throw"Target dimension not set"}this._plotDimensions.height=this._height;this._plotDimensions.width=this._width;this.grid._plotDimensions=this._plotDimensions;this.title._plotDimensions=this._plotDimensions;this.baseCanvas._plotDimensions=this._plotDimensions;this.eventCanvas._plotDimensions=this._plotDimensions;this.legend._plotDimensions=this._plotDimensions;for(var r in this.axes){this.axes[r]._plotWidth=this._width;this.axes[r]._plotHeight=this._height}this.title._plotWidth=this._width;if(this.textColor){this.target.css("color",this.textColor)}if(this.fontFamily){this.target.css("font-family",this.fontFamily)}if(this.fontSize){this.target.css("font-size",this.fontSize)}this._sumy=0;this._sumx=0;for(var p=0;p<this.series.length;p++){this.populatePlotData(this.series[p],p);this.series[p]._plotDimensions=this._plotDimensions;this.series[p].canvas._plotDimensions=this._plotDimensions;this._sumy+=this.series[p]._sumy;this._sumx+=this.series[p]._sumx}for(var m in this.axes){var o=this.axes[m]._ticks;for(var p=0;p<o.length;p++){var q=o[p]._elem;if(q){if(g.jqplot.use_excanvas){window.G_vmlCanvasManager.uninitElement(q.get(0))}q.emptyForce();q=null;o._elem=null}}o=null;this.axes[m]._plotDimensions=this._plotDimensions;this.axes[m]._ticks=[];this.axes[m].renderer.init.call(this.axes[m],{})}if(this.sortData){i(this.series)}this.grid._axes=this.axes;this.legend._series=this.series};function i(r){var v,w,x,m,u;for(var s=0;s<r.length;s++){var o;var t=[r[s].data,r[s]._stackData,r[s]._plotData,r[s]._prevPlotData];for(var p=0;p<4;p++){o=true;v=t[p];if(r[s]._stackAxis=="x"){for(var q=0;q<v.length;q++){if(typeof(v[q][1])!="number"){o=false;break}}if(o){v.sort(function(y,n){return y[1]-n[1]})}}else{for(var q=0;q<v.length;q++){if(typeof(v[q][0])!="number"){o=false;break}}if(o){v.sort(function(y,n){return y[0]-n[0]})}}}}}this.populatePlotData=function(q,r){this._plotData=[];this._stackData=[];q._stackData=[];q._plotData=[];var u={x:[],y:[]};if(this.stackSeries&&!q.disableStack){q._stack=true;var s=q._stackAxis=="x"?0:1;var t=s?0:1;var v=g.extend(true,[],q.data);var w=g.extend(true,[],q.data);for(var o=0;o<r;o++){var m=this.series[o].data;for(var n=0;n<m.length;n++){v[n][0]+=m[n][0];v[n][1]+=m[n][1];w[n][s]+=m[n][s]}}for(var p=0;p<w.length;p++){u.x.push(w[p][0]);u.y.push(w[p][1])}this._plotData.push(w);this._stackData.push(v);q._stackData=v;q._plotData=w;q._plotValues=u}else{for(var p=0;p<q.data.length;p++){u.x.push(q.data[p][0]);u.y.push(q.data[p][1])}this._stackData.push(q.data);this.series[r]._stackData=q.data;this._plotData.push(q.data);q._plotData=q.data;q._plotValues=u}if(r>0){q._prevPlotData=this.series[r-1]._plotData}q._sumy=0;q._sumx=0;for(p=q.data.length-1;p>-1;p--){q._sumy+=q.data[p][1];q._sumx+=q.data[p][0]}};this.getNextSeriesColor=(function(n){var m=0;var o=n.seriesColors;return function(){if(m<o.length){return o[m++]}else{m=0;return o[m++]}}})(this);this.parseOptions=function(v){for(var s=0;s<this.preParseOptionsHooks.hooks.length;s++){this.preParseOptionsHooks.hooks[s].call(this,v)}for(var s=0;s<g.jqplot.preParseOptionsHooks.length;s++){g.jqplot.preParseOptionsHooks[s].call(this,v)}this.options=g.extend(true,{},this.defaults,v);this.stackSeries=this.options.stackSeries;if(this.options.seriesColors){this.seriesColors=this.options.seriesColors}if(this.options.negativeSeriesColors){this.negativeSeriesColors=this.options.negativeSeriesColors}if(this.options.captureRightClick){this.captureRightClick=this.options.captureRightClick}this.defaultAxisStart=(v&&v.defaultAxisStart!=null)?v.defaultAxisStart:this.defaultAxisStart;var m=new this.colorGenerator(this.seriesColors);g.extend(true,this._gridPadding,this.options.gridPadding);this.sortData=(this.options.sortData!=null)?this.options.sortData:this.sortData;for(var o in this.axes){var q=this.axes[o];q._options=g.extend(true,{},this.options.axesDefaults,this.options.axes[o]);g.extend(true,q,this.options.axesDefaults,this.options.axes[o]);q._plotWidth=this._width;q._plotHeight=this._height}var t=function(y,w,z){var n=[];var x;w=w||"vertical";if(!jQuery.isArray(y[0])){for(x=0;x<y.length;x++){if(w=="vertical"){n.push([z+x,y[x]])}else{n.push([y[x],z+x])}}}else{g.extend(true,n,y)}return n};for(var s=0;s<this.data.length;s++){var u=new c();for(var r=0;r<g.jqplot.preParseSeriesOptionsHooks.length;r++){g.jqplot.preParseSeriesOptionsHooks[r].call(u,this.options.seriesDefaults,this.options.series[s])}for(var r=0;r<this.preParseSeriesOptionsHooks.hooks.length;r++){this.preParseSeriesOptionsHooks.hooks[r].call(u,this.options.seriesDefaults,this.options.series[s])}g.extend(true,u,{seriesColors:this.seriesColors,negativeSeriesColors:this.negativeSeriesColors},this.options.seriesDefaults,this.options.series[s]);var p="vertical";if(u.renderer===g.jqplot.BarRenderer&&u.rendererOptions&&u.rendererOptions.barDirection=="horizontal"){p="horizontal"}u.data=t(this.data[s],p,this.defaultAxisStart);switch(u.xaxis){case"xaxis":u._xaxis=this.axes.xaxis;break;case"x2axis":u._xaxis=this.axes.x2axis;break;default:break}u._yaxis=this.axes[u.yaxis];u._xaxis._series.push(u);u._yaxis._series.push(u);if(u.show){u._xaxis.show=true;u._yaxis.show=true}if(!u.color&&u.show!=false){u.color=m.next()}if(!u.label){u.label="Series "+(s+1).toString()}this.series.push(u);for(var r=0;r<g.jqplot.postParseSeriesOptionsHooks.length;r++){g.jqplot.postParseSeriesOptionsHooks[r].call(this.series[s],this.options.seriesDefaults,this.options.series[s])}for(var r=0;r<this.postParseSeriesOptionsHooks.hooks.length;r++){this.postParseSeriesOptionsHooks.hooks[r].call(this.series[s],this.options.seriesDefaults,this.options.series[s]) -}}g.extend(true,this.grid,this.options.grid);for(var o in this.axes){var q=this.axes[o];if(q.borderWidth==null){q.borderWidth=this.grid.borderWidth}if(q.borderColor==null){if(o!="xaxis"&&o!="x2axis"&&q.useSeriesColor===true&&q.show){q.borderColor=q._series[0].color}else{q.borderColor=this.grid.borderColor}}}if(typeof this.options.title=="string"){this.title.text=this.options.title}else{if(typeof this.options.title=="object"){g.extend(true,this.title,this.options.title)}}this.title._plotWidth=this._width;this.legend.setOptions(this.options.legend);for(var s=0;s<g.jqplot.postParseOptionsHooks.length;s++){g.jqplot.postParseOptionsHooks[s].call(this,v)}for(var s=0;s<this.postParseOptionsHooks.hooks.length;s++){this.postParseOptionsHooks.hooks[s].call(this,v)}};this.destroy=function(){this.canvasManager.freeAllCanvases();this.target[0].innerHTML=""};this.replot=function(n){var o=n||{};var m=o.clear||true;var p=o.resetAxes||false;this.target.trigger("jqplotPreReplot");if(m){this.canvasManager.freeAllCanvases();this.eventCanvas._elem.unbind();this.target.unbind();this.target.empty()}this.reInitialize();if(p){this.resetAxesScale(p,o.axes)}this.draw();this.target.trigger("jqplotPostReplot")};this.redraw=function(m){m=(m!=null)?m:true;this.target.trigger("jqplotPreRedraw");if(m){this.target.empty()}for(var o in this.axes){this.axes[o]._ticks=[]}for(var n=0;n<this.series.length;n++){this.populatePlotData(this.series[n],n)}this._sumy=0;this._sumx=0;for(n=0;n<this.series.length;n++){this._sumy+=this.series[n]._sumy;this._sumx+=this.series[n]._sumx}this.draw();this.target.trigger("jqplotPostRedraw")};this.draw=function(){if(this.drawIfHidden||this.target.is(":visible")){this.target.trigger("jqplotPreDraw");var t,s;for(t=0;t<g.jqplot.preDrawHooks.length;t++){g.jqplot.preDrawHooks[t].call(this)}for(t=0;t<this.preDrawHooks.hooks.length;t++){this.preDrawHooks.hooks[t].call(this)}this.target.append(this.baseCanvas.createElement({left:0,right:0,top:0,bottom:0},"jqplot-base-canvas",null,this));this.baseCanvas.setContext();this.target.append(this.title.draw());this.title.pack({top:0,left:0});var y=this.legend.draw();var x={top:0,left:0,bottom:0,right:0};if(this.legend.placement=="outsideGrid"){this.target.append(y);switch(this.legend.location){case"n":x.top+=this.legend.getHeight();break;case"s":x.bottom+=this.legend.getHeight();break;case"ne":case"e":case"se":x.right+=this.legend.getWidth();break;case"nw":case"w":case"sw":x.left+=this.legend.getWidth();break;default:x.right+=this.legend.getWidth();break}y=y.detach()}var m=this.axes;for(var p in m){this.target.append(m[p].draw(this.baseCanvas._ctx,this));m[p].set()}if(m.yaxis.show){x.left+=m.yaxis.getWidth()}var q=["y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis"];var o=[0,0,0,0,0,0,0,0];var v=0;var r;for(r=0;r<8;r++){if(m[q[r]].show){v+=m[q[r]].getWidth();o[r]=v}}x.right+=v;if(m.x2axis.show){x.top+=m.x2axis.getHeight()}if(this.title.show){x.top+=this.title.getHeight()}if(m.xaxis.show){x.bottom+=m.xaxis.getHeight()}var u=["top","bottom","left","right"];for(var r in u){if(this._gridPadding[u[r]]==null&&x[u[r]]>0){this._gridPadding[u[r]]=x[u[r]]}else{if(this._gridPadding[u[r]]==null){this._gridPadding[u[r]]=this._defaultGridPadding[u[r]]}}}var w=(this.legend.placement=="outsideGrid")?{top:this.title.getHeight(),left:0,right:0,bottom:0}:this._gridPadding;m.xaxis.pack({position:"absolute",bottom:this._gridPadding.bottom-m.xaxis.getHeight(),left:0,width:this._width},{min:this._gridPadding.left,max:this._width-this._gridPadding.right});m.yaxis.pack({position:"absolute",top:0,left:this._gridPadding.left-m.yaxis.getWidth(),height:this._height},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top});m.x2axis.pack({position:"absolute",top:this._gridPadding.top-m.x2axis.getHeight(),left:0,width:this._width},{min:this._gridPadding.left,max:this._width-this._gridPadding.right});for(t=8;t>0;t--){m[q[t-1]].pack({position:"absolute",top:0,right:this._gridPadding.right-o[t-1]},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top})}this.target.append(this.grid.createElement(this._gridPadding,this));this.grid.draw();for(t=0;t<this.series.length;t++){s=this.seriesStack[t];this.target.append(this.series[s].shadowCanvas.createElement(this._gridPadding,"jqplot-series-shadowCanvas",null,this));this.series[s].shadowCanvas.setContext();this.series[s].shadowCanvas._elem.data("seriesIndex",s)}for(t=0;t<this.series.length;t++){s=this.seriesStack[t];this.target.append(this.series[s].canvas.createElement(this._gridPadding,"jqplot-series-canvas",null,this));this.series[s].canvas.setContext();this.series[s].canvas._elem.data("seriesIndex",s)}this.target.append(this.eventCanvas.createElement(this._gridPadding,"jqplot-event-canvas",null,this));this.eventCanvas.setContext();this.eventCanvas._ctx.fillStyle="rgba(0,0,0,0)";this.eventCanvas._ctx.fillRect(0,0,this.eventCanvas._ctx.canvas.width,this.eventCanvas._ctx.canvas.height);this.bindCustomEvents();if(this.legend.preDraw){this.eventCanvas._elem.before(y);this.legend.pack(w);if(this.legend._elem){this.drawSeries({legendInfo:{location:this.legend.location,placement:this.legend.placement,width:this.legend.getWidth(),height:this.legend.getHeight(),xoffset:this.legend.xoffset,yoffset:this.legend.yoffset}})}else{this.drawSeries()}}else{this.drawSeries();if(this.series.length){g(this.series[this.series.length-1].canvas._elem).after(y)}this.legend.pack(w)}for(var t=0;t<g.jqplot.eventListenerHooks.length;t++){this.eventCanvas._elem.bind(g.jqplot.eventListenerHooks[t][0],{plot:this},g.jqplot.eventListenerHooks[t][1])}for(var t=0;t<this.eventListenerHooks.hooks.length;t++){this.eventCanvas._elem.bind(this.eventListenerHooks.hooks[t][0],{plot:this},this.eventListenerHooks.hooks[t][1])}for(var t=0;t<g.jqplot.postDrawHooks.length;t++){g.jqplot.postDrawHooks[t].call(this)}for(var t=0;t<this.postDrawHooks.hooks.length;t++){this.postDrawHooks.hooks[t].call(this)}if(this.target.is(":visible")){this._drawCount+=1}this.target.trigger("jqplotPostDraw",[this])}};this.bindCustomEvents=function(){this.eventCanvas._elem.bind("click",{plot:this},this.onClick);this.eventCanvas._elem.bind("dblclick",{plot:this},this.onDblClick);this.eventCanvas._elem.bind("mousedown",{plot:this},this.onMouseDown);this.eventCanvas._elem.bind("mousemove",{plot:this},this.onMouseMove);this.eventCanvas._elem.bind("mouseenter",{plot:this},this.onMouseEnter);this.eventCanvas._elem.bind("mouseleave",{plot:this},this.onMouseLeave);if(this.captureRightClick){this.eventCanvas._elem.bind("mouseup",{plot:this},this.onRightClick);this.eventCanvas._elem.get(0).oncontextmenu=function(){return false}}else{this.eventCanvas._elem.bind("mouseup",{plot:this},this.onMouseUp)}};function j(v){var u=v.data.plot;var q=u.eventCanvas._elem.offset();var t={x:v.pageX-q.left,y:v.pageY-q.top};var r={xaxis:null,yaxis:null,x2axis:null,y2axis:null,y3axis:null,y4axis:null,y5axis:null,y6axis:null,y7axis:null,y8axis:null,y9axis:null};var s=["xaxis","yaxis","x2axis","y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis"];var m=u.axes;var o,p;for(o=11;o>0;o--){p=s[o-1];if(m[p].show){r[p]=m[p].series_p2u(t[p.charAt(0)])}}return{offsets:q,gridPos:t,dataPos:r}}function l(m,n){var w=n.series;var ac,ab,aa,V,W,Q,P,D,B,G,H,R;var Z,ad,X,z,O,T;var o,U;for(aa=n.seriesStack.length-1;aa>=0;aa--){ac=n.seriesStack[aa];V=w[ac];switch(V.renderer.constructor){case g.jqplot.BarRenderer:Q=m.x;P=m.y;for(ab=0;ab<V._barPoints.length;ab++){O=V._barPoints[ab];X=V.gridData[ab];if(Q>O[0][0]&&Q<O[2][0]&&P>O[2][1]&&P<O[0][1]){return{seriesIndex:V.index,pointIndex:ab,gridData:X,data:V.data[ab],points:V._barPoints[ab]}}}break;case g.jqplot.DonutRenderer:G=V.startAngle/180*Math.PI;Q=m.x-V._center[0];P=m.y-V._center[1];W=Math.sqrt(Math.pow(Q,2)+Math.pow(P,2));if(Q>0&&-P>=0){D=2*Math.PI-Math.atan(-P/Q)}else{if(Q>0&&-P<0){D=-Math.atan(-P/Q)}else{if(Q<0){D=Math.PI-Math.atan(-P/Q)}else{if(Q==0&&-P>0){D=3*Math.PI/2}else{if(Q==0&&-P<0){D=Math.PI/2}else{if(Q==0&&P==0){D=0}}}}}}if(G){D-=G;if(D<0){D+=2*Math.PI}else{if(D>2*Math.PI){D-=2*Math.PI}}}B=V.sliceMargin/180*Math.PI;if(W<V._radius&&W>V._innerRadius){for(ab=0;ab<V.gridData.length;ab++){H=(ab>0)?V.gridData[ab-1][1]+B:B;R=V.gridData[ab][1];if(D>H&&D<R){return{seriesIndex:V.index,pointIndex:ab,gridData:V.gridData[ab],data:V.data[ab]}}}}break;case g.jqplot.PieRenderer:G=V.startAngle/180*Math.PI;Q=m.x-V._center[0];P=m.y-V._center[1];W=Math.sqrt(Math.pow(Q,2)+Math.pow(P,2));if(Q>0&&-P>=0){D=2*Math.PI-Math.atan(-P/Q)}else{if(Q>0&&-P<0){D=-Math.atan(-P/Q)}else{if(Q<0){D=Math.PI-Math.atan(-P/Q)}else{if(Q==0&&-P>0){D=3*Math.PI/2}else{if(Q==0&&-P<0){D=Math.PI/2}else{if(Q==0&&P==0){D=0}}}}}}if(G){D-=G;if(D<0){D+=2*Math.PI}else{if(D>2*Math.PI){D-=2*Math.PI}}}B=V.sliceMargin/180*Math.PI;if(W<V._radius){for(ab=0;ab<V.gridData.length;ab++){H=(ab>0)?V.gridData[ab-1][1]+B:B;R=V.gridData[ab][1];if(D>H&&D<R){return{seriesIndex:V.index,pointIndex:ab,gridData:V.gridData[ab],data:V.data[ab]}}}}break;case g.jqplot.BubbleRenderer:Q=m.x;P=m.y;var M=null;if(V.show){for(var ab=0;ab<V.gridData.length;ab++){X=V.gridData[ab];ad=Math.sqrt((Q-X[0])*(Q-X[0])+(P-X[1])*(P-X[1]));if(ad<=X[2]&&(ad<=Z||Z==null)){Z=ad;M={seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}if(M!=null){return M}}break;case g.jqplot.FunnelRenderer:Q=m.x;P=m.y;var S=V._vertices,u=S[0],q=S[S.length-1],A,L,F;function Y(s,v,t){var r=(v[1]-t[1])/(v[0]-t[0]);var p=v[1]-r*v[0];var x=s+v[1];return[(x-p)/r,x]}A=Y(P,u[0],q[3]);L=Y(P,u[1],q[2]);for(ab=0;ab<S.length;ab++){F=S[ab];if(P>=F[0][1]&&P<=F[3][1]&&Q>=A[0]&&Q<=L[0]){return{seriesIndex:V.index,pointIndex:ab,gridData:null,data:V.data[ab]}}}break;case g.jqplot.LineRenderer:Q=m.x;P=m.y;W=V.renderer;if(V.show){if(V.fill){var E=false;if(Q>V._boundingBox[0][0]&&Q<V._boundingBox[1][0]&&P>V._boundingBox[1][1]&&P<V._boundingBox[0][1]){var K=V._areaPoints.length;var N;var ab=K-1;for(var N=0;N<K;N++){var J=[V._areaPoints[N][0],V._areaPoints[N][1]];var I=[V._areaPoints[ab][0],V._areaPoints[ab][1]];if(J[1]<P&&I[1]>=P||I[1]<P&&J[1]>=P){if(J[0]+(P-J[1])/(I[1]-J[1])*(I[0]-J[0])<Q){E=!E}}ab=N}}if(E){return{seriesIndex:ac,pointIndex:null,gridData:V.gridData,data:V.data,points:V._areaPoints}}break}else{U=V.markerRenderer.size/2+V.neighborThreshold;o=(U>0)?U:0;for(var ab=0;ab<V.gridData.length;ab++){X=V.gridData[ab];if(W.constructor==g.jqplot.OHLCRenderer){if(W.candleStick){var C=V._yaxis.series_u2p;if(Q>=X[0]-W._bodyWidth/2&&Q<=X[0]+W._bodyWidth/2&&P>=C(V.data[ab][2])&&P<=C(V.data[ab][3])){return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}else{if(!W.hlc){var C=V._yaxis.series_u2p;if(Q>=X[0]-W._tickLength&&Q<=X[0]+W._tickLength&&P>=C(V.data[ab][2])&&P<=C(V.data[ab][3])){return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}else{var C=V._yaxis.series_u2p;if(Q>=X[0]-W._tickLength&&Q<=X[0]+W._tickLength&&P>=C(V.data[ab][1])&&P<=C(V.data[ab][2])){return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}}}else{if(X[0]!=null&&X[1]!=null){ad=Math.sqrt((Q-X[0])*(Q-X[0])+(P-X[1])*(P-X[1]));if(ad<=o&&(ad<=Z||Z==null)){Z=ad;return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}}}}}break;default:Q=m.x;P=m.y;W=V.renderer;if(V.show){U=V.markerRenderer.size/2+V.neighborThreshold;o=(U>0)?U:0;for(var ab=0;ab<V.gridData.length;ab++){X=V.gridData[ab];if(W.constructor==g.jqplot.OHLCRenderer){if(W.candleStick){var C=V._yaxis.series_u2p;if(Q>=X[0]-W._bodyWidth/2&&Q<=X[0]+W._bodyWidth/2&&P>=C(V.data[ab][2])&&P<=C(V.data[ab][3])){return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}else{if(!W.hlc){var C=V._yaxis.series_u2p;if(Q>=X[0]-W._tickLength&&Q<=X[0]+W._tickLength&&P>=C(V.data[ab][2])&&P<=C(V.data[ab][3])){return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}else{var C=V._yaxis.series_u2p;if(Q>=X[0]-W._tickLength&&Q<=X[0]+W._tickLength&&P>=C(V.data[ab][1])&&P<=C(V.data[ab][2])){return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}}}else{ad=Math.sqrt((Q-X[0])*(Q-X[0])+(P-X[1])*(P-X[1]));if(ad<=o&&(ad<=Z||Z==null)){Z=ad;return{seriesIndex:ac,pointIndex:ab,gridData:X,data:V.data[ab]}}}}}break}}return null}this.onClick=function(o){var n=j(o);var r=o.data.plot;var q=l(n.gridPos,r);var m=jQuery.Event("jqplotClick");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,q,r])};this.onDblClick=function(o){var n=j(o);var r=o.data.plot;var q=l(n.gridPos,r);var m=jQuery.Event("jqplotDblClick");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,q,r])};this.onMouseDown=function(o){var n=j(o);var r=o.data.plot;var q=l(n.gridPos,r);var m=jQuery.Event("jqplotMouseDown");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,q,r])};this.onMouseUp=function(o){var n=j(o);var m=jQuery.Event("jqplotMouseUp");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,null,o.data.plot])};this.onRightClick=function(o){var n=j(o);var r=o.data.plot;var q=l(n.gridPos,r);if(r.captureRightClick){if(o.which==3){var m=jQuery.Event("jqplotRightClick");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,q,r])}else{var m=jQuery.Event("jqplotMouseUp");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,q,r])}}};this.onMouseMove=function(o){var n=j(o);var r=o.data.plot;var q=l(n.gridPos,r);var m=jQuery.Event("jqplotMouseMove");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,q,r])};this.onMouseEnter=function(o){var n=j(o);var q=o.data.plot;var m=jQuery.Event("jqplotMouseEnter");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,null,q])};this.onMouseLeave=function(o){var n=j(o);var q=o.data.plot;var m=jQuery.Event("jqplotMouseLeave");m.pageX=o.pageX;m.pageY=o.pageY;g(this).trigger(m,[n.gridPos,n.dataPos,null,q])};this.drawSeries=function(o,m){var q,p,n;m=(typeof(o)==="number"&&m==null)?o:m;o=(typeof(o)==="object")?o:{};if(m!=h){p=this.series[m];n=p.shadowCanvas._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);p.drawShadow(n,o,this);n=p.canvas._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);p.draw(n,o,this);if(p.renderer.constructor==g.jqplot.BezierCurveRenderer){if(m<this.series.length-1){this.drawSeries(m+1)}}}else{for(q=0;q<this.series.length;q++){p=this.series[q];n=p.shadowCanvas._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);p.drawShadow(n,o,this);n=p.canvas._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);p.draw(n,o,this)}}o=m=q=p=n=null};this.moveSeriesToFront=function(n){n=parseInt(n,10);var q=g.inArray(n,this.seriesStack);if(q==-1){return}if(q==this.seriesStack.length-1){this.previousSeriesStack=this.seriesStack.slice(0);return}var m=this.seriesStack[this.seriesStack.length-1];var p=this.series[n].canvas._elem.detach();var o=this.series[n].shadowCanvas._elem.detach();this.series[m].shadowCanvas._elem.after(o);this.series[m].canvas._elem.after(p);this.previousSeriesStack=this.seriesStack.slice(0);this.seriesStack.splice(q,1);this.seriesStack.push(n)};this.moveSeriesToBack=function(n){n=parseInt(n,10);var q=g.inArray(n,this.seriesStack);if(q==0||q==-1){return}var m=this.seriesStack[0];var p=this.series[n].canvas._elem.detach();var o=this.series[n].shadowCanvas._elem.detach();this.series[m].shadowCanvas._elem.before(o);this.series[m].canvas._elem.before(p);this.previousSeriesStack=this.seriesStack.slice(0);this.seriesStack.splice(q,1);this.seriesStack.unshift(n)};this.restorePreviousSeriesOrder=function(){var s,r,q,p,o,m,n;if(this.seriesStack==this.previousSeriesStack){return}for(s=1;s<this.previousSeriesStack.length;s++){m=this.previousSeriesStack[s];n=this.previousSeriesStack[s-1];q=this.series[m].canvas._elem.detach();p=this.series[m].shadowCanvas._elem.detach();this.series[n].shadowCanvas._elem.after(p);this.series[n].canvas._elem.after(q)}o=this.seriesStack.slice(0);this.seriesStack=this.previousSeriesStack.slice(0);this.previousSeriesStack=o};this.restoreOriginalSeriesOrder=function(){var q,p,m=[],o,n;for(q=0;q<this.series.length;q++){m.push(q)}if(this.seriesStack==m){return}this.previousSeriesStack=this.seriesStack.slice(0);this.seriesStack=m;for(q=1;q<this.seriesStack.length;q++){o=this.series[q].canvas._elem.detach();n=this.series[q].shadowCanvas._elem.detach();this.series[q-1].shadowCanvas._elem.after(n);this.series[q-1].canvas._elem.after(o)}};this.activateTheme=function(m){this.themeEngine.activate(this,m)}}g.jqplot.computeHighlightColors=function(l){var n;if(jQuery.isArray(l)){n=[];for(var p=0;p<l.length;p++){var o=g.jqplot.getColorComponents(l[p]);var k=[o[0],o[1],o[2]];var q=k[0]+k[1]+k[2];for(var m=0;m<3;m++){k[m]=(q>570)?k[m]*0.8:k[m]+0.3*(255-k[m]);k[m]=parseInt(k[m],10)}n.push("rgb("+k[0]+","+k[1]+","+k[2]+")")}}else{var o=g.jqplot.getColorComponents(l);var k=[o[0],o[1],o[2]];var q=k[0]+k[1]+k[2];for(var m=0;m<3;m++){k[m]=(q>570)?k[m]*0.8:k[m]+0.3*(255-k[m]);k[m]=parseInt(k[m],10)}n="rgb("+k[0]+","+k[1]+","+k[2]+")"}return n};g.jqplot.ColorGenerator=function(j){j=j||g.jqplot.config.defaultColors;var i=0;this.next=function(){if(i<j.length){return j[i++]}else{i=0;return j[i++]}};this.previous=function(){if(i>0){return j[i--]}else{i=j.length-1;return j[i]}};this.get=function(l){var k=l-j.length*Math.floor(l/j.length);return j[k]};this.setColors=function(k){j=k};this.reset=function(){i=0}};g.jqplot.hex2rgb=function(k,i){k=k.replace("#","");if(k.length==3){k=k.charAt(0)+k.charAt(0)+k.charAt(1)+k.charAt(1)+k.charAt(2)+k.charAt(2)}var j;j="rgba("+parseInt(k.slice(0,2),16)+", "+parseInt(k.slice(2,4),16)+", "+parseInt(k.slice(4,6),16);if(i){j+=", "+i}j+=")";return j};g.jqplot.rgb2hex=function(p){var l=/rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *(?:, *[0-9.]*)?\)/;var j=p.match(l);var o="#";for(var n=1;n<4;n++){var k;if(j[n].search(/%/)!=-1){k=parseInt(255*j[n]/100,10).toString(16);if(k.length==1){k="0"+k}}else{k=parseInt(j[n],10).toString(16);if(k.length==1){k="0"+k}}o+=k}return o};g.jqplot.normalize2rgb=function(j,i){if(j.search(/^ *rgba?\(/)!=-1){return j}else{if(j.search(/^ *#?[0-9a-fA-F]?[0-9a-fA-F]/)!=-1){return g.jqplot.hex2rgb(j,i)}else{throw"invalid color spec"}}};g.jqplot.getColorComponents=function(p){p=g.jqplot.colorKeywordMap[p]||p;var n=g.jqplot.normalize2rgb(p);var l=/rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *,? *([0-9.]* *)?\)/;var j=n.match(l);var k=[];for(var o=1;o<4;o++){if(j[o].search(/%/)!=-1){k[o-1]=parseInt(255*j[o]/100,10)}else{k[o-1]=parseInt(j[o],10)}}k[3]=parseFloat(j[4])?parseFloat(j[4]):1;return k};g.jqplot.colorKeywordMap={aliceblue:"rgb(240, 248, 255)",antiquewhite:"rgb(250, 235, 215)",aqua:"rgb( 0, 255, 255)",aquamarine:"rgb(127, 255, 212)",azure:"rgb(240, 255, 255)",beige:"rgb(245, 245, 220)",bisque:"rgb(255, 228, 196)",black:"rgb( 0, 0, 0)",blanchedalmond:"rgb(255, 235, 205)",blue:"rgb( 0, 0, 255)",blueviolet:"rgb(138, 43, 226)",brown:"rgb(165, 42, 42)",burlywood:"rgb(222, 184, 135)",cadetblue:"rgb( 95, 158, 160)",chartreuse:"rgb(127, 255, 0)",chocolate:"rgb(210, 105, 30)",coral:"rgb(255, 127, 80)",cornflowerblue:"rgb(100, 149, 237)",cornsilk:"rgb(255, 248, 220)",crimson:"rgb(220, 20, 60)",cyan:"rgb( 0, 255, 255)",darkblue:"rgb( 0, 0, 139)",darkcyan:"rgb( 0, 139, 139)",darkgoldenrod:"rgb(184, 134, 11)",darkgray:"rgb(169, 169, 169)",darkgreen:"rgb( 0, 100, 0)",darkgrey:"rgb(169, 169, 169)",darkkhaki:"rgb(189, 183, 107)",darkmagenta:"rgb(139, 0, 139)",darkolivegreen:"rgb( 85, 107, 47)",darkorange:"rgb(255, 140, 0)",darkorchid:"rgb(153, 50, 204)",darkred:"rgb(139, 0, 0)",darksalmon:"rgb(233, 150, 122)",darkseagreen:"rgb(143, 188, 143)",darkslateblue:"rgb( 72, 61, 139)",darkslategray:"rgb( 47, 79, 79)",darkslategrey:"rgb( 47, 79, 79)",darkturquoise:"rgb( 0, 206, 209)",darkviolet:"rgb(148, 0, 211)",deeppink:"rgb(255, 20, 147)",deepskyblue:"rgb( 0, 191, 255)",dimgray:"rgb(105, 105, 105)",dimgrey:"rgb(105, 105, 105)",dodgerblue:"rgb( 30, 144, 255)",firebrick:"rgb(178, 34, 34)",floralwhite:"rgb(255, 250, 240)",forestgreen:"rgb( 34, 139, 34)",fuchsia:"rgb(255, 0, 255)",gainsboro:"rgb(220, 220, 220)",ghostwhite:"rgb(248, 248, 255)",gold:"rgb(255, 215, 0)",goldenrod:"rgb(218, 165, 32)",gray:"rgb(128, 128, 128)",grey:"rgb(128, 128, 128)",green:"rgb( 0, 128, 0)",greenyellow:"rgb(173, 255, 47)",honeydew:"rgb(240, 255, 240)",hotpink:"rgb(255, 105, 180)",indianred:"rgb(205, 92, 92)",indigo:"rgb( 75, 0, 130)",ivory:"rgb(255, 255, 240)",khaki:"rgb(240, 230, 140)",lavender:"rgb(230, 230, 250)",lavenderblush:"rgb(255, 240, 245)",lawngreen:"rgb(124, 252, 0)",lemonchiffon:"rgb(255, 250, 205)",lightblue:"rgb(173, 216, 230)",lightcoral:"rgb(240, 128, 128)",lightcyan:"rgb(224, 255, 255)",lightgoldenrodyellow:"rgb(250, 250, 210)",lightgray:"rgb(211, 211, 211)",lightgreen:"rgb(144, 238, 144)",lightgrey:"rgb(211, 211, 211)",lightpink:"rgb(255, 182, 193)",lightsalmon:"rgb(255, 160, 122)",lightseagreen:"rgb( 32, 178, 170)",lightskyblue:"rgb(135, 206, 250)",lightslategray:"rgb(119, 136, 153)",lightslategrey:"rgb(119, 136, 153)",lightsteelblue:"rgb(176, 196, 222)",lightyellow:"rgb(255, 255, 224)",lime:"rgb( 0, 255, 0)",limegreen:"rgb( 50, 205, 50)",linen:"rgb(250, 240, 230)",magenta:"rgb(255, 0, 255)",maroon:"rgb(128, 0, 0)",mediumaquamarine:"rgb(102, 205, 170)",mediumblue:"rgb( 0, 0, 205)",mediumorchid:"rgb(186, 85, 211)",mediumpurple:"rgb(147, 112, 219)",mediumseagreen:"rgb( 60, 179, 113)",mediumslateblue:"rgb(123, 104, 238)",mediumspringgreen:"rgb( 0, 250, 154)",mediumturquoise:"rgb( 72, 209, 204)",mediumvioletred:"rgb(199, 21, 133)",midnightblue:"rgb( 25, 25, 112)",mintcream:"rgb(245, 255, 250)",mistyrose:"rgb(255, 228, 225)",moccasin:"rgb(255, 228, 181)",navajowhite:"rgb(255, 222, 173)",navy:"rgb( 0, 0, 128)",oldlace:"rgb(253, 245, 230)",olive:"rgb(128, 128, 0)",olivedrab:"rgb(107, 142, 35)",orange:"rgb(255, 165, 0)",orangered:"rgb(255, 69, 0)",orchid:"rgb(218, 112, 214)",palegoldenrod:"rgb(238, 232, 170)",palegreen:"rgb(152, 251, 152)",paleturquoise:"rgb(175, 238, 238)",palevioletred:"rgb(219, 112, 147)",papayawhip:"rgb(255, 239, 213)",peachpuff:"rgb(255, 218, 185)",peru:"rgb(205, 133, 63)",pink:"rgb(255, 192, 203)",plum:"rgb(221, 160, 221)",powderblue:"rgb(176, 224, 230)",purple:"rgb(128, 0, 128)",red:"rgb(255, 0, 0)",rosybrown:"rgb(188, 143, 143)",royalblue:"rgb( 65, 105, 225)",saddlebrown:"rgb(139, 69, 19)",salmon:"rgb(250, 128, 114)",sandybrown:"rgb(244, 164, 96)",seagreen:"rgb( 46, 139, 87)",seashell:"rgb(255, 245, 238)",sienna:"rgb(160, 82, 45)",silver:"rgb(192, 192, 192)",skyblue:"rgb(135, 206, 235)",slateblue:"rgb(106, 90, 205)",slategray:"rgb(112, 128, 144)",slategrey:"rgb(112, 128, 144)",snow:"rgb(255, 250, 250)",springgreen:"rgb( 0, 255, 127)",steelblue:"rgb( 70, 130, 180)",tan:"rgb(210, 180, 140)",teal:"rgb( 0, 128, 128)",thistle:"rgb(216, 191, 216)",tomato:"rgb(255, 99, 71)",turquoise:"rgb( 64, 224, 208)",violet:"rgb(238, 130, 238)",wheat:"rgb(245, 222, 179)",white:"rgb(255, 255, 255)",whitesmoke:"rgb(245, 245, 245)",yellow:"rgb(255, 255, 0)",yellowgreen:"rgb(154, 205, 50)"}})(jQuery);(function(a){a.jqplot.LinearAxisRenderer=function(){};a.jqplot.LinearAxisRenderer.prototype.init=function(b){this.breakPoints=null;this.breakTickLabel="≈";this.forceTickAt0=false;this.forceTickAt100=false;this._autoFormatString="";this._overrideFormatString=false;a.extend(true,this,b);if(this.breakPoints){if(!a.isArray(this.breakPoints)){this.breakPoints=null}else{if(this.breakPoints.length<2||this.breakPoints[1]<=this.breakPoints[0]){this.breakPoints=null}}}this.resetDataBounds()};a.jqplot.LinearAxisRenderer.prototype.draw=function(b,j){if(this.show){this.renderer.createTicks.call(this);var h=0;var c;if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=a(document.createElement("div"));this._elem.addClass("jqplot-axis jqplot-"+this.name);this._elem.css("posiiton","absolute");if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var g=this._label.draw(b,j);g.appendTo(this._elem);g=null}var f=this._ticks;var e;for(var d=0;d<f.length;d++){e=f[d];if(e.show&&e.showLabel&&(!e.isMinorTick||this.showMinorTicks)){this._elem.append(e.draw(b,j))}}e=null;f=null}return this._elem};a.jqplot.LinearAxisRenderer.prototype.reset=function(){this.min=this._min;this.max=this._max;this.tickInterval=this._tickInterval;this.numberTicks=this._numberTicks;this._autoFormatString="";if(this._overrideFormatString&&this.tickOptions&&this.tickOptions.formatString){this.tickOptions.formatString=""}};a.jqplot.LinearAxisRenderer.prototype.set=function(){var k=0;var d;var c=0;var j=0;var b=(this._label==null)?false:this._label.show;if(this.show){var g=this._ticks;var f;for(var e=0;e<g.length;e++){f=g[e];if(!f._breakTick&&f.show&&f.showLabel&&(!f.isMinorTick||this.showMinorTicks)){if(this.name=="xaxis"||this.name=="x2axis"){d=f._elem.outerHeight(true)}else{d=f._elem.outerWidth(true)}if(d>k){k=d}}}f=null;g=null;if(b){c=this._label._elem.outerWidth(true);j=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){k=k+j;this._elem.css({height:k+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){k=k+j;this._elem.css({height:k+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){k=k+c;this._elem.css({width:k+"px",left:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}else{k=k+c;this._elem.css({width:k+"px",right:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}}}}};a.jqplot.LinearAxisRenderer.prototype.createTicks=function(){var P=this._ticks;var G=this.ticks;var x=this.name;var z=this._dataBounds;var b,g;var ab,E;var k,h;var Z,W;var D=this.min;var aa=this.max;var S=this.numberTicks;var ae=this.tickInterval;if(G.length){for(W=0;W<G.length;W++){var J=G[W];var Q=new this.tickRenderer(this.tickOptions);if(J.constructor==Array){Q.value=J[0];if(this.breakPoints){if(J[0]==this.breakPoints[0]){Q.label=this.breakTickLabel;Q._breakTick=true;Q.showGridline=false;Q.showMark=false}else{if(J[0]>this.breakPoints[0]&&J[0]<=this.breakPoints[1]){Q.show=false;Q.showGridline=false;Q.label=J[1]}else{Q.label=J[1]}}}else{Q.label=J[1]}Q.setTick(J[0],this.name);this._ticks.push(Q)}else{Q.value=J;if(this.breakPoints){if(J==this.breakPoints[0]){Q.label=this.breakTickLabel;Q._breakTick=true;Q.showGridline=false;Q.showMark=false}else{if(J>this.breakPoints[0]&&J<=this.breakPoints[1]){Q.show=false;Q.showGridline=false}}}Q.setTick(J,this.name);this._ticks.push(Q)}}this.numberTicks=G.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.tickInterval=(this.max-this.min)/(this.numberTicks-1)}else{if(x=="xaxis"||x=="x2axis"){b=this._plotDimensions.width}else{b=this._plotDimensions.height}ab=((this.min!=null)?this.min:z.min);E=((this.max!=null)?this.max:z.max);var r=E-ab;var O,w;var p;if(this.min==null&&this.max==null&&this.numberTicks==null&&this.tickInterval==null&&!this.autoscale){if(this.tickOptions==null||!this.tickOptions.formatString){this._overrideFormatString=true}if(this.forceTickAt0){if(ab>0){ab=0}if(E<0){E=0}}if(this.forceTickAt100){if(ab>100){ab=100}if(E<100){E=100}}var f=30;var L=Math.max(b,f+1);var u=(L-f)/300;var K=a.jqplot.LinearTickGenerator(ab,E,u);var v=ab+r*(this.padMin-1);var M=E-r*(this.padMax-1);if(ab<=v||E>=M){v=ab-r*(this.padMin-1);M=E+r*(this.padMax-1);K=a.jqplot.LinearTickGenerator(v,M,u)}this.min=K[0];this.max=K[1];this.numberTicks=K[2];this._autoFormatString=K[3];this.tickInterval=K[4]}else{if(ab==E){var c=0.05;if(ab>0){c=Math.max(Math.log(ab)/Math.LN10,0.05)}ab-=c;E+=c}if(this.autoscale&&this.min==null&&this.max==null){var d,e,o;var A=false;var I=false;var y={min:null,max:null,average:null,stddev:null};for(var W=0;W<this._series.length;W++){var R=this._series[W];var B=(R.fillAxis=="x")?R._xaxis.name:R._yaxis.name;if(this.name==B){var N=R._plotValues[R.fillAxis];var C=N[0];var X=N[0];for(var V=1;V<N.length;V++){if(N[V]<C){C=N[V]}else{if(N[V]>X){X=N[V]}}}var q=(X-C)/X;if(R.renderer.constructor==a.jqplot.BarRenderer){if(C>=0&&(R.fillToZero||q>0.1)){A=true}else{A=false;if(R.fill&&R.fillToZero&&C<0&&X>0){I=true}else{I=false}}}else{if(R.fill){if(C>=0&&(R.fillToZero||q>0.1)){A=true}else{if(C<0&&X>0&&R.fillToZero){A=false;I=true}else{A=false;I=false}}}else{if(C<0){A=false}}}}}if(A){this.numberTicks=2+Math.ceil((b-(this.tickSpacing-1))/this.tickSpacing);this.min=0;D=0;e=E/(this.numberTicks-1);p=Math.pow(10,Math.abs(Math.floor(Math.log(e)/Math.LN10)));if(e/p==parseInt(e/p,10)){e+=p}this.tickInterval=Math.ceil(e/p)*p;this.max=this.tickInterval*(this.numberTicks-1)}else{if(I){this.numberTicks=2+Math.ceil((b-(this.tickSpacing-1))/this.tickSpacing);var F=Math.ceil(Math.abs(ab)/r*(this.numberTicks-1));var ad=this.numberTicks-1-F;e=Math.max(Math.abs(ab/F),Math.abs(E/ad));p=Math.pow(10,Math.abs(Math.floor(Math.log(e)/Math.LN10)));this.tickInterval=Math.ceil(e/p)*p;this.max=this.tickInterval*ad;this.min=-this.tickInterval*F}else{if(this.numberTicks==null){if(this.tickInterval){this.numberTicks=3+Math.ceil(r/this.tickInterval)}else{this.numberTicks=2+Math.ceil((b-(this.tickSpacing-1))/this.tickSpacing)}}if(this.tickInterval==null){e=r/(this.numberTicks-1);if(e<1){p=Math.pow(10,Math.abs(Math.floor(Math.log(e)/Math.LN10)))}else{p=1}this.tickInterval=Math.ceil(e*p*this.pad)/p}else{p=1/this.tickInterval}d=this.tickInterval*(this.numberTicks-1);o=(d-r)/2;if(this.min==null){this.min=Math.floor(p*(ab-o))/p}if(this.max==null){this.max=this.min+d}}}}else{O=(this.min!=null)?this.min:ab-r*(this.padMin-1);w=(this.max!=null)?this.max:E+r*(this.padMax-1);this.min=O;this.max=w;r=this.max-this.min;if(this.numberTicks==null){if(this.tickInterval!=null){this.numberTicks=Math.ceil((this.max-this.min)/this.tickInterval)+1;this.max=this.min+this.tickInterval*(this.numberTicks-1)}else{if(b>100){this.numberTicks=parseInt(3+(b-100)/75,10)}else{this.numberTicks=2}}}if(this.tickInterval==null){this.tickInterval=r/(this.numberTicks-1)}}if(this.renderer.constructor==a.jqplot.LinearAxisRenderer&&this._autoFormatString==""){r=this.max-this.min;var ac=new this.tickRenderer(this.tickOptions);var H=ac.formatString||a.jqplot.config.defaultTickFormatString;var H=H.match(a.jqplot.sprintf.regex)[0];var Y=0;if(H){if(H.search(/[fFeEgGpP]/)>-1){var U=H.match(/\%\.(\d{0,})?[eEfFgGpP]/);if(U){Y=parseInt(U[1],10)}else{Y=6}}else{if(H.search(/[di]/)>-1){Y=0}}var l=Math.pow(10,-Y);if(this.tickInterval<l){if(S==null&&ae==null){this.tickInterval=l;if(aa==null&&D==null){this.min=Math.floor(this._dataBounds.min/l)*l;if(this.min==this._dataBounds.min){this.min=this._dataBounds.min-this.tickInterval}this.max=Math.ceil(this._dataBounds.max/l)*l;if(this.max==this._dataBounds.max){this.max=this._dataBounds.max+this.tickInterval}var T=(this.max-this.min)/this.tickInterval;T=T.toFixed(11);T=Math.ceil(T);this.numberTicks=T+1}else{if(aa==null){var T=(this._dataBounds.max-this.min)/this.tickInterval;T=T.toFixed(11);this.numberTicks=Math.ceil(T)+2;this.max=this.min+this.tickInterval*(this.numberTicks-1)}else{if(D==null){var T=(this.max-this._dataBounds.min)/this.tickInterval;T=T.toFixed(11);this.numberTicks=Math.ceil(T)+2;this.min=this.max-this.tickInterval*(this.numberTicks-1)}else{this.numberTicks=Math.ceil((aa-D)/this.tickInterval)+1;this.min=Math.floor(D*Math.pow(10,Y))/Math.pow(10,Y);this.max=Math.ceil(aa*Math.pow(10,Y))/Math.pow(10,Y);this.numberTicks=Math.ceil((this.max-this.min)/this.tickInterval)+1}}}}}}}}if(this._overrideFormatString&&this._autoFormatString!=""){this.tickOptions=this.tickOptions||{};this.tickOptions.formatString=this._autoFormatString}for(var W=0;W<this.numberTicks;W++){Z=this.min+W*this.tickInterval;var Q=new this.tickRenderer(this.tickOptions);Q.setTick(Z,this.name);this._ticks.push(Q);Q=null}}P=null};a.jqplot.LinearAxisRenderer.prototype.resetTickValues=function(d){if(a.isArray(d)&&d.length==this._ticks.length){var c;for(var b=0;b<d.length;b++){c=this._ticks[b];c.value=d[b]; -c.label=c.formatter(c.formatString,d[b]);c.label=c.prefix+c.label;c._elem.html(c.label)}c=null;this.min=a.jqplot.arrayMin(d);this.max=a.jqplot.arrayMax(d);this.pack()}};a.jqplot.LinearAxisRenderer.prototype.pack=function(d,c){d=d||{};c=c||this._offsets;var v=this._ticks;var q=this.max;var o=this.min;var k=c.max;var g=c.min;var m=(this._label==null)?false:this._label.show;for(var n in d){this._elem.css(n,d[n])}this._offsets=c;var e=k-g;var f=q-o;if(this.breakPoints){f=f-this.breakPoints[1]+this.breakPoints[0];this.p2u=function(h){return(h-g)*f/e+o};this.u2p=function(h){if(h>this.breakPoints[0]&&h<this.breakPoints[1]){h=this.breakPoints[0]}if(h<=this.breakPoints[0]){return(h-o)*e/f+g}else{return(h-this.breakPoints[1]+this.breakPoints[0]-o)*e/f+g}};if(this.name.charAt(0)=="x"){this.series_u2p=function(h){if(h>this.breakPoints[0]&&h<this.breakPoints[1]){h=this.breakPoints[0]}if(h<=this.breakPoints[0]){return(h-o)*e/f}else{return(h-this.breakPoints[1]+this.breakPoints[0]-o)*e/f}};this.series_p2u=function(h){return h*f/e+o}}else{this.series_u2p=function(h){if(h>this.breakPoints[0]&&h<this.breakPoints[1]){h=this.breakPoints[0]}if(h>=this.breakPoints[1]){return(h-q)*e/f}else{return(h+this.breakPoints[1]-this.breakPoints[0]-q)*e/f}};this.series_p2u=function(h){return h*f/e+q}}}else{this.p2u=function(h){return(h-g)*f/e+o};this.u2p=function(h){return(h-o)*e/f+g};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(h){return(h-o)*e/f};this.series_p2u=function(h){return h*f/e+o}}else{this.series_u2p=function(h){return(h-q)*e/f};this.series_p2u=function(h){return h*f/e+q}}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(var r=0;r<v.length;r++){var l=v[r];if(l.show&&l.showLabel){var b;if(l.constructor==a.jqplot.CanvasAxisTickRenderer&&l.angle){var u=(this.name=="xaxis")?1:-1;switch(l.labelPosition){case"auto":if(u*l.angle<0){b=-l.getWidth()+l._textRenderer.height*Math.sin(-l._textRenderer.angle)/2}else{b=-l._textRenderer.height*Math.sin(l._textRenderer.angle)/2}break;case"end":b=-l.getWidth()+l._textRenderer.height*Math.sin(-l._textRenderer.angle)/2;break;case"start":b=-l._textRenderer.height*Math.sin(l._textRenderer.angle)/2;break;case"middle":b=-l.getWidth()/2+l._textRenderer.height*Math.sin(-l._textRenderer.angle)/2;break;default:b=-l.getWidth()/2+l._textRenderer.height*Math.sin(-l._textRenderer.angle)/2;break}}else{b=-l.getWidth()/2}var x=this.u2p(l.value)+b+"px";l._elem.css("left",x);l.pack()}}if(m){var j=this._label._elem.outerWidth(true);this._label._elem.css("left",g+e/2-j/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px")}else{this._label._elem.css("top","0px")}this._label.pack()}}else{for(var r=0;r<v.length;r++){var l=v[r];if(l.show&&l.showLabel){var b;if(l.constructor==a.jqplot.CanvasAxisTickRenderer&&l.angle){var u=(this.name=="yaxis")?1:-1;switch(l.labelPosition){case"auto":case"end":if(u*l.angle<0){b=-l._textRenderer.height*Math.cos(-l._textRenderer.angle)/2}else{b=-l.getHeight()+l._textRenderer.height*Math.cos(l._textRenderer.angle)/2}break;case"start":if(l.angle>0){b=-l._textRenderer.height*Math.cos(-l._textRenderer.angle)/2}else{b=-l.getHeight()+l._textRenderer.height*Math.cos(l._textRenderer.angle)/2}break;case"middle":b=-l.getHeight()/2;break;default:b=-l.getHeight()/2;break}}else{b=-l.getHeight()/2}var x=this.u2p(l.value)+b+"px";l._elem.css("top",x);l.pack()}}if(m){var s=this._label._elem.outerHeight(true);this._label._elem.css("top",k-e/2-s/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}v=null}})(jQuery);(function(a){a.jqplot.AxisTickRenderer=function(b){a.jqplot.ElemContainer.call(this);this.mark="outside";this.axis;this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.size=4;this.markSize=6;this.show=true;this.showLabel=true;this.label="";this.value=null;this._styles={};this.formatter=a.jqplot.DefaultTickFormatter;this.prefix="";this.formatString="";this.fontFamily;this.fontSize;this.textColor;this._elem;this._breakTick=false;a.extend(true,this,b)};a.jqplot.AxisTickRenderer.prototype.init=function(b){a.extend(true,this,b)};a.jqplot.AxisTickRenderer.prototype=new a.jqplot.ElemContainer();a.jqplot.AxisTickRenderer.prototype.constructor=a.jqplot.AxisTickRenderer;a.jqplot.AxisTickRenderer.prototype.setTick=function(b,d,c){this.value=b;this.axis=d;if(c){this.isMinorTick=true}return this};a.jqplot.AxisTickRenderer.prototype.draw=function(){if(!this.label){this.label=this.prefix+this.formatter(this.formatString,this.value)}var c={position:"absolute"};if(Number(this.label)){c.whitSpace="nowrap"}if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=a(document.createElement("div"));this._elem.addClass("jqplot-"+this.axis+"-tick");this._elem.text(this.label);this._elem.css(c);for(var b in this._styles){this._elem.css(b,this._styles[b])}if(this.fontFamily){this._elem.css("font-family",this.fontFamily)}if(this.fontSize){this._elem.css("font-size",this.fontSize)}if(this.textColor){this._elem.css("color",this.textColor)}if(this._breakTick){this._elem.addClass("jqplot-breakTick")}return this._elem};a.jqplot.DefaultTickFormatter=function(b,c){if(typeof c=="number"){if(!b){b=a.jqplot.config.defaultTickFormatString}return a.jqplot.sprintf(b,c)}else{return String(c)}};a.jqplot.AxisTickRenderer.prototype.pack=function(){}})(jQuery);(function(a){a.jqplot.AxisLabelRenderer=function(b){a.jqplot.ElemContainer.call(this);this.axis;this.show=true;this.label="";this.fontFamily=null;this.fontSize=null;this.textColor=null;this._elem;this.escapeHTML=false;a.extend(true,this,b)};a.jqplot.AxisLabelRenderer.prototype=new a.jqplot.ElemContainer();a.jqplot.AxisLabelRenderer.prototype.constructor=a.jqplot.AxisLabelRenderer;a.jqplot.AxisLabelRenderer.prototype.init=function(b){a.extend(true,this,b)};a.jqplot.AxisLabelRenderer.prototype.draw=function(b,c){if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=a('<div style="position:absolute;" class="jqplot-'+this.axis+'-label"></div>');if(Number(this.label)){this._elem.css("white-space","nowrap")}if(!this.escapeHTML){this._elem.html(this.label)}else{this._elem.text(this.label)}if(this.fontFamily){this._elem.css("font-family",this.fontFamily)}if(this.fontSize){this._elem.css("font-size",this.fontSize)}if(this.textColor){this._elem.css("color",this.textColor)}return this._elem};a.jqplot.AxisLabelRenderer.prototype.pack=function(){}})(jQuery);(function(a){a.jqplot.TableLegendRenderer=function(){};a.jqplot.TableLegendRenderer.prototype.init=function(b){a.extend(true,this,b)};a.jqplot.TableLegendRenderer.prototype.addrow=function(k,e,b,i){var f=(b)?this.rowSpacing+"px":"0px";var j;var d;var c;var h;var g;c=document.createElement("tr");j=a(c);j.addClass("jqplot-table-legend");c=null;if(i){j.prependTo(this._elem)}else{j.appendTo(this._elem)}if(this.showSwatches){d=a(document.createElement("td"));d.addClass("jqplot-table-legend");d.css({textAlign:"center",paddingTop:f});h=a(document.createElement("div"));g=a(document.createElement("div"));g.addClass("jqplot-table-legend-swatch");g.css({backgroundColor:e,borderColor:e});j.append(d.append(h.append(g)))}if(this.showLabels){d=a(document.createElement("td"));d.addClass("jqplot-table-legend");d.css("paddingTop",f);j.append(d);if(this.escapeHtml){d.text(k)}else{d.html(k)}}d=null;h=null;g=null;j=null;c=null};a.jqplot.TableLegendRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}if(this.show){var g=this._series;var c=document.createElement("table");this._elem=a(c);this._elem.addClass("jqplot-table-legend");var n={position:"absolute"};if(this.background){n.background=this.background}if(this.border){n.border=this.border}if(this.fontSize){n.fontSize=this.fontSize}if(this.fontFamily){n.fontFamily=this.fontFamily}if(this.textColor){n.textColor=this.textColor}if(this.marginTop!=null){n.marginTop=this.marginTop}if(this.marginBottom!=null){n.marginBottom=this.marginBottom}if(this.marginLeft!=null){n.marginLeft=this.marginLeft}if(this.marginRight!=null){n.marginRight=this.marginRight}var b=false,k=false,m;for(var h=0;h<g.length;h++){m=g[h];if(m._stack||m.renderer.constructor==a.jqplot.BezierCurveRenderer){k=true}if(m.show&&m.showLabel){var f=this.labels[h]||m.label.toString();if(f){var d=m.color;if(k&&h<g.length-1){b=true}else{if(k&&h==g.length-1){b=false}}this.renderer.addrow.call(this,f,d,b,k);b=true}for(var e=0;e<a.jqplot.addLegendRowHooks.length;e++){var l=a.jqplot.addLegendRowHooks[e].call(this,m);if(l){this.renderer.addrow.call(this,l.label,l.color,b);b=true}}f=null}}}return this._elem};a.jqplot.TableLegendRenderer.prototype.pack=function(e){if(this.show){if(this.placement=="insideGrid"){switch(this.location){case"nw":var d=e.left;var c=e.top;this._elem.css("left",d);this._elem.css("top",c);break;case"n":var d=(e.left+(this._plotDimensions.width-e.right))/2-this.getWidth()/2;var c=e.top;this._elem.css("left",d);this._elem.css("top",c);break;case"ne":var d=e.right;var c=e.top;this._elem.css({right:d,top:c});break;case"e":var d=e.right;var c=(e.top+(this._plotDimensions.height-e.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;case"se":var d=e.right;var c=e.bottom;this._elem.css({right:d,bottom:c});break;case"s":var d=(e.left+(this._plotDimensions.width-e.right))/2-this.getWidth()/2;var c=e.bottom;this._elem.css({left:d,bottom:c});break;case"sw":var d=e.left;var c=e.bottom;this._elem.css({left:d,bottom:c});break;case"w":var d=e.left;var c=(e.top+(this._plotDimensions.height-e.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;default:var d=e.right;var c=e.bottom;this._elem.css({right:d,bottom:c});break}}else{if(this.placement=="outside"){switch(this.location){case"nw":var d=this._plotDimensions.width-e.left;var c=e.top;this._elem.css("right",d);this._elem.css("top",c);break;case"n":var d=(e.left+(this._plotDimensions.width-e.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-e.top;this._elem.css("left",d);this._elem.css("bottom",c);break;case"ne":var d=this._plotDimensions.width-e.right;var c=e.top;this._elem.css({left:d,top:c});break;case"e":var d=this._plotDimensions.width-e.right;var c=(e.top+(this._plotDimensions.height-e.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;case"se":var d=this._plotDimensions.width-e.right;var c=e.bottom;this._elem.css({left:d,bottom:c});break;case"s":var d=(e.left+(this._plotDimensions.width-e.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-e.bottom;this._elem.css({left:d,top:c});break;case"sw":var d=this._plotDimensions.width-e.left;var c=e.bottom;this._elem.css({right:d,bottom:c});break;case"w":var d=this._plotDimensions.width-e.left;var c=(e.top+(this._plotDimensions.height-e.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;default:var d=e.right;var c=e.bottom;this._elem.css({right:d,bottom:c});break}}else{switch(this.location){case"nw":this._elem.css({left:0,top:e.top});break;case"n":var d=(e.left+(this._plotDimensions.width-e.right))/2-this.getWidth()/2;this._elem.css({left:d,top:e.top});break;case"ne":this._elem.css({right:0,top:e.top});break;case"e":var c=(e.top+(this._plotDimensions.height-e.bottom))/2-this.getHeight()/2;this._elem.css({right:e.right,top:c});break;case"se":this._elem.css({right:e.right,bottom:e.bottom});break;case"s":var d=(e.left+(this._plotDimensions.width-e.right))/2-this.getWidth()/2;this._elem.css({left:d,bottom:e.bottom});break;case"sw":this._elem.css({left:e.left,bottom:e.bottom});break;case"w":var c=(e.top+(this._plotDimensions.height-e.bottom))/2-this.getHeight()/2;this._elem.css({left:e.left,top:c});break;default:this._elem.css({right:e.right,bottom:e.bottom});break}}}}}})(jQuery);(function(d){d.jqplot.LineRenderer=function(){this.shapeRenderer=new d.jqplot.ShapeRenderer();this.shadowRenderer=new d.jqplot.ShadowRenderer()};d.jqplot.LineRenderer.prototype.init=function(l,p){l=l||{};this._type="line";var n={highlightMouseOver:l.highlightMouseOver,highlightMouseDown:l.highlightMouseDown,highlightColor:l.highlightColor};delete (l.highlightMouseOver);delete (l.highlightMouseDown);delete (l.highlightColor);d.extend(true,this.renderer,l);var o={lineJoin:this.lineJoin,lineCap:this.lineCap,fill:this.fill,isarc:false,strokeStyle:this.color,fillStyle:this.fillColor,lineWidth:this.lineWidth,closePath:this.fill};this.renderer.shapeRenderer.init(o);if(this.lineWidth>2.5){var m=this.shadowOffset*(1+(Math.atan((this.lineWidth/2.5))/0.785398163-1)*0.6)}else{var m=this.shadowOffset*Math.atan((this.lineWidth/2.5))/0.785398163}var k={lineJoin:this.lineJoin,lineCap:this.lineCap,fill:this.fill,isarc:false,angle:this.shadowAngle,offset:m,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.lineWidth,closePath:this.fill};this.renderer.shadowRenderer.init(k);this._areaPoints=[];this._boundingBox=[[],[]];if(!this.isTrendline&&this.fill){this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColor=null;if(n.highlightMouseDown&&n.highlightMouseOver==null){n.highlightMouseOver=false}d.extend(true,this,{highlightMouseOver:n.highlightMouseOver,highlightMouseDown:n.highlightMouseDown,highlightColor:n.highlightColor});if(!this.highlightColor){this.highlightColor=d.jqplot.computeHighlightColors(this.fillColor)}if(this.highlighter){this.highlighter.show=false}}if(!this.isTrendline&&p){p.plugins.lineRenderer={};p.postInitHooks.addOnce(f);p.postDrawHooks.addOnce(g);p.eventListenerHooks.addOnce("jqplotMouseMove",a);p.eventListenerHooks.addOnce("jqplotMouseDown",b);p.eventListenerHooks.addOnce("jqplotMouseUp",i);p.eventListenerHooks.addOnce("jqplotClick",e);p.eventListenerHooks.addOnce("jqplotRightClick",j)}};d.jqplot.LineRenderer.prototype.setGridData=function(p){var l=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var m=this._plotData;var n=this._prevPlotData;this.gridData=[];this._prevGridData=[];for(var k=0;k<this.data.length;k++){if(m[k][0]!=null&&m[k][1]!=null){this.gridData.push([l.call(this._xaxis,m[k][0]),o.call(this._yaxis,m[k][1])])}else{if(m[k][0]==null){this.gridData.push([null,o.call(this._yaxis,m[k][1])])}else{if(m[k][1]==null){this.gridData.push([l.call(this._xaxis,m[k][0]),null])}}}if(n[k]!=null&&n[k][0]!=null&&n[k][1]!=null){this._prevGridData.push([l.call(this._xaxis,n[k][0]),o.call(this._yaxis,n[k][1])])}else{if(n[k]!=null&&n[k][0]==null){this._prevGridData.push([null,o.call(this._yaxis,n[k][1])])}else{if(n[k]!=null&&n[k][0]!=null&&n[k][1]==null){this._prevGridData.push([l.call(this._xaxis,n[k][0]),null])}}}}};d.jqplot.LineRenderer.prototype.makeGridData=function(n,p){var m=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var l=[];var q=[];for(var k=0;k<n.length;k++){if(n[k][0]!=null&&n[k][1]!=null){l.push([m.call(this._xaxis,n[k][0]),o.call(this._yaxis,n[k][1])])}else{if(n[k][0]==null){l.push([null,o.call(this._yaxis,n[k][1])])}else{if(n[k][1]==null){l.push([m.call(this._xaxis,n[k][0]),null])}}}}return l};d.jqplot.LineRenderer.prototype.draw=function(A,K,l){var E;var u=(l!=undefined)?l:{};var n=(u.shadow!=undefined)?u.shadow:this.shadow;var L=(u.showLine!=undefined)?u.showLine:this.showLine;var D=(u.fill!=undefined)?u.fill:this.fill;var k=(u.fillAndStroke!=undefined)?u.fillAndStroke:this.fillAndStroke;var v,B,y,G;A.save();if(K.length){if(L){if(D){if(this.fillToZero){var o=new d.jqplot.ColorGenerator(this.negativeSeriesColors);var H=o.get(this.index);if(!this.useNegativeColors){H=u.fillStyle}var s=false;var t=u.fillStyle;if(k){var J=K.slice(0)}if(this.index==0||!this._stack){var z=[];this._areaPoints=[];var I=this._yaxis.series_u2p(this.fillToValue);var m=this._xaxis.series_u2p(this.fillToValue);if(this.fillAxis=="y"){z.push([K[0][0],I]);this._areaPoints.push([K[0][0],I]);for(var E=0;E<K.length-1;E++){z.push(K[E]);this._areaPoints.push(K[E]);if(this._plotData[E][1]*this._plotData[E+1][1]<0){if(this._plotData[E][1]<0){s=true;u.fillStyle=H}else{s=false;u.fillStyle=t}var r=K[E][0]+(K[E+1][0]-K[E][0])*(I-K[E][1])/(K[E+1][1]-K[E][1]);z.push([r,I]);this._areaPoints.push([r,I]);if(n){this.renderer.shadowRenderer.draw(A,z,u)}this.renderer.shapeRenderer.draw(A,z,u);z=[[r,I]]}}if(this._plotData[K.length-1][1]<0){s=true;u.fillStyle=H}else{s=false;u.fillStyle=t}z.push(K[K.length-1]);this._areaPoints.push(K[K.length-1]);z.push([K[K.length-1][0],I]);this._areaPoints.push([K[K.length-1][0],I])}if(n){this.renderer.shadowRenderer.draw(A,z,u)}this.renderer.shapeRenderer.draw(A,z,u)}else{var x=this._prevGridData;for(var E=x.length;E>0;E--){K.push(x[E-1])}if(n){this.renderer.shadowRenderer.draw(A,K,u)}this._areaPoints=K;this.renderer.shapeRenderer.draw(A,K,u)}}else{if(k){var J=K.slice(0)}if(this.index==0||!this._stack){var q=A.canvas.height;K.unshift([K[0][0],q]);var F=K.length;K.push([K[F-1][0],q])}else{var x=this._prevGridData;for(var E=x.length;E>0;E--){K.push(x[E-1])}}this._areaPoints=K;if(n){this.renderer.shadowRenderer.draw(A,K,u)}this.renderer.shapeRenderer.draw(A,K,u)}if(k){var C=d.extend(true,{},u,{fill:false,closePath:false});this.renderer.shapeRenderer.draw(A,J,C);if(this.markerRenderer.show){for(E=0;E<J.length;E++){this.markerRenderer.draw(J[E][0],J[E][1],A,u.markerOptions)}}}}else{if(n){this.renderer.shadowRenderer.draw(A,K,u)}this.renderer.shapeRenderer.draw(A,K,u)}}var v=y=B=G=null;for(E=0;E<this._areaPoints.length;E++){var w=this._areaPoints[E];if(v>w[0]||v==null){v=w[0]}if(G<w[1]||G==null){G=w[1]}if(y<w[0]||y==null){y=w[0]}if(B>w[1]||B==null){B=w[1]}}this._boundingBox=[[v,G],[y,B]];if(this.markerRenderer.show&&!D){for(E=0;E<K.length;E++){if(K[E][0]!=null&&K[E][1]!=null){this.markerRenderer.draw(K[E][0],K[E][1],A,u.markerOptions)}}}}A.restore()};d.jqplot.LineRenderer.prototype.drawShadow=function(k,m,l){};function f(n,m,k){for(var l=0;l<this.series.length;l++){if(this.series[l].renderer.constructor==d.jqplot.LineRenderer){if(this.series[l].highlightMouseOver){this.series[l].highlightMouseDown=false}}}this.target.bind("mouseout",{plot:this},function(o){h(o.data.plot)})}function g(){if(this.plugins.lineRenderer&&this.plugins.lineRenderer.highlightCanvas){this.plugins.lineRenderer.highlightCanvas.resetCanvas();this.plugins.lineRenderer.highlightCanvas=null}this.plugins.lineRenderer.highlightedSeriesIndex=null;this.plugins.lineRenderer.highlightCanvas=new d.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-lineRenderer-highlight-canvas",this._plotDimensions,this));this.plugins.lineRenderer.highlightCanvas.setContext()}function c(q,p,n,m){var l=q.series[p];var k=q.plugins.lineRenderer.highlightCanvas;k._ctx.clearRect(0,0,k._ctx.canvas.width,k._ctx.canvas.height);l._highlightedPoint=n;q.plugins.lineRenderer.highlightedSeriesIndex=p;var o={fillStyle:l.highlightColor};l.renderer.shapeRenderer.draw(k._ctx,m,o);k=null}function h(m){var k=m.plugins.lineRenderer.highlightCanvas;k._ctx.clearRect(0,0,k._ctx.canvas.width,k._ctx.canvas.height);for(var l=0;l<m.series.length;l++){m.series[l]._highlightedPoint=null}m.plugins.lineRenderer.highlightedSeriesIndex=null;m.target.trigger("jqplotDataUnhighlight");k=null}function a(o,n,r,q,p){if(q){var m=[q.seriesIndex,q.pointIndex,q.data];var l=jQuery.Event("jqplotDataMouseOver");l.pageX=o.pageX;l.pageY=o.pageY;p.target.trigger(l,m);if(p.series[m[0]].highlightMouseOver&&!(m[0]==p.plugins.lineRenderer.highlightedSeriesIndex)){var k=jQuery.Event("jqplotDataHighlight");k.pageX=o.pageX;k.pageY=o.pageY;p.target.trigger(k,m);c(p,q.seriesIndex,q.pointIndex,q.points)}}else{if(q==null){h(p)}}}function b(n,m,q,p,o){if(p){var l=[p.seriesIndex,p.pointIndex,p.data];if(o.series[l[0]].highlightMouseDown&&!(l[0]==o.plugins.lineRenderer.highlightedSeriesIndex)){var k=jQuery.Event("jqplotDataHighlight");k.pageX=n.pageX;k.pageY=n.pageY;o.target.trigger(k,l);c(o,p.seriesIndex,p.pointIndex,p.points)}}else{if(p==null){h(o)}}}function i(m,l,p,o,n){var k=n.plugins.lineRenderer.highlightedSeriesIndex;if(k!=null&&n.series[k].highlightMouseDown){h(n)}}function e(n,m,q,p,o){if(p){var l=[p.seriesIndex,p.pointIndex,p.data];var k=jQuery.Event("jqplotDataClick");k.pageX=n.pageX;k.pageY=n.pageY;o.target.trigger(k,l)}}function j(o,n,r,q,p){if(q){var m=[q.seriesIndex,q.pointIndex,q.data];var k=p.plugins.lineRenderer.highlightedSeriesIndex;if(k!=null&&p.series[k].highlightMouseDown){h(p)}var l=jQuery.Event("jqplotDataRightClick");l.pageX=o.pageX;l.pageY=o.pageY;p.target.trigger(l,m)}}})(jQuery);(function(a){a.jqplot.MarkerRenderer=function(b){this.show=true;this.style="filledCircle";this.lineWidth=2;this.size=9;this.color="#666666";this.shadow=true;this.shadowAngle=45;this.shadowOffset=1;this.shadowDepth=3;this.shadowAlpha="0.07";this.shadowRenderer=new a.jqplot.ShadowRenderer();this.shapeRenderer=new a.jqplot.ShapeRenderer();a.extend(true,this,b)};a.jqplot.MarkerRenderer.prototype.init=function(b){a.extend(true,this,b);var d={angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,lineWidth:this.lineWidth,depth:this.shadowDepth,closePath:true};if(this.style.indexOf("filled")!=-1){d.fill=true}if(this.style.indexOf("ircle")!=-1){d.isarc=true;d.closePath=false}this.shadowRenderer.init(d);var c={fill:false,isarc:false,strokeStyle:this.color,fillStyle:this.color,lineWidth:this.lineWidth,closePath:true};if(this.style.indexOf("filled")!=-1){c.fill=true}if(this.style.indexOf("ircle")!=-1){c.isarc=true;c.closePath=false}this.shapeRenderer.init(c)};a.jqplot.MarkerRenderer.prototype.drawDiamond=function(d,c,g,f,i){var b=1.2;var j=this.size/2/b;var h=this.size/2*b;var e=[[d-j,c],[d,c+h],[d+j,c],[d,c-h]];if(this.shadow){this.shadowRenderer.draw(g,e)}this.shapeRenderer.draw(g,e,i)};a.jqplot.MarkerRenderer.prototype.drawPlus=function(e,d,h,g,k){var c=1;var l=this.size/2*c;var i=this.size/2*c;var j=[[e,d-i],[e,d+i]];var f=[[e+l,d],[e-l,d]];var b=a.extend(true,{},this.options,{closePath:false});if(this.shadow){this.shadowRenderer.draw(h,j,{closePath:false});this.shadowRenderer.draw(h,f,{closePath:false})}this.shapeRenderer.draw(h,j,b);this.shapeRenderer.draw(h,f,b)};a.jqplot.MarkerRenderer.prototype.drawX=function(e,d,h,g,k){var c=1;var l=this.size/2*c;var i=this.size/2*c;var b=a.extend(true,{},this.options,{closePath:false});var j=[[e-l,d-i],[e+l,d+i]];var f=[[e-l,d+i],[e+l,d-i]];if(this.shadow){this.shadowRenderer.draw(h,j,{closePath:false});this.shadowRenderer.draw(h,f,{closePath:false})}this.shapeRenderer.draw(h,j,b);this.shapeRenderer.draw(h,f,b)};a.jqplot.MarkerRenderer.prototype.drawDash=function(d,c,g,f,i){var b=1;var j=this.size/2*b;var h=this.size/2*b;var e=[[d-j,c],[d+j,c]];if(this.shadow){this.shadowRenderer.draw(g,e)}this.shapeRenderer.draw(g,e,i)};a.jqplot.MarkerRenderer.prototype.drawLine=function(g,f,b,e,c){var d=[g,f];if(this.shadow){this.shadowRenderer.draw(b,d)}this.shapeRenderer.draw(b,d,c)};a.jqplot.MarkerRenderer.prototype.drawSquare=function(d,c,g,f,i){var b=1;var j=this.size/2/b;var h=this.size/2*b;var e=[[d-j,c-h],[d-j,c+h],[d+j,c+h],[d+j,c-h]];if(this.shadow){this.shadowRenderer.draw(g,e)}this.shapeRenderer.draw(g,e,i)};a.jqplot.MarkerRenderer.prototype.drawCircle=function(c,i,e,h,f){var b=this.size/2;var d=2*Math.PI;var g=[c,i,b,0,d,true];if(this.shadow){this.shadowRenderer.draw(e,g)}this.shapeRenderer.draw(e,g,f)};a.jqplot.MarkerRenderer.prototype.draw=function(b,e,c,d){d=d||{};if(d.show==null||d.show!=false){if(d.color&&!d.fillStyle){d.fillStyle=d.color}if(d.color&&!d.strokeStyle){d.strokeStyle=d.color}switch(this.style){case"diamond":this.drawDiamond(b,e,c,false,d);break;case"filledDiamond":this.drawDiamond(b,e,c,true,d);break;case"circle":this.drawCircle(b,e,c,false,d);break;case"filledCircle":this.drawCircle(b,e,c,true,d);break;case"square":this.drawSquare(b,e,c,false,d);break;case"filledSquare":this.drawSquare(b,e,c,true,d);break;case"x":this.drawX(b,e,c,true,d);break;case"plus":this.drawPlus(b,e,c,true,d);break;case"dash":this.drawDash(b,e,c,true,d);break;case"line":this.drawLine(b,e,c,false,d);break;default:this.drawDiamond(b,e,c,false,d);break}}}})(jQuery);(function(a){a.jqplot.DivTitleRenderer=function(){};a.jqplot.DivTitleRenderer.prototype.init=function(b){a.extend(true,this,b)};a.jqplot.DivTitleRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}var e=this.renderer;var d=document.createElement("div");this._elem=a(d);this._elem.addClass("jqplot-title");if(!this.text){this.show=false;this._elem.height(0);this._elem.width(0)}else{if(this.text){var b;if(this.color){b=this.color}else{if(this.textColor){b=this.textColor}}var c={position:"absolute",top:"0px",left:"0px"};if(this._plotWidth){c.width=this._plotWidth+"px"}if(this.fontSize){c.fontSize=this.fontSize}if(this.textAlign){c.textAlign=this.textAlign}else{c.textAlign="center"}if(b){c.color=b}if(this.paddingBottom){c.paddingBottom=this.paddingBottom}if(this.fontFamily){c.fontFamily=this.fontFamily}this._elem.css(c);this._elem.text(this.text)}}d=null;return this._elem};a.jqplot.DivTitleRenderer.prototype.pack=function(){}})(jQuery);(function(a){a.jqplot.CanvasGridRenderer=function(){this.shadowRenderer=new a.jqplot.ShadowRenderer()};a.jqplot.CanvasGridRenderer.prototype.init=function(c){this._ctx;a.extend(true,this,c);var b={lineJoin:"miter",lineCap:"round",fill:false,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.shadowWidth,closePath:false,strokeStyle:this.shadowColor};this.renderer.shadowRenderer.init(b)};a.jqplot.CanvasGridRenderer.prototype.createElement=function(e){var d;if(this._elem){if(a.jqplot.use_excanvas){d=this._elem.get(0);window.G_vmlCanvasManager.uninitElement(d);d=null}this._elem.emptyForce();this._elem=null}d=e.canvasManager.getCanvas();var b=this._plotDimensions.width;var c=this._plotDimensions.height;d.width=b;d.height=c;this._elem=a(d);this._elem.addClass("jqplot-grid-canvas");this._elem.css({position:"absolute",left:0,top:0});d=e.canvasManager.initCanvas(d);this._top=this._offsets.top;this._bottom=c-this._offsets.bottom;this._left=this._offsets.left;this._right=b-this._offsets.right;this._width=this._right-this._left;this._height=this._bottom-this._top;d=null;return this._elem};a.jqplot.CanvasGridRenderer.prototype.draw=function(){this._ctx=this._elem.get(0).getContext("2d");var q=this._ctx;var v=this._axes;q.save();q.clearRect(0,0,this._plotDimensions.width,this._plotDimensions.height);q.fillStyle=this.backgroundColor||this.background;q.fillRect(this._left,this._top,this._width,this._height);if(true){q.save();q.lineJoin="miter";q.lineCap="butt";q.lineWidth=this.gridLineWidth;q.strokeStyle=this.gridLineColor;var y,x,o,p;var k=["xaxis","yaxis","x2axis","y2axis"];for(var w=4;w>0;w--){var A=k[w-1];var c=v[A];var z=c._ticks;if(c.show){for(var r=z.length;r>0;r--){var l=z[r-1];if(l.show){var g=Math.round(c.u2p(l.value))+0.5;switch(A){case"xaxis":if(l.showGridline&&this.drawGridlines){n(g,this._top,g,this._bottom)}if(l.showMark&&l.mark){o=l.markSize;p=l.mark;var g=Math.round(c.u2p(l.value))+0.5;switch(p){case"outside":y=this._bottom;x=this._bottom+o;break;case"inside":y=this._bottom-o;x=this._bottom;break;case"cross":y=this._bottom-o;x=this._bottom+o;break;default:y=this._bottom;x=this._bottom+o;break}if(this.shadow){this.renderer.shadowRenderer.draw(q,[[g,y],[g,x]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}n(g,y,g,x)}break;case"yaxis":if(l.showGridline&&this.drawGridlines){n(this._right,g,this._left,g)}if(l.showMark&&l.mark){o=l.markSize;p=l.mark;var g=Math.round(c.u2p(l.value))+0.5;switch(p){case"outside":y=this._left-o;x=this._left;break;case"inside":y=this._left;x=this._left+o;break;case"cross":y=this._left-o;x=this._left+o;break;default:y=this._left-o;x=this._left;break}if(this.shadow){this.renderer.shadowRenderer.draw(q,[[y,g],[x,g]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}n(y,g,x,g,{strokeStyle:c.borderColor})}break;case"x2axis":if(l.showGridline&&this.drawGridlines){n(g,this._bottom,g,this._top)}if(l.showMark&&l.mark){o=l.markSize;p=l.mark;var g=Math.round(c.u2p(l.value))+0.5;switch(p){case"outside":y=this._top-o;x=this._top;break;case"inside":y=this._top;x=this._top+o;break;case"cross":y=this._top-o;x=this._top+o;break;default:y=this._top-o;x=this._top;break}if(this.shadow){this.renderer.shadowRenderer.draw(q,[[g,y],[g,x]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}n(g,y,g,x)}break;case"y2axis":if(l.showGridline&&this.drawGridlines){n(this._left,g,this._right,g)}if(l.showMark&&l.mark){o=l.markSize;p=l.mark;var g=Math.round(c.u2p(l.value))+0.5;switch(p){case"outside":y=this._right;x=this._right+o;break;case"inside":y=this._right-o;x=this._right;break;case"cross":y=this._right-o;x=this._right+o;break;default:y=this._right;x=this._right+o;break}if(this.shadow){this.renderer.shadowRenderer.draw(q,[[y,g],[x,g]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}n(y,g,x,g,{strokeStyle:c.borderColor})}break;default:break}}}l=null}c=null;z=null}k=["y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis"];for(var w=7;w>0;w--){var c=v[k[w-1]];var z=c._ticks;if(c.show){var d=z[c.numberTicks-1];var h=z[0];var f=c.getLeft();var u=[[f,d.getTop()+d.getHeight()/2],[f,h.getTop()+h.getHeight()/2+1]];if(this.shadow){this.renderer.shadowRenderer.draw(q,u,{lineCap:"butt",fill:false,closePath:false})}n(u[0][0],u[0][1],u[1][0],u[1][1],{lineCap:"butt",strokeStyle:c.borderColor,lineWidth:c.borderWidth});for(var r=z.length;r>0;r--){var l=z[r-1];o=l.markSize;p=l.mark;var g=Math.round(c.u2p(l.value))+0.5;if(l.showMark&&l.mark){switch(p){case"outside":y=f;x=f+o;break;case"inside":y=f-o;x=f;break;case"cross":y=f-o;x=f+o;break;default:y=f;x=f+o;break}u=[[y,g],[x,g]];if(this.shadow){this.renderer.shadowRenderer.draw(q,u,{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}n(y,g,x,g,{strokeStyle:c.borderColor})}l=null}h=null}c=null;z=null}q.restore()}function n(m,j,e,b,i){q.save();i=i||{};if(i.lineWidth==null||i.lineWidth!=0){a.extend(true,q,i);q.beginPath();q.moveTo(m,j);q.lineTo(e,b);q.stroke();q.restore()}}if(this.shadow){var u=[[this._left,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(q,u)}if(this.borderWidth!=0&&this.drawBorder){n(this._left,this._top,this._right,this._top,{lineCap:"round",strokeStyle:v.x2axis.borderColor,lineWidth:v.x2axis.borderWidth});n(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:v.y2axis.borderColor,lineWidth:v.y2axis.borderWidth});n(this._right,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:v.xaxis.borderColor,lineWidth:v.xaxis.borderWidth});n(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:v.yaxis.borderColor,lineWidth:v.yaxis.borderWidth})}q.restore();q=null;v=null}})(jQuery);(function(a){a.jqplot.ShadowRenderer=function(b){this.angle=45;this.offset=1;this.alpha=0.07;this.lineWidth=1.5;this.lineJoin="miter";this.lineCap="round";this.closePath=false;this.fill=false;this.depth=3;this.strokeStyle="rgba(0,0,0,0.1)";this.isarc=false;a.extend(true,this,b)};a.jqplot.ShadowRenderer.prototype.init=function(b){a.extend(true,this,b)};a.jqplot.ShadowRenderer.prototype.draw=function(n,l,p){n.save();var b=(p!=null)?p:{};var m=(b.fill!=null)?b.fill:this.fill;var k=(b.closePath!=null)?b.closePath:this.closePath;var f=(b.offset!=null)?b.offset:this.offset;var d=(b.alpha!=null)?b.alpha:this.alpha;var h=(b.depth!=null)?b.depth:this.depth;var o=(b.isarc!=null)?b.isarc:this.isarc;n.lineWidth=(b.lineWidth!=null)?b.lineWidth:this.lineWidth;n.lineJoin=(b.lineJoin!=null)?b.lineJoin:this.lineJoin;n.lineCap=(b.lineCap!=null)?b.lineCap:this.lineCap;n.strokeStyle=b.strokeStyle||this.strokeStyle||"rgba(0,0,0,"+d+")";n.fillStyle=b.fillStyle||this.fillStyle||"rgba(0,0,0,"+d+")";for(var e=0;e<h;e++){n.translate(Math.cos(this.angle*Math.PI/180)*f,Math.sin(this.angle*Math.PI/180)*f); -n.beginPath();if(o){n.arc(l[0],l[1],l[2],l[3],l[4],true)}else{if(l&&l.length){var c=true;for(var g=0;g<l.length;g++){if(l[g][0]!=null&&l[g][1]!=null){if(c){n.moveTo(l[g][0],l[g][1]);c=false}else{n.lineTo(l[g][0],l[g][1])}}else{c=true}}}}if(k){n.closePath()}if(m){n.fill()}else{n.stroke()}}n.restore()}})(jQuery);(function(a){a.jqplot.ShapeRenderer=function(b){this.lineWidth=1.5;this.lineJoin="miter";this.lineCap="round";this.closePath=false;this.fill=false;this.isarc=false;this.fillRect=false;this.strokeRect=false;this.clearRect=false;this.strokeStyle="#999999";this.fillStyle="#999999";a.extend(true,this,b)};a.jqplot.ShapeRenderer.prototype.init=function(b){a.extend(true,this,b)};a.jqplot.ShapeRenderer.prototype.draw=function(l,j,n){l.save();var b=(n!=null)?n:{};var k=(b.fill!=null)?b.fill:this.fill;var g=(b.closePath!=null)?b.closePath:this.closePath;var h=(b.fillRect!=null)?b.fillRect:this.fillRect;var e=(b.strokeRect!=null)?b.strokeRect:this.strokeRect;var c=(b.clearRect!=null)?b.clearRect:this.clearRect;var m=(b.isarc!=null)?b.isarc:this.isarc;l.lineWidth=b.lineWidth||this.lineWidth;l.lineJoin=b.lineJoin||this.lineJoin;l.lineCap=b.lineCap||this.lineCap;l.strokeStyle=(b.strokeStyle||b.color)||this.strokeStyle;l.fillStyle=b.fillStyle||this.fillStyle;l.beginPath();if(m){l.arc(j[0],j[1],j[2],j[3],j[4],true);if(g){l.closePath()}if(k){l.fill()}else{l.stroke()}l.restore();return}else{if(c){l.clearRect(j[0],j[1],j[2],j[3]);l.restore();return}else{if(h||e){if(h){l.fillRect(j[0],j[1],j[2],j[3])}if(e){l.strokeRect(j[0],j[1],j[2],j[3]);l.restore();return}}else{if(j&&j.length){var d=true;for(var f=0;f<j.length;f++){if(j[f][0]!=null&&j[f][1]!=null){if(d){l.moveTo(j[f][0],j[f][1]);d=false}else{l.lineTo(j[f][0],j[f][1])}}else{d=true}}if(g){l.closePath()}if(k){l.fill()}else{l.stroke()}}}}}l.restore()}})(jQuery);(function(a){a.jqplot.sprintf=function(){function h(n,i,k,m){var l=(n.length>=i)?"":Array(1+i-n.length>>>0).join(k);return m?n+l:l+n}function e(m){var l=new String(m);for(var k=10;k>0;k--){if(l==(l=l.replace(/^(\d+)(\d{3})/,"$1"+a.jqplot.sprintf.thousandsSeparator+"$2"))){break}}return l}function d(o,n,q,l,m,k){var p=l-o.length;if(p>0){var i=" ";if(k){i=" "}if(q||!m){o=h(o,l,i,q)}else{o=o.slice(0,n.length)+h("",p,"0",true)+o.slice(n.length)}}return o}function j(r,k,p,l,i,o,q,n){var m=r>>>0;p=p&&m&&{"2":"0b","8":"0","16":"0x"}[k]||"";r=p+h(m.toString(k),o||0,"0",false);return d(r,p,l,i,q,n)}function b(n,o,l,i,m,k){if(i!=null){n=n.slice(0,i)}return d(n,"",o,l,m,k)}var c=arguments,f=0,g=c[f++];return g.replace(a.jqplot.sprintf.regex,function(E,q,r,u,G,B,o){if(E=="%%"){return"%"}var v=false,s="",t=false,D=false,p=false,n=false;for(var A=0;r&&A<r.length;A++){switch(r.charAt(A)){case" ":s=" ";break;case"+":s="+";break;case"-":v=true;break;case"0":t=true;break;case"#":D=true;break;case"&":p=true;break;case"'":n=true;break}}if(!u){u=0}else{if(u=="*"){u=+c[f++]}else{if(u.charAt(0)=="*"){u=+c[u.slice(1,-1)]}else{u=+u}}}if(u<0){u=-u;v=true}if(!isFinite(u)){throw new Error("$.jqplot.sprintf: (minimum-)width must be finite")}if(!B){B="fFeE".indexOf(o)>-1?6:(o=="d")?0:void (0)}else{if(B=="*"){B=+c[f++]}else{if(B.charAt(0)=="*"){B=+c[B.slice(1,-1)]}else{B=+B}}}var x=q?c[q.slice(0,-1)]:c[f++];switch(o){case"s":if(x==null){return""}return b(String(x),v,u,B,t,p);case"c":return b(String.fromCharCode(+x),v,u,B,t,p);case"b":return j(x,2,D,v,u,B,t,p);case"o":return j(x,8,D,v,u,B,t,p);case"x":return j(x,16,D,v,u,B,t,p);case"X":return j(x,16,D,v,u,B,t,p).toUpperCase();case"u":return j(x,10,D,v,u,B,t,p);case"i":var l=parseInt(+x,10);if(isNaN(l)){return""}var z=l<0?"-":s;var C=n?e(String(Math.abs(l))):String(Math.abs(l));x=z+h(C,B,"0",false);return d(x,z,v,u,t,p);case"d":var l=Math.round(+x);if(isNaN(l)){return""}var z=l<0?"-":s;var C=n?e(String(Math.abs(l))):String(Math.abs(l));x=z+h(C,B,"0",false);return d(x,z,v,u,t,p);case"e":case"E":case"f":case"F":case"g":case"G":var l=+x;if(isNaN(l)){return""}var z=l<0?"-":s;var m=["toExponential","toFixed","toPrecision"]["efg".indexOf(o.toLowerCase())];var F=["toString","toUpperCase"]["eEfFgG".indexOf(o)%2];var C=Math.abs(l)[m](B);C=n?e(C):C;x=z+C;return d(x,z,v,u,t,p)[F]();case"p":case"P":var l=+x;if(isNaN(l)){return""}var z=l<0?"-":s;var w=String(Number(Math.abs(l)).toExponential()).split(/e|E/);var k=(w[0].indexOf(".")!=-1)?w[0].length-1:w[0].length;var y=(w[1]<0)?-w[1]-1:0;if(Math.abs(l)<1){if(k+y<=B){x=z+Math.abs(l).toPrecision(k)}else{if(k<=B-1){x=z+Math.abs(l).toExponential(k-1)}else{x=z+Math.abs(l).toExponential(B-1)}}}else{var i=(k<=B)?k:B;x=z+Math.abs(l).toPrecision(i)}var F=["toString","toUpperCase"]["pP".indexOf(o)%2];return d(x,z,v,u,t,p)[F]();case"n":return"";default:return E}})};a.jqplot.sprintf.thousandsSeparator=",";a.jqplot.sprintf.regex=/%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g})(jQuery);(function(g){g.jqplot.ThemeEngine=function(){this.themes={};this.activeTheme=null};g.jqplot.ThemeEngine.prototype.init=function(){var r=new g.jqplot.Theme({_name:"Default"});var v,p,u;for(v in r.target){if(v=="textColor"){r.target[v]=this.target.css("color")}else{r.target[v]=this.target.css(v)}}if(this.title.show&&this.title._elem){for(v in r.title){if(v=="textColor"){r.title[v]=this.title._elem.css("color")}else{r.title[v]=this.title._elem.css(v)}}}for(v in r.grid){r.grid[v]=this.grid[v]}if(r.grid.backgroundColor==null&&this.grid.background!=null){r.grid.backgroundColor=this.grid.background}if(this.legend.show&&this.legend._elem){for(v in r.legend){if(v=="textColor"){r.legend[v]=this.legend._elem.css("color")}else{r.legend[v]=this.legend._elem.css(v)}}}var q;for(p=0;p<this.series.length;p++){q=this.series[p];if(q.renderer.constructor==g.jqplot.LineRenderer){r.series.push(new h())}else{if(q.renderer.constructor==g.jqplot.BarRenderer){r.series.push(new a())}else{if(q.renderer.constructor==g.jqplot.PieRenderer){r.series.push(new b())}else{if(q.renderer.constructor==g.jqplot.DonutRenderer){r.series.push(new c())}else{if(q.renderer.constructor==g.jqplot.FunnelRenderer){r.series.push(new j())}else{if(q.renderer.constructor==g.jqplot.MeterGaugeRenderer){r.series.push(new m())}else{r.series.push({})}}}}}}for(v in r.series[p]){r.series[p][v]=q[v]}}var o,t;for(v in this.axes){t=this.axes[v];o=r.axes[v]=new d();o.borderColor=t.borderColor;o.borderWidth=t.borderWidth;if(t._ticks&&t._ticks[0]){for(u in o.ticks){if(t._ticks[0].hasOwnProperty(u)){o.ticks[u]=t._ticks[0][u]}else{if(t._ticks[0]._elem){o.ticks[u]=t._ticks[0]._elem.css(u)}}}}if(t._label&&t._label.show){for(u in o.label){if(t._label[u]){o.label[u]=t._label[u]}else{if(t._label._elem){if(u=="textColor"){o.label[u]=t._label._elem.css("color")}else{o.label[u]=t._label._elem.css(u)}}}}}}this.themeEngine._add(r);this.themeEngine.activeTheme=this.themeEngine.themes[r._name]};g.jqplot.ThemeEngine.prototype.get=function(o){if(!o){return this.activeTheme}else{return this.themes[o]}};function i(p,o){return p-o}g.jqplot.ThemeEngine.prototype.getThemeNames=function(){var o=[];for(var p in this.themes){o.push(p)}return o.sort(i)};g.jqplot.ThemeEngine.prototype.getThemes=function(){var p=[];var o=[];for(var r in this.themes){p.push(r)}p.sort(i);for(var q=0;q<p.length;q++){o.push(this.themes[p[q]])}return o};g.jqplot.ThemeEngine.prototype.activate=function(B,G){var o=false;if(!G&&this.activeTheme&&this.activeTheme._name){G=this.activeTheme._name}if(!this.themes.hasOwnProperty(G)){throw new Error("No theme of that name")}else{var t=this.themes[G];this.activeTheme=t;var F,z=false,y=false;var p=["xaxis","x2axis","yaxis","y2axis"];for(C=0;C<p.length;C++){var u=p[C];if(t.axesStyles.borderColor!=null){B.axes[u].borderColor=t.axesStyles.borderColor}if(t.axesStyles.borderWidth!=null){B.axes[u].borderWidth=t.axesStyles.borderWidth}}for(var E in B.axes){var r=B.axes[E];if(r.show){var x=t.axes[E]||{};var v=t.axesStyles;var s=g.jqplot.extend(true,{},x,v);F=(t.axesStyles.borderColor!=null)?t.axesStyles.borderColor:s.borderColor;if(s.borderColor!=null){r.borderColor=s.borderColor;o=true}F=(t.axesStyles.borderWidth!=null)?t.axesStyles.borderWidth:s.borderWidth;if(s.borderWidth!=null){r.borderWidth=s.borderWidth;o=true}if(r._ticks&&r._ticks[0]){for(var q in s.ticks){F=s.ticks[q];if(F!=null){r.tickOptions[q]=F;r._ticks=[];o=true}}}if(r._label&&r._label.show){for(var q in s.label){F=s.label[q];if(F!=null){r.labelOptions[q]=F;o=true}}}}}for(var A in t.grid){if(t.grid[A]!=null){B.grid[A]=t.grid[A]}}if(!o){B.grid.draw()}if(B.legend.show){for(A in t.legend){if(t.legend[A]!=null){B.legend[A]=t.legend[A]}}}if(B.title.show){for(A in t.title){if(t.title[A]!=null){B.title[A]=t.title[A]}}}var C;for(C=0;C<t.series.length;C++){var w={};var D=false;for(A in t.series[C]){F=(t.seriesStyles[A]!=null)?t.seriesStyles[A]:t.series[C][A];if(F!=null){w[A]=F;if(A=="color"){B.series[C].renderer.shapeRenderer.fillStyle=F;B.series[C].renderer.shapeRenderer.strokeStyle=F;B.series[C][A]=F}else{if(A=="lineWidth"){B.series[C].renderer.shapeRenderer.lineWidth=F;B.series[C][A]=F}else{if(A=="markerOptions"){l(B.series[C].markerOptions,F);l(B.series[C].markerRenderer,F)}else{B.series[C][A]=F}}}o=true}}}if(o){B.target.empty();B.draw()}for(A in t.target){if(t.target[A]!=null){B.target.css(A,t.target[A])}}}};g.jqplot.ThemeEngine.prototype._add=function(p,o){if(o){p._name=o}if(!p._name){p._name=Date.parse(new Date())}if(!this.themes.hasOwnProperty(p._name)){this.themes[p._name]=p}else{throw new Error("jqplot.ThemeEngine Error: Theme already in use")}};g.jqplot.ThemeEngine.prototype.remove=function(o){if(o=="Default"){return false}return delete this.themes[o]};g.jqplot.ThemeEngine.prototype.newTheme=function(o,q){if(typeof(o)=="object"){q=q||o;o=null}if(q&&q._name){o=q._name}else{o=o||Date.parse(new Date())}var p=this.copy(this.themes.Default._name,o);g.jqplot.extend(p,q);return p};function k(q){if(q==null||typeof(q)!="object"){return q}var o=new q.constructor();for(var p in q){o[p]=k(q[p])}return o}g.jqplot.clone=k;function l(q,p){if(p==null||typeof(p)!="object"){return}for(var o in p){if(o=="highlightColors"){q[o]=k(p[o])}if(p[o]!=null&&typeof(p[o])=="object"){if(!q.hasOwnProperty(o)){q[o]={}}l(q[o],p[o])}else{q[o]=p[o]}}}g.jqplot.merge=l;g.jqplot.extend=function(){var t=arguments[0]||{},r=1,s=arguments.length,o=false,q;if(typeof t==="boolean"){o=t;t=arguments[1]||{};r=2}if(typeof t!=="object"&&!toString.call(t)==="[object Function]"){t={}}for(;r<s;r++){if((q=arguments[r])!=null){for(var p in q){var u=t[p],v=q[p];if(t===v){continue}if(o&&v&&typeof v==="object"&&!v.nodeType){t[p]=g.jqplot.extend(o,u||(v.length!=null?[]:{}),v)}else{if(v!==undefined){t[p]=v}}}}}return t};g.jqplot.ThemeEngine.prototype.rename=function(p,o){if(p=="Default"||o=="Default"){throw new Error("jqplot.ThemeEngine Error: Cannot rename from/to Default")}if(this.themes.hasOwnProperty(o)){throw new Error("jqplot.ThemeEngine Error: New name already in use.")}else{if(this.themes.hasOwnProperty(p)){var q=this.copy(p,o);this.remove(p);return q}}throw new Error("jqplot.ThemeEngine Error: Old name or new name invalid")};g.jqplot.ThemeEngine.prototype.copy=function(o,q,t){if(q=="Default"){throw new Error("jqplot.ThemeEngine Error: Cannot copy over Default theme")}if(!this.themes.hasOwnProperty(o)){var p="jqplot.ThemeEngine Error: Source name invalid";throw new Error(p)}if(this.themes.hasOwnProperty(q)){var p="jqplot.ThemeEngine Error: Target name invalid";throw new Error(p)}else{var r=k(this.themes[o]);r._name=q;g.jqplot.extend(true,r,t);this._add(r);return r}};g.jqplot.Theme=function(o,p){if(typeof(o)=="object"){p=p||o;o=null}o=o||Date.parse(new Date());this._name=o;this.target={backgroundColor:null};this.legend={textColor:null,fontFamily:null,fontSize:null,border:null,background:null};this.title={textColor:null,fontFamily:null,fontSize:null,textAlign:null};this.seriesStyles={};this.series=[];this.grid={drawGridlines:null,gridLineColor:null,gridLineWidth:null,backgroundColor:null,borderColor:null,borderWidth:null,shadow:null};this.axesStyles={label:{},ticks:{}};this.axes={};if(typeof(p)=="string"){this._name=p}else{if(typeof(p)=="object"){g.jqplot.extend(true,this,p)}}};var d=function(){this.borderColor=null;this.borderWidth=null;this.ticks=new f();this.label=new e()};var f=function(){this.show=null;this.showGridline=null;this.showLabel=null;this.showMark=null;this.size=null;this.textColor=null;this.whiteSpace=null;this.fontSize=null;this.fontFamily=null};var e=function(){this.textColor=null;this.whiteSpace=null;this.fontSize=null;this.fontFamily=null;this.fontWeight=null};var h=function(){this.color=null;this.lineWidth=null;this.shadow=null;this.fillColor=null;this.showMarker=null;this.markerOptions=new n()};var n=function(){this.show=null;this.style=null;this.lineWidth=null;this.size=null;this.color=null;this.shadow=null};var a=function(){this.color=null;this.seriesColors=null;this.lineWidth=null;this.shadow=null;this.barPadding=null;this.barMargin=null;this.barWidth=null;this.highlightColors=null};var b=function(){this.seriesColors=null;this.padding=null;this.sliceMargin=null;this.fill=null;this.shadow=null;this.startAngle=null;this.lineWidth=null;this.highlightColors=null};var c=function(){this.seriesColors=null;this.padding=null;this.sliceMargin=null;this.fill=null;this.shadow=null;this.startAngle=null;this.lineWidth=null;this.innerDiameter=null;this.thickness=null;this.ringMargin=null;this.highlightColors=null};var j=function(){this.color=null;this.lineWidth=null;this.shadow=null;this.padding=null;this.sectionMargin=null;this.seriesColors=null;this.highlightColors=null};var m=function(){this.padding=null;this.backgroundColor=null;this.ringColor=null;this.tickColor=null;this.ringWidth=null;this.intervalColors=null;this.intervalInnerRadius=null;this.intervalOuterRadius=null;this.hubRadius=null;this.needleThickness=null;this.needlePad=null}})(jQuery);(function(e){e.jqplot.PieRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.PieRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.PieRenderer.prototype.constructor=e.jqplot.PieRenderer;e.jqplot.PieRenderer.prototype.init=function(q,u){this.diameter=null;this.padding=20;this.sliceMargin=0;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this.dataLabelPositionFactor=0.52;this.dataLabelNudge=2;this.dataLabelCenterOn=true;this.startAngle=0;this.tickRenderer=e.jqplot.PieTickRenderer;this._drawData=true;this._type="pie";if(q.highlightMouseDown&&q.highlightMouseOver==null){q.highlightMouseOver=false}e.extend(true,this,q);if(this.sliceMargin<0){this.sliceMargin=0}this._diameter=null;this._radius=null;this._sliceAngles=[];this._highlightedPoint=null;if(this.highlightColors.length==0){for(var s=0;s<this.seriesColors.length;s++){var r=e.jqplot.getColorComponents(this.seriesColors[s]);var o=[r[0],r[1],r[2]];var t=o[0]+o[1]+o[2];for(var p=0;p<3;p++){o[p]=(t>570)?o[p]*0.8:o[p]+0.3*(255-o[p]);o[p]=parseInt(o[p],10)}this.highlightColors.push("rgb("+o[0]+","+o[1]+","+o[2]+")")}}this.highlightColorGenerator=new e.jqplot.ColorGenerator(this.highlightColors);u.postParseOptionsHooks.addOnce(m);u.postInitHooks.addOnce(g);u.eventListenerHooks.addOnce("jqplotMouseMove",b);u.eventListenerHooks.addOnce("jqplotMouseDown",a);u.eventListenerHooks.addOnce("jqplotMouseUp",l);u.eventListenerHooks.addOnce("jqplotClick",f);u.eventListenerHooks.addOnce("jqplotRightClick",n);u.postDrawHooks.addOnce(i)};e.jqplot.PieRenderer.prototype.setGridData=function(t){var p=[];var u=[];var o=this.startAngle/180*Math.PI;var s=0;this._drawData=false;for(var r=0;r<this.data.length;r++){if(this.data[r][1]!=0){this._drawData=true}p.push(this.data[r][1]);u.push([this.data[r][0]]);if(r>0){p[r]+=p[r-1]}s+=this.data[r][1]}var q=Math.PI*2/p[p.length-1];for(var r=0;r<p.length;r++){u[r][1]=p[r]*q;u[r][2]=this.data[r][1]/s}this.gridData=u};e.jqplot.PieRenderer.prototype.makeGridData=function(t,u){var p=[];var v=[];var s=0;var o=this.startAngle/180*Math.PI;this._drawData=false;for(var r=0;r<t.length;r++){if(this.data[r][1]!=0){this._drawData=true}p.push(t[r][1]);v.push([t[r][0]]);if(r>0){p[r]+=p[r-1]}s+=t[r][1]}var q=Math.PI*2/p[p.length-1];for(var r=0;r<p.length;r++){v[r][1]=p[r]*q;v[r][2]=t[r][1]/s}return v};function h(o){return Math.sin((o-(o-Math.PI)/8/Math.PI)/2)}function j(u,t,o,v,r){var w=0;var q=t-u;var s=Math.abs(q);var p=o;if(v==false){p+=r}if(p>0&&s>0.01&&s<6.282){w=parseFloat(p)/2/h(q)}return w}e.jqplot.PieRenderer.prototype.drawSlice=function(B,z,y,u,w){if(this._drawData){var p=this._radius;var A=this.fill;var x=this.lineWidth;var s=this.sliceMargin;if(this.fill==false){s+=this.lineWidth}B.save();B.translate(this._center[0],this._center[1]);var D=j(z,y,this.sliceMargin,this.fill,this.lineWidth);var o=D*Math.cos((z+y)/2);var C=D*Math.sin((z+y)/2);if((y-z)<=Math.PI){p-=D}else{p+=D}B.translate(o,C);if(w){for(var v=0,t=this.shadowDepth;v<t;v++){B.save();B.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));q(p)}for(var v=0,t=this.shadowDepth;v<t;v++){B.restore()}}else{q(p)}B.restore()}function q(r){if(y>6.282+this.startAngle){y=6.282+this.startAngle;if(z>y){z=6.281+this.startAngle}}if(z>=y){return}B.beginPath();B.fillStyle=u;B.strokeStyle=u;B.lineWidth=x;B.arc(0,0,r,z,y,false);B.lineTo(0,0);B.closePath();if(A){B.fill()}else{B.stroke()}}};e.jqplot.PieRenderer.prototype.draw=function(B,z,E,o){var W;var H=(E!=undefined)?E:{};var t=0;var s=0;var N=1;var L=new e.jqplot.ColorGenerator(this.seriesColors);if(E.legendInfo&&E.legendInfo.placement=="insideGrid"){var J=E.legendInfo;switch(J.location){case"nw":t=J.width+J.xoffset;break;case"w":t=J.width+J.xoffset;break;case"sw":t=J.width+J.xoffset;break;case"ne":t=J.width+J.xoffset;N=-1;break;case"e":t=J.width+J.xoffset;N=-1;break;case"se":t=J.width+J.xoffset;N=-1;break;case"n":s=J.height+J.yoffset;break;case"s":s=J.height+J.yoffset;N=-1;break;default:break}}var K=(H.shadow!=undefined)?H.shadow:this.shadow;var A=(H.fill!=undefined)?H.fill:this.fill;var C=B.canvas.width;var I=B.canvas.height;var Q=C-t-2*this.padding;var X=I-s-2*this.padding;var M=Math.min(Q,X);var Y=M;this._sliceAngles=[];var v=this.sliceMargin;if(this.fill==false){v+=this.lineWidth}var q;var G=0;var R,aa,Z,ab;var D=this.startAngle/180*Math.PI;for(var W=0,V=z.length;W<V;W++){aa=(W==0)?D:z[W-1][1]+D;Z=z[W][1]+D;this._sliceAngles.push([aa,Z]);q=j(aa,Z,this.sliceMargin,this.fill,this.lineWidth);if(Math.abs(Z-aa)>Math.PI){G=Math.max(q,G)}}if(this.diameter!=null&&this.diameter>0){this._diameter=this.diameter-2*G}else{this._diameter=Y-2*G}if(this._diameter<6){e.jqplot.log("Diameter of pie too small, not rendering.");return}var S=this._radius=this._diameter/2;this._center=[(C-N*t)/2+N*t+G*Math.cos(D),(I-N*s)/2+N*s+G*Math.sin(D)];if(this.shadow){for(var W=0,V=z.length;W<V;W++){ab="rgba(0,0,0,"+this.shadowAlpha+")";this.renderer.drawSlice.call(this,B,this._sliceAngles[W][0],this._sliceAngles[W][1],ab,true)}}for(var W=0;W<z.length;W++){this.renderer.drawSlice.call(this,B,this._sliceAngles[W][0],this._sliceAngles[W][1],L.next(),false);if(this.showDataLabels&&z[W][2]*100>=this.dataLabelThreshold){var F,U=(this._sliceAngles[W][0]+this._sliceAngles[W][1])/2,T;if(this.dataLabels=="label"){F=this.dataLabelFormatString||"%s";T=e.jqplot.sprintf(F,z[W][0])}else{if(this.dataLabels=="value"){F=this.dataLabelFormatString||"%d";T=e.jqplot.sprintf(F,this.data[W][1])}else{if(this.dataLabels=="percent"){F=this.dataLabelFormatString||"%d%%";T=e.jqplot.sprintf(F,z[W][2]*100)}else{if(this.dataLabels.constructor==Array){F=this.dataLabelFormatString||"%s";T=e.jqplot.sprintf(F,this.dataLabels[W])}}}}var p=(this._radius)*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var P=this._center[0]+Math.cos(U)*p+this.canvas._offsets.left;var O=this._center[1]+Math.sin(U)*p+this.canvas._offsets.top;var u=e('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">'+T+"</div>").insertBefore(o.eventCanvas._elem);if(this.dataLabelCenterOn){P-=u.width()/2;O-=u.height()/2}else{P-=u.width()*Math.sin(U/2);O-=u.height()/2}P=Math.round(P);O=Math.round(O);u.css({left:P,top:O})}}};e.jqplot.PieAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.PieAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.PieAxisRenderer.prototype.constructor=e.jqplot.PieAxisRenderer;e.jqplot.PieAxisRenderer.prototype.init=function(o){this.tickRenderer=e.jqplot.PieTickRenderer;e.extend(true,this,o);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.PieLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.PieLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.PieLegendRenderer.prototype.constructor=e.jqplot.PieLegendRenderer;e.jqplot.PieLegendRenderer.prototype.init=function(o){this.numberRows=null;this.numberColumns=null;e.extend(true,this,o)};e.jqplot.PieLegendRenderer.prototype.draw=function(){var r=this;if(this.show){var B=this._series;this._elem=e(document.createElement("table"));this._elem.addClass("jqplot-table-legend");var E={position:"absolute"};if(this.background){E.background=this.background}if(this.border){E.border=this.border}if(this.fontSize){E.fontSize=this.fontSize}if(this.fontFamily){E.fontFamily=this.fontFamily}if(this.textColor){E.textColor=this.textColor}if(this.marginTop!=null){E.marginTop=this.marginTop}if(this.marginBottom!=null){E.marginBottom=this.marginBottom}if(this.marginLeft!=null){E.marginLeft=this.marginLeft}if(this.marginRight!=null){E.marginRight=this.marginRight}this._elem.css(E);var I=false,A=false,o,y;var C=B[0];var p=new e.jqplot.ColorGenerator(C.seriesColors);if(C.show){var J=C.data;if(this.numberRows){o=this.numberRows;if(!this.numberColumns){y=Math.ceil(J.length/o)}else{y=this.numberColumns}}else{if(this.numberColumns){y=this.numberColumns;o=Math.ceil(J.length/this.numberColumns)}else{o=J.length;y=1}}var H,G;var q,w,v;var x,z,F;var D=0;var u,t;for(H=0;H<o;H++){q=e(document.createElement("tr"));q.addClass("jqplot-table-legend");if(A){q.prependTo(this._elem)}else{q.appendTo(this._elem)}for(G=0;G<y;G++){if(D<J.length){x=this.labels[D]||J[D][0].toString();F=p.next();if(!A){if(H>0){I=true}else{I=false}}else{if(H==o-1){I=false}else{I=true}}z=(I)?this.rowSpacing:"0";w=e(document.createElement("td"));w.addClass("jqplot-table-legend");w.css({textAlign:"center",paddingTop:z});u=e(document.createElement("div"));t=e(document.createElement("div"));t.addClass("jqplot-table-legend-swatch");t.css({backgroundColor:F,borderColor:F});w.append(u.append(t));v=e(document.createElement("td"));v.addClass("jqplot-table-legend");v.css("paddingTop",z);if(this.escapeHtml){v.text(x)}else{v.html(x)}if(A){v.prependTo(q);w.prependTo(q)}else{w.appendTo(q);v.appendTo(q)}I=true}D++}}}}return this._elem};e.jqplot.PieRenderer.prototype.handleMove=function(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];r.target.trigger("jqplotDataMouseOver",o);if(r.series[o[0]].highlightMouseOver&&!(o[0]==r.plugins.pieRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){r.target.trigger("jqplotDataHighlight",o);d(r,o[0],o[1])}}else{if(s==null){k(r)}}};function c(s,r,p){p=p||{};p.axesDefaults=p.axesDefaults||{};p.legend=p.legend||{};p.seriesDefaults=p.seriesDefaults||{};var o=false;if(p.seriesDefaults.renderer==e.jqplot.PieRenderer){o=true}else{if(p.series){for(var q=0;q<p.series.length;q++){if(p.series[q].renderer==e.jqplot.PieRenderer){o=true}}}}if(o){p.axesDefaults.renderer=e.jqplot.PieAxisRenderer;p.legend.renderer=e.jqplot.PieLegendRenderer;p.legend.preDraw=true;p.seriesDefaults.pointLabels={show:false}}}function g(r,q,o){for(var p=0;p<this.series.length;p++){if(this.series[p].renderer.constructor==e.jqplot.PieRenderer){if(this.series[p].highlightMouseOver){this.series[p].highlightMouseDown=false}}}this.target.bind("mouseout",{plot:this},function(s){k(s.data.plot)})}function m(o){for(var p=0;p<this.series.length;p++){this.series[p].seriesColors=this.seriesColors;this.series[p].colorGenerator=this.colorGenerator}}function d(t,r,q){var p=t.series[r];var o=t.plugins.pieRenderer.highlightCanvas;o._ctx.clearRect(0,0,o._ctx.canvas.width,o._ctx.canvas.height);p._highlightedPoint=q;t.plugins.pieRenderer.highlightedSeriesIndex=r;p.renderer.drawSlice.call(p,o._ctx,p._sliceAngles[q][0],p._sliceAngles[q][1],p.highlightColorGenerator.get(q),false)}function k(q){var o=q.plugins.pieRenderer.highlightCanvas;o._ctx.clearRect(0,0,o._ctx.canvas.width,o._ctx.canvas.height);for(var p=0;p<q.series.length;p++){q.series[p]._highlightedPoint=null}q.plugins.pieRenderer.highlightedSeriesIndex=null;q.target.trigger("jqplotDataUnhighlight")}function b(s,r,v,u,t){if(u){var q=[u.seriesIndex,u.pointIndex,u.data];var p=jQuery.Event("jqplotDataMouseOver");p.pageX=s.pageX;p.pageY=s.pageY;t.target.trigger(p,q);if(t.series[q[0]].highlightMouseOver&&!(q[0]==t.plugins.pieRenderer.highlightedSeriesIndex&&q[1]==t.series[q[0]]._highlightedPoint)){var o=jQuery.Event("jqplotDataHighlight");o.pageX=s.pageX;o.pageY=s.pageY;t.target.trigger(o,q);d(t,q[0],q[1])}}else{if(u==null){k(t)}}}function a(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];if(s.series[p[0]].highlightMouseDown&&!(p[0]==s.plugins.pieRenderer.highlightedSeriesIndex&&p[1]==s.series[p[0]]._highlightedPoint)){var o=jQuery.Event("jqplotDataHighlight");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p);d(s,p[0],p[1])}}else{if(t==null){k(s)}}}function l(q,p,t,s,r){var o=r.plugins.pieRenderer.highlightedSeriesIndex;if(o!=null&&r.series[o].highlightMouseDown){k(r)}}function f(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var o=jQuery.Event("jqplotDataClick");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p)}}function n(s,r,v,u,t){if(u){var q=[u.seriesIndex,u.pointIndex,u.data];var o=t.plugins.pieRenderer.highlightedSeriesIndex;if(o!=null&&t.series[o].highlightMouseDown){k(t)}var p=jQuery.Event("jqplotDataRightClick");p.pageX=s.pageX;p.pageY=s.pageY;t.target.trigger(p,q)}}function i(){if(this.plugins.pieRenderer&&this.plugins.pieRenderer.highlightCanvas){this.plugins.pieRenderer.highlightCanvas.resetCanvas();this.plugins.pieRenderer.highlightCanvas=null}this.plugins.pieRenderer={highlightedSeriesIndex:null};this.plugins.pieRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var p=e(this.targetId+" .jqplot-data-label");if(p.length){e(p[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pieRenderer-highlight-canvas",this._plotDimensions,this))}else{this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pieRenderer-highlight-canvas",this._plotDimensions,this))}var o=this.plugins.pieRenderer.highlightCanvas.setContext()}e.jqplot.preInitHooks.push(c);e.jqplot.PieTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.PieTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.PieTickRenderer.prototype.constructor=e.jqplot.PieTickRenderer})(jQuery);(function(d){d.jqplot.BarRenderer=function(){d.jqplot.LineRenderer.call(this)};d.jqplot.BarRenderer.prototype=new d.jqplot.LineRenderer();d.jqplot.BarRenderer.prototype.constructor=d.jqplot.BarRenderer;d.jqplot.BarRenderer.prototype.init=function(n,p){this.barPadding=8;this.barMargin=10;this.barDirection="vertical";this.barWidth=null;this.shadowOffset=2;this.shadowDepth=5;this.shadowAlpha=0.08;this.waterfall=false;this.groups=1;this.varyBarColor=false;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this._type="bar";if(n.highlightMouseDown&&n.highlightMouseOver==null){n.highlightMouseOver=false}d.extend(true,this,n);this.fill=true;if(this.waterfall){this.fillToZero=false;this.disableStack=true}if(this.barDirection=="vertical"){this._primaryAxis="_xaxis";this._stackAxis="y";this.fillAxis="y"}else{this._primaryAxis="_yaxis";this._stackAxis="x";this.fillAxis="x"}this._highlightedPoint=null;this._plotSeriesInfo=null;this._dataColors=[];this._barPoints=[];var o={lineJoin:"miter",lineCap:"round",fill:true,isarc:false,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill};this.renderer.shapeRenderer.init(o);var m={lineJoin:"miter",lineCap:"round",fill:true,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill};this.renderer.shadowRenderer.init(m);p.postInitHooks.addOnce(h);p.postDrawHooks.addOnce(i);p.eventListenerHooks.addOnce("jqplotMouseMove",b);p.eventListenerHooks.addOnce("jqplotMouseDown",a);p.eventListenerHooks.addOnce("jqplotMouseUp",k);p.eventListenerHooks.addOnce("jqplotClick",e);p.eventListenerHooks.addOnce("jqplotRightClick",l)};function g(s,o,n,v){if(this.rendererOptions.barDirection=="horizontal"){this._stackAxis="x";this._primaryAxis="_yaxis"}if(this.rendererOptions.waterfall==true){this._data=d.extend(true,[],this.data);var r=0;var t=(!this.rendererOptions.barDirection||this.rendererOptions.barDirection=="vertical")?1:0;for(var p=0;p<this.data.length;p++){r+=this.data[p][t];if(p>0){this.data[p][t]+=this.data[p-1][t]}}this.data[this.data.length]=(t==1)?[this.data.length+1,r]:[r,this.data.length+1];this._data[this._data.length]=(t==1)?[this._data.length+1,r]:[r,this._data.length+1]}if(this.rendererOptions.groups>1){this.breakOnNull=true;var m=this.data.length;var u=parseInt(m/this.rendererOptions.groups,10);var q=0;for(var p=u;p<m;p+=u){this.data.splice(p+q,0,[null,null]);q++}for(p=0;p<this.data.length;p++){if(this._primaryAxis=="_xaxis"){this.data[p][0]=p+1}else{this.data[p][1]=p+1}}}}d.jqplot.preSeriesInitHooks.push(g);d.jqplot.BarRenderer.prototype.calcSeriesNumbers=function(){var q=0;var r=0;var p=this[this._primaryAxis];var o,n,t;for(var m=0;m<p._series.length;m++){n=p._series[m];if(n===this){t=m}if(n.renderer.constructor==d.jqplot.BarRenderer){q+=n.data.length;r+=1}}return[q,r,t]};d.jqplot.BarRenderer.prototype.setBarWidth=function(){var p;var m=0;var n=0;var r=this[this._primaryAxis];var w,q,u;var v=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);m=v[0];n=v[1];var t=r.numberTicks;var o=(t-1)/2;if(r.name=="xaxis"||r.name=="x2axis"){if(this._stack){this.barWidth=(r._offsets.max-r._offsets.min)/m*n-this.barMargin}else{this.barWidth=((r._offsets.max-r._offsets.min)/o-this.barPadding*(n-1)-this.barMargin*2)/n}}else{if(this._stack){this.barWidth=(r._offsets.min-r._offsets.max)/m*n-this.barMargin}else{this.barWidth=((r._offsets.min-r._offsets.max)/o-this.barPadding*(n-1)-this.barMargin*2)/n}}return[m,n]};function f(n){var p=[];for(var r=0;r<n.length;r++){var q=d.jqplot.getColorComponents(n[r]);var m=[q[0],q[1],q[2]];var s=m[0]+m[1]+m[2];for(var o=0;o<3;o++){m[o]=(s>570)?m[o]*0.8:m[o]+0.3*(255-m[o]);m[o]=parseInt(m[o],10)}p.push("rgb("+m[0]+","+m[1]+","+m[2]+")")}return p}d.jqplot.BarRenderer.prototype.draw=function(D,J,p){var G;var z=d.extend({},p);var u=(z.shadow!=undefined)?z.shadow:this.shadow;var M=(z.showLine!=undefined)?z.showLine:this.showLine;var E=(z.fill!=undefined)?z.fill:this.fill;var o=this.xaxis;var H=this.yaxis;var x=this._xaxis.series_u2p;var I=this._yaxis.series_u2p;var C,B;this._dataColors=[];this._barPoints=[];if(this.barWidth==null){this.renderer.setBarWidth.call(this)}var L=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);var w=L[0];var v=L[1];var r=L[2];var F=[];if(this._stack){this._barNudge=0}else{this._barNudge=(-Math.abs(v/2-0.5)+r)*(this.barWidth+this.barPadding)}if(M){var t=new d.jqplot.ColorGenerator(this.negativeSeriesColors);var A=new d.jqplot.ColorGenerator(this.seriesColors);var K=t.get(this.index);if(!this.useNegativeColors){K=z.fillStyle}var s=z.fillStyle;var q;var N;var n;if(this.barDirection=="vertical"){for(var G=0;G<J.length;G++){if(this.data[G][1]==null){continue}F=[];q=J[G][0]+this._barNudge;n;if(this._stack&&this._prevGridData.length){n=this._prevGridData[G][1] -}else{if(this.fillToZero){n=this._yaxis.series_u2p(0)}else{if(this.waterfall&&G>0&&G<this.gridData.length-1){n=this.gridData[G-1][1]}else{if(this.waterfall&&G==0&&G<this.gridData.length-1){if(this._yaxis.min<=0&&this._yaxis.max>=0){n=this._yaxis.series_u2p(0)}else{if(this._yaxis.min>0){n=D.canvas.height}else{n=0}}}else{if(this.waterfall&&G==this.gridData.length-1){if(this._yaxis.min<=0&&this._yaxis.max>=0){n=this._yaxis.series_u2p(0)}else{if(this._yaxis.min>0){n=D.canvas.height}else{n=0}}}else{n=D.canvas.height}}}}}if((this.fillToZero&&this._plotData[G][1]<0)||(this.waterfall&&this._data[G][1]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){z.fillStyle=t.next()}else{z.fillStyle=A.next()}}else{z.fillStyle=K}}else{if(this.varyBarColor&&!this._stack){z.fillStyle=A.next()}else{z.fillStyle=s}}if(!this.fillToZero||this._plotData[G][1]>=0){F.push([q-this.barWidth/2,n]);F.push([q-this.barWidth/2,J[G][1]]);F.push([q+this.barWidth/2,J[G][1]]);F.push([q+this.barWidth/2,n])}else{F.push([q-this.barWidth/2,J[G][1]]);F.push([q-this.barWidth/2,n]);F.push([q+this.barWidth/2,n]);F.push([q+this.barWidth/2,J[G][1]])}this._barPoints.push(F);if(u&&!this._stack){var y=d.extend(true,{},z);delete y.fillStyle;this.renderer.shadowRenderer.draw(D,F,y)}var m=z.fillStyle||this.color;this._dataColors.push(m);this.renderer.shapeRenderer.draw(D,F,z)}}else{if(this.barDirection=="horizontal"){for(var G=0;G<J.length;G++){if(this.data[G][0]==null){continue}F=[];q=J[G][1]-this._barNudge;N;if(this._stack&&this._prevGridData.length){N=this._prevGridData[G][0]}else{if(this.fillToZero){N=this._xaxis.series_u2p(0)}else{if(this.waterfall&&G>0&&G<this.gridData.length-1){N=this.gridData[G-1][1]}else{if(this.waterfall&&G==0&&G<this.gridData.length-1){if(this._xaxis.min<=0&&this._xaxis.max>=0){N=this._xaxis.series_u2p(0)}else{if(this._xaxis.min>0){N=0}else{N=D.canvas.width}}}else{if(this.waterfall&&G==this.gridData.length-1){if(this._xaxis.min<=0&&this._xaxis.max>=0){N=this._xaxis.series_u2p(0)}else{if(this._xaxis.min>0){N=0}else{N=D.canvas.width}}}else{N=0}}}}}if((this.fillToZero&&this._plotData[G][1]<0)||(this.waterfall&&this._data[G][1]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){z.fillStyle=t.next()}else{z.fillStyle=A.next()}}}else{if(this.varyBarColor&&!this._stack){z.fillStyle=A.next()}else{z.fillStyle=s}}F.push([N,q+this.barWidth/2]);F.push([N,q-this.barWidth/2]);F.push([J[G][0],q-this.barWidth/2]);F.push([J[G][0],q+this.barWidth/2]);this._barPoints.push(F);if(u&&!this._stack){var y=d.extend(true,{},z);delete y.fillStyle;this.renderer.shadowRenderer.draw(D,F,y)}var m=z.fillStyle||this.color;this._dataColors.push(m);this.renderer.shapeRenderer.draw(D,F,z)}}}}if(this.highlightColors.length==0){this.highlightColors=f(this._dataColors)}else{if(typeof(this.highlightColors)=="string"){var L=this.highlightColors;this.highlightColors=[];for(var G=0;G<this._dataColors.length;G++){this.highlightColors.push(L)}}}};d.jqplot.BarRenderer.prototype.drawShadow=function(y,E,o){var B;var v=(o!=undefined)?o:{};var r=(v.shadow!=undefined)?v.shadow:this.shadow;var G=(v.showLine!=undefined)?v.showLine:this.showLine;var z=(v.fill!=undefined)?v.fill:this.fill;var n=this.xaxis;var C=this.yaxis;var u=this._xaxis.series_u2p;var D=this._yaxis.series_u2p;var x,A,w,t,s,q;if(this._stack&&this.shadow){if(this.barWidth==null){this.renderer.setBarWidth.call(this)}var F=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);t=F[0];s=F[1];q=F[2];if(this._stack){this._barNudge=0}else{this._barNudge=(-Math.abs(s/2-0.5)+q)*(this.barWidth+this.barPadding)}if(G){if(this.barDirection=="vertical"){for(var B=0;B<E.length;B++){if(this.data[B][1]==null){continue}A=[];var p=E[B][0]+this._barNudge;var m;if(this._stack&&this._prevGridData.length){m=this._prevGridData[B][1]}else{if(this.fillToZero){m=this._yaxis.series_u2p(0)}else{m=y.canvas.height}}A.push([p-this.barWidth/2,m]);A.push([p-this.barWidth/2,E[B][1]]);A.push([p+this.barWidth/2,E[B][1]]);A.push([p+this.barWidth/2,m]);this.renderer.shadowRenderer.draw(y,A,v)}}else{if(this.barDirection=="horizontal"){for(var B=0;B<E.length;B++){if(this.data[B][0]==null){continue}A=[];var p=E[B][1]-this._barNudge;var H;if(this._stack&&this._prevGridData.length){H=this._prevGridData[B][0]}else{H=0}A.push([H,p+this.barWidth/2]);A.push([E[B][0],p+this.barWidth/2]);A.push([E[B][0],p-this.barWidth/2]);A.push([H,p-this.barWidth/2]);this.renderer.shadowRenderer.draw(y,A,v)}}}}}};function h(p,o,m){for(var n=0;n<this.series.length;n++){if(this.series[n].renderer.constructor==d.jqplot.BarRenderer){if(this.series[n].highlightMouseOver){this.series[n].highlightMouseDown=false}}}this.target.bind("mouseout",{plot:this},function(q){j(q.data.plot)})}function i(){if(this.plugins.barRenderer&&this.plugins.barRenderer.highlightCanvas){this.plugins.barRenderer.highlightCanvas.resetCanvas();this.plugins.barRenderer.highlightCanvas=null}this.plugins.barRenderer={highlightedSeriesIndex:null};this.plugins.barRenderer.highlightCanvas=new d.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-barRenderer-highlight-canvas",this._plotDimensions,this));this.plugins.barRenderer.highlightCanvas.setContext()}function c(t,r,p,o){var n=t.series[r];var m=t.plugins.barRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);n._highlightedPoint=p;t.plugins.barRenderer.highlightedSeriesIndex=r;var q={fillStyle:n.highlightColors[p]};n.renderer.shapeRenderer.draw(m._ctx,o,q);m=null}function j(o){var m=o.plugins.barRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n<o.series.length;n++){o.series[n]._highlightedPoint=null}o.plugins.barRenderer.highlightedSeriesIndex=null;o.target.trigger("jqplotDataUnhighlight");m=null}function b(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataMouseOver");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);if(r.series[o[0]].highlightMouseOver&&!(o[0]==r.plugins.barRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=q.pageX;m.pageY=q.pageY;r.target.trigger(m,o);c(r,s.seriesIndex,s.pointIndex,s.points)}}else{if(s==null){j(r)}}}function a(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];if(q.series[n[0]].highlightMouseDown&&!(n[0]==q.plugins.barRenderer.highlightedSeriesIndex&&n[1]==q.series[n[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n);c(q,r.seriesIndex,r.pointIndex,r.points)}}else{if(r==null){j(q)}}}function k(o,n,r,q,p){var m=p.plugins.barRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){j(p)}}function e(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];var m=jQuery.Event("jqplotDataClick");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n)}}function l(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var m=r.plugins.barRenderer.highlightedSeriesIndex;if(m!=null&&r.series[m].highlightMouseDown){j(r)}var n=jQuery.Event("jqplotDataRightClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}})(jQuery);(function(a){a.jqplot.CategoryAxisRenderer=function(b){a.jqplot.LinearAxisRenderer.call(this);this.sortMergedLabels=false};a.jqplot.CategoryAxisRenderer.prototype=new a.jqplot.LinearAxisRenderer();a.jqplot.CategoryAxisRenderer.prototype.constructor=a.jqplot.CategoryAxisRenderer;a.jqplot.CategoryAxisRenderer.prototype.init=function(e){this.groups=1;this.groupLabels=[];this._groupLabels=[];this._grouped=false;this._barsPerGroup=null;a.extend(true,this,{tickOptions:{formatString:"%d"}},e);var b=this._dataBounds;for(var f=0;f<this._series.length;f++){var g=this._series[f];if(g.groups){this.groups=g.groups}var h=g.data;for(var c=0;c<h.length;c++){if(this.name=="xaxis"||this.name=="x2axis"){if(h[c][0]<b.min||b.min==null){b.min=h[c][0]}if(h[c][0]>b.max||b.max==null){b.max=h[c][0]}}else{if(h[c][1]<b.min||b.min==null){b.min=h[c][1]}if(h[c][1]>b.max||b.max==null){b.max=h[c][1]}}}}if(this.groupLabels.length){this.groups=this.groupLabels.length}};a.jqplot.CategoryAxisRenderer.prototype.createTicks=function(){var D=this._ticks;var z=this.ticks;var F=this.name;var C=this._dataBounds;var v,A;var q,w;var d,c;var b,x;if(z.length){if(this.groups>1&&!this._grouped){var r=z.length;var p=parseInt(r/this.groups,10);var e=0;for(var x=p;x<r;x+=p){z.splice(x+e,0," ");e++}this._grouped=true}this.min=0.5;this.max=z.length+0.5;var m=this.max-this.min;this.numberTicks=2*z.length+1;for(x=0;x<z.length;x++){b=this.min+2*x*m/(this.numberTicks-1);var h=new this.tickRenderer(this.tickOptions);h.showLabel=false;h.setTick(b,this.name);this._ticks.push(h);var h=new this.tickRenderer(this.tickOptions);h.label=z[x];h.showMark=false;h.showGridline=false;h.setTick(b+0.5,this.name);this._ticks.push(h)}var h=new this.tickRenderer(this.tickOptions);h.showLabel=false;h.setTick(b+1,this.name);this._ticks.push(h)}else{if(F=="xaxis"||F=="x2axis"){v=this._plotDimensions.width}else{v=this._plotDimensions.height}if(this.min!=null&&this.max!=null&&this.numberTicks!=null){this.tickInterval=null}if(this.min!=null&&this.max!=null&&this.tickInterval!=null){if(parseInt((this.max-this.min)/this.tickInterval,10)!=(this.max-this.min)/this.tickInterval){this.tickInterval=null}}var y=[];var B=0;var q=0.5;var w,E;var f=false;for(var x=0;x<this._series.length;x++){var k=this._series[x];for(var u=0;u<k.data.length;u++){if(this.name=="xaxis"||this.name=="x2axis"){E=k.data[u][0]}else{E=k.data[u][1]}if(a.inArray(E,y)==-1){f=true;B+=1;y.push(E)}}}if(f&&this.sortMergedLabels){y.sort(function(j,i){return j-i})}this.ticks=y;for(var x=0;x<this._series.length;x++){var k=this._series[x];for(var u=0;u<k.data.length;u++){if(this.name=="xaxis"||this.name=="x2axis"){E=k.data[u][0]}else{E=k.data[u][1]}var n=a.inArray(E,y)+1;if(this.name=="xaxis"||this.name=="x2axis"){k.data[u][0]=n}else{k.data[u][1]=n}}}if(this.groups>1&&!this._grouped){var r=y.length;var p=parseInt(r/this.groups,10);var e=0;for(var x=p;x<r;x+=p+1){y[x]=" "}this._grouped=true}w=B+0.5;if(this.numberTicks==null){this.numberTicks=2*B+1}var m=w-q;this.min=q;this.max=w;var o=0;var g=parseInt(3+v/20,10);var p=parseInt(B/g,10);if(this.tickInterval==null){this.tickInterval=m/(this.numberTicks-1)}for(var x=0;x<this.numberTicks;x++){b=this.min+x*this.tickInterval;var h=new this.tickRenderer(this.tickOptions);if(x/2==parseInt(x/2,10)){h.showLabel=false;h.showMark=true}else{if(p>0&&o<p){h.showLabel=false;o+=1}else{h.showLabel=true;o=0}h.label=h.formatter(h.formatString,y[(x-1)/2]);h.showMark=false;h.showGridline=false}h.setTick(b,this.name);this._ticks.push(h)}}};a.jqplot.CategoryAxisRenderer.prototype.draw=function(b,j){if(this.show){this.renderer.createTicks.call(this);var h=0;var c;if(this._elem){this._elem.emptyForce()}this._elem=this._elem||a('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>');if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var g=this._label.draw(b);g.appendTo(this._elem)}var f=this._ticks;for(var e=0;e<f.length;e++){var d=f[e];if(d.showLabel&&(!d.isMinorTick||this.showMinorTicks)){var g=d.draw(b,j);g.appendTo(this._elem)}}this._groupLabels=[];for(var e=0;e<this.groupLabels.length;e++){var g=a('<div style="position:absolute;" class="jqplot-'+this.name+'-groupLabel"></div>');g.html(this.groupLabels[e]);this._groupLabels.push(g);g.appendTo(this._elem)}}return this._elem};a.jqplot.CategoryAxisRenderer.prototype.set=function(){var e=0;var m;var k=0;var f=0;var d=(this._label==null)?false:this._label.show;if(this.show){var n=this._ticks;for(var c=0;c<n.length;c++){var g=n[c];if(g.showLabel&&(!g.isMinorTick||this.showMinorTicks)){if(this.name=="xaxis"||this.name=="x2axis"){m=g._elem.outerHeight(true)}else{m=g._elem.outerWidth(true)}if(m>e){e=m}}}var j=0;for(var c=0;c<this._groupLabels.length;c++){var b=this._groupLabels[c];if(this.name=="xaxis"||this.name=="x2axis"){m=b.outerHeight(true)}else{m=b.outerWidth(true)}if(m>j){j=m}}if(d){k=this._label._elem.outerWidth(true);f=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){e+=j+f;this._elem.css({height:e+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){e+=j+f;this._elem.css({height:e+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){e+=j+k;this._elem.css({width:e+"px",left:"0px",top:"0px"});if(d&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",k+"px")}}else{e+=j+k;this._elem.css({width:e+"px",right:"0px",top:"0px"});if(d&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",k+"px")}}}}}};a.jqplot.CategoryAxisRenderer.prototype.pack=function(e,c){var C=this._ticks;var v=this.max;var s=this.min;var n=c.max;var l=c.min;var q=(this._label==null)?false:this._label.show;var x;for(var r in e){this._elem.css(r,e[r])}this._offsets=c;var g=n-l;var k=v-s;this.p2u=function(h){return(h-l)*k/g+s};this.u2p=function(h){return(h-s)*g/k+l};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(h){return(h-s)*g/k};this.series_p2u=function(h){return h*k/g+s}}else{this.series_u2p=function(h){return(h-v)*g/k};this.series_p2u=function(h){return h*k/g+v}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(x=0;x<C.length;x++){var o=C[x];if(o.show&&o.showLabel){var b;if(o.constructor==a.jqplot.CanvasAxisTickRenderer&&o.angle){var A=(this.name=="xaxis")?1:-1;switch(o.labelPosition){case"auto":if(A*o.angle<0){b=-o.getWidth()+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2}else{b=-o._textRenderer.height*Math.sin(o._textRenderer.angle)/2}break;case"end":b=-o.getWidth()+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2;break;case"start":b=-o._textRenderer.height*Math.sin(o._textRenderer.angle)/2;break;case"middle":b=-o.getWidth()/2+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2;break;default:b=-o.getWidth()/2+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2;break}}else{b=-o.getWidth()/2}var D=this.u2p(o.value)+b+"px";o._elem.css("left",D);o.pack()}}var z=["bottom",0];if(q){var m=this._label._elem.outerWidth(true);this._label._elem.css("left",l+g/2-m/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px");z=["bottom",this._label._elem.outerHeight(true)]}else{this._label._elem.css("top","0px");z=["top",this._label._elem.outerHeight(true)]}this._label.pack()}var d=parseInt(this._ticks.length/this.groups,10);for(x=0;x<this._groupLabels.length;x++){var B=0;var f=0;for(var u=x*d;u<=(x+1)*d;u++){if(this._ticks[u]._elem&&this._ticks[u].label!=" "){var o=this._ticks[u]._elem;var r=o.position();B+=r.left+o.outerWidth(true)/2;f++}}B=B/f;this._groupLabels[x].css({left:(B-this._groupLabels[x].outerWidth(true)/2)});this._groupLabels[x].css(z[0],z[1])}}else{for(x=0;x<C.length;x++){var o=C[x];if(o.show&&o.showLabel){var b;if(o.constructor==a.jqplot.CanvasAxisTickRenderer&&o.angle){var A=(this.name=="yaxis")?1:-1;switch(o.labelPosition){case"auto":case"end":if(A*o.angle<0){b=-o._textRenderer.height*Math.cos(-o._textRenderer.angle)/2}else{b=-o.getHeight()+o._textRenderer.height*Math.cos(o._textRenderer.angle)/2}break;case"start":if(o.angle>0){b=-o._textRenderer.height*Math.cos(-o._textRenderer.angle)/2}else{b=-o.getHeight()+o._textRenderer.height*Math.cos(o._textRenderer.angle)/2}break;case"middle":b=-o.getHeight()/2;break;default:b=-o.getHeight()/2;break}}else{b=-o.getHeight()/2}var D=this.u2p(o.value)+b+"px";o._elem.css("top",D);o.pack()}}var z=["left",0];if(q){var y=this._label._elem.outerHeight(true);this._label._elem.css("top",n-g/2-y/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px");z=["left",this._label._elem.outerWidth(true)]}else{this._label._elem.css("right","0px");z=["right",this._label._elem.outerWidth(true)]}this._label.pack()}var d=parseInt(this._ticks.length/this.groups,10);for(x=0;x<this._groupLabels.length;x++){var B=0;var f=0;for(var u=x*d;u<=(x+1)*d;u++){if(this._ticks[u]._elem&&this._ticks[u].label!=" "){var o=this._ticks[u]._elem;var r=o.position();B+=r.top+o.outerHeight()/2;f++}}B=B/f;this._groupLabels[x].css({top:B-this._groupLabels[x].outerHeight()/2});this._groupLabels[x].css(z[0],z[1])}}}}})(jQuery);(function(a){a.jqplot.CanvasTextRenderer=function(b){this.fontStyle="normal";this.fontVariant="normal";this.fontWeight="normal";this.fontSize="10px";this.fontFamily="sans-serif";this.fontStretch=1;this.fillStyle="#666666";this.angle=0;this.textAlign="start";this.textBaseline="alphabetic";this.text;this.width;this.height;this.pt2px=1.28;a.extend(true,this,b);this.normalizedFontSize=this.normalizeFontSize(this.fontSize);this.setHeight()};a.jqplot.CanvasTextRenderer.prototype.init=function(b){a.extend(true,this,b);this.normalizedFontSize=this.normalizeFontSize(this.fontSize);this.setHeight()};a.jqplot.CanvasTextRenderer.prototype.normalizeFontSize=function(b){b=String(b);var c=parseFloat(b);if(b.indexOf("px")>-1){return c/this.pt2px}else{if(b.indexOf("pt")>-1){return c}else{if(b.indexOf("em")>-1){return c*12}else{if(b.indexOf("%")>-1){return c*12/100}else{return c/this.pt2px}}}}};a.jqplot.CanvasTextRenderer.prototype.fontWeight2Float=function(b){if(Number(b)){return b/400}else{switch(b){case"normal":return 1;break;case"bold":return 1.75;break;case"bolder":return 2.25;break;case"lighter":return 0.75;break;default:return 1;break}}};a.jqplot.CanvasTextRenderer.prototype.getText=function(){return this.text};a.jqplot.CanvasTextRenderer.prototype.setText=function(c,b){this.text=c;this.setWidth(b);return this};a.jqplot.CanvasTextRenderer.prototype.getWidth=function(b){return this.width};a.jqplot.CanvasTextRenderer.prototype.setWidth=function(c,b){if(!b){this.width=this.measure(c,this.text)}else{this.width=b}return this};a.jqplot.CanvasTextRenderer.prototype.getHeight=function(b){return this.height};a.jqplot.CanvasTextRenderer.prototype.setHeight=function(b){if(!b){this.height=this.normalizedFontSize*this.pt2px}else{this.height=b}return this};a.jqplot.CanvasTextRenderer.prototype.letter=function(b){return this.letters[b]};a.jqplot.CanvasTextRenderer.prototype.ascent=function(){return this.normalizedFontSize};a.jqplot.CanvasTextRenderer.prototype.descent=function(){return 7*this.normalizedFontSize/25};a.jqplot.CanvasTextRenderer.prototype.measure=function(d,g){var f=0;var b=g.length;for(var e=0;e<b;e++){var h=this.letter(g.charAt(e));if(h){f+=h.width*this.normalizedFontSize/25*this.fontStretch}}return f};a.jqplot.CanvasTextRenderer.prototype.draw=function(s,n){var r=0;var o=this.height*0.72;var p=0;var l=n.length;var k=this.normalizedFontSize/25;s.save();var h,f;if((-Math.PI/2<=this.angle&&this.angle<=0)||(Math.PI*3/2<=this.angle&&this.angle<=Math.PI*2)){h=0;f=-Math.sin(this.angle)*this.width}else{if((0<this.angle&&this.angle<=Math.PI/2)||(-Math.PI*2<=this.angle&&this.angle<=-Math.PI*3/2)){h=Math.sin(this.angle)*this.height;f=0}else{if((-Math.PI<this.angle&&this.angle<-Math.PI/2)||(Math.PI<=this.angle&&this.angle<=Math.PI*3/2)){h=-Math.cos(this.angle)*this.width;f=-Math.sin(this.angle)*this.width-Math.cos(this.angle)*this.height}else{if((-Math.PI*3/2<this.angle&&this.angle<Math.PI)||(Math.PI/2<this.angle&&this.angle<Math.PI)){h=Math.sin(this.angle)*this.height-Math.cos(this.angle)*this.width;f=-Math.cos(this.angle)*this.height}}}}s.strokeStyle=this.fillStyle;s.fillStyle=this.fillStyle;s.translate(h,f);s.rotate(this.angle);s.lineCap="round";var t=(this.normalizedFontSize>30)?2:2+(30-this.normalizedFontSize)/20;s.lineWidth=t*k*this.fontWeight2Float(this.fontWeight);for(var g=0;g<l;g++){var m=this.letter(n.charAt(g));if(!m){continue}s.beginPath();var e=1;var b=0;for(var d=0;d<m.points.length;d++){var q=m.points[d];if(q[0]==-1&&q[1]==-1){e=1;continue}if(e){s.moveTo(r+q[0]*k*this.fontStretch,o-q[1]*k);e=false}else{s.lineTo(r+q[0]*k*this.fontStretch,o-q[1]*k)}}s.stroke();r+=m.width*k*this.fontStretch}s.restore();return p};a.jqplot.CanvasTextRenderer.prototype.letters={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},"$":{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:18,points:[[6,9],[12,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},"0":{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},"1":{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},"2":{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},"3":{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"4":{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},"5":{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"6":{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},"7":{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},"8":{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},"9":{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},";":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};a.jqplot.CanvasFontRenderer=function(b){b=b||{};if(!b.pt2px){b.pt2px=1.5}a.jqplot.CanvasTextRenderer.call(this,b)};a.jqplot.CanvasFontRenderer.prototype=new a.jqplot.CanvasTextRenderer({});a.jqplot.CanvasFontRenderer.prototype.constructor=a.jqplot.CanvasFontRenderer;a.jqplot.CanvasFontRenderer.prototype.measure=function(c,e){var d=this.fontSize+" "+this.fontFamily;c.save();c.font=d;var b=c.measureText(e).width;c.restore();return b};a.jqplot.CanvasFontRenderer.prototype.draw=function(e,g){var c=0;var h=this.height*0.72;e.save();var d,b;if((-Math.PI/2<=this.angle&&this.angle<=0)||(Math.PI*3/2<=this.angle&&this.angle<=Math.PI*2)){d=0;b=-Math.sin(this.angle)*this.width}else{if((0<this.angle&&this.angle<=Math.PI/2)||(-Math.PI*2<=this.angle&&this.angle<=-Math.PI*3/2)){d=Math.sin(this.angle)*this.height;b=0}else{if((-Math.PI<this.angle&&this.angle<-Math.PI/2)||(Math.PI<=this.angle&&this.angle<=Math.PI*3/2)){d=-Math.cos(this.angle)*this.width;b=-Math.sin(this.angle)*this.width-Math.cos(this.angle)*this.height}else{if((-Math.PI*3/2<this.angle&&this.angle<Math.PI)||(Math.PI/2<this.angle&&this.angle<Math.PI)){d=Math.sin(this.angle)*this.height-Math.cos(this.angle)*this.width;b=-Math.cos(this.angle)*this.height -}}}}e.strokeStyle=this.fillStyle;e.fillStyle=this.fillStyle;var f=this.fontSize+" "+this.fontFamily;e.font=f;e.translate(d,b);e.rotate(this.angle);e.fillText(g,c,h);e.restore()}})(jQuery);(function(a){a.jqplot.CanvasAxisTickRenderer=function(b){this.mark="outside";this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.angle=0;this.markSize=4;this.show=true;this.showLabel=true;this.labelPosition="auto";this.label="";this.value=null;this._styles={};this.formatter=a.jqplot.DefaultTickFormatter;this.formatString="";this.prefix="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="10pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){function d(){return !!(document.createElement("canvas").getContext&&typeof document.createElement("canvas").getContext("2d").fillText=="function")}if(d()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisTickRenderer.prototype=new a.jqplot.ElemContainer();a.jqplot.CanvasAxisTickRenderer.prototype.constructor=a.jqplot.CanvasAxisTickRenderer;a.jqplot.CanvasAxisTickRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisTickRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisTickRenderer.prototype.setTick=function(b,d,c){this.value=b;if(c){this.isMinorTick=true}return this};a.jqplot.CanvasAxisTickRenderer.prototype.draw=function(c,f){if(!this.label){this.label=this.prefix+this.formatter(this.formatString,this.value)}if(this._elem){if(a.jqplot.use_excanvas){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce();this._elem=null}var e=f.canvasManager.getCanvas();this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e.style.textAlign="left";e.style.position="absolute";e=f.canvasManager.initCanvas(e);this._elem=a(e);this._elem.css(this._styles);this._elem.addClass("jqplot-"+this.axis+"-tick");e=null;return this._elem};a.jqplot.CanvasAxisTickRenderer.prototype.pack=function(){this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery);
\ No newline at end of file +/** + * Title: jqPlot Charts + * + * Pure JavaScript plotting plugin for jQuery. + * + * About: Version + * + * version: @VERSION + * revision: @REVISION + * + * About: Copyright & License + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT and GPL version 2.0 licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * See <GPL Version 2> and <MIT License> contained within this distribution for further information. + * + * The author would appreciate an email letting him know of any substantial + * use of jqPlot. You can reach the author at: chris at jqplot dot com + * or see http://www.jqplot.com/info.php. This is, of course, not required. + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php. + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + * + * About: Introduction + * + * jqPlot requires jQuery (1.4+ required for certain features). jQuery 1.4.2 is included in the distribution. + * To use jqPlot include jQuery, the jqPlot jQuery plugin, the jqPlot css file and optionally + * the excanvas script for IE support in your web page: + * + * > <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]--> + * > <script language="javascript" type="text/javascript" src="jquery-1.4.4.min.js"></script> + * > <script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script> + * > <link rel="stylesheet" type="text/css" href="jquery.jqplot.css" /> + * + * jqPlot can be customized by overriding the defaults of any of the objects which make + * up the plot. The general usage of jqplot is: + * + * > chart = $.jqplot('targetElemId', [dataArray,...], {optionsObject}); + * + * The options available to jqplot are detailed in <jqPlot Options> in the jqPlotOptions.txt file. + * + * An actual call to $.jqplot() may look like the + * examples below: + * + * > chart = $.jqplot('chartdiv', [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]); + * + * or + * + * > dataArray = [34,12,43,55,77]; + * > chart = $.jqplot('targetElemId', [dataArray, ...], {title:'My Plot', axes:{yaxis:{min:20, max:100}}}); + * + * For more inforrmation, see <jqPlot Usage>. + * + * About: Usage + * + * See <jqPlot Usage> + * + * About: Available Options + * + * See <jqPlot Options> for a list of options available thorugh the options object (not complete yet!) + * + * About: Options Usage + * + * See <Options Tutorial> + * + * About: Changes + * + * See <Change Log> + * + */ + +(function($) { + // make sure undefined is undefined + var undefined; + + $.fn.emptyForce = function() { + for ( var i = 0, elem; (elem = $(this)[i]) != null; i++ ) { + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + $.cleanData( elem.getElementsByTagName("*") ); + } + + // Remove any remaining nodes + if ($.jqplot.use_excanvas) { + elem.outerHTML = ""; + } + else { + while ( elem.firstChild ) { + elem.removeChild( elem.firstChild ); + } + } + + elem = null; + } + + return $(this); + }; + + $.fn.removeChildForce = function(parent) { + while ( parent.firstChild ) { + this.removeChildForce( parent.firstChild ); + parent.removeChild( parent.firstChild ); + } + }; + + $.fn.jqplot = function() { + var datas = []; + var options = []; + // see how many data arrays we have + for (var i=0, l=arguments.length; i<l; i++) { + if ($.isArray(arguments[i])) { + datas.push(arguments[i]); + } + else if ($.isPlainObject(arguments[i])) { + options.push(arguments[i]); + } + } + + return this.each(function(index) { + var tid, + plot, + $this = $(this), + dl = datas.length, + ol = options.length, + data, + opts; + + if (index < dl) { + data = datas[index]; + } + else { + data = dl ? datas[dl-1] : null; + } + + if (index < ol) { + opts = options[index]; + } + else { + opts = ol ? options[ol-1] : null; + } + + // does el have an id? + // if not assign it one. + tid = $this.attr('id'); + if (tid === undefined) { + tid = 'jqplot_target_' + $.jqplot.targetCounter++; + $this.attr('id', tid); + } + + plot = $.jqplot(tid, data, opts); + + $this.data('jqplot', plot); + }); + }; + + + /** + * Namespace: $.jqplot + * jQuery function called by the user to create a plot. + * + * Parameters: + * target - ID of target element to render the plot into. + * data - an array of data series. + * options - user defined options object. See the individual classes for available options. + * + * Properties: + * config - object to hold configuration information for jqPlot plot object. + * + * attributes: + * enablePlugins - False to disable plugins by default. Plugins must then be explicitly + * enabled in the individual plot options. Default: false. + * This property sets the "show" property of certain plugins to true or false. + * Only plugins that can be immediately active upon loading are affected. This includes + * non-renderer plugins like cursor, dragable, highlighter, and trendline. + * defaultHeight - Default height for plots where no css height specification exists. This + * is a jqplot wide default. + * defaultWidth - Default height for plots where no css height specification exists. This + * is a jqplot wide default. + */ + + $.jqplot = function(target, data, options) { + var _data = null, _options = null; + + if (arguments.length === 3) { + _data = data; + _options = options; + } + + else if (arguments.length === 2) { + if ($.isArray(data)) { + _data = data; + } + + else if ($.isPlainObject(data)) { + _options = data; + } + } + + if (_data === null && _options !== null && _options.data) { + _data = _options.data; + } + + var plot = new jqPlot(); + // remove any error class that may be stuck on target. + $('#'+target).removeClass('jqplot-error'); + + if ($.jqplot.config.catchErrors) { + try { + plot.init(target, _data, _options); + plot.draw(); + plot.themeEngine.init.call(plot); + return plot; + } + catch(e) { + var msg = $.jqplot.config.errorMessage || e.message; + $('#'+target).append('<div class="jqplot-error-message">'+msg+'</div>'); + $('#'+target).addClass('jqplot-error'); + document.getElementById(target).style.background = $.jqplot.config.errorBackground; + document.getElementById(target).style.border = $.jqplot.config.errorBorder; + document.getElementById(target).style.fontFamily = $.jqplot.config.errorFontFamily; + document.getElementById(target).style.fontSize = $.jqplot.config.errorFontSize; + document.getElementById(target).style.fontStyle = $.jqplot.config.errorFontStyle; + document.getElementById(target).style.fontWeight = $.jqplot.config.errorFontWeight; + } + } + else { + plot.init(target, _data, _options); + plot.draw(); + plot.themeEngine.init.call(plot); + return plot; + } + }; + + $.jqplot.version = "@VERSION"; + $.jqplot.revision = "@REVISION"; + + $.jqplot.targetCounter = 1; + + // canvas manager to reuse canvases on the plot. + // Should help solve problem of canvases not being freed and + // problem of waiting forever for firefox to decide to free memory. + $.jqplot.CanvasManager = function() { + // canvases are managed globally so that they can be reused + // across plots after they have been freed + if (typeof $.jqplot.CanvasManager.canvases == 'undefined') { + $.jqplot.CanvasManager.canvases = []; + $.jqplot.CanvasManager.free = []; + } + + var myCanvases = []; + + this.getCanvas = function() { + var canvas; + var makeNew = true; + + if (!$.jqplot.use_excanvas) { + for (var i = 0, l = $.jqplot.CanvasManager.canvases.length; i < l; i++) { + if ($.jqplot.CanvasManager.free[i] === true) { + makeNew = false; + canvas = $.jqplot.CanvasManager.canvases[i]; + // $(canvas).removeClass('jqplot-canvasManager-free').addClass('jqplot-canvasManager-inuse'); + $.jqplot.CanvasManager.free[i] = false; + myCanvases.push(i); + break; + } + } + } + + if (makeNew) { + canvas = document.createElement('canvas'); + myCanvases.push($.jqplot.CanvasManager.canvases.length); + $.jqplot.CanvasManager.canvases.push(canvas); + $.jqplot.CanvasManager.free.push(false); + } + + return canvas; + }; + + // this method has to be used after settings the dimesions + // on the element returned by getCanvas() + this.initCanvas = function(canvas) { + if ($.jqplot.use_excanvas) { + return window.G_vmlCanvasManager.initElement(canvas); + } + return canvas; + }; + + this.freeAllCanvases = function() { + for (var i = 0, l=myCanvases.length; i < l; i++) { + this.freeCanvas(myCanvases[i]); + } + myCanvases = []; + }; + + this.freeCanvas = function(idx) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { + // excanvas can't be reused, but properly unset + window.G_vmlCanvasManager.uninitElement($.jqplot.CanvasManager.canvases[idx]); + $.jqplot.CanvasManager.canvases[idx] = null; + } + else { + var canvas = $.jqplot.CanvasManager.canvases[idx]; + canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height); + $(canvas).unbind().removeAttr('class').removeAttr('style'); + // Style attributes seemed to be still hanging around. wierd. Some ticks + // still retained a left: 0px attribute after reusing a canvas. + $(canvas).css({left: '', top: '', position: ''}); + // setting size to 0 may save memory of unused canvases? + canvas.width = 0; + canvas.height = 0; + $.jqplot.CanvasManager.free[idx] = true; + } + }; + + }; + + + // Convienence function that won't hang IE or FF without FireBug. + $.jqplot.log = function() { + if (window.console) { + window.console.log.apply(window.console, arguments); + } + }; + + $.jqplot.config = { + addDomReference: false, + enablePlugins:false, + defaultHeight:300, + defaultWidth:400, + UTCAdjust:false, + timezoneOffset: new Date(new Date().getTimezoneOffset() * 60000), + errorMessage: '', + errorBackground: '', + errorBorder: '', + errorFontFamily: '', + errorFontSize: '', + errorFontStyle: '', + errorFontWeight: '', + catchErrors: false, + defaultTickFormatString: "%.1f", + defaultColors: [ "#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"], + defaultNegativeColors: [ "#498991", "#C08840", "#9F9274", "#546D61", "#646C4A", "#6F6621", "#6E3F5F", "#4F64B0", "#A89050", "#C45923", "#187399", "#945381", "#959E5C", "#C7AF7B", "#478396", "#907294"], + dashLength: 4, + gapLength: 4, + dotGapLength: 2.5, + srcLocation: 'jqplot/src/', + pluginLocation: 'jqplot/src/plugins/' + }; + + + $.jqplot.arrayMax = function( array ){ + return Math.max.apply( Math, array ); + }; + + $.jqplot.arrayMin = function( array ){ + return Math.min.apply( Math, array ); + }; + + $.jqplot.enablePlugins = $.jqplot.config.enablePlugins; + + // canvas related tests taken from modernizer: + // Copyright (c) 2009 - 2010 Faruk Ates. + // http://www.modernizr.com + + $.jqplot.support_canvas = function() { + if (typeof $.jqplot.support_canvas.result == 'undefined') { + $.jqplot.support_canvas.result = !!document.createElement('canvas').getContext; + } + return $.jqplot.support_canvas.result; + }; + + $.jqplot.support_canvas_text = function() { + if (typeof $.jqplot.support_canvas_text.result == 'undefined') { + if (window.G_vmlCanvasManager !== undefined && window.G_vmlCanvasManager._version > 887) { + $.jqplot.support_canvas_text.result = true; + } + else { + $.jqplot.support_canvas_text.result = !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function'); + } + + } + return $.jqplot.support_canvas_text.result; + }; + + $.jqplot.use_excanvas = ((!$.support.boxModel || !$.support.objectAll || !$support.leadingWhitespace) && !$.jqplot.support_canvas()) ? true : false; + + /** + * + * Hooks: jqPlot Pugin Hooks + * + * $.jqplot.preInitHooks - called before initialization. + * $.jqplot.postInitHooks - called after initialization. + * $.jqplot.preParseOptionsHooks - called before user options are parsed. + * $.jqplot.postParseOptionsHooks - called after user options are parsed. + * $.jqplot.preDrawHooks - called before plot draw. + * $.jqplot.postDrawHooks - called after plot draw. + * $.jqplot.preDrawSeriesHooks - called before each series is drawn. + * $.jqplot.postDrawSeriesHooks - called after each series is drawn. + * $.jqplot.preDrawLegendHooks - called before the legend is drawn. + * $.jqplot.addLegendRowHooks - called at the end of legend draw, so plugins + * can add rows to the legend table. + * $.jqplot.preSeriesInitHooks - called before series is initialized. + * $.jqplot.postSeriesInitHooks - called after series is initialized. + * $.jqplot.preParseSeriesOptionsHooks - called before series related options + * are parsed. + * $.jqplot.postParseSeriesOptionsHooks - called after series related options + * are parsed. + * $.jqplot.eventListenerHooks - called at the end of plot drawing, binds + * listeners to the event canvas which lays on top of the grid area. + * $.jqplot.preDrawSeriesShadowHooks - called before series shadows are drawn. + * $.jqplot.postDrawSeriesShadowHooks - called after series shadows are drawn. + * + */ + + $.jqplot.preInitHooks = []; + $.jqplot.postInitHooks = []; + $.jqplot.preParseOptionsHooks = []; + $.jqplot.postParseOptionsHooks = []; + $.jqplot.preDrawHooks = []; + $.jqplot.postDrawHooks = []; + $.jqplot.preDrawSeriesHooks = []; + $.jqplot.postDrawSeriesHooks = []; + $.jqplot.preDrawLegendHooks = []; + $.jqplot.addLegendRowHooks = []; + $.jqplot.preSeriesInitHooks = []; + $.jqplot.postSeriesInitHooks = []; + $.jqplot.preParseSeriesOptionsHooks = []; + $.jqplot.postParseSeriesOptionsHooks = []; + $.jqplot.eventListenerHooks = []; + $.jqplot.preDrawSeriesShadowHooks = []; + $.jqplot.postDrawSeriesShadowHooks = []; + + // A superclass holding some common properties and methods. + $.jqplot.ElemContainer = function() { + this._elem; + this._plotWidth; + this._plotHeight; + this._plotDimensions = {height:null, width:null}; + }; + + $.jqplot.ElemContainer.prototype.createElement = function(el, offsets, clss, cssopts, attrib) { + this._offsets = offsets; + var klass = clss || 'jqplot'; + var elem = document.createElement(el); + this._elem = $(elem); + this._elem.addClass(klass); + this._elem.css(cssopts); + this._elem.attr(attrib); + // avoid memory leak; + elem = null; + return this._elem; + }; + + $.jqplot.ElemContainer.prototype.getWidth = function() { + if (this._elem) { + return this._elem.outerWidth(true); + } + else { + return null; + } + }; + + $.jqplot.ElemContainer.prototype.getHeight = function() { + if (this._elem) { + return this._elem.outerHeight(true); + } + else { + return null; + } + }; + + $.jqplot.ElemContainer.prototype.getPosition = function() { + if (this._elem) { + return this._elem.position(); + } + else { + return {top:null, left:null, bottom:null, right:null}; + } + }; + + $.jqplot.ElemContainer.prototype.getTop = function() { + return this.getPosition().top; + }; + + $.jqplot.ElemContainer.prototype.getLeft = function() { + return this.getPosition().left; + }; + + $.jqplot.ElemContainer.prototype.getBottom = function() { + return this._elem.css('bottom'); + }; + + $.jqplot.ElemContainer.prototype.getRight = function() { + return this._elem.css('right'); + }; + + + /** + * Class: Axis + * An individual axis object. Cannot be instantiated directly, but created + * by the Plot oject. Axis properties can be set or overriden by the + * options passed in from the user. + * + */ + function Axis(name) { + $.jqplot.ElemContainer.call(this); + // Group: Properties + // + // Axes options are specified within an axes object at the top level of the + // plot options like so: + // > { + // > axes: { + // > xaxis: {min: 5}, + // > yaxis: {min: 2, max: 8, numberTicks:4}, + // > x2axis: {pad: 1.5}, + // > y2axis: {ticks:[22, 44, 66, 88]} + // > } + // > } + // There are 2 x axes, 'xaxis' and 'x2axis', and + // 9 yaxes, 'yaxis', 'y2axis'. 'y3axis', ... Any or all of which may be specified. + this.name = name; + this._series = []; + // prop: show + // Wether to display the axis on the graph. + this.show = false; + // prop: tickRenderer + // A class of a rendering engine for creating the ticks labels displayed on the plot, + // See <$.jqplot.AxisTickRenderer>. + this.tickRenderer = $.jqplot.AxisTickRenderer; + // prop: tickOptions + // Options that will be passed to the tickRenderer, see <$.jqplot.AxisTickRenderer> options. + this.tickOptions = {}; + // prop: labelRenderer + // A class of a rendering engine for creating an axis label. + this.labelRenderer = $.jqplot.AxisLabelRenderer; + // prop: labelOptions + // Options passed to the label renderer. + this.labelOptions = {}; + // prop: label + // Label for the axis + this.label = null; + // prop: showLabel + // true to show the axis label. + this.showLabel = true; + // prop: min + // minimum value of the axis (in data units, not pixels). + this.min = null; + // prop: max + // maximum value of the axis (in data units, not pixels). + this.max = null; + // prop: autoscale + // DEPRECATED + // the default scaling algorithm produces superior results. + this.autoscale = false; + // prop: pad + // Padding to extend the range above and below the data bounds. + // The data range is multiplied by this factor to determine minimum and maximum axis bounds. + // A value of 0 will be interpreted to mean no padding, and pad will be set to 1.0. + this.pad = 1.2; + // prop: padMax + // Padding to extend the range above data bounds. + // The top of the data range is multiplied by this factor to determine maximum axis bounds. + // A value of 0 will be interpreted to mean no padding, and padMax will be set to 1.0. + this.padMax = null; + // prop: padMin + // Padding to extend the range below data bounds. + // The bottom of the data range is multiplied by this factor to determine minimum axis bounds. + // A value of 0 will be interpreted to mean no padding, and padMin will be set to 1.0. + this.padMin = null; + // prop: ticks + // 1D [val, val, ...] or 2D [[val, label], [val, label], ...] array of ticks for the axis. + // If no label is specified, the value is formatted into an appropriate label. + this.ticks = []; + // prop: numberTicks + // Desired number of ticks. Default is to compute automatically. + this.numberTicks; + // prop: tickInterval + // number of units between ticks. Mutually exclusive with numberTicks. + this.tickInterval; + // prop: renderer + // A class of a rendering engine that handles tick generation, + // scaling input data to pixel grid units and drawing the axis element. + this.renderer = $.jqplot.LinearAxisRenderer; + // prop: rendererOptions + // renderer specific options. See <$.jqplot.LinearAxisRenderer> for options. + this.rendererOptions = {}; + // prop: showTicks + // Wether to show the ticks (both marks and labels) or not. + // Will not override showMark and showLabel options if specified on the ticks themselves. + this.showTicks = true; + // prop: showTickMarks + // Wether to show the tick marks (line crossing grid) or not. + // Overridden by showTicks and showMark option of tick itself. + this.showTickMarks = true; + // prop: showMinorTicks + // Wether or not to show minor ticks. This is renderer dependent. + this.showMinorTicks = true; + // prop: drawMajorGridlines + // True to draw gridlines for major axis ticks. + this.drawMajorGridlines = true; + // prop: drawMinorGridlines + // True to draw gridlines for minor ticks. + this.drawMinorGridlines = false; + // prop: drawMajorTickMarks + // True to draw tick marks for major axis ticks. + this.drawMajorTickMarks = true; + // prop: drawMinorTickMarks + // True to draw tick marks for minor ticks. This is renderer dependent. + this.drawMinorTickMarks = true; + // prop: useSeriesColor + // Use the color of the first series associated with this axis for the + // tick marks and line bordering this axis. + this.useSeriesColor = false; + // prop: borderWidth + // width of line stroked at the border of the axis. Defaults + // to the width of the grid boarder. + this.borderWidth = null; + // prop: borderColor + // color of the border adjacent to the axis. Defaults to grid border color. + this.borderColor = null; + // prop: scaleToHiddenSeries + // True to include hidden series when computing axes bounds and scaling. + this.scaleToHiddenSeries = false; + // minimum and maximum values on the axis. + this._dataBounds = {min:null, max:null}; + // statistics (min, max, mean) as well as actual data intervals for each series attached to axis. + // holds collection of {intervals:[], min:, max:, mean: } objects for each series on axis. + this._intervalStats = []; + // pixel position from the top left of the min value and max value on the axis. + this._offsets = {min:null, max:null}; + this._ticks=[]; + this._label = null; + // prop: syncTicks + // true to try and synchronize tick spacing across multiple axes so that ticks and + // grid lines line up. This has an impact on autoscaling algorithm, however. + // In general, autoscaling an individual axis will work better if it does not + // have to sync ticks. + this.syncTicks = null; + // prop: tickSpacing + // Approximate pixel spacing between ticks on graph. Used during autoscaling. + // This number will be an upper bound, actual spacing will be less. + this.tickSpacing = 75; + // Properties to hold the original values for min, max, ticks, tickInterval and numberTicks + // so they can be restored if altered by plugins. + this._min = null; + this._max = null; + this._tickInterval = null; + this._numberTicks = null; + this.__ticks = null; + // hold original user options. + this._options = {}; + } + + Axis.prototype = new $.jqplot.ElemContainer(); + Axis.prototype.constructor = Axis; + + Axis.prototype.init = function() { + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } + // set the axis name + this.tickOptions.axis = this.name; + // if showMark or showLabel tick options not specified, use value of axis option. + // showTicks overrides showTickMarks. + if (this.tickOptions.showMark == null) { + this.tickOptions.showMark = this.showTicks; + } + if (this.tickOptions.showMark == null) { + this.tickOptions.showMark = this.showTickMarks; + } + if (this.tickOptions.showLabel == null) { + this.tickOptions.showLabel = this.showTicks; + } + + if (this.label == null || this.label == '') { + this.showLabel = false; + } + else { + this.labelOptions.label = this.label; + } + if (this.showLabel == false) { + this.labelOptions.show = false; + } + // set the default padMax, padMin if not specified + // special check, if no padding desired, padding + // should be set to 1.0 + if (this.pad == 0) { + this.pad = 1.0; + } + if (this.padMax == 0) { + this.padMax = 1.0; + } + if (this.padMin == 0) { + this.padMin = 1.0; + } + if (this.padMax == null) { + this.padMax = (this.pad-1)/2 + 1; + } + if (this.padMin == null) { + this.padMin = (this.pad-1)/2 + 1; + } + // now that padMin and padMax are correctly set, reset pad in case user has supplied + // padMin and/or padMax + this.pad = this.padMax + this.padMin - 1; + if (this.min != null || this.max != null) { + this.autoscale = false; + } + // if not set, sync ticks for y axes but not x by default. + if (this.syncTicks == null && this.name.indexOf('y') > -1) { + this.syncTicks = true; + } + else if (this.syncTicks == null){ + this.syncTicks = false; + } + this.renderer.init.call(this, this.rendererOptions); + + }; + + Axis.prototype.draw = function(ctx, plot) { + // Memory Leaks patch + if (this.__ticks) { + this.__ticks = null; + } + + return this.renderer.draw.call(this, ctx, plot); + + }; + + Axis.prototype.set = function() { + this.renderer.set.call(this); + }; + + Axis.prototype.pack = function(pos, offsets) { + if (this.show) { + this.renderer.pack.call(this, pos, offsets); + } + // these properties should all be available now. + if (this._min == null) { + this._min = this.min; + this._max = this.max; + this._tickInterval = this.tickInterval; + this._numberTicks = this.numberTicks; + this.__ticks = this._ticks; + } + }; + + // reset the axis back to original values if it has been scaled, zoomed, etc. + Axis.prototype.reset = function() { + this.renderer.reset.call(this); + }; + + Axis.prototype.resetScale = function(opts) { + $.extend(true, this, {min: null, max: null, numberTicks: null, tickInterval: null, _ticks: [], ticks: []}, opts); + this.resetDataBounds(); + }; + + Axis.prototype.resetDataBounds = function() { + // Go through all the series attached to this axis and find + // the min/max bounds for this axis. + var db = this._dataBounds; + db.min = null; + db.max = null; + var l, s, d; + // check for when to force min 0 on bar series plots. + var doforce = (this.show) ? true : false; + for (var i=0; i<this._series.length; i++) { + s = this._series[i]; + if (s.show || this.scaleToHiddenSeries) { + d = s._plotData; + if (s._type === 'line' && s.renderer.bands.show && this.name.charAt(0) !== 'x') { + d = [[0, s.renderer.bands._min], [1, s.renderer.bands._max]]; + } + + var minyidx = 1, maxyidx = 1; + + if (s._type != null && s._type == 'ohlc') { + minyidx = 3; + maxyidx = 2; + } + + for (var j=0, l=d.length; j<l; j++) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) { + db.min = d[j][0]; + } + if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) { + db.max = d[j][0]; + } + } + else { + if ((d[j][minyidx] != null && d[j][minyidx] < db.min) || db.min == null) { + db.min = d[j][minyidx]; + } + if ((d[j][maxyidx] != null && d[j][maxyidx] > db.max) || db.max == null) { + db.max = d[j][maxyidx]; + } + } + } + + // Hack to not pad out bottom of bar plots unless user has specified a padding. + // every series will have a chance to set doforce to false. once it is set to + // false, it cannot be reset to true. + // If any series attached to axis is not a bar, wont force 0. + if (doforce && s.renderer.constructor !== $.jqplot.BarRenderer) { + doforce = false; + } + + else if (doforce && this._options.hasOwnProperty('forceTickAt0') && this._options.forceTickAt0 == false) { + doforce = false; + } + + else if (doforce && s.renderer.constructor === $.jqplot.BarRenderer) { + if (s.barDirection == 'vertical' && this.name != 'xaxis' && this.name != 'x2axis') { + if (this._options.pad != null || this._options.padMin != null) { + doforce = false; + } + } + + else if (s.barDirection == 'horizontal' && (this.name == 'xaxis' || this.name == 'x2axis')) { + if (this._options.pad != null || this._options.padMin != null) { + doforce = false; + } + } + + } + } + } + + if (doforce && this.renderer.constructor === $.jqplot.LinearAxisRenderer && db.min >= 0) { + this.padMin = 1.0; + this.forceTickAt0 = true; + } + }; + + /** + * Class: Legend + * Legend object. Cannot be instantiated directly, but created + * by the Plot oject. Legend properties can be set or overriden by the + * options passed in from the user. + */ + function Legend(options) { + $.jqplot.ElemContainer.call(this); + // Group: Properties + + // prop: show + // Wether to display the legend on the graph. + this.show = false; + // prop: location + // Placement of the legend. one of the compass directions: nw, n, ne, e, se, s, sw, w + this.location = 'ne'; + // prop: labels + // Array of labels to use. By default the renderer will look for labels on the series. + // Labels specified in this array will override labels specified on the series. + this.labels = []; + // prop: showLabels + // true to show the label text on the legend. + this.showLabels = true; + // prop: showSwatch + // true to show the color swatches on the legend. + this.showSwatches = true; + // prop: placement + // "insideGrid" places legend inside the grid area of the plot. + // "outsideGrid" places the legend outside the grid but inside the plot container, + // shrinking the grid to accomodate the legend. + // "inside" synonym for "insideGrid", + // "outside" places the legend ouside the grid area, but does not shrink the grid which + // can cause the legend to overflow the plot container. + this.placement = "insideGrid"; + // prop: xoffset + // DEPRECATED. Set the margins on the legend using the marginTop, marginLeft, etc. + // properties or via CSS margin styling of the .jqplot-table-legend class. + this.xoffset = 0; + // prop: yoffset + // DEPRECATED. Set the margins on the legend using the marginTop, marginLeft, etc. + // properties or via CSS margin styling of the .jqplot-table-legend class. + this.yoffset = 0; + // prop: border + // css spec for the border around the legend box. + this.border; + // prop: background + // css spec for the background of the legend box. + this.background; + // prop: textColor + // css color spec for the legend text. + this.textColor; + // prop: fontFamily + // css font-family spec for the legend text. + this.fontFamily; + // prop: fontSize + // css font-size spec for the legend text. + this.fontSize ; + // prop: rowSpacing + // css padding-top spec for the rows in the legend. + this.rowSpacing = '0.5em'; + // renderer + // A class that will create a DOM object for the legend, + // see <$.jqplot.TableLegendRenderer>. + this.renderer = $.jqplot.TableLegendRenderer; + // prop: rendererOptions + // renderer specific options passed to the renderer. + this.rendererOptions = {}; + // prop: predraw + // Wether to draw the legend before the series or not. + // Used with series specific legend renderers for pie, donut, mekko charts, etc. + this.preDraw = false; + // prop: marginTop + // CSS margin for the legend DOM element. This will set an element + // CSS style for the margin which will override any style sheet setting. + // The default will be taken from the stylesheet. + this.marginTop = null; + // prop: marginRight + // CSS margin for the legend DOM element. This will set an element + // CSS style for the margin which will override any style sheet setting. + // The default will be taken from the stylesheet. + this.marginRight = null; + // prop: marginBottom + // CSS margin for the legend DOM element. This will set an element + // CSS style for the margin which will override any style sheet setting. + // The default will be taken from the stylesheet. + this.marginBottom = null; + // prop: marginLeft + // CSS margin for the legend DOM element. This will set an element + // CSS style for the margin which will override any style sheet setting. + // The default will be taken from the stylesheet. + this.marginLeft = null; + // prop: escapeHtml + // True to escape special characters with their html entity equivalents + // in legend text. "<" becomes < and so on, so html tags are not rendered. + this.escapeHtml = false; + this._series = []; + + $.extend(true, this, options); + } + + Legend.prototype = new $.jqplot.ElemContainer(); + Legend.prototype.constructor = Legend; + + Legend.prototype.setOptions = function(options) { + $.extend(true, this, options); + + // Try to emulate deprecated behaviour + // if user has specified xoffset or yoffset, copy these to + // the margin properties. + + if (this.placement == 'inside') { + this.placement = 'insideGrid'; + } + + if (this.xoffset >0) { + if (this.placement == 'insideGrid') { + switch (this.location) { + case 'nw': + case 'w': + case 'sw': + if (this.marginLeft == null) { + this.marginLeft = this.xoffset + 'px'; + } + this.marginRight = '0px'; + break; + case 'ne': + case 'e': + case 'se': + default: + if (this.marginRight == null) { + this.marginRight = this.xoffset + 'px'; + } + this.marginLeft = '0px'; + break; + } + } + else if (this.placement == 'outside') { + switch (this.location) { + case 'nw': + case 'w': + case 'sw': + if (this.marginRight == null) { + this.marginRight = this.xoffset + 'px'; + } + this.marginLeft = '0px'; + break; + case 'ne': + case 'e': + case 'se': + default: + if (this.marginLeft == null) { + this.marginLeft = this.xoffset + 'px'; + } + this.marginRight = '0px'; + break; + } + } + this.xoffset = 0; + } + + if (this.yoffset >0) { + if (this.placement == 'outside') { + switch (this.location) { + case 'sw': + case 's': + case 'se': + if (this.marginTop == null) { + this.marginTop = this.yoffset + 'px'; + } + this.marginBottom = '0px'; + break; + case 'ne': + case 'n': + case 'nw': + default: + if (this.marginBottom == null) { + this.marginBottom = this.yoffset + 'px'; + } + this.marginTop = '0px'; + break; + } + } + else if (this.placement == 'insideGrid') { + switch (this.location) { + case 'sw': + case 's': + case 'se': + if (this.marginBottom == null) { + this.marginBottom = this.yoffset + 'px'; + } + this.marginTop = '0px'; + break; + case 'ne': + case 'n': + case 'nw': + default: + if (this.marginTop == null) { + this.marginTop = this.yoffset + 'px'; + } + this.marginBottom = '0px'; + break; + } + } + this.yoffset = 0; + } + + // TO-DO: + // Handle case where offsets are < 0. + // + }; + + Legend.prototype.init = function() { + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } + this.renderer.init.call(this, this.rendererOptions); + }; + + Legend.prototype.draw = function(offsets, plot) { + for (var i=0; i<$.jqplot.preDrawLegendHooks.length; i++){ + $.jqplot.preDrawLegendHooks[i].call(this, offsets); + } + return this.renderer.draw.call(this, offsets, plot); + }; + + Legend.prototype.pack = function(offsets) { + this.renderer.pack.call(this, offsets); + }; + + /** + * Class: Title + * Plot Title object. Cannot be instantiated directly, but created + * by the Plot oject. Title properties can be set or overriden by the + * options passed in from the user. + * + * Parameters: + * text - text of the title. + */ + function Title(text) { + $.jqplot.ElemContainer.call(this); + // Group: Properties + + // prop: text + // text of the title; + this.text = text; + // prop: show + // wether or not to show the title + this.show = true; + // prop: fontFamily + // css font-family spec for the text. + this.fontFamily; + // prop: fontSize + // css font-size spec for the text. + this.fontSize ; + // prop: textAlign + // css text-align spec for the text. + this.textAlign; + // prop: textColor + // css color spec for the text. + this.textColor; + // prop: renderer + // A class for creating a DOM element for the title, + // see <$.jqplot.DivTitleRenderer>. + this.renderer = $.jqplot.DivTitleRenderer; + // prop: rendererOptions + // renderer specific options passed to the renderer. + this.rendererOptions = {}; + // prop: escapeHtml + // True to escape special characters with their html entity equivalents + // in title text. "<" becomes < and so on, so html tags are not rendered. + this.escapeHtml = false; + } + + Title.prototype = new $.jqplot.ElemContainer(); + Title.prototype.constructor = Title; + + Title.prototype.init = function() { + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } + this.renderer.init.call(this, this.rendererOptions); + }; + + Title.prototype.draw = function(width) { + return this.renderer.draw.call(this, width); + }; + + Title.prototype.pack = function() { + this.renderer.pack.call(this); + }; + + + /** + * Class: Series + * An individual data series object. Cannot be instantiated directly, but created + * by the Plot oject. Series properties can be set or overriden by the + * options passed in from the user. + */ + function Series(options) { + options = options || {}; + $.jqplot.ElemContainer.call(this); + // Group: Properties + // Properties will be assigned from a series array at the top level of the + // options. If you had two series and wanted to change the color and line + // width of the first and set the second to use the secondary y axis with + // no shadow and supply custom labels for each: + // > { + // > series:[ + // > {color: '#ff4466', lineWidth: 5, label:'good line'}, + // > {yaxis: 'y2axis', shadow: false, label:'bad line'} + // > ] + // > } + + // prop: show + // wether or not to draw the series. + this.show = true; + // prop: xaxis + // which x axis to use with this series, either 'xaxis' or 'x2axis'. + this.xaxis = 'xaxis'; + this._xaxis; + // prop: yaxis + // which y axis to use with this series, either 'yaxis' or 'y2axis'. + this.yaxis = 'yaxis'; + this._yaxis; + this.gridBorderWidth = 2.0; + // prop: renderer + // A class of a renderer which will draw the series, + // see <$.jqplot.LineRenderer>. + this.renderer = $.jqplot.LineRenderer; + // prop: rendererOptions + // Options to pass on to the renderer. + this.rendererOptions = {}; + this.data = []; + this.gridData = []; + // prop: label + // Line label to use in the legend. + this.label = ''; + // prop: showLabel + // true to show label for this series in the legend. + this.showLabel = true; + // prop: color + // css color spec for the series + this.color; + // prop: negativeColor + // css color spec used for filled (area) plots that are filled to zero and + // the "useNegativeColors" option is true. + this.negativeColor; + // prop: lineWidth + // width of the line in pixels. May have different meanings depending on renderer. + this.lineWidth = 2.5; + // prop: lineJoin + // Canvas lineJoin style between segments of series. + this.lineJoin = 'round'; + // prop: lineCap + // Canvas lineCap style at ends of line. + this.lineCap = 'round'; + // prop: linePattern + // line pattern 'dashed', 'dotted', 'solid', some combination + // of '-' and '.' characters such as '.-.' or a numerical array like + // [draw, skip, draw, skip, ...] such as [1, 10] to draw a dotted line, + // [1, 10, 20, 10] to draw a dot-dash line, and so on. + this.linePattern = 'solid'; + this.shadow = true; + // prop: shadowAngle + // Shadow angle in degrees + this.shadowAngle = 45; + // prop: shadowOffset + // Shadow offset from line in pixels + this.shadowOffset = 1.25; + // prop: shadowDepth + // Number of times shadow is stroked, each stroke offset shadowOffset from the last. + this.shadowDepth = 3; + // prop: shadowAlpha + // Alpha channel transparency of shadow. 0 = transparent. + this.shadowAlpha = '0.1'; + // prop: breakOnNull + // Wether line segments should be be broken at null value. + // False will join point on either side of line. + this.breakOnNull = false; + // prop: markerRenderer + // A class of a renderer which will draw marker (e.g. circle, square, ...) at the data points, + // see <$.jqplot.MarkerRenderer>. + this.markerRenderer = $.jqplot.MarkerRenderer; + // prop: markerOptions + // renderer specific options to pass to the markerRenderer, + // see <$.jqplot.MarkerRenderer>. + this.markerOptions = {}; + // prop: showLine + // wether to actually draw the line or not. Series will still be renderered, even if no line is drawn. + this.showLine = true; + // prop: showMarker + // wether or not to show the markers at the data points. + this.showMarker = true; + // prop: index + // 0 based index of this series in the plot series array. + this.index; + // prop: fill + // true or false, wether to fill under lines or in bars. + // May not be implemented in all renderers. + this.fill = false; + // prop: fillColor + // CSS color spec to use for fill under line. Defaults to line color. + this.fillColor; + // prop: fillAlpha + // Alpha transparency to apply to the fill under the line. + // Use this to adjust alpha separate from fill color. + this.fillAlpha; + // prop: fillAndStroke + // If true will stroke the line (with color this.color) as well as fill under it. + // Applies only when fill is true. + this.fillAndStroke = false; + // prop: disableStack + // true to not stack this series with other series in the plot. + // To render properly, non-stacked series must come after any stacked series + // in the plot's data series array. So, the plot's data series array would look like: + // > [stackedSeries1, stackedSeries2, ..., nonStackedSeries1, nonStackedSeries2, ...] + // disableStack will put a gap in the stacking order of series, and subsequent + // stacked series will not fill down through the non-stacked series and will + // most likely not stack properly on top of the non-stacked series. + this.disableStack = false; + // _stack is set by the Plot if the plot is a stacked chart. + // will stack lines or bars on top of one another to build a "mountain" style chart. + // May not be implemented in all renderers. + this._stack = false; + // prop: neighborThreshold + // how close or far (in pixels) the cursor must be from a point marker to detect the point. + this.neighborThreshold = 4; + // prop: fillToZero + // true will force bar and filled series to fill toward zero on the fill Axis. + this.fillToZero = false; + // prop: fillToValue + // fill a filled series to this value on the fill axis. + // Works in conjunction with fillToZero, so that must be true. + this.fillToValue = 0; + // prop: fillAxis + // Either 'x' or 'y'. Which axis to fill the line toward if fillToZero is true. + // 'y' means fill up/down to 0 on the y axis for this series. + this.fillAxis = 'y'; + // prop: useNegativeColors + // true to color negative values differently in filled and bar charts. + this.useNegativeColors = true; + this._stackData = []; + // _plotData accounts for stacking. If plots not stacked, _plotData and data are same. If + // stacked, _plotData is accumulation of stacking data. + this._plotData = []; + // _plotValues hold the individual x and y values that will be plotted for this series. + this._plotValues = {x:[], y:[]}; + // statistics about the intervals between data points. Used for auto scaling. + this._intervals = {x:{}, y:{}}; + // data from the previous series, for stacked charts. + this._prevPlotData = []; + this._prevGridData = []; + this._stackAxis = 'y'; + this._primaryAxis = '_xaxis'; + // give each series a canvas to draw on. This should allow for redrawing speedups. + this.canvas = new $.jqplot.GenericCanvas(); + this.shadowCanvas = new $.jqplot.GenericCanvas(); + this.plugins = {}; + // sum of y values in this series. + this._sumy = 0; + this._sumx = 0; + this._type = ''; + } + + Series.prototype = new $.jqplot.ElemContainer(); + Series.prototype.constructor = Series; + + Series.prototype.init = function(index, gridbw, plot) { + // weed out any null values in the data. + this.index = index; + this.gridBorderWidth = gridbw; + var d = this.data; + var temp = [], i, l; + for (i=0, l=d.length; i<l; i++) { + if (! this.breakOnNull) { + if (d[i] == null || d[i][0] == null || d[i][1] == null) { + continue; + } + else { + temp.push(d[i]); + } + } + else { + // TODO: figure out what to do with null values + // probably involve keeping nulls in data array + // and then updating renderers to break line + // when it hits null value. + // For now, just keep value. + temp.push(d[i]); + } + } + this.data = temp; + + // parse the renderer options and apply default colors if not provided + // Set color even if not shown, so series don't change colors when other + // series on plot shown/hidden. + if (!this.color) { + this.color = plot.colorGenerator.get(this.index); + } + if (!this.negativeColor) { + this.negativeColor = plot.negativeColorGenerator.get(this.index); + } + + + if (!this.fillColor) { + this.fillColor = this.color; + } + if (this.fillAlpha) { + var comp = $.jqplot.normalize2rgb(this.fillColor); + var comp = $.jqplot.getColorComponents(comp); + this.fillColor = 'rgba('+comp[0]+','+comp[1]+','+comp[2]+','+this.fillAlpha+')'; + } + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } + this.renderer.init.call(this, this.rendererOptions, plot); + this.markerRenderer = new this.markerRenderer(); + if (!this.markerOptions.color) { + this.markerOptions.color = this.color; + } + if (this.markerOptions.show == null) { + this.markerOptions.show = this.showMarker; + } + this.showMarker = this.markerOptions.show; + // the markerRenderer is called within it's own scaope, don't want to overwrite series options!! + this.markerRenderer.init(this.markerOptions); + }; + + // data - optional data point array to draw using this series renderer + // gridData - optional grid data point array to draw using this series renderer + // stackData - array of cumulative data for stacked plots. + Series.prototype.draw = function(sctx, opts, plot) { + var options = (opts == undefined) ? {} : opts; + sctx = (sctx == undefined) ? this.canvas._ctx : sctx; + + var j, data, gridData; + + // hooks get called even if series not shown + // we don't clear canvas here, it would wipe out all other series as well. + for (j=0; j<$.jqplot.preDrawSeriesHooks.length; j++) { + $.jqplot.preDrawSeriesHooks[j].call(this, sctx, options); + } + if (this.show) { + this.renderer.setGridData.call(this, plot); + if (!options.preventJqPlotSeriesDrawTrigger) { + $(sctx.canvas).trigger('jqplotSeriesDraw', [this.data, this.gridData]); + } + data = []; + if (options.data) { + data = options.data; + } + else if (!this._stack) { + data = this.data; + } + else { + data = this._plotData; + } + gridData = options.gridData || this.renderer.makeGridData.call(this, data, plot); + + if (this._type === 'line' && this.renderer.smooth && this.renderer._smoothedData.length) { + gridData = this.renderer._smoothedData; + } + + this.renderer.draw.call(this, sctx, gridData, options, plot); + } + + for (j=0; j<$.jqplot.postDrawSeriesHooks.length; j++) { + $.jqplot.postDrawSeriesHooks[j].call(this, sctx, options, plot); + } + + sctx = opts = plot = j = data = gridData = null; + }; + + Series.prototype.drawShadow = function(sctx, opts, plot) { + var options = (opts == undefined) ? {} : opts; + sctx = (sctx == undefined) ? this.shadowCanvas._ctx : sctx; + + var j, data, gridData; + + // hooks get called even if series not shown + // we don't clear canvas here, it would wipe out all other series as well. + for (j=0; j<$.jqplot.preDrawSeriesShadowHooks.length; j++) { + $.jqplot.preDrawSeriesShadowHooks[j].call(this, sctx, options); + } + if (this.shadow) { + this.renderer.setGridData.call(this, plot); + + data = []; + if (options.data) { + data = options.data; + } + else if (!this._stack) { + data = this.data; + } + else { + data = this._plotData; + } + gridData = options.gridData || this.renderer.makeGridData.call(this, data, plot); + + this.renderer.drawShadow.call(this, sctx, gridData, options, plot); + } + + for (j=0; j<$.jqplot.postDrawSeriesShadowHooks.length; j++) { + $.jqplot.postDrawSeriesShadowHooks[j].call(this, sctx, options); + } + + sctx = opts = plot = j = data = gridData = null; + + }; + + // toggles series display on plot, e.g. show/hide series + Series.prototype.toggleDisplay = function(ev, callback) { + var s, speed; + if (ev.data.series) { + s = ev.data.series; + } + else { + s = this; + } + + if (ev.data.speed) { + speed = ev.data.speed; + } + if (speed) { + // this can be tricky because series may not have a canvas element if replotting. + if (s.canvas._elem.is(':hidden') || !s.show) { + s.show = true; + + s.canvas._elem.removeClass('jqplot-series-hidden'); + if (s.shadowCanvas._elem) { + s.shadowCanvas._elem.fadeIn(speed); + } + s.canvas._elem.fadeIn(speed, callback); + s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).fadeIn(speed); + } + else { + s.show = false; + + s.canvas._elem.addClass('jqplot-series-hidden'); + if (s.shadowCanvas._elem) { + s.shadowCanvas._elem.fadeOut(speed); + } + s.canvas._elem.fadeOut(speed, callback); + s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).fadeOut(speed); + } + } + else { + // this can be tricky because series may not have a canvas element if replotting. + if (s.canvas._elem.is(':hidden') || !s.show) { + s.show = true; + + s.canvas._elem.removeClass('jqplot-series-hidden'); + if (s.shadowCanvas._elem) { + s.shadowCanvas._elem.show(); + } + s.canvas._elem.show(0, callback); + s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).show(); + } + else { + s.show = false; + + s.canvas._elem.addClass('jqplot-series-hidden'); + if (s.shadowCanvas._elem) { + s.shadowCanvas._elem.hide(); + } + s.canvas._elem.hide(0, callback); + s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).hide(); + } + } + }; + + + + /** + * Class: Grid + * + * Object representing the grid on which the plot is drawn. The grid in this + * context is the area bounded by the axes, the area which will contain the series. + * Note, the series are drawn on their own canvas. + * The Grid object cannot be instantiated directly, but is created by the Plot oject. + * Grid properties can be set or overriden by the options passed in from the user. + */ + function Grid() { + $.jqplot.ElemContainer.call(this); + // Group: Properties + + // prop: drawGridlines + // wether to draw the gridlines on the plot. + this.drawGridlines = true; + // prop: gridLineColor + // color of the grid lines. + this.gridLineColor = '#cccccc'; + // prop: gridLineWidth + // width of the grid lines. + this.gridLineWidth = 1.0; + // prop: background + // css spec for the background color. + this.background = '#fffdf6'; + // prop: borderColor + // css spec for the color of the grid border. + this.borderColor = '#999999'; + // prop: borderWidth + // width of the border in pixels. + this.borderWidth = 2.0; + // prop: drawBorder + // True to draw border around grid. + this.drawBorder = true; + // prop: shadow + // wether to show a shadow behind the grid. + this.shadow = true; + // prop: shadowAngle + // shadow angle in degrees + this.shadowAngle = 45; + // prop: shadowOffset + // Offset of each shadow stroke from the border in pixels + this.shadowOffset = 1.5; + // prop: shadowWidth + // width of the stoke for the shadow + this.shadowWidth = 3; + // prop: shadowDepth + // Number of times shadow is stroked, each stroke offset shadowOffset from the last. + this.shadowDepth = 3; + // prop: shadowColor + // an optional css color spec for the shadow in 'rgba(n, n, n, n)' form + this.shadowColor = null; + // prop: shadowAlpha + // Alpha channel transparency of shadow. 0 = transparent. + this.shadowAlpha = '0.07'; + this._left; + this._top; + this._right; + this._bottom; + this._width; + this._height; + this._axes = []; + // prop: renderer + // Instance of a renderer which will actually render the grid, + // see <$.jqplot.CanvasGridRenderer>. + this.renderer = $.jqplot.CanvasGridRenderer; + // prop: rendererOptions + // Options to pass on to the renderer, + // see <$.jqplot.CanvasGridRenderer>. + this.rendererOptions = {}; + this._offsets = {top:null, bottom:null, left:null, right:null}; + } + + Grid.prototype = new $.jqplot.ElemContainer(); + Grid.prototype.constructor = Grid; + + Grid.prototype.init = function() { + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } + this.renderer.init.call(this, this.rendererOptions); + }; + + Grid.prototype.createElement = function(offsets,plot) { + this._offsets = offsets; + return this.renderer.createElement.call(this, plot); + }; + + Grid.prototype.draw = function() { + this.renderer.draw.call(this); + }; + + $.jqplot.GenericCanvas = function() { + $.jqplot.ElemContainer.call(this); + this._ctx; + }; + + $.jqplot.GenericCanvas.prototype = new $.jqplot.ElemContainer(); + $.jqplot.GenericCanvas.prototype.constructor = $.jqplot.GenericCanvas; + + $.jqplot.GenericCanvas.prototype.createElement = function(offsets, clss, plotDimensions, plot) { + this._offsets = offsets; + var klass = 'jqplot'; + if (clss != undefined) { + klass = clss; + } + var elem; + + elem = plot.canvasManager.getCanvas(); + + // if new plotDimensions supplied, use them. + if (plotDimensions != null) { + this._plotDimensions = plotDimensions; + } + + elem.width = this._plotDimensions.width - this._offsets.left - this._offsets.right; + elem.height = this._plotDimensions.height - this._offsets.top - this._offsets.bottom; + this._elem = $(elem); + this._elem.css({ position: 'absolute', left: this._offsets.left, top: this._offsets.top }); + + this._elem.addClass(klass); + + elem = plot.canvasManager.initCanvas(elem); + + elem = null; + return this._elem; + }; + + $.jqplot.GenericCanvas.prototype.setContext = function() { + this._ctx = this._elem.get(0).getContext("2d"); + return this._ctx; + }; + + // Memory Leaks patch + $.jqplot.GenericCanvas.prototype.resetCanvas = function() { + if (this._elem) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { + window.G_vmlCanvasManager.uninitElement(this._elem.get(0)); + } + + //this._elem.remove(); + this._elem.emptyForce(); + } + + this._ctx = null; + }; + + $.jqplot.HooksManager = function () { + this.hooks =[]; + this.args = []; + }; + + $.jqplot.HooksManager.prototype.addOnce = function(fn, args) { + args = args || []; + var havehook = false; + for (var i=0, l=this.hooks.length; i<l; i++) { + if (this.hooks[i] == fn) { + havehook = true; + } + } + if (!havehook) { + this.hooks.push(fn); + this.args.push(args); + } + }; + + $.jqplot.HooksManager.prototype.add = function(fn, args) { + args = args || []; + this.hooks.push(fn); + this.args.push(args); + }; + + $.jqplot.EventListenerManager = function () { + this.hooks =[]; + }; + + $.jqplot.EventListenerManager.prototype.addOnce = function(ev, fn) { + var havehook = false, h, i; + for (var i=0, l=this.hooks.length; i<l; i++) { + h = this.hooks[i]; + if (h[0] == ev && h[1] == fn) { + havehook = true; + } + } + if (!havehook) { + this.hooks.push([ev, fn]); + } + }; + + $.jqplot.EventListenerManager.prototype.add = function(ev, fn) { + this.hooks.push([ev, fn]); + }; + + + var _axisNames = ['yMidAxis', 'xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis']; + + /** + * Class: jqPlot + * Plot object returned by call to $.jqplot. Handles parsing user options, + * creating sub objects (Axes, legend, title, series) and rendering the plot. + */ + function jqPlot() { + // Group: Properties + // These properties are specified at the top of the options object + // like so: + // > { + // > axesDefaults:{min:0}, + // > series:[{color:'#6633dd'}], + // > title: 'A Plot' + // > } + // + + // prop: animate + // True to animate the series on initial plot draw (renderer dependent). + // Actual animation functionality must be supported in the renderer. + this.animate = false; + // prop: animateReplot + // True to animate series after a call to the replot() method. + // Use with caution! Replots can happen very frequently under + // certain circumstances (e.g. resizing, dragging points) and + // animation in these situations can cause problems. + this.animateReplot = false; + // prop: axes + // up to 4 axes are supported, each with it's own options, + // See <Axis> for axis specific options. + this.axes = {xaxis: new Axis('xaxis'), yaxis: new Axis('yaxis'), x2axis: new Axis('x2axis'), y2axis: new Axis('y2axis'), y3axis: new Axis('y3axis'), y4axis: new Axis('y4axis'), y5axis: new Axis('y5axis'), y6axis: new Axis('y6axis'), y7axis: new Axis('y7axis'), y8axis: new Axis('y8axis'), y9axis: new Axis('y9axis'), yMidAxis: new Axis('yMidAxis')}; + this.baseCanvas = new $.jqplot.GenericCanvas(); + // true to intercept right click events and fire a 'jqplotRightClick' event. + // this will also block the context menu. + this.captureRightClick = false; + // prop: data + // user's data. Data should *NOT* be specified in the options object, + // but be passed in as the second argument to the $.jqplot() function. + // The data property is described here soley for reference. + // The data should be in the form of an array of 2D or 1D arrays like + // > [ [[x1, y1], [x2, y2],...], [y1, y2, ...] ]. + this.data = []; + // prop: dataRenderer + // A callable which can be used to preprocess data passed into the plot. + // Will be called with 2 arguments, the plot data and a reference to the plot. + this.dataRenderer; + // prop: dataRendererOptions + // Options that will be passed to the dataRenderer. + // Can be of any type. + this.dataRendererOptions; + this.defaults = { + // prop: axesDefaults + // default options that will be applied to all axes. + // see <Axis> for axes options. + axesDefaults: {}, + axes: {xaxis:{}, yaxis:{}, x2axis:{}, y2axis:{}, y3axis:{}, y4axis:{}, y5axis:{}, y6axis:{}, y7axis:{}, y8axis:{}, y9axis:{}, yMidAxis:{}}, + // prop: seriesDefaults + // default options that will be applied to all series. + // see <Series> for series options. + seriesDefaults: {}, + series:[] + }; + // prop: defaultAxisStart + // 1-D data series are internally converted into 2-D [x,y] data point arrays + // by jqPlot. This is the default starting value for the missing x or y value. + // The added data will be a monotonically increasing series (e.g. [1, 2, 3, ...]) + // starting at this value. + this.defaultAxisStart = 1; + // this.doCustomEventBinding = true; + // prop: drawIfHidden + // True to execute the draw method even if the plot target is hidden. + // Generally, this should be false. Most plot elements will not be sized/ + // positioned correclty if renderered into a hidden container. To render into + // a hidden container, call the replot method when the container is shown. + this.drawIfHidden = false; + this.eventCanvas = new $.jqplot.GenericCanvas(); + // prop: fillBetween + // Fill between 2 line series in a plot. + // Options object: + // { + // series1: first index (0 based) of series in fill + // series2: second index (0 based) of series in fill + // color: color of fill [default fillColor of series1] + // baseSeries: fill will be drawn below this series (0 based index) + // fill: false to turn off fill [default true]. + // } + this.fillBetween = { + series1: null, + series2: null, + color: null, + baseSeries: 0, + fill: true + }; + // prop; fontFamily + // css spec for the font-family attribute. Default for the entire plot. + this.fontFamily; + // prop: fontSize + // css spec for the font-size attribute. Default for the entire plot. + this.fontSize; + // prop: grid + // See <Grid> for grid specific options. + this.grid = new Grid(); + // prop: legend + // see <$.jqplot.TableLegendRenderer> + this.legend = new Legend(); + // prop: noDataIndicator + // Options to set up a mock plot with a data loading indicator if no data is specified. + this.negativeSeriesColors = $.jqplot.config.defaultNegativeColors; + this.noDataIndicator = { + show: false, + indicator: 'Loading Data...', + axes: { + xaxis: { + min: 0, + max: 10, + tickInterval: 2, + show: true + }, + yaxis: { + min: 0, + max: 12, + tickInterval: 3, + show: true + } + } + }; + // container to hold all of the merged options. Convienence for plugins. + this.options = {}; + this.previousSeriesStack = []; + // Namespece to hold plugins. Generally non-renderer plugins add themselves to here. + this.plugins = {}; + // prop: series + // Array of series object options. + // see <Series> for series specific options. + this.series = []; + // array of series indicies. Keep track of order + // which series canvases are displayed, lowest + // to highest, back to front. + this.seriesStack = []; + // prop: seriesColors + // Ann array of CSS color specifications that will be applied, in order, + // to the series in the plot. Colors will wrap around so, if their + // are more series than colors, colors will be reused starting at the + // beginning. For pie charts, this specifies the colors of the slices. + this.seriesColors = $.jqplot.config.defaultColors; + // prop: sortData + // false to not sort the data passed in by the user. + // Many bar, stakced and other graphs as well as many plugins depend on + // having sorted data. + this.sortData = true; + // prop: stackSeries + // true or false, creates a stack or "mountain" plot. + // Not all series renderers may implement this option. + this.stackSeries = false; + // a shortcut for axis syncTicks options. Not implemented yet. + this.syncXTicks = true; + // a shortcut for axis syncTicks options. Not implemented yet. + this.syncYTicks = true; + // the jquery object for the dom target. + this.target = null; + // The id of the dom element to render the plot into + this.targetId = null; + // prop textColor + // css spec for the css color attribute. Default for the entire plot. + this.textColor; + // prop: title + // Title object. See <Title> for specific options. As a shortcut, you + // can specify the title option as just a string like: title: 'My Plot' + // and this will create a new title object with the specified text. + this.title = new Title(); + // Count how many times the draw method has been called while the plot is visible. + // Mostly used to test if plot has never been dran (=0), has been successfully drawn + // into a visible container once (=1) or draw more than once into a visible container. + // Can use this in tests to see if plot has been visibly drawn at least one time. + // After plot has been visibly drawn once, it generally doesn't need redrawn if its + // container is hidden and shown. + this._drawCount = 0; + // sum of y values for all series in plot. + // used in mekko chart. + this._sumy = 0; + this._sumx = 0; + // array to hold the cumulative stacked series data. + // used to ajust the individual series data, which won't have access to other + // series data. + this._stackData = []; + // array that holds the data to be plotted. This will be the series data + // merged with the the appropriate data from _stackData according to the stackAxis. + this._plotData = []; + this._width = null; + this._height = null; + this._plotDimensions = {height:null, width:null}; + this._gridPadding = {top:null, right:null, bottom:null, left:null}; + this._defaultGridPadding = {top:10, right:10, bottom:23, left:10}; + + this._addDomReference = $.jqplot.config.addDomReference; + + this.preInitHooks = new $.jqplot.HooksManager(); + this.postInitHooks = new $.jqplot.HooksManager(); + this.preParseOptionsHooks = new $.jqplot.HooksManager(); + this.postParseOptionsHooks = new $.jqplot.HooksManager(); + this.preDrawHooks = new $.jqplot.HooksManager(); + this.postDrawHooks = new $.jqplot.HooksManager(); + this.preDrawSeriesHooks = new $.jqplot.HooksManager(); + this.postDrawSeriesHooks = new $.jqplot.HooksManager(); + this.preDrawLegendHooks = new $.jqplot.HooksManager(); + this.addLegendRowHooks = new $.jqplot.HooksManager(); + this.preSeriesInitHooks = new $.jqplot.HooksManager(); + this.postSeriesInitHooks = new $.jqplot.HooksManager(); + this.preParseSeriesOptionsHooks = new $.jqplot.HooksManager(); + this.postParseSeriesOptionsHooks = new $.jqplot.HooksManager(); + this.eventListenerHooks = new $.jqplot.EventListenerManager(); + this.preDrawSeriesShadowHooks = new $.jqplot.HooksManager(); + this.postDrawSeriesShadowHooks = new $.jqplot.HooksManager(); + + this.colorGenerator = new $.jqplot.ColorGenerator(); + this.negativeColorGenerator = new $.jqplot.ColorGenerator(); + + this.canvasManager = new $.jqplot.CanvasManager(); + + this.themeEngine = new $.jqplot.ThemeEngine(); + + var seriesColorsIndex = 0; + + // Group: methods + // + // method: init + // sets the plot target, checks data and applies user + // options to plot. + this.init = function(target, data, options) { + options = options || {}; + for (var i=0; i<$.jqplot.preInitHooks.length; i++) { + $.jqplot.preInitHooks[i].call(this, target, data, options); + } + + for (var i=0; i<this.preInitHooks.hooks.length; i++) { + this.preInitHooks.hooks[i].call(this, target, data, options); + } + + this.targetId = '#'+target; + this.target = $('#'+target); + + ////// + // Add a reference to plot + ////// + if (this._addDomReference) { + this.target.data('jqplot', this); + } + // remove any error class that may be stuck on target. + this.target.removeClass('jqplot-error'); + if (!this.target.get(0)) { + throw "No plot target specified"; + } + + // make sure the target is positioned by some means and set css + if (this.target.css('position') == 'static') { + this.target.css('position', 'relative'); + } + if (!this.target.hasClass('jqplot-target')) { + this.target.addClass('jqplot-target'); + } + + // if no height or width specified, use a default. + if (!this.target.height()) { + var h; + if (options && options.height) { + h = parseInt(options.height, 10); + } + else if (this.target.attr('data-height')) { + h = parseInt(this.target.attr('data-height'), 10); + } + else { + h = parseInt($.jqplot.config.defaultHeight, 10); + } + this._height = h; + this.target.css('height', h+'px'); + } + else { + this._height = h = this.target.height(); + } + if (!this.target.width()) { + var w; + if (options && options.width) { + w = parseInt(options.width, 10); + } + else if (this.target.attr('data-width')) { + w = parseInt(this.target.attr('data-width'), 10); + } + else { + w = parseInt($.jqplot.config.defaultWidth, 10); + } + this._width = w; + this.target.css('width', w+'px'); + } + else { + this._width = w = this.target.width(); + } + + for (var i=0, l=_axisNames.length; i<l; i++) { + this.axes[_axisNames[i]] = new Axis(_axisNames[i]); + } + + this._plotDimensions.height = this._height; + this._plotDimensions.width = this._width; + this.grid._plotDimensions = this._plotDimensions; + this.title._plotDimensions = this._plotDimensions; + this.baseCanvas._plotDimensions = this._plotDimensions; + this.eventCanvas._plotDimensions = this._plotDimensions; + this.legend._plotDimensions = this._plotDimensions; + if (this._height <=0 || this._width <=0 || !this._height || !this._width) { + throw "Canvas dimension not set"; + } + + if (options.dataRenderer && $.isFunction(options.dataRenderer)) { + if (options.dataRendererOptions) { + this.dataRendererOptions = options.dataRendererOptions; + } + this.dataRenderer = options.dataRenderer; + data = this.dataRenderer(data, this, this.dataRendererOptions); + } + + if (options.noDataIndicator && $.isPlainObject(options.noDataIndicator)) { + $.extend(true, this.noDataIndicator, options.noDataIndicator); + } + + if (data == null || $.isArray(data) == false || data.length == 0 || $.isArray(data[0]) == false || data[0].length == 0) { + + if (this.noDataIndicator.show == false) { + throw "No Data"; + } + + else { + // have to be descructive here in order for plot to not try and render series. + // This means that $.jqplot() will have to be called again when there is data. + //delete options.series; + + for (var ax in this.noDataIndicator.axes) { + for (var prop in this.noDataIndicator.axes[ax]) { + this.axes[ax][prop] = this.noDataIndicator.axes[ax][prop]; + } + } + + this.postDrawHooks.add(function() { + var eh = this.eventCanvas.getHeight(); + var ew = this.eventCanvas.getWidth(); + var temp = $('<div class="jqplot-noData-container" style="position:absolute;"></div>'); + this.target.append(temp); + temp.height(eh); + temp.width(ew); + temp.css('top', this.eventCanvas._offsets.top); + temp.css('left', this.eventCanvas._offsets.left); + + var temp2 = $('<div class="jqplot-noData-contents" style="text-align:center; position:relative; margin-left:auto; margin-right:auto;"></div>'); + temp.append(temp2); + temp2.html(this.noDataIndicator.indicator); + var th = temp2.height(); + var tw = temp2.width(); + temp2.height(th); + temp2.width(tw); + temp2.css('top', (eh - th)/2 + 'px'); + }); + + } + } + + // make a copy of the data + this.data = $.extend(true, [], data); + + this.parseOptions(options); + + if (this.textColor) { + this.target.css('color', this.textColor); + } + if (this.fontFamily) { + this.target.css('font-family', this.fontFamily); + } + if (this.fontSize) { + this.target.css('font-size', this.fontSize); + } + + this.title.init(); + this.legend.init(); + this._sumy = 0; + this._sumx = 0; + this.computePlotData(); + for (var i=0; i<this.series.length; i++) { + // set default stacking order for series canvases + this.seriesStack.push(i); + this.previousSeriesStack.push(i); + this.series[i].shadowCanvas._plotDimensions = this._plotDimensions; + this.series[i].canvas._plotDimensions = this._plotDimensions; + for (var j=0; j<$.jqplot.preSeriesInitHooks.length; j++) { + $.jqplot.preSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + for (var j=0; j<this.preSeriesInitHooks.hooks.length; j++) { + this.preSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + // this.populatePlotData(this.series[i], i); + this.series[i]._plotDimensions = this._plotDimensions; + this.series[i].init(i, this.grid.borderWidth, this); + for (var j=0; j<$.jqplot.postSeriesInitHooks.length; j++) { + $.jqplot.postSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + for (var j=0; j<this.postSeriesInitHooks.hooks.length; j++) { + this.postSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + this._sumy += this.series[i]._sumy; + this._sumx += this.series[i]._sumx; + } + + var name, + axis; + for (var i=0, l=_axisNames.length; i<l; i++) { + name = _axisNames[i]; + axis = this.axes[name]; + axis._plotDimensions = this._plotDimensions; + axis.init(); + if (this.axes[name].borderColor == null) { + if (name.charAt(0) !== 'x' && axis.useSeriesColor === true && axis.show) { + axis.borderColor = axis._series[0].color; + } + else { + axis.borderColor = this.grid.borderColor; + } + } + } + + if (this.sortData) { + sortData(this.series); + } + this.grid.init(); + this.grid._axes = this.axes; + + this.legend._series = this.series; + + for (var i=0; i<$.jqplot.postInitHooks.length; i++) { + $.jqplot.postInitHooks[i].call(this, target, this.data, options); + } + + for (var i=0; i<this.postInitHooks.hooks.length; i++) { + this.postInitHooks.hooks[i].call(this, target, this.data, options); + } + }; + + // method: resetAxesScale + // Reset the specified axes min, max, numberTicks and tickInterval properties to null + // or reset these properties on all axes if no list of axes is provided. + // + // Parameters: + // axes - Boolean to reset or not reset all axes or an array or object of axis names to reset. + this.resetAxesScale = function(axes, options) { + var opts = options || {}; + var ax = axes || this.axes; + if (ax === true) { + ax = this.axes; + } + if ($.isArray(ax)) { + for (var i = 0; i < ax.length; i++) { + this.axes[ax[i]].resetScale(opts[ax[i]]); + } + } + else if (typeof(ax) === 'object') { + for (var name in ax) { + this.axes[name].resetScale(opts[name]); + } + } + }; + // method: reInitialize + // reinitialize plot for replotting. + // not called directly. + this.reInitialize = function (data, opts) { + // Plot should be visible and have a height and width. + // If plot doesn't have height and width for some + // reason, set it by other means. Plot must not have + // a display:none attribute, however. + + var options = $.extend(true, {}, this.options, opts); + + var target = this.targetId.substr(1); + var tdata = (data == null) ? this.data : data; + + for (var i=0; i<$.jqplot.preInitHooks.length; i++) { + $.jqplot.preInitHooks[i].call(this, target, tdata, options); + } + + for (var i=0; i<this.preInitHooks.hooks.length; i++) { + this.preInitHooks.hooks[i].call(this, target, tdata, options); + } + + this._height = this.target.height(); + this._width = this.target.width(); + + if (this._height <=0 || this._width <=0 || !this._height || !this._width) { + throw "Target dimension not set"; + } + + this._plotDimensions.height = this._height; + this._plotDimensions.width = this._width; + this.grid._plotDimensions = this._plotDimensions; + this.title._plotDimensions = this._plotDimensions; + this.baseCanvas._plotDimensions = this._plotDimensions; + this.eventCanvas._plotDimensions = this._plotDimensions; + this.legend._plotDimensions = this._plotDimensions; + + var name, + t, + j, + axis; + + for (var i=0, l=_axisNames.length; i<l; i++) { + name = _axisNames[i]; + axis = this.axes[name]; + + // Memory Leaks patch : clear ticks elements + t = axis._ticks; + for (var j = 0, tlen = t.length; j < tlen; j++) { + var el = t[j]._elem; + if (el) { + // if canvas renderer + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { + window.G_vmlCanvasManager.uninitElement(el.get(0)); + } + el.emptyForce(); + el = null; + t._elem = null; + } + } + t = null; + + delete axis.ticks; + delete axis._ticks; + this.axes[name] = new Axis(name); + this.axes[name]._plotWidth = this._width; + this.axes[name]._plotHeight = this._height; + } + + if (data) { + if (options.dataRenderer && $.isFunction(options.dataRenderer)) { + if (options.dataRendererOptions) { + this.dataRendererOptions = options.dataRendererOptions; + } + this.dataRenderer = options.dataRenderer; + data = this.dataRenderer(data, this, this.dataRendererOptions); + } + + // make a copy of the data + this.data = $.extend(true, [], data); + } + + if (opts) { + this.parseOptions(options); + } + + this.title._plotWidth = this._width; + + if (this.textColor) { + this.target.css('color', this.textColor); + } + if (this.fontFamily) { + this.target.css('font-family', this.fontFamily); + } + if (this.fontSize) { + this.target.css('font-size', this.fontSize); + } + + this.title.init(); + this.legend.init(); + this._sumy = 0; + this._sumx = 0; + + this.seriesStack = []; + this.previousSeriesStack = []; + + this.computePlotData(); + for (var i=0, l=this.series.length; i<l; i++) { + // set default stacking order for series canvases + this.seriesStack.push(i); + this.previousSeriesStack.push(i); + this.series[i].shadowCanvas._plotDimensions = this._plotDimensions; + this.series[i].canvas._plotDimensions = this._plotDimensions; + for (var j=0; j<$.jqplot.preSeriesInitHooks.length; j++) { + $.jqplot.preSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + for (var j=0; j<this.preSeriesInitHooks.hooks.length; j++) { + this.preSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + // this.populatePlotData(this.series[i], i); + this.series[i]._plotDimensions = this._plotDimensions; + this.series[i].init(i, this.grid.borderWidth, this); + for (var j=0; j<$.jqplot.postSeriesInitHooks.length; j++) { + $.jqplot.postSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + for (var j=0; j<this.postSeriesInitHooks.hooks.length; j++) { + this.postSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + this._sumy += this.series[i]._sumy; + this._sumx += this.series[i]._sumx; + } + + for (var i=0, l=_axisNames.length; i<l; i++) { + name = _axisNames[i]; + axis = this.axes[name]; + + axis._plotDimensions = this._plotDimensions; + axis.init(); + if (axis.borderColor == null) { + if (name.charAt(0) !== 'x' && axis.useSeriesColor === true && axis.show) { + axis.borderColor = axis._series[0].color; + } + else { + axis.borderColor = this.grid.borderColor; + } + } + } + + if (this.sortData) { + sortData(this.series); + } + this.grid.init(); + this.grid._axes = this.axes; + + this.legend._series = this.series; + + for (var i=0, l=$.jqplot.postInitHooks.length; i<l; i++) { + $.jqplot.postInitHooks[i].call(this, target, this.data, options); + } + + for (var i=0, l=this.postInitHooks.hooks.length; i<l; i++) { + this.postInitHooks.hooks[i].call(this, target, this.data, options); + } + }; + + + + // method: quickInit + // + // Quick reinitialization plot for replotting. + // Does not parse options ore recreate axes and series. + // not called directly. + this.quickInit = function () { + // Plot should be visible and have a height and width. + // If plot doesn't have height and width for some + // reason, set it by other means. Plot must not have + // a display:none attribute, however. + + this._height = this.target.height(); + this._width = this.target.width(); + + if (this._height <=0 || this._width <=0 || !this._height || !this._width) { + throw "Target dimension not set"; + } + + this._plotDimensions.height = this._height; + this._plotDimensions.width = this._width; + this.grid._plotDimensions = this._plotDimensions; + this.title._plotDimensions = this._plotDimensions; + this.baseCanvas._plotDimensions = this._plotDimensions; + this.eventCanvas._plotDimensions = this._plotDimensions; + this.legend._plotDimensions = this._plotDimensions; + + for (var n in this.axes) { + this.axes[n]._plotWidth = this._width; + this.axes[n]._plotHeight = this._height; + } + + this.title._plotWidth = this._width; + + if (this.textColor) { + this.target.css('color', this.textColor); + } + if (this.fontFamily) { + this.target.css('font-family', this.fontFamily); + } + if (this.fontSize) { + this.target.css('font-size', this.fontSize); + } + + this._sumy = 0; + this._sumx = 0; + this.computePlotData(); + for (var i=0; i<this.series.length; i++) { + // this.populatePlotData(this.series[i], i); + if (this.series[i]._type === 'line' && this.series[i].renderer.bands.show) { + this.series[i].renderer.initBands.call(this.series[i], this.series[i].renderer.options, this); + } + this.series[i]._plotDimensions = this._plotDimensions; + this.series[i].canvas._plotDimensions = this._plotDimensions; + //this.series[i].init(i, this.grid.borderWidth); + this._sumy += this.series[i]._sumy; + this._sumx += this.series[i]._sumx; + } + + var name; + + for (var j=0; j<12; j++) { + name = _axisNames[j]; + // Memory Leaks patch : clear ticks elements + var t = this.axes[name]._ticks; + for (var i = 0; i < t.length; i++) { + var el = t[i]._elem; + if (el) { + // if canvas renderer + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { + window.G_vmlCanvasManager.uninitElement(el.get(0)); + } + el.emptyForce(); + el = null; + t._elem = null; + } + } + t = null; + + this.axes[name]._plotDimensions = this._plotDimensions; + this.axes[name]._ticks = []; + // this.axes[name].renderer.init.call(this.axes[name], {}); + } + + if (this.sortData) { + sortData(this.series); + } + + this.grid._axes = this.axes; + + this.legend._series = this.series; + }; + + // sort the series data in increasing order. + function sortData(series) { + var d, sd, pd, ppd, ret; + for (var i=0; i<series.length; i++) { + var check; + var bat = [series[i].data, series[i]._stackData, series[i]._plotData, series[i]._prevPlotData]; + for (var n=0; n<4; n++) { + check = true; + d = bat[n]; + if (series[i]._stackAxis == 'x') { + for (var j = 0; j < d.length; j++) { + if (typeof(d[j][1]) != "number") { + check = false; + break; + } + } + if (check) { + d.sort(function(a,b) { return a[1] - b[1]; }); + } + } + else { + for (var j = 0; j < d.length; j++) { + if (typeof(d[j][0]) != "number") { + check = false; + break; + } + } + if (check) { + d.sort(function(a,b) { return a[0] - b[0]; }); + } + } + } + + } + } + + this.computePlotData = function() { + this._plotData = []; + this._stackData = []; + var series, + index, + l; + + + for (index=0, l=this.series.length; index<l; index++) { + series = this.series[index]; + this._plotData.push([]); + this._stackData.push([]); + var cd = series.data; + this._plotData[index] = $.extend(true, [], cd); + this._stackData[index] = $.extend(true, [], cd); + series._plotData = this._plotData[index]; + series._stackData = this._stackData[index]; + var plotValues = {x:[], y:[]}; + + if (this.stackSeries && !series.disableStack) { + series._stack = true; + /////////////////////////// + // have to check for nulls + /////////////////////////// + var sidx = (series._stackAxis === 'x') ? 0 : 1; + + for (var k=0, cdl=cd.length; k<cdl; k++) { + var temp = cd[k][sidx]; + if (temp == null) { + temp = 0; + } + this._plotData[index][k][sidx] = temp; + this._stackData[index][k][sidx] = temp; + + if (index > 0) { + for (var j=index; j--;) { + var prevval = this._plotData[j][k][sidx]; + // only need to sum up the stack axis column of data + // and only sum if it is of same sign. + // if previous series isn't same sign, keep looking + // at earlier series untill we find one of same sign. + if (temp * prevval >= 0) { + this._plotData[index][k][sidx] += prevval; + this._stackData[index][k][sidx] += prevval; + break; + } + } + } + } + + } + else { + for (var i=0; i<series.data.length; i++) { + plotValues.x.push(series.data[i][0]); + plotValues.y.push(series.data[i][1]); + } + this._stackData.push(series.data); + this.series[index]._stackData = series.data; + this._plotData.push(series.data); + series._plotData = series.data; + series._plotValues = plotValues; + } + if (index>0) { + series._prevPlotData = this.series[index-1]._plotData; + } + series._sumy = 0; + series._sumx = 0; + for (i=series.data.length-1; i>-1; i--) { + series._sumy += series.data[i][1]; + series._sumx += series.data[i][0]; + } + } + + }; + + // populate the _stackData and _plotData arrays for the plot and the series. + this.populatePlotData = function(series, index) { + // if a stacked chart, compute the stacked data + this._plotData = []; + this._stackData = []; + series._stackData = []; + series._plotData = []; + var plotValues = {x:[], y:[]}; + if (this.stackSeries && !series.disableStack) { + series._stack = true; + var sidx = (series._stackAxis === 'x') ? 0 : 1; + // var idx = sidx ? 0 : 1; + // push the current data into stackData + //this._stackData.push(this.series[i].data); + var temp = $.extend(true, [], series.data); + // create the data that will be plotted for this series + var plotdata = $.extend(true, [], series.data); + var tempx, tempy, dval, stackval, comparator; + // for first series, nothing to add to stackData. + for (var j=0; j<index; j++) { + var cd = this.series[j].data; + for (var k=0; k<cd.length; k++) { + dval = cd[k]; + tempx = (dval[0] != null) ? dval[0] : 0; + tempy = (dval[1] != null) ? dval[1] : 0; + temp[k][0] += tempx; + temp[k][1] += tempy; + stackval = (sidx) ? tempy : tempx; + // only need to sum up the stack axis column of data + // and only sum if it is of same sign. + if (series.data[k][sidx] * stackval >= 0) { + plotdata[k][sidx] += stackval; + } + } + } + for (var i=0; i<plotdata.length; i++) { + plotValues.x.push(plotdata[i][0]); + plotValues.y.push(plotdata[i][1]); + } + this._plotData.push(plotdata); + this._stackData.push(temp); + series._stackData = temp; + series._plotData = plotdata; + series._plotValues = plotValues; + } + else { + for (var i=0; i<series.data.length; i++) { + plotValues.x.push(series.data[i][0]); + plotValues.y.push(series.data[i][1]); + } + this._stackData.push(series.data); + this.series[index]._stackData = series.data; + this._plotData.push(series.data); + series._plotData = series.data; + series._plotValues = plotValues; + } + if (index>0) { + series._prevPlotData = this.series[index-1]._plotData; + } + series._sumy = 0; + series._sumx = 0; + for (i=series.data.length-1; i>-1; i--) { + series._sumy += series.data[i][1]; + series._sumx += series.data[i][0]; + } + }; + + // function to safely return colors from the color array and wrap around at the end. + this.getNextSeriesColor = (function(t) { + var idx = 0; + var sc = t.seriesColors; + + return function () { + if (idx < sc.length) { + return sc[idx++]; + } + else { + idx = 0; + return sc[idx++]; + } + }; + })(this); + + this.parseOptions = function(options){ + for (var i=0; i<this.preParseOptionsHooks.hooks.length; i++) { + this.preParseOptionsHooks.hooks[i].call(this, options); + } + for (var i=0; i<$.jqplot.preParseOptionsHooks.length; i++) { + $.jqplot.preParseOptionsHooks[i].call(this, options); + } + this.options = $.extend(true, {}, this.defaults, options); + var opts = this.options; + this.animate = opts.animate; + this.animateReplot = opts.animateReplot; + this.stackSeries = opts.stackSeries; + if ($.isPlainObject(opts.fillBetween)) { + + var temp = ['series1', 'series2', 'color', 'baseSeries', 'fill'], + tempi; + + for (var i=0, l=temp.length; i<l; i++) { + tempi = temp[i]; + if (opts.fillBetween[tempi] != null) { + this.fillBetween[tempi] = opts.fillBetween[tempi]; + } + } + } + + if (opts.seriesColors) { + this.seriesColors = opts.seriesColors; + } + if (opts.negativeSeriesColors) { + this.negativeSeriesColors = opts.negativeSeriesColors; + } + if (opts.captureRightClick) { + this.captureRightClick = opts.captureRightClick; + } + this.defaultAxisStart = (options && options.defaultAxisStart != null) ? options.defaultAxisStart : this.defaultAxisStart; + this.colorGenerator.setColors(this.seriesColors); + this.negativeColorGenerator.setColors(this.negativeSeriesColors); + // var cg = new this.colorGenerator(this.seriesColors); + // var ncg = new this.colorGenerator(this.negativeSeriesColors); + // this._gridPadding = this.options.gridPadding; + $.extend(true, this._gridPadding, opts.gridPadding); + this.sortData = (opts.sortData != null) ? opts.sortData : this.sortData; + for (var i=0; i<12; i++) { + var n = _axisNames[i]; + var axis = this.axes[n]; + axis._options = $.extend(true, {}, opts.axesDefaults, opts.axes[n]); + $.extend(true, axis, opts.axesDefaults, opts.axes[n]); + axis._plotWidth = this._width; + axis._plotHeight = this._height; + } + // if (this.data.length == 0) { + // this.data = []; + // for (var i=0; i<this.options.series.length; i++) { + // this.data.push(this.options.series.data); + // } + // } + + var normalizeData = function(data, dir, start) { + // return data as an array of point arrays, + // in form [[x1,y1...], [x2,y2...], ...] + var temp = []; + var i, l; + dir = dir || 'vertical'; + if (!$.isArray(data[0])) { + // we have a series of scalars. One line with just y values. + // turn the scalar list of data into a data array of form: + // [[1, data[0]], [2, data[1]], ...] + for (i=0, l=data.length; i<l; i++) { + if (dir == 'vertical') { + temp.push([start + i, data[i]]); + } + else { + temp.push([data[i], start+i]); + } + } + } + else { + // we have a properly formatted data series, copy it. + $.extend(true, temp, data); + } + return temp; + }; + + var colorIndex = 0; + this.series = []; + for (var i=0; i<this.data.length; i++) { + var sopts = $.extend(true, {index: i}, {seriesColors:this.seriesColors, negativeSeriesColors:this.negativeSeriesColors}, this.options.seriesDefaults, this.options.series[i], {rendererOptions:{animation:{show: this.animate}}}); + // pass in options in case something needs set prior to initialization. + var temp = new Series(sopts); + for (var j=0; j<$.jqplot.preParseSeriesOptionsHooks.length; j++) { + $.jqplot.preParseSeriesOptionsHooks[j].call(temp, this.options.seriesDefaults, this.options.series[i]); + } + for (var j=0; j<this.preParseSeriesOptionsHooks.hooks.length; j++) { + this.preParseSeriesOptionsHooks.hooks[j].call(temp, this.options.seriesDefaults, this.options.series[i]); + } + // Now go back and apply the options to the series. Really should just do this during initializaiton, but don't want to + // mess up preParseSeriesOptionsHooks at this point. + $.extend(true, temp, sopts); + var dir = 'vertical'; + if (temp.renderer === $.jqplot.BarRenderer && temp.rendererOptions && temp.rendererOptions.barDirection == 'horizontal') { + dir = 'horizontal'; + temp._stackAxis = 'x'; + temp._primaryAxis = '_yaxis'; + } + temp.data = normalizeData(this.data[i], dir, this.defaultAxisStart); + switch (temp.xaxis) { + case 'xaxis': + temp._xaxis = this.axes.xaxis; + break; + case 'x2axis': + temp._xaxis = this.axes.x2axis; + break; + default: + break; + } + temp._yaxis = this.axes[temp.yaxis]; + temp._xaxis._series.push(temp); + temp._yaxis._series.push(temp); + if (temp.show) { + temp._xaxis.show = true; + temp._yaxis.show = true; + } + else { + if (temp._xaxis.scaleToHiddenSeries) { + temp._xaxis.show = true; + } + if (temp._yaxis.scaleToHiddenSeries) { + temp._yaxis.show = true; + } + } + + // // parse the renderer options and apply default colors if not provided + // if (!temp.color && temp.show != false) { + // temp.color = cg.next(); + // colorIndex = cg.getIndex() - 1;; + // } + // if (!temp.negativeColor && temp.show != false) { + // temp.negativeColor = ncg.get(colorIndex); + // ncg.setIndex(colorIndex); + // } + if (!temp.label) { + temp.label = 'Series '+ (i+1).toString(); + } + // temp.rendererOptions.show = temp.show; + // $.extend(true, temp.renderer, {color:this.seriesColors[i]}, this.rendererOptions); + this.series.push(temp); + for (var j=0; j<$.jqplot.postParseSeriesOptionsHooks.length; j++) { + $.jqplot.postParseSeriesOptionsHooks[j].call(this.series[i], this.options.seriesDefaults, this.options.series[i]); + } + for (var j=0; j<this.postParseSeriesOptionsHooks.hooks.length; j++) { + this.postParseSeriesOptionsHooks.hooks[j].call(this.series[i], this.options.seriesDefaults, this.options.series[i]); + } + } + + // copy the grid and title options into this object. + $.extend(true, this.grid, this.options.grid); + // if axis border properties aren't set, set default. + for (var i=0, l=_axisNames.length; i<l; i++) { + var n = _axisNames[i]; + var axis = this.axes[n]; + if (axis.borderWidth == null) { + axis.borderWidth =this.grid.borderWidth; + } + } + + if (typeof this.options.title == 'string') { + this.title.text = this.options.title; + } + else if (typeof this.options.title == 'object') { + $.extend(true, this.title, this.options.title); + } + this.title._plotWidth = this._width; + this.legend.setOptions(this.options.legend); + + for (var i=0; i<$.jqplot.postParseOptionsHooks.length; i++) { + $.jqplot.postParseOptionsHooks[i].call(this, options); + } + for (var i=0; i<this.postParseOptionsHooks.hooks.length; i++) { + this.postParseOptionsHooks.hooks[i].call(this, options); + } + }; + + // method: destroy + // Releases all resources occupied by the plot + this.destroy = function() { + this.canvasManager.freeAllCanvases(); + if (this.eventCanvas && this.eventCanvas._elem) { + this.eventCanvas._elem.unbind(); + } + // Couple of posts on Stack Overflow indicate that empty() doesn't + // always cear up the dom and release memory. Sometimes setting + // innerHTML property to null is needed. Particularly on IE, may + // have to directly set it to null, bypassing $. + this.target.empty(); + + this.target[0].innerHTML = ''; + }; + + // method: replot + // Does a reinitialization of the plot followed by + // a redraw. Method could be used to interactively + // change plot characteristics and then replot. + // + // Parameters: + // options - Options used for replotting. + // + // Properties: + // clear - false to not clear (empty) the plot container before replotting (default: true). + // resetAxes - true to reset all axes min, max, numberTicks and tickInterval setting so axes will rescale themselves. + // optionally pass in list of axes to reset (e.g. ['xaxis', 'y2axis']) (default: false). + this.replot = function(options) { + var opts = options || {}; + var data = opts.data || null; + var clear = (opts.clear === false) ? false : true; + var resetAxes = opts.resetAxes || false; + delete opts.data; + delete opts.clear; + delete opts.resetAxes; + + this.target.trigger('jqplotPreReplot'); + + if (clear) { + this.destroy(); + } + // if have data or other options, full reinit. + // otherwise, quickinit. + if (data || !$.isEmptyObject(opts)) { + this.reInitialize(data, opts); + } + else { + this.quickInit(); + } + + if (resetAxes) { + this.resetAxesScale(resetAxes, opts.axes); + } + this.draw(); + this.target.trigger('jqplotPostReplot'); + }; + + // method: redraw + // Empties the plot target div and redraws the plot. + // This enables plot data and properties to be changed + // and then to comletely clear the plot and redraw. + // redraw *will not* reinitialize any plot elements. + // That is, axes will not be autoscaled and defaults + // will not be reapplied to any plot elements. redraw + // is used primarily with zooming. + // + // Parameters: + // clear - false to not clear (empty) the plot container before redrawing (default: true). + this.redraw = function(clear) { + clear = (clear != null) ? clear : true; + this.target.trigger('jqplotPreRedraw'); + if (clear) { + this.canvasManager.freeAllCanvases(); + this.eventCanvas._elem.unbind(); + // Dont think I bind any events to the target, this shouldn't be necessary. + // It will remove user's events. + // this.target.unbind(); + this.target.empty(); + } + for (var ax in this.axes) { + this.axes[ax]._ticks = []; + } + this.computePlotData(); + // for (var i=0; i<this.series.length; i++) { + // this.populatePlotData(this.series[i], i); + // } + this._sumy = 0; + this._sumx = 0; + for (var i=0, tsl = this.series.length; i<tsl; i++) { + this._sumy += this.series[i]._sumy; + this._sumx += this.series[i]._sumx; + } + this.draw(); + this.target.trigger('jqplotPostRedraw'); + }; + + // method: draw + // Draws all elements of the plot into the container. + // Does not clear the container before drawing. + this.draw = function(){ + if (this.drawIfHidden || this.target.is(':visible')) { + this.target.trigger('jqplotPreDraw'); + var i, + j, + l, + tempseries; + for (i=0, l=$.jqplot.preDrawHooks.length; i<l; i++) { + $.jqplot.preDrawHooks[i].call(this); + } + for (i=0, l=this.preDrawHooks.length; i<l; i++) { + this.preDrawHooks.hooks[i].apply(this, this.preDrawSeriesHooks.args[i]); + } + // create an underlying canvas to be used for special features. + this.target.append(this.baseCanvas.createElement({left:0, right:0, top:0, bottom:0}, 'jqplot-base-canvas', null, this)); + this.baseCanvas.setContext(); + this.target.append(this.title.draw()); + this.title.pack({top:0, left:0}); + + // make room for the legend between the grid and the edge. + // pass a dummy offsets object and a reference to the plot. + var legendElem = this.legend.draw({}, this); + + var gridPadding = {top:0, left:0, bottom:0, right:0}; + + if (this.legend.placement == "outsideGrid") { + // temporarily append the legend to get dimensions + this.target.append(legendElem); + switch (this.legend.location) { + case 'n': + gridPadding.top += this.legend.getHeight(); + break; + case 's': + gridPadding.bottom += this.legend.getHeight(); + break; + case 'ne': + case 'e': + case 'se': + gridPadding.right += this.legend.getWidth(); + break; + case 'nw': + case 'w': + case 'sw': + gridPadding.left += this.legend.getWidth(); + break; + default: // same as 'ne' + gridPadding.right += this.legend.getWidth(); + break; + } + legendElem = legendElem.detach(); + } + + var ax = this.axes; + var name; + // draw the yMidAxis first, so xaxis of pyramid chart can adjust itself if needed. + for (i=0; i<12; i++) { + name = _axisNames[i]; + this.target.append(ax[name].draw(this.baseCanvas._ctx, this)); + ax[name].set(); + } + if (ax.yaxis.show) { + gridPadding.left += ax.yaxis.getWidth(); + } + var ra = ['y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis']; + var rapad = [0, 0, 0, 0, 0, 0, 0, 0]; + var gpr = 0; + var n; + for (n=0; n<8; n++) { + if (ax[ra[n]].show) { + gpr += ax[ra[n]].getWidth(); + rapad[n] = gpr; + } + } + gridPadding.right += gpr; + if (ax.x2axis.show) { + gridPadding.top += ax.x2axis.getHeight(); + } + if (this.title.show) { + gridPadding.top += this.title.getHeight(); + } + if (ax.xaxis.show) { + gridPadding.bottom += ax.xaxis.getHeight(); + } + + // end of gridPadding adjustments. + + // if user passed in gridDimensions option, check against calculated gridPadding + if (this.options.gridDimensions && $.isPlainObject(this.options.gridDimensions)) { + var gdw = parseInt(this.options.gridDimensions.width, 10) || 0; + var gdh = parseInt(this.options.gridDimensions.height, 10) || 0; + var widthAdj = (this._width - gridPadding.left - gridPadding.right - gdw)/2; + var heightAdj = (this._height - gridPadding.top - gridPadding.bottom - gdh)/2; + + if (heightAdj >= 0 && widthAdj >= 0) { + gridPadding.top += heightAdj; + gridPadding.bottom += heightAdj; + gridPadding.left += widthAdj; + gridPadding.right += widthAdj; + } + } + var arr = ['top', 'bottom', 'left', 'right']; + for (var n in arr) { + if (this._gridPadding[arr[n]] == null && gridPadding[arr[n]] > 0) { + this._gridPadding[arr[n]] = gridPadding[arr[n]]; + } + else if (this._gridPadding[arr[n]] == null) { + this._gridPadding[arr[n]] = this._defaultGridPadding[arr[n]]; + } + } + + var legendPadding = this._gridPadding; + + if (this.legend.placement === 'outsideGrid') { + legendPadding = {top:this.title.getHeight(), left: 0, right: 0, bottom: 0}; + if (this.legend.location === 's') { + legendPadding.left = this._gridPadding.left; + legendPadding.right = this._gridPadding.right; + } + } + + ax.xaxis.pack({position:'absolute', bottom:this._gridPadding.bottom - ax.xaxis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right}); + ax.yaxis.pack({position:'absolute', top:0, left:this._gridPadding.left - ax.yaxis.getWidth(), height:this._height}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top}); + ax.x2axis.pack({position:'absolute', top:this._gridPadding.top - ax.x2axis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right}); + for (i=8; i>0; i--) { + ax[ra[i-1]].pack({position:'absolute', top:0, right:this._gridPadding.right - rapad[i-1]}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top}); + } + var ltemp = (this._width - this._gridPadding.left - this._gridPadding.right)/2.0 + this._gridPadding.left - ax.yMidAxis.getWidth()/2.0; + ax.yMidAxis.pack({position:'absolute', top:0, left:ltemp, zIndex:9, textAlign: 'center'}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top}); + + this.target.append(this.grid.createElement(this._gridPadding, this)); + this.grid.draw(); + + var series = this.series; + var seriesLength = series.length; + // put the shadow canvases behind the series canvases so shadows don't overlap on stacked bars. + for (i=0, l=seriesLength; i<l; i++) { + // draw series in order of stacking. This affects only + // order in which canvases are added to dom. + j = this.seriesStack[i]; + this.target.append(series[j].shadowCanvas.createElement(this._gridPadding, 'jqplot-series-shadowCanvas', null, this)); + series[j].shadowCanvas.setContext(); + series[j].shadowCanvas._elem.data('seriesIndex', j); + } + + for (i=0, l=seriesLength; i<l; i++) { + // draw series in order of stacking. This affects only + // order in which canvases are added to dom. + j = this.seriesStack[i]; + this.target.append(series[j].canvas.createElement(this._gridPadding, 'jqplot-series-canvas', null, this)); + series[j].canvas.setContext(); + series[j].canvas._elem.data('seriesIndex', j); + } + // Need to use filled canvas to capture events in IE. + // Also, canvas seems to block selection of other elements in document on FF. + this.target.append(this.eventCanvas.createElement(this._gridPadding, 'jqplot-event-canvas', null, this)); + this.eventCanvas.setContext(); + this.eventCanvas._ctx.fillStyle = 'rgba(0,0,0,0)'; + this.eventCanvas._ctx.fillRect(0,0,this.eventCanvas._ctx.canvas.width, this.eventCanvas._ctx.canvas.height); + + // bind custom event handlers to regular events. + this.bindCustomEvents(); + + // draw legend before series if the series needs to know the legend dimensions. + if (this.legend.preDraw) { + this.eventCanvas._elem.before(legendElem); + this.legend.pack(legendPadding); + if (this.legend._elem) { + this.drawSeries({legendInfo:{location:this.legend.location, placement:this.legend.placement, width:this.legend.getWidth(), height:this.legend.getHeight(), xoffset:this.legend.xoffset, yoffset:this.legend.yoffset}}); + } + else { + this.drawSeries(); + } + } + else { // draw series before legend + this.drawSeries(); + if (seriesLength) { + $(series[seriesLength-1].canvas._elem).after(legendElem); + } + this.legend.pack(legendPadding); + } + + // register event listeners on the overlay canvas + for (var i=0, l=$.jqplot.eventListenerHooks.length; i<l; i++) { + // in the handler, this will refer to the eventCanvas dom element. + // make sure there are references back into plot objects. + this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]); + } + + // register event listeners on the overlay canvas + for (var i=0, l=this.eventListenerHooks.hooks.length; i<l; i++) { + // in the handler, this will refer to the eventCanvas dom element. + // make sure there are references back into plot objects. + this.eventCanvas._elem.bind(this.eventListenerHooks.hooks[i][0], {plot:this}, this.eventListenerHooks.hooks[i][1]); + } + + var fb = this.fillBetween; + if (fb.fill && fb.series1 !== fb.series2 && fb.series1 < seriesLength && fb.series2 < seriesLength && series[fb.series1]._type === 'line' && series[fb.series2]._type === 'line') { + this.doFillBetweenLines(); + } + + for (var i=0, l=$.jqplot.postDrawHooks.length; i<l; i++) { + $.jqplot.postDrawHooks[i].call(this); + } + + for (var i=0, l=this.postDrawHooks.hooks.length; i<l; i++) { + this.postDrawHooks.hooks[i].apply(this, this.postDrawHooks.args[i]); + } + + if (this.target.is(':visible')) { + this._drawCount += 1; + } + + var temps, + tempr, + sel, + _els; + // ughh. ideally would hide all series then show them. + for (i=0, l=seriesLength; i<l; i++) { + temps = series[i]; + tempr = temps.renderer; + sel = '.jqplot-point-label.jqplot-series-'+i; + if (tempr.animation && tempr.animation._supported && tempr.animation.show && (this._drawCount < 2 || this.animateReplot)) { + _els = this.target.find(sel); + _els.stop(true, true).hide(); + temps.canvas._elem.stop(true, true).hide(); + temps.shadowCanvas._elem.stop(true, true).hide(); + temps.canvas._elem.jqplotEffect('blind', {mode: 'show', direction: tempr.animation.direction}, tempr.animation.speed); + temps.shadowCanvas._elem.jqplotEffect('blind', {mode: 'show', direction: tempr.animation.direction}, tempr.animation.speed); + _els.fadeIn(tempr.animation.speed*0.8); + } + } + _els = null; + + this.target.trigger('jqplotPostDraw', [this]); + } + }; + + jqPlot.prototype.doFillBetweenLines = function () { + var fb = this.fillBetween; + var sid1 = fb.series1; + var sid2 = fb.series2; + // first series should always be lowest index + var id1 = (sid1 < sid2) ? sid1 : sid2; + var id2 = (sid2 > sid1) ? sid2 : sid1; + + var series1 = this.series[id1]; + var series2 = this.series[id2]; + + if (series2.renderer.smooth) { + var tempgd = series2.renderer._smoothedData.slice(0).reverse(); + } + else { + var tempgd = series2.gridData.slice(0).reverse(); + } + + if (series1.renderer.smooth) { + var gd = series1.renderer._smoothedData.concat(tempgd); + } + else { + var gd = series1.gridData.concat(tempgd); + } + + var color = (fb.color !== null) ? fb.color : this.series[sid1].fillColor; + var baseSeries = (fb.baseSeries !== null) ? fb.baseSeries : id1; + + // now apply a fill to the shape on the lower series shadow canvas, + // so it is behind both series. + var sr = this.series[baseSeries].renderer.shapeRenderer; + var opts = {fillStyle: color, fill: true, closePath: true}; + sr.draw(series1.shadowCanvas._ctx, gd, opts); + }; + + this.bindCustomEvents = function() { + this.eventCanvas._elem.bind('click', {plot:this}, this.onClick); + this.eventCanvas._elem.bind('dblclick', {plot:this}, this.onDblClick); + this.eventCanvas._elem.bind('mousedown', {plot:this}, this.onMouseDown); + this.eventCanvas._elem.bind('mousemove', {plot:this}, this.onMouseMove); + this.eventCanvas._elem.bind('mouseenter', {plot:this}, this.onMouseEnter); + this.eventCanvas._elem.bind('mouseleave', {plot:this}, this.onMouseLeave); + if (this.captureRightClick) { + this.eventCanvas._elem.bind('mouseup', {plot:this}, this.onRightClick); + this.eventCanvas._elem.get(0).oncontextmenu = function() { + return false; + }; + } + else { + this.eventCanvas._elem.bind('mouseup', {plot:this}, this.onMouseUp); + } + }; + + function getEventPosition(ev) { + var plot = ev.data.plot; + var go = plot.eventCanvas._elem.offset(); + var gridPos = {x:ev.pageX - go.left, y:ev.pageY - go.top}; + var dataPos = {xaxis:null, yaxis:null, x2axis:null, y2axis:null, y3axis:null, y4axis:null, y5axis:null, y6axis:null, y7axis:null, y8axis:null, y9axis:null, yMidAxis:null}; + var an = ['xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis', 'yMidAxis']; + var ax = plot.axes; + var n, axis; + for (n=11; n>0; n--) { + axis = an[n-1]; + if (ax[axis].show) { + dataPos[axis] = ax[axis].series_p2u(gridPos[axis.charAt(0)]); + } + } + + return {offsets:go, gridPos:gridPos, dataPos:dataPos}; + } + + + // function to check if event location is over a area area + function checkIntersection(gridpos, plot) { + var series = plot.series; + var i, j, k, s, r, x, y, theta, sm, sa, minang, maxang; + var d0, d, p, pp, points, bw, hp; + var threshold, t; + for (k=plot.seriesStack.length-1; k>=0; k--) { + i = plot.seriesStack[k]; + s = series[i]; + hp = s._highlightThreshold; + switch (s.renderer.constructor) { + case $.jqplot.BarRenderer: + x = gridpos.x; + y = gridpos.y; + for (j=0; j<s._barPoints.length; j++) { + points = s._barPoints[j]; + p = s.gridData[j]; + if (x>points[0][0] && x<points[2][0] && y>points[2][1] && y<points[0][1]) { + return {seriesIndex:s.index, pointIndex:j, gridData:p, data:s.data[j], points:s._barPoints[j]}; + } + } + break; + case $.jqplot.PyramidRenderer: + x = gridpos.x; + y = gridpos.y; + for (j=0; j<s._barPoints.length; j++) { + points = s._barPoints[j]; + p = s.gridData[j]; + if (x > points[0][0] + hp[0][0] && x < points[2][0] + hp[2][0] && y > points[2][1] && y < points[0][1]) { + return {seriesIndex:s.index, pointIndex:j, gridData:p, data:s.data[j], points:s._barPoints[j]}; + } + } + break; + + case $.jqplot.DonutRenderer: + sa = s.startAngle/180*Math.PI; + x = gridpos.x - s._center[0]; + y = gridpos.y - s._center[1]; + r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); + if (x > 0 && -y >= 0) { + theta = 2*Math.PI - Math.atan(-y/x); + } + else if (x > 0 && -y < 0) { + theta = -Math.atan(-y/x); + } + else if (x < 0) { + theta = Math.PI - Math.atan(-y/x); + } + else if (x == 0 && -y > 0) { + theta = 3*Math.PI/2; + } + else if (x == 0 && -y < 0) { + theta = Math.PI/2; + } + else if (x == 0 && y == 0) { + theta = 0; + } + if (sa) { + theta -= sa; + if (theta < 0) { + theta += 2*Math.PI; + } + else if (theta > 2*Math.PI) { + theta -= 2*Math.PI; + } + } + + sm = s.sliceMargin/180*Math.PI; + if (r < s._radius && r > s._innerRadius) { + for (j=0; j<s.gridData.length; j++) { + minang = (j>0) ? s.gridData[j-1][1]+sm : sm; + maxang = s.gridData[j][1]; + if (theta > minang && theta < maxang) { + return {seriesIndex:s.index, pointIndex:j, gridData:s.gridData[j], data:s.data[j]}; + } + } + } + break; + + case $.jqplot.PieRenderer: + sa = s.startAngle/180*Math.PI; + x = gridpos.x - s._center[0]; + y = gridpos.y - s._center[1]; + r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); + if (x > 0 && -y >= 0) { + theta = 2*Math.PI - Math.atan(-y/x); + } + else if (x > 0 && -y < 0) { + theta = -Math.atan(-y/x); + } + else if (x < 0) { + theta = Math.PI - Math.atan(-y/x); + } + else if (x == 0 && -y > 0) { + theta = 3*Math.PI/2; + } + else if (x == 0 && -y < 0) { + theta = Math.PI/2; + } + else if (x == 0 && y == 0) { + theta = 0; + } + if (sa) { + theta -= sa; + if (theta < 0) { + theta += 2*Math.PI; + } + else if (theta > 2*Math.PI) { + theta -= 2*Math.PI; + } + } + + sm = s.sliceMargin/180*Math.PI; + if (r < s._radius) { + for (j=0; j<s.gridData.length; j++) { + minang = (j>0) ? s.gridData[j-1][1]+sm : sm; + maxang = s.gridData[j][1]; + if (theta > minang && theta < maxang) { + return {seriesIndex:s.index, pointIndex:j, gridData:s.gridData[j], data:s.data[j]}; + } + } + } + break; + + case $.jqplot.BubbleRenderer: + x = gridpos.x; + y = gridpos.y; + var ret = null; + + if (s.show) { + for (var j=0; j<s.gridData.length; j++) { + p = s.gridData[j]; + d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) * (y-p[1]) ); + if (d <= p[2] && (d <= d0 || d0 == null)) { + d0 = d; + ret = {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + if (ret != null) { + return ret; + } + } + break; + + case $.jqplot.FunnelRenderer: + x = gridpos.x; + y = gridpos.y; + var v = s._vertices, + vfirst = v[0], + vlast = v[v.length-1], + lex, + rex, + cv; + + // equations of right and left sides, returns x, y values given height of section (y value and 2 points) + + function findedge (l, p1 , p2) { + var m = (p1[1] - p2[1])/(p1[0] - p2[0]); + var b = p1[1] - m*p1[0]; + var y = l + p1[1]; + + return [(y - b)/m, y]; + } + + // check each section + lex = findedge(y, vfirst[0], vlast[3]); + rex = findedge(y, vfirst[1], vlast[2]); + for (j=0; j<v.length; j++) { + cv = v[j]; + if (y >= cv[0][1] && y <= cv[3][1] && x >= lex[0] && x <= rex[0]) { + return {seriesIndex:s.index, pointIndex:j, gridData:null, data:s.data[j]}; + } + } + break; + + case $.jqplot.LineRenderer: + x = gridpos.x; + y = gridpos.y; + r = s.renderer; + if (s.show) { + if ((s.fill || (s.renderer.bands.show && s.renderer.bands.fill)) && (!plot.plugins.highlighter || !plot.plugins.highlighter.show)) { + // first check if it is in bounding box + var inside = false; + if (x>s._boundingBox[0][0] && x<s._boundingBox[1][0] && y>s._boundingBox[1][1] && y<s._boundingBox[0][1]) { + // now check the crossing number + + var numPoints = s._areaPoints.length; + var ii; + var j = numPoints-1; + + for(var ii=0; ii < numPoints; ii++) { + var vertex1 = [s._areaPoints[ii][0], s._areaPoints[ii][1]]; + var vertex2 = [s._areaPoints[j][0], s._areaPoints[j][1]]; + + if (vertex1[1] < y && vertex2[1] >= y || vertex2[1] < y && vertex1[1] >= y) { + if (vertex1[0] + (y - vertex1[1]) / (vertex2[1] - vertex1[1]) * (vertex2[0] - vertex1[0]) < x) { + inside = !inside; + } + } + + j = ii; + } + } + if (inside) { + return {seriesIndex:i, pointIndex:null, gridData:s.gridData, data:s.data, points:s._areaPoints}; + } + break; + + } + + else { + t = s.markerRenderer.size/2+s.neighborThreshold; + threshold = (t > 0) ? t : 0; + for (var j=0; j<s.gridData.length; j++) { + p = s.gridData[j]; + // neighbor looks different to OHLC chart. + if (r.constructor == $.jqplot.OHLCRenderer) { + if (r.candleStick) { + var yp = s._yaxis.series_u2p; + if (x >= p[0]-r._bodyWidth/2 && x <= p[0]+r._bodyWidth/2 && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) { + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + // if an open hi low close chart + else if (!r.hlc){ + var yp = s._yaxis.series_u2p; + if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) { + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + // a hi low close chart + else { + var yp = s._yaxis.series_u2p; + if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][1]) && y <= yp(s.data[j][2])) { + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + + } + else if (p[0] != null && p[1] != null){ + d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) * (y-p[1]) ); + if (d <= threshold && (d <= d0 || d0 == null)) { + d0 = d; + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + } + } + } + break; + + default: + x = gridpos.x; + y = gridpos.y; + r = s.renderer; + if (s.show) { + t = s.markerRenderer.size/2+s.neighborThreshold; + threshold = (t > 0) ? t : 0; + for (var j=0; j<s.gridData.length; j++) { + p = s.gridData[j]; + // neighbor looks different to OHLC chart. + if (r.constructor == $.jqplot.OHLCRenderer) { + if (r.candleStick) { + var yp = s._yaxis.series_u2p; + if (x >= p[0]-r._bodyWidth/2 && x <= p[0]+r._bodyWidth/2 && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) { + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + // if an open hi low close chart + else if (!r.hlc){ + var yp = s._yaxis.series_u2p; + if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) { + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + // a hi low close chart + else { + var yp = s._yaxis.series_u2p; + if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][1]) && y <= yp(s.data[j][2])) { + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + + } + else { + d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) * (y-p[1]) ); + if (d <= threshold && (d <= d0 || d0 == null)) { + d0 = d; + return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}; + } + } + } + } + break; + } + } + + return null; + } + + + + this.onClick = function(ev) { + // Event passed in is normalized and will have data attribute. + // Event passed out is unnormalized. + var positions = getEventPosition(ev); + var p = ev.data.plot; + var neighbor = checkIntersection(positions.gridPos, p); + var evt = $.Event('jqplotClick'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); + }; + + this.onDblClick = function(ev) { + // Event passed in is normalized and will have data attribute. + // Event passed out is unnormalized. + var positions = getEventPosition(ev); + var p = ev.data.plot; + var neighbor = checkIntersection(positions.gridPos, p); + var evt = $.Event('jqplotDblClick'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); + }; + + this.onMouseDown = function(ev) { + var positions = getEventPosition(ev); + var p = ev.data.plot; + var neighbor = checkIntersection(positions.gridPos, p); + var evt = $.Event('jqplotMouseDown'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); + }; + + this.onMouseUp = function(ev) { + var positions = getEventPosition(ev); + var evt = $.Event('jqplotMouseUp'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, ev.data.plot]); + }; + + this.onRightClick = function(ev) { + var positions = getEventPosition(ev); + var p = ev.data.plot; + var neighbor = checkIntersection(positions.gridPos, p); + if (p.captureRightClick) { + if (ev.which == 3) { + var evt = $.Event('jqplotRightClick'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); + } + else { + var evt = $.Event('jqplotMouseUp'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); + } + } + }; + + this.onMouseMove = function(ev) { + var positions = getEventPosition(ev); + var p = ev.data.plot; + var neighbor = checkIntersection(positions.gridPos, p); + var evt = $.Event('jqplotMouseMove'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); + }; + + this.onMouseEnter = function(ev) { + var positions = getEventPosition(ev); + var p = ev.data.plot; + var evt = $.Event('jqplotMouseEnter'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + evt.relatedTarget = ev.relatedTarget; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, p]); + }; + + this.onMouseLeave = function(ev) { + var positions = getEventPosition(ev); + var p = ev.data.plot; + var evt = $.Event('jqplotMouseLeave'); + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + evt.relatedTarget = ev.relatedTarget; + $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, p]); + }; + + // method: drawSeries + // Redraws all or just one series on the plot. No axis scaling + // is performed and no other elements on the plot are redrawn. + // options is an options object to pass on to the series renderers. + // It can be an empty object {}. idx is the series index + // to redraw if only one series is to be redrawn. + this.drawSeries = function(options, idx){ + var i, series, ctx; + // if only one argument passed in and it is a number, use it ad idx. + idx = (typeof(options) === "number" && idx == null) ? options : idx; + options = (typeof(options) === "object") ? options : {}; + // draw specified series + if (idx != undefined) { + series = this.series[idx]; + ctx = series.shadowCanvas._ctx; + ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); + series.drawShadow(ctx, options, this); + ctx = series.canvas._ctx; + ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); + series.draw(ctx, options, this); + if (series.renderer.constructor == $.jqplot.BezierCurveRenderer) { + if (idx < this.series.length - 1) { + this.drawSeries(idx+1); + } + } + } + + else { + // if call series drawShadow method first, in case all series shadows + // should be drawn before any series. This will ensure, like for + // stacked bar plots, that shadows don't overlap series. + for (i=0; i<this.series.length; i++) { + // first clear the canvas + series = this.series[i]; + ctx = series.shadowCanvas._ctx; + ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); + series.drawShadow(ctx, options, this); + ctx = series.canvas._ctx; + ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); + series.draw(ctx, options, this); + } + } + options = idx = i = series = ctx = null; + }; + + // method: moveSeriesToFront + // This method requires jQuery 1.4+ + // Moves the specified series canvas in front of all other series canvases. + // This effectively "draws" the specified series on top of all other series, + // although it is performed through DOM manipulation, no redrawing is performed. + // + // Parameters: + // idx - 0 based index of the series to move. This will be the index of the series + // as it was first passed into the jqplot function. + this.moveSeriesToFront = function (idx) { + idx = parseInt(idx, 10); + var stackIndex = $.inArray(idx, this.seriesStack); + // if already in front, return + if (stackIndex == -1) { + return; + } + if (stackIndex == this.seriesStack.length -1) { + this.previousSeriesStack = this.seriesStack.slice(0); + return; + } + var opidx = this.seriesStack[this.seriesStack.length -1]; + var serelem = this.series[idx].canvas._elem.detach(); + var shadelem = this.series[idx].shadowCanvas._elem.detach(); + this.series[opidx].shadowCanvas._elem.after(shadelem); + this.series[opidx].canvas._elem.after(serelem); + this.previousSeriesStack = this.seriesStack.slice(0); + this.seriesStack.splice(stackIndex, 1); + this.seriesStack.push(idx); + }; + + // method: moveSeriesToBack + // This method requires jQuery 1.4+ + // Moves the specified series canvas behind all other series canvases. + // + // Parameters: + // idx - 0 based index of the series to move. This will be the index of the series + // as it was first passed into the jqplot function. + this.moveSeriesToBack = function (idx) { + idx = parseInt(idx, 10); + var stackIndex = $.inArray(idx, this.seriesStack); + // if already in back, return + if (stackIndex == 0 || stackIndex == -1) { + return; + } + var opidx = this.seriesStack[0]; + var serelem = this.series[idx].canvas._elem.detach(); + var shadelem = this.series[idx].shadowCanvas._elem.detach(); + this.series[opidx].shadowCanvas._elem.before(shadelem); + this.series[opidx].canvas._elem.before(serelem); + this.previousSeriesStack = this.seriesStack.slice(0); + this.seriesStack.splice(stackIndex, 1); + this.seriesStack.unshift(idx); + }; + + // method: restorePreviousSeriesOrder + // This method requires jQuery 1.4+ + // Restore the series canvas order to its previous state. + // Useful to put a series back where it belongs after moving + // it to the front. + this.restorePreviousSeriesOrder = function () { + var i, j, serelem, shadelem, temp, move, keep; + // if no change, return. + if (this.seriesStack == this.previousSeriesStack) { + return; + } + for (i=1; i<this.previousSeriesStack.length; i++) { + move = this.previousSeriesStack[i]; + keep = this.previousSeriesStack[i-1]; + serelem = this.series[move].canvas._elem.detach(); + shadelem = this.series[move].shadowCanvas._elem.detach(); + this.series[keep].shadowCanvas._elem.after(shadelem); + this.series[keep].canvas._elem.after(serelem); + } + temp = this.seriesStack.slice(0); + this.seriesStack = this.previousSeriesStack.slice(0); + this.previousSeriesStack = temp; + }; + + // method: restoreOriginalSeriesOrder + // This method requires jQuery 1.4+ + // Restore the series canvas order to its original order + // when the plot was created. + this.restoreOriginalSeriesOrder = function () { + var i, j, arr=[], serelem, shadelem; + for (i=0; i<this.series.length; i++) { + arr.push(i); + } + if (this.seriesStack == arr) { + return; + } + this.previousSeriesStack = this.seriesStack.slice(0); + this.seriesStack = arr; + for (i=1; i<this.seriesStack.length; i++) { + serelem = this.series[i].canvas._elem.detach(); + shadelem = this.series[i].shadowCanvas._elem.detach(); + this.series[i-1].shadowCanvas._elem.after(shadelem); + this.series[i-1].canvas._elem.after(serelem); + } + }; + + this.activateTheme = function (name) { + this.themeEngine.activate(this, name); + }; + } + + + // conpute a highlight color or array of highlight colors from given colors. + $.jqplot.computeHighlightColors = function(colors) { + var ret; + if ($.isArray(colors)) { + ret = []; + for (var i=0; i<colors.length; i++){ + var rgba = $.jqplot.getColorComponents(colors[i]); + var newrgb = [rgba[0], rgba[1], rgba[2]]; + var sum = newrgb[0] + newrgb[1] + newrgb[2]; + for (var j=0; j<3; j++) { + // when darkening, lowest color component can be is 60. + newrgb[j] = (sum > 660) ? newrgb[j] * 0.85 : 0.73 * newrgb[j] + 90; + newrgb[j] = parseInt(newrgb[j], 10); + (newrgb[j] > 255) ? 255 : newrgb[j]; + } + // newrgb[3] = (rgba[3] > 0.4) ? rgba[3] * 0.4 : rgba[3] * 1.5; + // newrgb[3] = (rgba[3] > 0.5) ? 0.8 * rgba[3] - .1 : rgba[3] + 0.2; + newrgb[3] = 0.3 + 0.35 * rgba[3]; + ret.push('rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+newrgb[3]+')'); + } + } + else { + var rgba = $.jqplot.getColorComponents(colors); + var newrgb = [rgba[0], rgba[1], rgba[2]]; + var sum = newrgb[0] + newrgb[1] + newrgb[2]; + for (var j=0; j<3; j++) { + // when darkening, lowest color component can be is 60. + // newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); + // newrgb[j] = parseInt(newrgb[j], 10); + newrgb[j] = (sum > 660) ? newrgb[j] * 0.85 : 0.73 * newrgb[j] + 90; + newrgb[j] = parseInt(newrgb[j], 10); + (newrgb[j] > 255) ? 255 : newrgb[j]; + } + // newrgb[3] = (rgba[3] > 0.4) ? rgba[3] * 0.4 : rgba[3] * 1.5; + // newrgb[3] = (rgba[3] > 0.5) ? 0.8 * rgba[3] - .1 : rgba[3] + 0.2; + newrgb[3] = 0.3 + 0.35 * rgba[3]; + ret = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+newrgb[3]+')'; + } + return ret; + }; + + $.jqplot.ColorGenerator = function(colors) { + colors = colors || $.jqplot.config.defaultColors; + var idx = 0; + + this.next = function () { + if (idx < colors.length) { + return colors[idx++]; + } + else { + idx = 0; + return colors[idx++]; + } + }; + + this.previous = function () { + if (idx > 0) { + return colors[idx--]; + } + else { + idx = colors.length-1; + return colors[idx]; + } + }; + + // get a color by index without advancing pointer. + this.get = function(i) { + var idx = i - colors.length * Math.floor(i/colors.length); + return colors[idx]; + }; + + this.setColors = function(c) { + colors = c; + }; + + this.reset = function() { + idx = 0; + }; + + this.getIndex = function() { + return idx; + }; + + this.setIndex = function(index) { + idx = index; + }; + }; + + // convert a hex color string to rgb string. + // h - 3 or 6 character hex string, with or without leading # + // a - optional alpha + $.jqplot.hex2rgb = function(h, a) { + h = h.replace('#', ''); + if (h.length == 3) { + h = h.charAt(0)+h.charAt(0)+h.charAt(1)+h.charAt(1)+h.charAt(2)+h.charAt(2); + } + var rgb; + rgb = 'rgba('+parseInt(h.slice(0,2), 16)+', '+parseInt(h.slice(2,4), 16)+', '+parseInt(h.slice(4,6), 16); + if (a) { + rgb += ', '+a; + } + rgb += ')'; + return rgb; + }; + + // convert an rgb color spec to a hex spec. ignore any alpha specification. + $.jqplot.rgb2hex = function(s) { + var pat = /rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *(?:, *[0-9.]*)?\)/; + var m = s.match(pat); + var h = '#'; + for (var i=1; i<4; i++) { + var temp; + if (m[i].search(/%/) != -1) { + temp = parseInt(255*m[i]/100, 10).toString(16); + if (temp.length == 1) { + temp = '0'+temp; + } + } + else { + temp = parseInt(m[i], 10).toString(16); + if (temp.length == 1) { + temp = '0'+temp; + } + } + h += temp; + } + return h; + }; + + // given a css color spec, return an rgb css color spec + $.jqplot.normalize2rgb = function(s, a) { + if (s.search(/^ *rgba?\(/) != -1) { + return s; + } + else if (s.search(/^ *#?[0-9a-fA-F]?[0-9a-fA-F]/) != -1) { + return $.jqplot.hex2rgb(s, a); + } + else { + throw 'invalid color spec'; + } + }; + + // extract the r, g, b, a color components out of a css color spec. + $.jqplot.getColorComponents = function(s) { + // check to see if a color keyword. + s = $.jqplot.colorKeywordMap[s] || s; + var rgb = $.jqplot.normalize2rgb(s); + var pat = /rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *,? *([0-9.]* *)?\)/; + var m = rgb.match(pat); + var ret = []; + for (var i=1; i<4; i++) { + if (m[i].search(/%/) != -1) { + ret[i-1] = parseInt(255*m[i]/100, 10); + } + else { + ret[i-1] = parseInt(m[i], 10); + } + } + ret[3] = parseFloat(m[4]) ? parseFloat(m[4]) : 1.0; + return ret; + }; + + $.jqplot.colorKeywordMap = { + aliceblue: 'rgb(240, 248, 255)', + antiquewhite: 'rgb(250, 235, 215)', + aqua: 'rgb( 0, 255, 255)', + aquamarine: 'rgb(127, 255, 212)', + azure: 'rgb(240, 255, 255)', + beige: 'rgb(245, 245, 220)', + bisque: 'rgb(255, 228, 196)', + black: 'rgb( 0, 0, 0)', + blanchedalmond: 'rgb(255, 235, 205)', + blue: 'rgb( 0, 0, 255)', + blueviolet: 'rgb(138, 43, 226)', + brown: 'rgb(165, 42, 42)', + burlywood: 'rgb(222, 184, 135)', + cadetblue: 'rgb( 95, 158, 160)', + chartreuse: 'rgb(127, 255, 0)', + chocolate: 'rgb(210, 105, 30)', + coral: 'rgb(255, 127, 80)', + cornflowerblue: 'rgb(100, 149, 237)', + cornsilk: 'rgb(255, 248, 220)', + crimson: 'rgb(220, 20, 60)', + cyan: 'rgb( 0, 255, 255)', + darkblue: 'rgb( 0, 0, 139)', + darkcyan: 'rgb( 0, 139, 139)', + darkgoldenrod: 'rgb(184, 134, 11)', + darkgray: 'rgb(169, 169, 169)', + darkgreen: 'rgb( 0, 100, 0)', + darkgrey: 'rgb(169, 169, 169)', + darkkhaki: 'rgb(189, 183, 107)', + darkmagenta: 'rgb(139, 0, 139)', + darkolivegreen: 'rgb( 85, 107, 47)', + darkorange: 'rgb(255, 140, 0)', + darkorchid: 'rgb(153, 50, 204)', + darkred: 'rgb(139, 0, 0)', + darksalmon: 'rgb(233, 150, 122)', + darkseagreen: 'rgb(143, 188, 143)', + darkslateblue: 'rgb( 72, 61, 139)', + darkslategray: 'rgb( 47, 79, 79)', + darkslategrey: 'rgb( 47, 79, 79)', + darkturquoise: 'rgb( 0, 206, 209)', + darkviolet: 'rgb(148, 0, 211)', + deeppink: 'rgb(255, 20, 147)', + deepskyblue: 'rgb( 0, 191, 255)', + dimgray: 'rgb(105, 105, 105)', + dimgrey: 'rgb(105, 105, 105)', + dodgerblue: 'rgb( 30, 144, 255)', + firebrick: 'rgb(178, 34, 34)', + floralwhite: 'rgb(255, 250, 240)', + forestgreen: 'rgb( 34, 139, 34)', + fuchsia: 'rgb(255, 0, 255)', + gainsboro: 'rgb(220, 220, 220)', + ghostwhite: 'rgb(248, 248, 255)', + gold: 'rgb(255, 215, 0)', + goldenrod: 'rgb(218, 165, 32)', + gray: 'rgb(128, 128, 128)', + grey: 'rgb(128, 128, 128)', + green: 'rgb( 0, 128, 0)', + greenyellow: 'rgb(173, 255, 47)', + honeydew: 'rgb(240, 255, 240)', + hotpink: 'rgb(255, 105, 180)', + indianred: 'rgb(205, 92, 92)', + indigo: 'rgb( 75, 0, 130)', + ivory: 'rgb(255, 255, 240)', + khaki: 'rgb(240, 230, 140)', + lavender: 'rgb(230, 230, 250)', + lavenderblush: 'rgb(255, 240, 245)', + lawngreen: 'rgb(124, 252, 0)', + lemonchiffon: 'rgb(255, 250, 205)', + lightblue: 'rgb(173, 216, 230)', + lightcoral: 'rgb(240, 128, 128)', + lightcyan: 'rgb(224, 255, 255)', + lightgoldenrodyellow: 'rgb(250, 250, 210)', + lightgray: 'rgb(211, 211, 211)', + lightgreen: 'rgb(144, 238, 144)', + lightgrey: 'rgb(211, 211, 211)', + lightpink: 'rgb(255, 182, 193)', + lightsalmon: 'rgb(255, 160, 122)', + lightseagreen: 'rgb( 32, 178, 170)', + lightskyblue: 'rgb(135, 206, 250)', + lightslategray: 'rgb(119, 136, 153)', + lightslategrey: 'rgb(119, 136, 153)', + lightsteelblue: 'rgb(176, 196, 222)', + lightyellow: 'rgb(255, 255, 224)', + lime: 'rgb( 0, 255, 0)', + limegreen: 'rgb( 50, 205, 50)', + linen: 'rgb(250, 240, 230)', + magenta: 'rgb(255, 0, 255)', + maroon: 'rgb(128, 0, 0)', + mediumaquamarine: 'rgb(102, 205, 170)', + mediumblue: 'rgb( 0, 0, 205)', + mediumorchid: 'rgb(186, 85, 211)', + mediumpurple: 'rgb(147, 112, 219)', + mediumseagreen: 'rgb( 60, 179, 113)', + mediumslateblue: 'rgb(123, 104, 238)', + mediumspringgreen: 'rgb( 0, 250, 154)', + mediumturquoise: 'rgb( 72, 209, 204)', + mediumvioletred: 'rgb(199, 21, 133)', + midnightblue: 'rgb( 25, 25, 112)', + mintcream: 'rgb(245, 255, 250)', + mistyrose: 'rgb(255, 228, 225)', + moccasin: 'rgb(255, 228, 181)', + navajowhite: 'rgb(255, 222, 173)', + navy: 'rgb( 0, 0, 128)', + oldlace: 'rgb(253, 245, 230)', + olive: 'rgb(128, 128, 0)', + olivedrab: 'rgb(107, 142, 35)', + orange: 'rgb(255, 165, 0)', + orangered: 'rgb(255, 69, 0)', + orchid: 'rgb(218, 112, 214)', + palegoldenrod: 'rgb(238, 232, 170)', + palegreen: 'rgb(152, 251, 152)', + paleturquoise: 'rgb(175, 238, 238)', + palevioletred: 'rgb(219, 112, 147)', + papayawhip: 'rgb(255, 239, 213)', + peachpuff: 'rgb(255, 218, 185)', + peru: 'rgb(205, 133, 63)', + pink: 'rgb(255, 192, 203)', + plum: 'rgb(221, 160, 221)', + powderblue: 'rgb(176, 224, 230)', + purple: 'rgb(128, 0, 128)', + red: 'rgb(255, 0, 0)', + rosybrown: 'rgb(188, 143, 143)', + royalblue: 'rgb( 65, 105, 225)', + saddlebrown: 'rgb(139, 69, 19)', + salmon: 'rgb(250, 128, 114)', + sandybrown: 'rgb(244, 164, 96)', + seagreen: 'rgb( 46, 139, 87)', + seashell: 'rgb(255, 245, 238)', + sienna: 'rgb(160, 82, 45)', + silver: 'rgb(192, 192, 192)', + skyblue: 'rgb(135, 206, 235)', + slateblue: 'rgb(106, 90, 205)', + slategray: 'rgb(112, 128, 144)', + slategrey: 'rgb(112, 128, 144)', + snow: 'rgb(255, 250, 250)', + springgreen: 'rgb( 0, 255, 127)', + steelblue: 'rgb( 70, 130, 180)', + tan: 'rgb(210, 180, 140)', + teal: 'rgb( 0, 128, 128)', + thistle: 'rgb(216, 191, 216)', + tomato: 'rgb(255, 99, 71)', + turquoise: 'rgb( 64, 224, 208)', + violet: 'rgb(238, 130, 238)', + wheat: 'rgb(245, 222, 179)', + white: 'rgb(255, 255, 255)', + whitesmoke: 'rgb(245, 245, 245)', + yellow: 'rgb(255, 255, 0)', + yellowgreen: 'rgb(154, 205, 50)' + }; + + +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // class: $.jqplot.LinearAxisRenderer + // The default jqPlot axis renderer, creating a numeric axis. + $.jqplot.LinearAxisRenderer = function() { + }; + + // called with scope of axis object. + $.jqplot.LinearAxisRenderer.prototype.init = function(options){ + // prop: breakPoints + // EXPERIMENTAL!! Use at your own risk! + // Works only with linear axes and the default tick renderer. + // Array of [start, stop] points to create a broken axis. + // Broken axes have a "jump" in them, which is an immediate + // transition from a smaller value to a larger value. + // Currently, axis ticks MUST be manually assigned if using breakPoints + // by using the axis ticks array option. + this.breakPoints = null; + // prop: breakTickLabel + // Label to use at the axis break if breakPoints are specified. + this.breakTickLabel = "≈"; + // prop: drawBaseline + // True to draw the axis baseline. + this.drawBaseline = true; + // prop: baselineWidth + // width of the baseline in pixels. + this.baselineWidth = null; + // prop: baselineColor + // CSS color spec for the baseline. + this.baselineColor = null; + // prop: forceTickAt0 + // This will ensure that there is always a tick mark at 0. + // If data range is strictly positive or negative, + // this will force 0 to be inside the axis bounds unless + // the appropriate axis pad (pad, padMin or padMax) is set + // to 0, then this will force an axis min or max value at 0. + // This has know effect when any of the following options + // are set: autoscale, min, max, numberTicks or tickInterval. + this.forceTickAt0 = false; + // prop: forceTickAt100 + // This will ensure that there is always a tick mark at 100. + // If data range is strictly above or below 100, + // this will force 100 to be inside the axis bounds unless + // the appropriate axis pad (pad, padMin or padMax) is set + // to 0, then this will force an axis min or max value at 100. + // This has know effect when any of the following options + // are set: autoscale, min, max, numberTicks or tickInterval. + this.forceTickAt100 = false; + // prop: tickInset + // Controls the amount to inset the first and last ticks from + // the edges of the grid, in multiples of the tick interval. + // 0 is no inset, 0.5 is one half a tick interval, 1 is a full + // tick interval, etc. + this.tickInset = 0; + // prop: minorTicks + // Number of ticks to add between "major" ticks. + // Major ticks are ticks supplied by user or auto computed. + // Minor ticks cannot be created by user. + this.minorTicks = 0; + // prop: alignTicks + // true to align tick marks across opposed axes + // such as from the y2axis to yaxis. + this.alignTicks = false; + this._autoFormatString = ''; + this._overrideFormatString = false; + this._scalefact = 1.0; + $.extend(true, this, options); + if (this.breakPoints) { + if (!$.isArray(this.breakPoints)) { + this.breakPoints = null; + } + else if (this.breakPoints.length < 2 || this.breakPoints[1] <= this.breakPoints[0]) { + this.breakPoints = null; + } + } + if (this.numberTicks != null && this.numberTicks < 2) { + this.numberTicks = 2; + } + this.resetDataBounds(); + }; + + // called with scope of axis + $.jqplot.LinearAxisRenderer.prototype.draw = function(ctx, plot) { + if (this.show) { + // populate the axis label and value properties. + // createTicks is a method on the renderer, but + // call it within the scope of the axis. + this.renderer.createTicks.call(this, plot); + // fill a div with axes labels in the right direction. + // Need to pregenerate each axis to get it's bounds and + // position it and the labels correctly on the plot. + var dim=0; + var temp; + // Added for theming. + if (this._elem) { + // Memory Leaks patch + //this._elem.empty(); + this._elem.emptyForce(); + this._elem = null; + } + + this._elem = $(document.createElement('div')); + this._elem.addClass('jqplot-axis jqplot-'+this.name); + this._elem.css('position', 'absolute'); + + + if (this.name == 'xaxis' || this.name == 'x2axis') { + this._elem.width(this._plotDimensions.width); + } + else { + this._elem.height(this._plotDimensions.height); + } + + // create a _label object. + this.labelOptions.axis = this.name; + this._label = new this.labelRenderer(this.labelOptions); + if (this._label.show) { + var elem = this._label.draw(ctx, plot); + elem.appendTo(this._elem); + elem = null; + } + + var t = this._ticks; + var tick; + for (var i=0; i<t.length; i++) { + tick = t[i]; + if (tick.show && tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { + this._elem.append(tick.draw(ctx, plot)); + } + } + tick = null; + t = null; + } + return this._elem; + }; + + // called with scope of an axis + $.jqplot.LinearAxisRenderer.prototype.reset = function() { + this.min = this._options.min; + this.max = this._options.max; + this.tickInterval = this._options.tickInterval; + this.numberTicks = this._options.numberTicks; + this._autoFormatString = ''; + if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) { + this.tickOptions.formatString = ''; + } + + // this._ticks = this.__ticks; + }; + + // called with scope of axis + $.jqplot.LinearAxisRenderer.prototype.set = function() { + var dim = 0; + var temp; + var w = 0; + var h = 0; + var lshow = (this._label == null) ? false : this._label.show; + if (this.show) { + var t = this._ticks; + var tick; + for (var i=0; i<t.length; i++) { + tick = t[i]; + if (!tick._breakTick && tick.show && tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + temp = tick._elem.outerHeight(true); + } + else { + temp = tick._elem.outerWidth(true); + } + if (temp > dim) { + dim = temp; + } + } + } + tick = null; + t = null; + + if (lshow) { + w = this._label._elem.outerWidth(true); + h = this._label._elem.outerHeight(true); + } + if (this.name == 'xaxis') { + dim = dim + h; + this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'}); + } + else if (this.name == 'x2axis') { + dim = dim + h; + this._elem.css({'height':dim+'px', left:'0px', top:'0px'}); + } + else if (this.name == 'yaxis') { + dim = dim + w; + this._elem.css({'width':dim+'px', left:'0px', top:'0px'}); + if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { + this._label._elem.css('width', w+'px'); + } + } + else { + dim = dim + w; + this._elem.css({'width':dim+'px', right:'0px', top:'0px'}); + if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { + this._label._elem.css('width', w+'px'); + } + } + } + }; + + // called with scope of axis + $.jqplot.LinearAxisRenderer.prototype.createTicks = function(plot) { + // we're are operating on an axis here + var ticks = this._ticks; + var userTicks = this.ticks; + var name = this.name; + // databounds were set on axis initialization. + var db = this._dataBounds; + var dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height; + var interval; + var min, max; + var pos1, pos2; + var tt, i; + // get a copy of user's settings for min/max. + var userMin = this.min; + var userMax = this.max; + var userNT = this.numberTicks; + var userTI = this.tickInterval; + + var threshold = 30; + this._scalefact = (Math.max(dim, threshold+1) - threshold)/300.0; + + // if we already have ticks, use them. + // ticks must be in order of increasing value. + + if (userTicks.length) { + // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed + for (i=0; i<userTicks.length; i++){ + var ut = userTicks[i]; + var t = new this.tickRenderer(this.tickOptions); + if ($.isArray(ut)) { + t.value = ut[0]; + if (this.breakPoints) { + if (ut[0] == this.breakPoints[0]) { + t.label = this.breakTickLabel; + t._breakTick = true; + t.showGridline = false; + t.showMark = false; + } + else if (ut[0] > this.breakPoints[0] && ut[0] <= this.breakPoints[1]) { + t.show = false; + t.showGridline = false; + t.label = ut[1]; + } + else { + t.label = ut[1]; + } + } + else { + t.label = ut[1]; + } + t.setTick(ut[0], this.name); + this._ticks.push(t); + } + + else if ($.isPlainObject(ut)) { + $.extend(true, t, ut); + t.axis = this.name; + this._ticks.push(t); + } + + else { + t.value = ut; + if (this.breakPoints) { + if (ut == this.breakPoints[0]) { + t.label = this.breakTickLabel; + t._breakTick = true; + t.showGridline = false; + t.showMark = false; + } + else if (ut > this.breakPoints[0] && ut <= this.breakPoints[1]) { + t.show = false; + t.showGridline = false; + } + } + t.setTick(ut, this.name); + this._ticks.push(t); + } + } + this.numberTicks = userTicks.length; + this.min = this._ticks[0].value; + this.max = this._ticks[this.numberTicks-1].value; + this.tickInterval = (this.max - this.min) / (this.numberTicks - 1); + } + + // we don't have any ticks yet, let's make some! + else { + if (name == 'xaxis' || name == 'x2axis') { + dim = this._plotDimensions.width; + } + else { + dim = this._plotDimensions.height; + } + + var _numberTicks = this.numberTicks; + + // if aligning this axis, use number of ticks from previous axis. + // Do I need to reset somehow if alignTicks is changed and then graph is replotted?? + if (this.alignTicks) { + if (this.name === 'x2axis' && plot.axes.xaxis.show) { + _numberTicks = plot.axes.xaxis.numberTicks; + } + else if (this.name.charAt(0) === 'y' && this.name !== 'yaxis' && this.name !== 'yMidAxis' && plot.axes.yaxis.show) { + _numberTicks = plot.axes.yaxis.numberTicks; + } + } + + min = ((this.min != null) ? this.min : db.min); + max = ((this.max != null) ? this.max : db.max); + + var range = max - min; + var rmin, rmax; + var temp; + + if (this.tickOptions == null || !this.tickOptions.formatString) { + this._overrideFormatString = true; + } + + // Doing complete autoscaling + if (this.min == null || this.max == null && this.tickInterval == null && !this.autoscale) { + // Check if user must have tick at 0 or 100 and ensure they are in range. + // The autoscaling algorithm will always place ticks at 0 and 100 if they are in range. + if (this.forceTickAt0) { + if (min > 0) { + min = 0; + } + if (max < 0) { + max = 0; + } + } + + if (this.forceTickAt100) { + if (min > 100) { + min = 100; + } + if (max < 100) { + max = 100; + } + } + + var keepMin = false, + keepMax = false; + + if (this.min != null) { + keepMin = true; + } + + else if (this.max != null) { + keepMax = true; + } + + // var threshold = 30; + // var tdim = Math.max(dim, threshold+1); + // this._scalefact = (tdim-threshold)/300.0; + var ret = $.jqplot.LinearTickGenerator(min, max, this._scalefact, _numberTicks, keepMin, keepMax); + // calculate a padded max and min, points should be less than these + // so that they aren't too close to the edges of the plot. + // User can adjust how much padding is allowed with pad, padMin and PadMax options. + // If min or max is set, don't pad that end of axis. + var tumin = (this.min != null) ? min : min + range*(this.padMin - 1); + var tumax = (this.max != null) ? max : max - range*(this.padMax - 1); + + // if they're equal, we shouldn't have to do anything, right? + // if (min <=tumin || max >= tumax) { + if (min <tumin || max > tumax) { + tumin = (this.min != null) ? min : min - range*(this.padMin - 1); + tumax = (this.max != null) ? max : max + range*(this.padMax - 1); + ret = $.jqplot.LinearTickGenerator(tumin, tumax, this._scalefact, _numberTicks, keepMin, keepMax); + } + + this.min = ret[0]; + this.max = ret[1]; + // if numberTicks specified, it should return the same. + this.numberTicks = ret[2]; + this._autoFormatString = ret[3]; + this.tickInterval = ret[4]; + } + + // User has specified some axis scale related option, can use auto algorithm + else { + + // if min and max are same, space them out a bit + if (min == max) { + var adj = 0.05; + if (min > 0) { + adj = Math.max(Math.log(min)/Math.LN10, 0.05); + } + min -= adj; + max += adj; + } + + // autoscale. Can't autoscale if min or max is supplied. + // Will use numberTicks and tickInterval if supplied. Ticks + // across multiple axes may not line up depending on how + // bars are to be plotted. + if (this.autoscale && this.min == null && this.max == null) { + var rrange, ti, margin; + var forceMinZero = false; + var forceZeroLine = false; + var intervals = {min:null, max:null, average:null, stddev:null}; + // if any series are bars, or if any are fill to zero, and if this + // is the axis to fill toward, check to see if we can start axis at zero. + for (var i=0; i<this._series.length; i++) { + var s = this._series[i]; + var faname = (s.fillAxis == 'x') ? s._xaxis.name : s._yaxis.name; + // check to see if this is the fill axis + if (this.name == faname) { + var vals = s._plotValues[s.fillAxis]; + var vmin = vals[0]; + var vmax = vals[0]; + for (var j=1; j<vals.length; j++) { + if (vals[j] < vmin) { + vmin = vals[j]; + } + else if (vals[j] > vmax) { + vmax = vals[j]; + } + } + var dp = (vmax - vmin) / vmax; + // is this sries a bar? + if (s.renderer.constructor == $.jqplot.BarRenderer) { + // if no negative values and could also check range. + if (vmin >= 0 && (s.fillToZero || dp > 0.1)) { + forceMinZero = true; + } + else { + forceMinZero = false; + if (s.fill && s.fillToZero && vmin < 0 && vmax > 0) { + forceZeroLine = true; + } + else { + forceZeroLine = false; + } + } + } + + // if not a bar and filling, use appropriate method. + else if (s.fill) { + if (vmin >= 0 && (s.fillToZero || dp > 0.1)) { + forceMinZero = true; + } + else if (vmin < 0 && vmax > 0 && s.fillToZero) { + forceMinZero = false; + forceZeroLine = true; + } + else { + forceMinZero = false; + forceZeroLine = false; + } + } + + // if not a bar and not filling, only change existing state + // if it doesn't make sense + else if (vmin < 0) { + forceMinZero = false; + } + } + } + + // check if we need make axis min at 0. + if (forceMinZero) { + // compute number of ticks + this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); + this.min = 0; + userMin = 0; + // what order is this range? + // what tick interval does that give us? + ti = max/(this.numberTicks-1); + temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10))); + if (ti/temp == parseInt(ti/temp, 10)) { + ti += temp; + } + this.tickInterval = Math.ceil(ti/temp) * temp; + this.max = this.tickInterval * (this.numberTicks - 1); + } + + // check if we need to make sure there is a tick at 0. + else if (forceZeroLine) { + // compute number of ticks + this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); + var ntmin = Math.ceil(Math.abs(min)/range*(this.numberTicks-1)); + var ntmax = this.numberTicks - 1 - ntmin; + ti = Math.max(Math.abs(min/ntmin), Math.abs(max/ntmax)); + temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10))); + this.tickInterval = Math.ceil(ti/temp) * temp; + this.max = this.tickInterval * ntmax; + this.min = -this.tickInterval * ntmin; + } + + // if nothing else, do autoscaling which will try to line up ticks across axes. + else { + if (this.numberTicks == null){ + if (this.tickInterval) { + this.numberTicks = 3 + Math.ceil(range / this.tickInterval); + } + else { + this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); + } + } + + if (this.tickInterval == null) { + // get a tick interval + ti = range/(this.numberTicks - 1); + + if (ti < 1) { + temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10))); + } + else { + temp = 1; + } + this.tickInterval = Math.ceil(ti*temp*this.pad)/temp; + } + else { + temp = 1 / this.tickInterval; + } + + // try to compute a nicer, more even tick interval + // temp = Math.pow(10, Math.floor(Math.log(ti)/Math.LN10)); + // this.tickInterval = Math.ceil(ti/temp) * temp; + rrange = this.tickInterval * (this.numberTicks - 1); + margin = (rrange - range)/2; + + if (this.min == null) { + this.min = Math.floor(temp*(min-margin))/temp; + } + if (this.max == null) { + this.max = this.min + rrange; + } + } + + // Compute a somewhat decent format string if it is needed. + // get precision of interval and determine a format string. + var sf = $.jqplot.getSignificantFigures(this.tickInterval); + + var fstr; + + // if we have only a whole number, use integer formatting + if (sf.digitsLeft >= sf.significantDigits) { + fstr = '%d'; + } + + else { + var temp = Math.max(0, 5 - sf.digitsLeft); + temp = Math.min(temp, sf.digitsRight); + fstr = '%.'+ temp + 'f'; + } + + this._autoFormatString = fstr; + } + + // Use the default algorithm which pads each axis to make the chart + // centered nicely on the grid. + else { + + rmin = (this.min != null) ? this.min : min - range*(this.padMin - 1); + rmax = (this.max != null) ? this.max : max + range*(this.padMax - 1); + range = rmax - rmin; + + if (this.numberTicks == null){ + // if tickInterval is specified by user, we will ignore computed maximum. + // max will be equal or greater to fit even # of ticks. + if (this.tickInterval != null) { + this.numberTicks = Math.ceil((rmax - rmin)/this.tickInterval)+1; + } + else if (dim > 100) { + this.numberTicks = parseInt(3+(dim-100)/75, 10); + } + else { + this.numberTicks = 2; + } + } + + if (this.tickInterval == null) { + this.tickInterval = range / (this.numberTicks-1); + } + + if (this.max == null) { + rmax = rmin + this.tickInterval*(this.numberTicks - 1); + } + if (this.min == null) { + rmin = rmax - this.tickInterval*(this.numberTicks - 1); + } + + // get precision of interval and determine a format string. + var sf = $.jqplot.getSignificantFigures(this.tickInterval); + + var fstr; + + // if we have only a whole number, use integer formatting + if (sf.digitsLeft >= sf.significantDigits) { + fstr = '%d'; + } + + else { + var temp = Math.max(0, 5 - sf.digitsLeft); + temp = Math.min(temp, sf.digitsRight); + fstr = '%.'+ temp + 'f'; + } + + + this._autoFormatString = fstr; + + this.min = rmin; + this.max = rmax; + } + + if (this.renderer.constructor == $.jqplot.LinearAxisRenderer && this._autoFormatString == '') { + // fix for misleading tick display with small range and low precision. + range = this.max - this.min; + // figure out precision + var temptick = new this.tickRenderer(this.tickOptions); + // use the tick formatString or, the default. + var fs = temptick.formatString || $.jqplot.config.defaultTickFormatString; + var fs = fs.match($.jqplot.sprintf.regex)[0]; + var precision = 0; + if (fs) { + if (fs.search(/[fFeEgGpP]/) > -1) { + var m = fs.match(/\%\.(\d{0,})?[eEfFgGpP]/); + if (m) { + precision = parseInt(m[1], 10); + } + else { + precision = 6; + } + } + else if (fs.search(/[di]/) > -1) { + precision = 0; + } + // fact will be <= 1; + var fact = Math.pow(10, -precision); + if (this.tickInterval < fact) { + // need to correct underrange + if (userNT == null && userTI == null) { + this.tickInterval = fact; + if (userMax == null && userMin == null) { + // this.min = Math.floor((this._dataBounds.min - this.tickInterval)/fact) * fact; + this.min = Math.floor(this._dataBounds.min/fact) * fact; + if (this.min == this._dataBounds.min) { + this.min = this._dataBounds.min - this.tickInterval; + } + // this.max = Math.ceil((this._dataBounds.max + this.tickInterval)/fact) * fact; + this.max = Math.ceil(this._dataBounds.max/fact) * fact; + if (this.max == this._dataBounds.max) { + this.max = this._dataBounds.max + this.tickInterval; + } + var n = (this.max - this.min)/this.tickInterval; + n = n.toFixed(11); + n = Math.ceil(n); + this.numberTicks = n + 1; + } + else if (userMax == null) { + // add one tick for top of range. + var n = (this._dataBounds.max - this.min) / this.tickInterval; + n = n.toFixed(11); + this.numberTicks = Math.ceil(n) + 2; + this.max = this.min + this.tickInterval * (this.numberTicks-1); + } + else if (userMin == null) { + // add one tick for bottom of range. + var n = (this.max - this._dataBounds.min) / this.tickInterval; + n = n.toFixed(11); + this.numberTicks = Math.ceil(n) + 2; + this.min = this.max - this.tickInterval * (this.numberTicks-1); + } + else { + // calculate a number of ticks so max is within axis scale + this.numberTicks = Math.ceil((userMax - userMin)/this.tickInterval) + 1; + // if user's min and max don't fit evenly in ticks, adjust. + // This takes care of cases such as user min set to 0, max set to 3.5 but tick + // format string set to %d (integer ticks) + this.min = Math.floor(userMin*Math.pow(10, precision))/Math.pow(10, precision); + this.max = Math.ceil(userMax*Math.pow(10, precision))/Math.pow(10, precision); + // this.max = this.min + this.tickInterval*(this.numberTicks-1); + this.numberTicks = Math.ceil((this.max - this.min)/this.tickInterval) + 1; + } + } + } + } + } + + } + + if (this._overrideFormatString && this._autoFormatString != '') { + this.tickOptions = this.tickOptions || {}; + this.tickOptions.formatString = this._autoFormatString; + } + + var t, to; + for (var i=0; i<this.numberTicks; i++){ + tt = this.min + i * this.tickInterval; + t = new this.tickRenderer(this.tickOptions); + // var t = new $.jqplot.AxisTickRenderer(this.tickOptions); + + t.setTick(tt, this.name); + this._ticks.push(t); + + if (i < this.numberTicks - 1) { + for (var j=0; j<this.minorTicks; j++) { + tt += this.tickInterval/(this.minorTicks+1); + to = $.extend(true, {}, this.tickOptions, {name:this.name, value:tt, label:'', isMinorTick:true}); + t = new this.tickRenderer(to); + this._ticks.push(t); + } + } + t = null; + } + } + + if (this.tickInset) { + this.min = this.min - this.tickInset * this.tickInterval; + this.max = this.max + this.tickInset * this.tickInterval; + } + + ticks = null; + }; + + // Used to reset just the values of the ticks and then repack, which will + // recalculate the positioning functions. It is assuemd that the + // number of ticks is the same and the values of the new array are at the + // proper interval. + // This method needs to be called with the scope of an axis object, like: + // + // > plot.axes.yaxis.renderer.resetTickValues.call(plot.axes.yaxis, yarr); + // + $.jqplot.LinearAxisRenderer.prototype.resetTickValues = function(opts) { + if ($.isArray(opts) && opts.length == this._ticks.length) { + var t; + for (var i=0; i<opts.length; i++) { + t = this._ticks[i]; + t.value = opts[i]; + t.label = t.formatter(t.formatString, opts[i]); + t.label = t.prefix + t.label; + t._elem.html(t.label); + } + t = null; + this.min = $.jqplot.arrayMin(opts); + this.max = $.jqplot.arrayMax(opts); + this.pack(); + } + // Not implemented yet. + // else if ($.isPlainObject(opts)) { + // + // } + }; + + // called with scope of axis + $.jqplot.LinearAxisRenderer.prototype.pack = function(pos, offsets) { + // Add defaults for repacking from resetTickValues function. + pos = pos || {}; + offsets = offsets || this._offsets; + + var ticks = this._ticks; + var max = this.max; + var min = this.min; + var offmax = offsets.max; + var offmin = offsets.min; + var lshow = (this._label == null) ? false : this._label.show; + + for (var p in pos) { + this._elem.css(p, pos[p]); + } + + this._offsets = offsets; + // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left. + var pixellength = offmax - offmin; + var unitlength = max - min; + + // point to unit and unit to point conversions references to Plot DOM element top left corner. + if (this.breakPoints) { + unitlength = unitlength - this.breakPoints[1] + this.breakPoints[0]; + + this.p2u = function(p){ + return (p - offmin) * unitlength / pixellength + min; + }; + + this.u2p = function(u){ + if (u > this.breakPoints[0] && u < this.breakPoints[1]){ + u = this.breakPoints[0]; + } + if (u <= this.breakPoints[0]) { + return (u - min) * pixellength / unitlength + offmin; + } + else { + return (u - this.breakPoints[1] + this.breakPoints[0] - min) * pixellength / unitlength + offmin; + } + }; + + if (this.name.charAt(0) == 'x'){ + this.series_u2p = function(u){ + if (u > this.breakPoints[0] && u < this.breakPoints[1]){ + u = this.breakPoints[0]; + } + if (u <= this.breakPoints[0]) { + return (u - min) * pixellength / unitlength; + } + else { + return (u - this.breakPoints[1] + this.breakPoints[0] - min) * pixellength / unitlength; + } + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + min; + }; + } + + else { + this.series_u2p = function(u){ + if (u > this.breakPoints[0] && u < this.breakPoints[1]){ + u = this.breakPoints[0]; + } + if (u >= this.breakPoints[1]) { + return (u - max) * pixellength / unitlength; + } + else { + return (u + this.breakPoints[1] - this.breakPoints[0] - max) * pixellength / unitlength; + } + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + max; + }; + } + } + else { + this.p2u = function(p){ + return (p - offmin) * unitlength / pixellength + min; + }; + + this.u2p = function(u){ + return (u - min) * pixellength / unitlength + offmin; + }; + + if (this.name == 'xaxis' || this.name == 'x2axis'){ + this.series_u2p = function(u){ + return (u - min) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + min; + }; + } + + else { + this.series_u2p = function(u){ + return (u - max) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + max; + }; + } + } + + if (this.show) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + for (var i=0; i<ticks.length; i++) { + var t = ticks[i]; + if (t.show && t.showLabel) { + var shim; + + if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { + // will need to adjust auto positioning based on which axis this is. + var temp = (this.name == 'xaxis') ? 1 : -1; + switch (t.labelPosition) { + case 'auto': + // position at end + if (temp * t.angle < 0) { + shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + } + // position at start + else { + shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; + } + break; + case 'end': + shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + break; + case 'start': + shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; + break; + case 'middle': + shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + break; + default: + shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + break; + } + } + else { + shim = -t.getWidth()/2; + } + var val = this.u2p(t.value) + shim + 'px'; + t._elem.css('left', val); + t.pack(); + } + } + if (lshow) { + var w = this._label._elem.outerWidth(true); + this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px'); + if (this.name == 'xaxis') { + this._label._elem.css('bottom', '0px'); + } + else { + this._label._elem.css('top', '0px'); + } + this._label.pack(); + } + } + else { + for (var i=0; i<ticks.length; i++) { + var t = ticks[i]; + if (t.show && t.showLabel) { + var shim; + if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { + // will need to adjust auto positioning based on which axis this is. + var temp = (this.name == 'yaxis') ? 1 : -1; + switch (t.labelPosition) { + case 'auto': + // position at end + case 'end': + if (temp * t.angle < 0) { + shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; + } + else { + shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; + } + break; + case 'start': + if (t.angle > 0) { + shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; + } + else { + shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; + } + break; + case 'middle': + // if (t.angle > 0) { + // shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + // } + // else { + // shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; + // } + shim = -t.getHeight()/2; + break; + default: + shim = -t.getHeight()/2; + break; + } + } + else { + shim = -t.getHeight()/2; + } + + var val = this.u2p(t.value) + shim + 'px'; + t._elem.css('top', val); + t.pack(); + } + } + if (lshow) { + var h = this._label._elem.outerHeight(true); + this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px'); + if (this.name == 'yaxis') { + this._label._elem.css('left', '0px'); + } + else { + this._label._elem.css('right', '0px'); + } + this._label.pack(); + } + } + } + + ticks = null; + }; +})(jQuery); +/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // class: $.jqplot.AxisTickRenderer + // A "tick" object showing the value of a tick/gridline on the plot. + $.jqplot.AxisTickRenderer = function(options) { + // Group: Properties + $.jqplot.ElemContainer.call(this); + // prop: mark + // tick mark on the axis. One of 'inside', 'outside', 'cross', '' or null. + this.mark = 'outside'; + // name of the axis associated with this tick + this.axis; + // prop: showMark + // wether or not to show the mark on the axis. + this.showMark = true; + // prop: showGridline + // wether or not to draw the gridline on the grid at this tick. + this.showGridline = true; + // prop: isMinorTick + // if this is a minor tick. + this.isMinorTick = false; + // prop: size + // Length of the tick beyond the grid in pixels. + // DEPRECATED: This has been superceeded by markSize + this.size = 4; + // prop: markSize + // Length of the tick marks in pixels. For 'cross' style, length + // will be stoked above and below axis, so total length will be twice this. + this.markSize = 6; + // prop: show + // wether or not to show the tick (mark and label). + // Setting this to false requires more testing. It is recommended + // to set showLabel and showMark to false instead. + this.show = true; + // prop: showLabel + // wether or not to show the label. + this.showLabel = true; + this.label = null; + this.value = null; + this._styles = {}; + // prop: formatter + // A class of a formatter for the tick text. sprintf by default. + this.formatter = $.jqplot.DefaultTickFormatter; + // prop: prefix + // String to prepend to the tick label. + // Prefix is prepended to the formatted tick label. + this.prefix = ''; + // prop: suffix + // String to append to the tick label. + // Suffix is appended to the formatted tick label. + this.suffix = ''; + // prop: formatString + // string passed to the formatter. + this.formatString = ''; + // prop: fontFamily + // css spec for the font-family css attribute. + this.fontFamily; + // prop: fontSize + // css spec for the font-size css attribute. + this.fontSize; + // prop: textColor + // css spec for the color attribute. + this.textColor; + // prop: escapeHTML + // true to escape HTML entities in the label. + this.escapeHTML = false; + this._elem; + this._breakTick = false; + + $.extend(true, this, options); + }; + + $.jqplot.AxisTickRenderer.prototype.init = function(options) { + $.extend(true, this, options); + }; + + $.jqplot.AxisTickRenderer.prototype = new $.jqplot.ElemContainer(); + $.jqplot.AxisTickRenderer.prototype.constructor = $.jqplot.AxisTickRenderer; + + $.jqplot.AxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) { + this.value = value; + this.axis = axisName; + if (isMinor) { + this.isMinorTick = true; + } + return this; + }; + + $.jqplot.AxisTickRenderer.prototype.draw = function() { + if (this.label === null) { + this.label = this.prefix + this.formatter(this.formatString, this.value) + this.suffix; + } + var style = {position: 'absolute'}; + if (Number(this.label)) { + style['whitSpace'] = 'nowrap'; + } + + // Memory Leaks patch + if (this._elem) { + this._elem.emptyForce(); + this._elem = null; + } + + this._elem = $(document.createElement('div')); + this._elem.addClass("jqplot-"+this.axis+"-tick"); + + if (!this.escapeHTML) { + this._elem.html(this.label); + } + else { + this._elem.text(this.label); + } + + this._elem.css(style); + + for (var s in this._styles) { + this._elem.css(s, this._styles[s]); + } + if (this.fontFamily) { + this._elem.css('font-family', this.fontFamily); + } + if (this.fontSize) { + this._elem.css('font-size', this.fontSize); + } + if (this.textColor) { + this._elem.css('color', this.textColor); + } + if (this._breakTick) { + this._elem.addClass('jqplot-breakTick'); + } + + return this._elem; + }; + + $.jqplot.DefaultTickFormatter = function (format, val) { + if (typeof val == 'number') { + if (!format) { + format = $.jqplot.config.defaultTickFormatString; + } + return $.jqplot.sprintf(format, val); + } + else { + return String(val); + } + }; + + $.jqplot.PercentTickFormatter = function (format, val) { + if (typeof val == 'number') { + val = 100 * val; + if (!format) { + format = $.jqplot.config.defaultTickFormatString; + } + return $.jqplot.sprintf(format, val); + } + else { + return String(val); + } + }; + + $.jqplot.AxisTickRenderer.prototype.pack = function() { + }; +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // class: $.jqplot.AxisLabelRenderer + // Renderer to place labels on the axes. + $.jqplot.AxisLabelRenderer = function(options) { + // Group: Properties + $.jqplot.ElemContainer.call(this); + // name of the axis associated with this tick + this.axis; + // prop: show + // wether or not to show the tick (mark and label). + this.show = true; + // prop: label + // The text or html for the label. + this.label = ''; + this.fontFamily = null; + this.fontSize = null; + this.textColor = null; + this._elem; + // prop: escapeHTML + // true to escape HTML entities in the label. + this.escapeHTML = false; + + $.extend(true, this, options); + }; + + $.jqplot.AxisLabelRenderer.prototype = new $.jqplot.ElemContainer(); + $.jqplot.AxisLabelRenderer.prototype.constructor = $.jqplot.AxisLabelRenderer; + + $.jqplot.AxisLabelRenderer.prototype.init = function(options) { + $.extend(true, this, options); + }; + + $.jqplot.AxisLabelRenderer.prototype.draw = function(ctx, plot) { + // Memory Leaks patch + if (this._elem) { + this._elem.emptyForce(); + this._elem = null; + } + + this._elem = $('<div style="position:absolute;" class="jqplot-'+this.axis+'-label"></div>'); + + if (Number(this.label)) { + this._elem.css('white-space', 'nowrap'); + } + + if (!this.escapeHTML) { + this._elem.html(this.label); + } + else { + this._elem.text(this.label); + } + if (this.fontFamily) { + this._elem.css('font-family', this.fontFamily); + } + if (this.fontSize) { + this._elem.css('font-size', this.fontSize); + } + if (this.textColor) { + this._elem.css('color', this.textColor); + } + + return this._elem; + }; + + $.jqplot.AxisLabelRenderer.prototype.pack = function() { + }; +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // class $.jqplot.TableLegendRenderer + // The default legend renderer for jqPlot. + $.jqplot.TableLegendRenderer = function(){ + // + }; + + $.jqplot.TableLegendRenderer.prototype.init = function(options) { + $.extend(true, this, options); + }; + + $.jqplot.TableLegendRenderer.prototype.addrow = function (label, color, pad, reverse) { + var rs = (pad) ? this.rowSpacing+'px' : '0px'; + var tr; + var td; + var elem; + var div0; + var div1; + elem = document.createElement('tr'); + tr = $(elem); + tr.addClass('jqplot-table-legend'); + elem = null; + + if (reverse){ + tr.prependTo(this._elem); + } + + else{ + tr.appendTo(this._elem); + } + + if (this.showSwatches) { + td = $(document.createElement('td')); + td.addClass('jqplot-table-legend jqplot-table-legend-swatch'); + td.css({textAlign: 'center', paddingTop: rs}); + + div0 = $(document.createElement('div')); + div0.addClass('jqplot-table-legend-swatch-outline'); + div1 = $(document.createElement('div')); + div1.addClass('jqplot-table-legend-swatch'); + div1.css({backgroundColor: color, borderColor: color}); + + tr.append(td.append(div0.append(div1))); + + // $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+ + // '<div><div class="jqplot-table-legend-swatch" style="background-color:'+color+';border-color:'+color+';"></div>'+ + // '</div></td>').appendTo(tr); + } + if (this.showLabels) { + td = $(document.createElement('td')); + td.addClass('jqplot-table-legend jqplot-table-legend-label'); + td.css('paddingTop', rs); + tr.append(td); + + // elem = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>'); + // elem.appendTo(tr); + if (this.escapeHtml) { + td.text(label); + } + else { + td.html(label); + } + } + td = null; + div0 = null; + div1 = null; + tr = null; + elem = null; + }; + + // called with scope of legend + $.jqplot.TableLegendRenderer.prototype.draw = function() { + if (this._elem) { + this._elem.emptyForce(); + this._elem = null; + } + + if (this.show) { + var series = this._series; + // make a table. one line label per row. + var elem = document.createElement('table'); + this._elem = $(elem); + this._elem.addClass('jqplot-table-legend'); + + var ss = {position:'absolute'}; + if (this.background) { + ss['background'] = this.background; + } + if (this.border) { + ss['border'] = this.border; + } + if (this.fontSize) { + ss['fontSize'] = this.fontSize; + } + if (this.fontFamily) { + ss['fontFamily'] = this.fontFamily; + } + if (this.textColor) { + ss['textColor'] = this.textColor; + } + if (this.marginTop != null) { + ss['marginTop'] = this.marginTop; + } + if (this.marginBottom != null) { + ss['marginBottom'] = this.marginBottom; + } + if (this.marginLeft != null) { + ss['marginLeft'] = this.marginLeft; + } + if (this.marginRight != null) { + ss['marginRight'] = this.marginRight; + } + + + var pad = false, + reverse = false, + s; + for (var i = 0; i< series.length; i++) { + s = series[i]; + if (s._stack || s.renderer.constructor == $.jqplot.BezierCurveRenderer){ + reverse = true; + } + if (s.show && s.showLabel) { + var lt = this.labels[i] || s.label.toString(); + if (lt) { + var color = s.color; + if (reverse && i < series.length - 1){ + pad = true; + } + else if (reverse && i == series.length - 1){ + pad = false; + } + this.renderer.addrow.call(this, lt, color, pad, reverse); + pad = true; + } + // let plugins add more rows to legend. Used by trend line plugin. + for (var j=0; j<$.jqplot.addLegendRowHooks.length; j++) { + var item = $.jqplot.addLegendRowHooks[j].call(this, s); + if (item) { + this.renderer.addrow.call(this, item.label, item.color, pad); + pad = true; + } + } + lt = null; + } + } + } + return this._elem; + }; + + $.jqplot.TableLegendRenderer.prototype.pack = function(offsets) { + if (this.show) { + if (this.placement == 'insideGrid') { + switch (this.location) { + case 'nw': + var a = offsets.left; + var b = offsets.top; + this._elem.css('left', a); + this._elem.css('top', b); + break; + case 'n': + var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; + var b = offsets.top; + this._elem.css('left', a); + this._elem.css('top', b); + break; + case 'ne': + var a = offsets.right; + var b = offsets.top; + this._elem.css({right:a, top:b}); + break; + case 'e': + var a = offsets.right; + var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; + this._elem.css({right:a, top:b}); + break; + case 'se': + var a = offsets.right; + var b = offsets.bottom; + this._elem.css({right:a, bottom:b}); + break; + case 's': + var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; + var b = offsets.bottom; + this._elem.css({left:a, bottom:b}); + break; + case 'sw': + var a = offsets.left; + var b = offsets.bottom; + this._elem.css({left:a, bottom:b}); + break; + case 'w': + var a = offsets.left; + var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; + this._elem.css({left:a, top:b}); + break; + default: // same as 'se' + var a = offsets.right; + var b = offsets.bottom; + this._elem.css({right:a, bottom:b}); + break; + } + + } + else if (this.placement == 'outside'){ + switch (this.location) { + case 'nw': + var a = this._plotDimensions.width - offsets.left; + var b = offsets.top; + this._elem.css('right', a); + this._elem.css('top', b); + break; + case 'n': + var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; + var b = this._plotDimensions.height - offsets.top; + this._elem.css('left', a); + this._elem.css('bottom', b); + break; + case 'ne': + var a = this._plotDimensions.width - offsets.right; + var b = offsets.top; + this._elem.css({left:a, top:b}); + break; + case 'e': + var a = this._plotDimensions.width - offsets.right; + var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; + this._elem.css({left:a, top:b}); + break; + case 'se': + var a = this._plotDimensions.width - offsets.right; + var b = offsets.bottom; + this._elem.css({left:a, bottom:b}); + break; + case 's': + var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; + var b = this._plotDimensions.height - offsets.bottom; + this._elem.css({left:a, top:b}); + break; + case 'sw': + var a = this._plotDimensions.width - offsets.left; + var b = offsets.bottom; + this._elem.css({right:a, bottom:b}); + break; + case 'w': + var a = this._plotDimensions.width - offsets.left; + var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; + this._elem.css({right:a, top:b}); + break; + default: // same as 'se' + var a = offsets.right; + var b = offsets.bottom; + this._elem.css({right:a, bottom:b}); + break; + } + } + else { + switch (this.location) { + case 'nw': + this._elem.css({left:0, top:offsets.top}); + break; + case 'n': + var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; + this._elem.css({left: a, top:offsets.top}); + break; + case 'ne': + this._elem.css({right:0, top:offsets.top}); + break; + case 'e': + var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; + this._elem.css({right:offsets.right, top:b}); + break; + case 'se': + this._elem.css({right:offsets.right, bottom:offsets.bottom}); + break; + case 's': + var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2; + this._elem.css({left: a, bottom:offsets.bottom}); + break; + case 'sw': + this._elem.css({left:offsets.left, bottom:offsets.bottom}); + break; + case 'w': + var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2; + this._elem.css({left:offsets.left, top:b}); + break; + default: // same as 'se' + this._elem.css({right:offsets.right, bottom:offsets.bottom}); + break; + } + } + } + }; +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // Class: $.jqplot.LineRenderer + // The default line renderer for jqPlot, this class has no options beyond the <Series> class. + // Draws series as a line. + $.jqplot.LineRenderer = function(){ + this.shapeRenderer = new $.jqplot.ShapeRenderer(); + this.shadowRenderer = new $.jqplot.ShadowRenderer(); + }; + + // called with scope of series. + $.jqplot.LineRenderer.prototype.init = function(options, plot) { + // Group: Properties + // + options = options || {}; + this._type='line'; + this.renderer.animation = { + show: false, + direction: 'left', + speed: 2500, + _supported: true + }; + // prop: smooth + // True to draw a smoothed (interpolated) line through the data points + // with automatically computed number of smoothing points. + // Set to an integer number > 2 to specify number of smoothing points + // to use between each data point. + this.renderer.smooth = false; // true or a number > 2 for smoothing. + this.renderer.tension = null; // null to auto compute or a number typically > 6. Fewer points requires higher tension. + // prop: constrainSmoothing + // True to use a more accurate smoothing algorithm that will + // not overshoot any data points. False to allow overshoot but + // produce a smoother looking line. + this.renderer.constrainSmoothing = true; + // this is smoothed data in grid coordinates, like gridData + this.renderer._smoothedData = []; + // this is smoothed data in plot units (plot coordinates), like plotData. + this.renderer._smoothedPlotData = []; + this.renderer._hiBandGridData = []; + this.renderer._lowBandGridData = []; + this.renderer._hiBandSmoothedData = []; + this.renderer._lowBandSmoothedData = []; + + // prop: bandData + // Data used to draw error bands or confidence intervals above/below a line. + // + // bandData can be input in 3 forms. jqPlot will figure out which is the + // low band line and which is the high band line for all forms: + // + // A 2 dimensional array like [[yl1, yl2, ...], [yu1, yu2, ...]] where + // [yl1, yl2, ...] are y values of the lower line and + // [yu1, yu2, ...] are y values of the upper line. + // In this case there must be the same number of y data points as data points + // in the series and the bands will inherit the x values of the series. + // + // A 2 dimensional array like [[[xl1, yl1], [xl2, yl2], ...], [[xh1, yh1], [xh2, yh2], ...]] + // where [xl1, yl1] are x,y data points for the lower line and + // [xh1, yh1] are x,y data points for the high line. + // x values do not have to correspond to the x values of the series and can + // be of any arbitrary length. + // + // Can be of form [[yl1, yu1], [yl2, yu2], [yl3, yu3], ...] where + // there must be 3 or more arrays and there must be the same number of arrays + // as there are data points in the series. In this case, + // [yl1, yu1] specifies the lower and upper y values for the 1st + // data point and so on. The bands will inherit the x + // values from the series. + this.renderer.bandData = []; + + // Group: bands + // Banding around line, e.g error bands or confidence intervals. + this.renderer.bands = { + // prop: show + // true to show the bands. If bandData or interval is + // supplied, show will be set to true by default. + show: false, + hiData: [], + lowData: [], + // prop: color + // color of lines at top and bottom of bands [default: series color]. + color: this.color, + // prop: showLines + // True to show lines at top and bottom of bands [default: false]. + showLines: false, + // prop: fill + // True to fill area between bands [default: true]. + fill: true, + // prop: fillColor + // css color spec for filled area. [default: series color]. + fillColor: null, + _min: null, + _max: null, + // prop: interval + // User specified interval above and below line for bands [default: '3%'']. + // Can be a value like 3 or a string like '3%' + // or an upper/lower array like [1, -2] or ['2%', '-1.5%'] + interval: '3%' + }; + + + var lopts = {highlightMouseOver: options.highlightMouseOver, highlightMouseDown: options.highlightMouseDown, highlightColor: options.highlightColor}; + + delete (options.highlightMouseOver); + delete (options.highlightMouseDown); + delete (options.highlightColor); + + $.extend(true, this.renderer, options); + + this.renderer.options = options; + + // if we are given some band data, and bands aren't explicity set to false in options, turn them on. + if (this.renderer.bandData.length > 1 && (!options.bands || options.bands.show == null)) { + this.renderer.bands.show = true; + } + + // if we are given an interval, and bands aren't explicity set to false in options, turn them on. + else if (options.bands && options.bands.show == null && options.bands.interval != null) { + this.renderer.bands.show = true; + } + + // if plot is filled, turn off bands. + if (this.fill) { + this.renderer.bands.show = false; + } + + if (this.renderer.bands.show) { + this.renderer.initBands.call(this, this.renderer.options, plot); + } + + + // smoothing is not compatible with stacked lines, disable + if (this._stack) { + this.renderer.smooth = false; + } + + // set the shape renderer options + var opts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.fillColor, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill}; + this.renderer.shapeRenderer.init(opts); + + var shadow_offset = options.shadowOffset; + // set the shadow renderer options + if (shadow_offset == null) { + // scale the shadowOffset to the width of the line. + if (this.lineWidth > 2.5) { + shadow_offset = 1.25 * (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6); + // var shadow_offset = this.shadowOffset; + } + // for skinny lines, don't make such a big shadow. + else { + shadow_offset = 1.25 * Math.atan((this.lineWidth/2.5))/0.785398163; + } + } + + var sopts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill}; + this.renderer.shadowRenderer.init(sopts); + this._areaPoints = []; + this._boundingBox = [[],[]]; + + if (!this.isTrendline && this.fill || this.renderer.bands.show) { + // Group: Properties + // + // prop: highlightMouseOver + // True to highlight area on a filled plot when moused over. + // This must be false to enable highlightMouseDown to highlight when clicking on an area on a filled plot. + this.highlightMouseOver = true; + // prop: highlightMouseDown + // True to highlight when a mouse button is pressed over an area on a filled plot. + // This will be disabled if highlightMouseOver is true. + this.highlightMouseDown = false; + // prop: highlightColor + // color to use when highlighting an area on a filled plot. + this.highlightColor = null; + // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver + if (lopts.highlightMouseDown && lopts.highlightMouseOver == null) { + lopts.highlightMouseOver = false; + } + + $.extend(true, this, {highlightMouseOver: lopts.highlightMouseOver, highlightMouseDown: lopts.highlightMouseDown, highlightColor: lopts.highlightColor}); + + if (!this.highlightColor) { + var fc = (this.renderer.bands.show) ? this.renderer.bands.fillColor : this.fillColor; + this.highlightColor = $.jqplot.computeHighlightColors(fc); + } + // turn off (disable) the highlighter plugin + if (this.highlighter) { + this.highlighter.show = false; + } + } + + if (!this.isTrendline && plot) { + plot.plugins.lineRenderer = {}; + plot.postInitHooks.addOnce(postInit); + plot.postDrawHooks.addOnce(postPlotDraw); + plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove); + plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown); + plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp); + plot.eventListenerHooks.addOnce('jqplotClick', handleClick); + plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick); + } + + }; + + $.jqplot.LineRenderer.prototype.initBands = function(options, plot) { + // use bandData if no data specified in bands option + //var bd = this.renderer.bandData; + var bd = options.bandData || []; + var bands = this.renderer.bands; + bands.hiData = []; + bands.lowData = []; + var data = this.data; + bands._max = null; + bands._min = null; + // If 2 arrays, and each array greater than 2 elements, assume it is hi and low data bands of y values. + if (bd.length == 2) { + // Do we have an array of x,y values? + // like [[[1,1], [2,4], [3,3]], [[1,3], [2,6], [3,5]]] + if ($.isArray(bd[0][0])) { + // since an arbitrary array of points, spin through all of them to determine max and min lines. + + var p; + var bdminidx = 0, bdmaxidx = 0; + for (var i = 0, l = bd[0].length; i<l; i++) { + p = bd[0][i]; + if ((p[1] != null && p[1] > bands._max) || bands._max == null) { + bands._max = p[1]; + } + if ((p[1] != null && p[1] < bands._min) || bands._min == null) { + bands._min = p[1]; + } + } + for (var i = 0, l = bd[1].length; i<l; i++) { + p = bd[1][i]; + if ((p[1] != null && p[1] > bands._max) || bands._max == null) { + bands._max = p[1]; + bdmaxidx = 1; + } + if ((p[1] != null && p[1] < bands._min) || bands._min == null) { + bands._min = p[1]; + bdminidx = 1; + } + } + + if (bdmaxidx === bdminidx) { + bands.show = false; + } + + bands.hiData = bd[bdmaxidx]; + bands.lowData = bd[bdminidx]; + } + // else data is arrays of y values + // like [[1,4,3], [3,6,5]] + // must have same number of band data points as points in series + else if (bd[0].length === data.length && bd[1].length === data.length) { + var hi = (bd[0][0] > bd[1][0]) ? 0 : 1; + var low = (hi) ? 0 : 1; + for (var i=0, l=data.length; i < l; i++) { + bands.hiData.push([data[i][0], bd[hi][i]]); + bands.lowData.push([data[i][0], bd[low][i]]); + } + } + + // we don't have proper data array, don't show bands. + else { + bands.show = false; + } + } + + // if more than 2 arrays, have arrays of [ylow, yhi] values. + // note, can't distinguish case of [[ylow, yhi], [ylow, yhi]] from [[ylow, ylow], [yhi, yhi]] + // this is assumed to be of the latter form. + else if (bd.length > 2 && !$.isArray(bd[0][0])) { + var hi = (bd[0][0] > bd[0][1]) ? 0 : 1; + var low = (hi) ? 0 : 1; + for (var i=0, l=bd.length; i<l; i++) { + bands.hiData.push([data[i][0], bd[i][hi]]); + bands.lowData.push([data[i][0], bd[i][low]]); + } + } + + // don't have proper data, auto calculate + else { + var intrv = bands.interval; + var a = null; + var b = null; + var afunc = null; + var bfunc = null; + + if ($.isArray(intrv)) { + a = intrv[0]; + b = intrv[1]; + } + else { + a = intrv; + } + + if (isNaN(a)) { + // we have a string + if (a.charAt(a.length - 1) === '%') { + afunc = 'multiply'; + a = parseFloat(a)/100 + 1; + } + } + + else { + a = parseFloat(a); + afunc = 'add'; + } + + if (b !== null && isNaN(b)) { + // we have a string + if (b.charAt(b.length - 1) === '%') { + bfunc = 'multiply'; + b = parseFloat(b)/100 + 1; + } + } + + else if (b !== null) { + b = parseFloat(b); + bfunc = 'add'; + } + + if (a !== null) { + if (b === null) { + b = -a; + bfunc = afunc; + if (bfunc === 'multiply') { + b += 2; + } + } + + // make sure a always applies to hi band. + if (a < b) { + var temp = a; + a = b; + b = temp; + temp = afunc; + afunc = bfunc; + bfunc = temp; + } + + for (var i=0, l = data.length; i < l; i++) { + switch (afunc) { + case 'add': + bands.hiData.push([data[i][0], data[i][1] + a]); + break; + case 'multiply': + bands.hiData.push([data[i][0], data[i][1] * a]); + break; + } + switch (bfunc) { + case 'add': + bands.lowData.push([data[i][0], data[i][1] + b]); + break; + case 'multiply': + bands.lowData.push([data[i][0], data[i][1] * b]); + break; + } + } + } + + else { + bands.show = false; + } + } + + var hd = bands.hiData; + var ld = bands.lowData; + for (var i = 0, l = hd.length; i<l; i++) { + if ((hd[i][1] != null && hd[i][1] > bands._max) || bands._max == null) { + bands._max = hd[i][1]; + } + } + for (var i = 0, l = ld.length; i<l; i++) { + if ((ld[i][1] != null && ld[i][1] < bands._min) || bands._min == null) { + bands._min = ld[i][1]; + } + } + + // one last check for proper data + // these don't apply any more since allowing arbitrary x,y values + // if (bands.hiData.length != bands.lowData.length) { + // bands.show = false; + // } + + // if (bands.hiData.length != this.data.length) { + // bands.show = false; + // } + + if (bands.fillColor === null) { + var c = $.jqplot.getColorComponents(bands.color); + // now adjust alpha to differentiate fill + c[3] = c[3] * 0.5; + bands.fillColor = 'rgba(' + c[0] +', '+ c[1] +', '+ c[2] +', '+ c[3] + ')'; + } + }; + + function getSteps (d, f) { + return (3.4182054+f) * Math.pow(d, -0.3534992); + } + + function computeSteps (d1, d2) { + var s = Math.sqrt(Math.pow((d2[0]- d1[0]), 2) + Math.pow ((d2[1] - d1[1]), 2)); + return 5.7648 * Math.log(s) + 7.4456; + } + + function tanh (x) { + var a = (Math.exp(2*x) - 1) / (Math.exp(2*x) + 1); + return a; + } + + ////////// + // computeConstrainedSmoothedData + // An implementation of the constrained cubic spline interpolation + // method as presented in: + // + // Kruger, CJC, Constrained Cubic Spine Interpolation for Chemical Engineering Applications + // http://www.korf.co.uk/spline.pdf + // + // The implementation below borrows heavily from the sample Visual Basic + // implementation by CJC Kruger found in http://www.korf.co.uk/spline.xls + // + ///////// + + // called with scope of series + function computeConstrainedSmoothedData (gd) { + var smooth = this.renderer.smooth; + var dim = this.canvas.getWidth(); + var xp = this._xaxis.series_p2u; + var yp = this._yaxis.series_p2u; + var steps =null; + var _steps = null; + var dist = gd.length/dim; + var _smoothedData = []; + var _smoothedPlotData = []; + + if (!isNaN(parseFloat(smooth))) { + steps = parseFloat(smooth); + } + else { + steps = getSteps(dist, 0.5); + } + + var yy = []; + var xx = []; + + for (var i=0, l = gd.length; i<l; i++) { + yy.push(gd[i][1]); + xx.push(gd[i][0]); + } + + function dxx(x1, x0) { + if (x1 - x0 == 0) { + return Math.pow(10,10); + } + else { + return x1 - x0; + } + } + + var A, B, C, D; + // loop through each line segment. Have # points - 1 line segments. Nmber segments starting at 1. + var nmax = gd.length - 1; + for (var num = 1, gdl = gd.length; num<gdl; num++) { + var gxx = []; + var ggxx = []; + // point at each end of segment. + for (var j = 0; j < 2; j++) { + var i = num - 1 + j; // point number, 0 to # points. + + if (i == 0 || i == nmax) { + gxx[j] = Math.pow(10, 10); + } + else if (yy[i+1] - yy[i] == 0 || yy[i] - yy[i-1] == 0) { + gxx[j] = 0; + } + else if (((xx[i+1] - xx[i]) / (yy[i+1] - yy[i]) + (xx[i] - xx[i-1]) / (yy[i] - yy[i-1])) == 0 ) { + gxx[j] = 0; + } + else if ( (yy[i+1] - yy[i]) * (yy[i] - yy[i-1]) < 0 ) { + gxx[j] = 0; + } + + else { + gxx[j] = 2 / (dxx(xx[i + 1], xx[i]) / (yy[i + 1] - yy[i]) + dxx(xx[i], xx[i - 1]) / (yy[i] - yy[i - 1])); + } + } + + // Reset first derivative (slope) at first and last point + if (num == 1) { + // First point has 0 2nd derivative + gxx[0] = 3 / 2 * (yy[1] - yy[0]) / dxx(xx[1], xx[0]) - gxx[1] / 2; + } + else if (num == nmax) { + // Last point has 0 2nd derivative + gxx[1] = 3 / 2 * (yy[nmax] - yy[nmax - 1]) / dxx(xx[nmax], xx[nmax - 1]) - gxx[0] / 2; + } + + // Calc second derivative at points + ggxx[0] = -2 * (gxx[1] + 2 * gxx[0]) / dxx(xx[num], xx[num - 1]) + 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2); + ggxx[1] = 2 * (2 * gxx[1] + gxx[0]) / dxx(xx[num], xx[num - 1]) - 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2); + + // Calc constants for cubic interpolation + D = 1 / 6 * (ggxx[1] - ggxx[0]) / dxx(xx[num], xx[num - 1]); + C = 1 / 2 * (xx[num] * ggxx[0] - xx[num - 1] * ggxx[1]) / dxx(xx[num], xx[num - 1]); + B = (yy[num] - yy[num - 1] - C * (Math.pow(xx[num], 2) - Math.pow(xx[num - 1], 2)) - D * (Math.pow(xx[num], 3) - Math.pow(xx[num - 1], 3))) / dxx(xx[num], xx[num - 1]); + A = yy[num - 1] - B * xx[num - 1] - C * Math.pow(xx[num - 1], 2) - D * Math.pow(xx[num - 1], 3); + + var increment = (xx[num] - xx[num - 1]) / steps; + var temp, tempx; + + for (var j = 0, l = steps; j < l; j++) { + temp = []; + tempx = xx[num - 1] + j * increment; + temp.push(tempx); + temp.push(A + B * tempx + C * Math.pow(tempx, 2) + D * Math.pow(tempx, 3)); + _smoothedData.push(temp); + _smoothedPlotData.push([xp(temp[0]), yp(temp[1])]); + } + } + + _smoothedData.push(gd[i]); + _smoothedPlotData.push([xp(gd[i][0]), yp(gd[i][1])]); + + return [_smoothedData, _smoothedPlotData]; + } + + /////// + // computeHermiteSmoothedData + // A hermite spline smoothing of the plot data. + // This implementation is derived from the one posted + // by krypin on the jqplot-users mailing list: + // + // http://groups.google.com/group/jqplot-users/browse_thread/thread/748be6a445723cea?pli=1 + // + // with a blog post: + // + // http://blog.statscollector.com/a-plugin-renderer-for-jqplot-to-draw-a-hermite-spline/ + // + // and download of the original plugin: + // + // http://blog.statscollector.com/wp-content/uploads/2010/02/jqplot.hermiteSplineRenderer.js + ////////// + + // called with scope of series + function computeHermiteSmoothedData (gd) { + var smooth = this.renderer.smooth; + var tension = this.renderer.tension; + var dim = this.canvas.getWidth(); + var xp = this._xaxis.series_p2u; + var yp = this._yaxis.series_p2u; + var steps =null; + var _steps = null; + var a = null; + var a1 = null; + var a2 = null; + var slope = null; + var slope2 = null; + var temp = null; + var t, s, h1, h2, h3, h4; + var TiX, TiY, Ti1X, Ti1Y; + var pX, pY, p; + var sd = []; + var spd = []; + var dist = gd.length/dim; + var min, max, stretch, scale, shift; + var _smoothedData = []; + var _smoothedPlotData = []; + if (!isNaN(parseFloat(smooth))) { + steps = parseFloat(smooth); + } + else { + steps = getSteps(dist, 0.5); + } + if (!isNaN(parseFloat(tension))) { + tension = parseFloat(tension); + } + + for (var i=0, l = gd.length-1; i < l; i++) { + + if (tension === null) { + slope = Math.abs((gd[i+1][1] - gd[i][1]) / (gd[i+1][0] - gd[i][0])); + + min = 0.3; + max = 0.6; + stretch = (max - min)/2.0; + scale = 2.5; + shift = -1.4; + + temp = slope/scale + shift; + + a1 = stretch * tanh(temp) - stretch * tanh(shift) + min; + + // if have both left and right line segments, will use minimum tension. + if (i > 0) { + slope2 = Math.abs((gd[i][1] - gd[i-1][1]) / (gd[i][0] - gd[i-1][0])); + } + temp = slope2/scale + shift; + + a2 = stretch * tanh(temp) - stretch * tanh(shift) + min; + + a = (a1 + a2)/2.0; + + } + else { + a = tension; + } + for (t=0; t < steps; t++) { + s = t / steps; + h1 = (1 + 2*s)*Math.pow((1-s),2); + h2 = s*Math.pow((1-s),2); + h3 = Math.pow(s,2)*(3-2*s); + h4 = Math.pow(s,2)*(s-1); + + if (gd[i-1]) { + TiX = a * (gd[i+1][0] - gd[i-1][0]); + TiY = a * (gd[i+1][1] - gd[i-1][1]); + } else { + TiX = a * (gd[i+1][0] - gd[i][0]); + TiY = a * (gd[i+1][1] - gd[i][1]); + } + if (gd[i+2]) { + Ti1X = a * (gd[i+2][0] - gd[i][0]); + Ti1Y = a * (gd[i+2][1] - gd[i][1]); + } else { + Ti1X = a * (gd[i+1][0] - gd[i][0]); + Ti1Y = a * (gd[i+1][1] - gd[i][1]); + } + + pX = h1*gd[i][0] + h3*gd[i+1][0] + h2*TiX + h4*Ti1X; + pY = h1*gd[i][1] + h3*gd[i+1][1] + h2*TiY + h4*Ti1Y; + p = [pX, pY]; + + _smoothedData.push(p); + _smoothedPlotData.push([xp(pX), yp(pY)]); + } + } + _smoothedData.push(gd[l]); + _smoothedPlotData.push([xp(gd[l][0]), yp(gd[l][1])]); + + return [_smoothedData, _smoothedPlotData]; + } + + // setGridData + // converts the user data values to grid coordinates and stores them + // in the gridData array. + // Called with scope of a series. + $.jqplot.LineRenderer.prototype.setGridData = function(plot) { + // recalculate the grid data + var xp = this._xaxis.series_u2p; + var yp = this._yaxis.series_u2p; + var data = this._plotData; + var pdata = this._prevPlotData; + this.gridData = []; + this._prevGridData = []; + this.renderer._smoothedData = []; + this.renderer._smoothedPlotData = []; + this.renderer._hiBandGridData = []; + this.renderer._lowBandGridData = []; + this.renderer._hiBandSmoothedData = []; + this.renderer._lowBandSmoothedData = []; + var bands = this.renderer.bands; + var hasNull = false; + for (var i=0, l=data.length; i < l; i++) { + // if not a line series or if no nulls in data, push the converted point onto the array. + if (data[i][0] != null && data[i][1] != null) { + this.gridData.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]); + } + // else if there is a null, preserve it. + else if (data[i][0] == null) { + hasNull = true; + this.gridData.push([null, yp.call(this._yaxis, data[i][1])]); + } + else if (data[i][1] == null) { + hasNull = true; + this.gridData.push([xp.call(this._xaxis, data[i][0]), null]); + } + // if not a line series or if no nulls in data, push the converted point onto the array. + if (pdata[i] != null && pdata[i][0] != null && pdata[i][1] != null) { + this._prevGridData.push([xp.call(this._xaxis, pdata[i][0]), yp.call(this._yaxis, pdata[i][1])]); + } + // else if there is a null, preserve it. + else if (pdata[i] != null && pdata[i][0] == null) { + this._prevGridData.push([null, yp.call(this._yaxis, pdata[i][1])]); + } + else if (pdata[i] != null && pdata[i][0] != null && pdata[i][1] == null) { + this._prevGridData.push([xp.call(this._xaxis, pdata[i][0]), null]); + } + } + + // don't do smoothing or bands on broken lines. + if (hasNull) { + this.renderer.smooth = false; + if (this._type === 'line') { + bands.show = false; + } + } + + if (this._type === 'line' && bands.show) { + for (var i=0, l=bands.hiData.length; i<l; i++) { + this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]); + } + for (var i=0, l=bands.lowData.length; i<l; i++) { + this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]); + } + } + + // calculate smoothed data if enough points and no nulls + if (this._type === 'line' && this.renderer.smooth && this.gridData.length > 2) { + var ret; + if (this.renderer.constrainSmoothing) { + ret = computeConstrainedSmoothedData.call(this, this.gridData); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + else { + ret = computeHermiteSmoothedData.call(this, this.gridData); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + } + }; + + // makeGridData + // converts any arbitrary data values to grid coordinates and + // returns them. This method exists so that plugins can use a series' + // linerenderer to generate grid data points without overwriting the + // grid data associated with that series. + // Called with scope of a series. + $.jqplot.LineRenderer.prototype.makeGridData = function(data, plot) { + // recalculate the grid data + var xp = this._xaxis.series_u2p; + var yp = this._yaxis.series_u2p; + var gd = []; + var pgd = []; + this.renderer._smoothedData = []; + this.renderer._smoothedPlotData = []; + this.renderer._hiBandGridData = []; + this.renderer._lowBandGridData = []; + this.renderer._hiBandSmoothedData = []; + this.renderer._lowBandSmoothedData = []; + var bands = this.renderer.bands; + var hasNull = false; + for (var i=0; i<data.length; i++) { + // if not a line series or if no nulls in data, push the converted point onto the array. + if (data[i][0] != null && data[i][1] != null) { + gd.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]); + } + // else if there is a null, preserve it. + else if (data[i][0] == null) { + hasNull = true; + gd.push([null, yp.call(this._yaxis, data[i][1])]); + } + else if (data[i][1] == null) { + hasNull = true; + gd.push([xp.call(this._xaxis, data[i][0]), null]); + } + } + + // don't do smoothing or bands on broken lines. + if (hasNull) { + this.renderer.smooth = false; + if (this._type === 'line') { + bands.show = false; + } + } + + if (this._type === 'line' && bands.show) { + for (var i=0, l=bands.hiData.length; i<l; i++) { + this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]); + } + for (var i=0, l=bands.lowData.length; i<l; i++) { + this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]); + } + } + + if (this._type === 'line' && this.renderer.smooth && gd.length > 2) { + var ret; + if (this.renderer.constrainSmoothing) { + ret = computeConstrainedSmoothedData.call(this, gd); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + else { + ret = computeHermiteSmoothedData.call(this, gd); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + } + return gd; + }; + + + // called within scope of series. + $.jqplot.LineRenderer.prototype.draw = function(ctx, gd, options, plot) { + var i; + // get a copy of the options, so we don't modify the original object. + var opts = $.extend(true, {}, options); + var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; + var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; + var fill = (opts.fill != undefined) ? opts.fill : this.fill; + var fillAndStroke = (opts.fillAndStroke != undefined) ? opts.fillAndStroke : this.fillAndStroke; + var xmin, ymin, xmax, ymax; + ctx.save(); + if (gd.length) { + if (showLine) { + // if we fill, we'll have to add points to close the curve. + if (fill) { + if (this.fillToZero) { + // have to break line up into shapes at axis crossings + var negativeColor = this.negativeColor; + if (! this.useNegativeColors) { + negativeColor = opts.fillStyle; + } + var isnegative = false; + var posfs = opts.fillStyle; + + // if stoking line as well as filling, get a copy of line data. + if (fillAndStroke) { + var fasgd = gd.slice(0); + } + // if not stacked, fill down to axis + if (this.index == 0 || !this._stack) { + + var tempgd = []; + var pd = (this.renderer.smooth) ? this.renderer._smoothedPlotData : this._plotData; + this._areaPoints = []; + var pyzero = this._yaxis.series_u2p(this.fillToValue); + var pxzero = this._xaxis.series_u2p(this.fillToValue); + + opts.closePath = true; + + if (this.fillAxis == 'y') { + tempgd.push([gd[0][0], pyzero]); + this._areaPoints.push([gd[0][0], pyzero]); + + for (var i=0; i<gd.length-1; i++) { + tempgd.push(gd[i]); + this._areaPoints.push(gd[i]); + // do we have an axis crossing? + if (pd[i][1] * pd[i+1][1] < 0) { + if (pd[i][1] < 0) { + isnegative = true; + opts.fillStyle = negativeColor; + } + else { + isnegative = false; + opts.fillStyle = posfs; + } + + var xintercept = gd[i][0] + (gd[i+1][0] - gd[i][0]) * (pyzero-gd[i][1])/(gd[i+1][1] - gd[i][1]); + tempgd.push([xintercept, pyzero]); + this._areaPoints.push([xintercept, pyzero]); + // now draw this shape and shadow. + if (shadow) { + this.renderer.shadowRenderer.draw(ctx, tempgd, opts); + } + this.renderer.shapeRenderer.draw(ctx, tempgd, opts); + // now empty temp array and continue + tempgd = [[xintercept, pyzero]]; + // this._areaPoints = [[xintercept, pyzero]]; + } + } + if (pd[gd.length-1][1] < 0) { + isnegative = true; + opts.fillStyle = negativeColor; + } + else { + isnegative = false; + opts.fillStyle = posfs; + } + tempgd.push(gd[gd.length-1]); + this._areaPoints.push(gd[gd.length-1]); + tempgd.push([gd[gd.length-1][0], pyzero]); + this._areaPoints.push([gd[gd.length-1][0], pyzero]); + } + // now draw the last area. + if (shadow) { + this.renderer.shadowRenderer.draw(ctx, tempgd, opts); + } + this.renderer.shapeRenderer.draw(ctx, tempgd, opts); + + + // var gridymin = this._yaxis.series_u2p(0); + // // IE doesn't return new length on unshift + // gd.unshift([gd[0][0], gridymin]); + // len = gd.length; + // gd.push([gd[len - 1][0], gridymin]); + } + // if stacked, fill to line below + else { + var prev = this._prevGridData; + for (var i=prev.length; i>0; i--) { + gd.push(prev[i-1]); + // this._areaPoints.push(prev[i-1]); + } + if (shadow) { + this.renderer.shadowRenderer.draw(ctx, gd, opts); + } + this._areaPoints = gd; + this.renderer.shapeRenderer.draw(ctx, gd, opts); + } + } + ///////////////////////// + // Not filled to zero + //////////////////////// + else { + // if stoking line as well as filling, get a copy of line data. + if (fillAndStroke) { + var fasgd = gd.slice(0); + } + // if not stacked, fill down to axis + if (this.index == 0 || !this._stack) { + // var gridymin = this._yaxis.series_u2p(this._yaxis.min) - this.gridBorderWidth / 2; + var gridymin = ctx.canvas.height; + // IE doesn't return new length on unshift + gd.unshift([gd[0][0], gridymin]); + var len = gd.length; + gd.push([gd[len - 1][0], gridymin]); + } + // if stacked, fill to line below + else { + var prev = this._prevGridData; + for (var i=prev.length; i>0; i--) { + gd.push(prev[i-1]); + } + } + this._areaPoints = gd; + + if (shadow) { + this.renderer.shadowRenderer.draw(ctx, gd, opts); + } + + this.renderer.shapeRenderer.draw(ctx, gd, opts); + } + if (fillAndStroke) { + var fasopts = $.extend(true, {}, opts, {fill:false, closePath:false}); + this.renderer.shapeRenderer.draw(ctx, fasgd, fasopts); + ////////// + // TODO: figure out some way to do shadows nicely + // if (shadow) { + // this.renderer.shadowRenderer.draw(ctx, fasgd, fasopts); + // } + // now draw the markers + if (this.markerRenderer.show) { + if (this.renderer.smooth) { + fasgd = this.gridData; + } + for (i=0; i<fasgd.length; i++) { + this.markerRenderer.draw(fasgd[i][0], fasgd[i][1], ctx, opts.markerOptions); + } + } + } + } + else { + + if (this.renderer.bands.show) { + var bdat; + var bopts = $.extend(true, {}, opts); + if (this.renderer.bands.showLines) { + bdat = (this.renderer.smooth) ? this.renderer._hiBandSmoothedData : this.renderer._hiBandGridData; + this.renderer.shapeRenderer.draw(ctx, bdat, opts); + bdat = (this.renderer.smooth) ? this.renderer._lowBandSmoothedData : this.renderer._lowBandGridData; + this.renderer.shapeRenderer.draw(ctx, bdat, bopts); + } + + if (this.renderer.bands.fill) { + if (this.renderer.smooth) { + bdat = this.renderer._hiBandSmoothedData.concat(this.renderer._lowBandSmoothedData.reverse()); + } + else { + bdat = this.renderer._hiBandGridData.concat(this.renderer._lowBandGridData.reverse()); + } + this._areaPoints = bdat; + bopts.closePath = true; + bopts.fill = true; + bopts.fillStyle = this.renderer.bands.fillColor; + this.renderer.shapeRenderer.draw(ctx, bdat, bopts); + } + } + + if (shadow) { + this.renderer.shadowRenderer.draw(ctx, gd, opts); + } + + this.renderer.shapeRenderer.draw(ctx, gd, opts); + } + } + // calculate the bounding box + var xmin = xmax = ymin = ymax = null; + for (i=0; i<this._areaPoints.length; i++) { + var p = this._areaPoints[i]; + if (xmin > p[0] || xmin == null) { + xmin = p[0]; + } + if (ymax < p[1] || ymax == null) { + ymax = p[1]; + } + if (xmax < p[0] || xmax == null) { + xmax = p[0]; + } + if (ymin > p[1] || ymin == null) { + ymin = p[1]; + } + } + + if (this.type === 'line' && this.renderer.bands.show) { + ymax = this._yaxis.series_u2p(this.renderer.bands._min); + ymin = this._yaxis.series_u2p(this.renderer.bands._max); + } + + this._boundingBox = [[xmin, ymax], [xmax, ymin]]; + + // now draw the markers + if (this.markerRenderer.show && !fill) { + if (this.renderer.smooth) { + gd = this.gridData; + } + for (i=0; i<gd.length; i++) { + if (gd[i][0] != null && gd[i][1] != null) { + this.markerRenderer.draw(gd[i][0], gd[i][1], ctx, opts.markerOptions); + } + } + } + } + + ctx.restore(); + }; + + $.jqplot.LineRenderer.prototype.drawShadow = function(ctx, gd, options) { + // This is a no-op, shadows drawn with lines. + }; + + // called with scope of plot. + // make sure to not leave anything highlighted. + function postInit(target, data, options) { + for (var i=0; i<this.series.length; i++) { + if (this.series[i].renderer.constructor == $.jqplot.LineRenderer) { + // don't allow mouseover and mousedown at same time. + if (this.series[i].highlightMouseOver) { + this.series[i].highlightMouseDown = false; + } + } + } + } + + // called within context of plot + // create a canvas which we can draw on. + // insert it before the eventCanvas, so eventCanvas will still capture events. + function postPlotDraw() { + // Memory Leaks patch + if (this.plugins.lineRenderer && this.plugins.lineRenderer.highlightCanvas) { + this.plugins.lineRenderer.highlightCanvas.resetCanvas(); + this.plugins.lineRenderer.highlightCanvas = null; + } + + this.plugins.lineRenderer.highlightedSeriesIndex = null; + this.plugins.lineRenderer.highlightCanvas = new $.jqplot.GenericCanvas(); + + this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-lineRenderer-highlight-canvas', this._plotDimensions, this)); + this.plugins.lineRenderer.highlightCanvas.setContext(); + this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); + } + + function highlight (plot, sidx, pidx, points) { + var s = plot.series[sidx]; + var canvas = plot.plugins.lineRenderer.highlightCanvas; + canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height); + s._highlightedPoint = pidx; + plot.plugins.lineRenderer.highlightedSeriesIndex = sidx; + var opts = {fillStyle: s.highlightColor}; + if (s.type === 'line' && s.renderer.bands.show) { + opts.fill = true; + opts.closePath = true; + } + s.renderer.shapeRenderer.draw(canvas._ctx, points, opts); + canvas = null; + } + + function unhighlight (plot) { + var canvas = plot.plugins.lineRenderer.highlightCanvas; + canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height); + for (var i=0; i<plot.series.length; i++) { + plot.series[i]._highlightedPoint = null; + } + plot.plugins.lineRenderer.highlightedSeriesIndex = null; + plot.target.trigger('jqplotDataUnhighlight'); + canvas = null; + } + + + function handleMove(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var evt1 = jQuery.Event('jqplotDataMouseOver'); + evt1.pageX = ev.pageX; + evt1.pageY = ev.pageY; + plot.target.trigger(evt1, ins); + if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) { + var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points); + } + } + else if (neighbor == null) { + unhighlight (plot); + } + } + + function handleMouseDown(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) { + var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points); + } + } + else if (neighbor == null) { + unhighlight (plot); + } + } + + function handleMouseUp(ev, gridpos, datapos, neighbor, plot) { + var idx = plot.plugins.lineRenderer.highlightedSeriesIndex; + if (idx != null && plot.series[idx].highlightMouseDown) { + unhighlight(plot); + } + } + + function handleClick(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var evt = jQuery.Event('jqplotDataClick'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + } + } + + function handleRightClick(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var idx = plot.plugins.lineRenderer.highlightedSeriesIndex; + if (idx != null && plot.series[idx].highlightMouseDown) { + unhighlight(plot); + } + var evt = jQuery.Event('jqplotDataRightClick'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + } + } + +})(jQuery); /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ + + /** + * The following dashed line support contributed by Cory Sharp. + * After I implemented an inferior method, Cory responded with a generous + * contribution of code and input which proved a more powerful and + * elegant solution. + */ + +(function($) { + + var dotlen = 0.1; + + $.jqplot.LinePattern = function (ctx, pattern) { + + var defaultLinePatterns = { + dotted: [ dotlen, $.jqplot.config.dotGapLength ], + dashed: [ $.jqplot.config.dashLength, $.jqplot.config.gapLength ], + solid: null + }; + + if (typeof pattern === 'string') { + if (pattern[0] === '.' || pattern[0] === '-') { + var s = pattern; + pattern = []; + for (var i=0, imax=s.length; i<imax; i++) { + if (s[i] === '.') { + pattern.push( dotlen ); + } + else if (s[i] === '-') { + pattern.push( $.jqplot.config.dashLength ); + } + else { + continue; + } + pattern.push( $.jqplot.config.gapLength ); + } + } + else { + pattern = defaultLinePatterns[pattern]; + } + } + + if (!(pattern && pattern.length)) { + return ctx; + } + + var patternIndex = 0; + var patternDistance = pattern[0]; + var px = 0; + var py = 0; + var pathx0 = 0; + var pathy0 = 0; + + var moveTo = function (x, y) { + ctx.moveTo( x, y ); + px = x; + py = y; + pathx0 = x; + pathy0 = y; + }; + + var lineTo = function (x, y) { + var scale = ctx.lineWidth; + var dx = x - px; + var dy = y - py; + var dist = Math.sqrt(dx*dx+dy*dy); + if ((dist > 0) && (scale > 0)) { + dx /= dist; + dy /= dist; + while (true) { + var dp = scale * patternDistance; + if (dp < dist) { + px += dp * dx; + py += dp * dy; + if ((patternIndex & 1) == 0) { + ctx.lineTo( px, py ); + } + else { + ctx.moveTo( px, py ); + } + dist -= dp; + patternIndex++; + if (patternIndex >= pattern.length) { + patternIndex = 0; + } + patternDistance = pattern[patternIndex]; + } + else { + px = x; + py = y; + if ((patternIndex & 1) == 0) { + ctx.lineTo( px, py ); + } + else { + ctx.moveTo( px, py ); + } + patternDistance -= dist / scale; + break; + } + } + } + }; + + var beginPath = function () { + ctx.beginPath(); + }; + + var closePath = function () { + lineTo( pathx0, pathy0 ); + }; + + return { + moveTo: moveTo, + lineTo: lineTo, + beginPath: beginPath, + closePath: closePath + }; + }; +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // class: $.jqplot.MarkerRenderer + // The default jqPlot marker renderer, rendering the points on the line. + $.jqplot.MarkerRenderer = function(options){ + // Group: Properties + + // prop: show + // wether or not to show the marker. + this.show = true; + // prop: style + // One of diamond, circle, square, x, plus, dash, filledDiamond, filledCircle, filledSquare + this.style = 'filledCircle'; + // prop: lineWidth + // size of the line for non-filled markers. + this.lineWidth = 2; + // prop: size + // Size of the marker (diameter or circle, length of edge of square, etc.) + this.size = 9.0; + // prop: color + // color of marker. Will be set to color of series by default on init. + this.color = '#666666'; + // prop: shadow + // wether or not to draw a shadow on the line + this.shadow = true; + // prop: shadowAngle + // Shadow angle in degrees + this.shadowAngle = 45; + // prop: shadowOffset + // Shadow offset from line in pixels + this.shadowOffset = 1; + // prop: shadowDepth + // Number of times shadow is stroked, each stroke offset shadowOffset from the last. + this.shadowDepth = 3; + // prop: shadowAlpha + // Alpha channel transparency of shadow. 0 = transparent. + this.shadowAlpha = '0.07'; + // prop: shadowRenderer + // Renderer that will draws the shadows on the marker. + this.shadowRenderer = new $.jqplot.ShadowRenderer(); + // prop: shapeRenderer + // Renderer that will draw the marker. + this.shapeRenderer = new $.jqplot.ShapeRenderer(); + + $.extend(true, this, options); + }; + + $.jqplot.MarkerRenderer.prototype.init = function(options) { + $.extend(true, this, options); + var sdopt = {angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, lineWidth:this.lineWidth, depth:this.shadowDepth, closePath:true}; + if (this.style.indexOf('filled') != -1) { + sdopt.fill = true; + } + if (this.style.indexOf('ircle') != -1) { + sdopt.isarc = true; + sdopt.closePath = false; + } + this.shadowRenderer.init(sdopt); + + var shopt = {fill:false, isarc:false, strokeStyle:this.color, fillStyle:this.color, lineWidth:this.lineWidth, closePath:true}; + if (this.style.indexOf('filled') != -1) { + shopt.fill = true; + } + if (this.style.indexOf('ircle') != -1) { + shopt.isarc = true; + shopt.closePath = false; + } + this.shapeRenderer.init(shopt); + }; + + $.jqplot.MarkerRenderer.prototype.drawDiamond = function(x, y, ctx, fill, options) { + var stretch = 1.2; + var dx = this.size/2/stretch; + var dy = this.size/2*stretch; + var points = [[x-dx, y], [x, y+dy], [x+dx, y], [x, y-dy]]; + if (this.shadow) { + this.shadowRenderer.draw(ctx, points); + } + this.shapeRenderer.draw(ctx, points, options); + }; + + $.jqplot.MarkerRenderer.prototype.drawPlus = function(x, y, ctx, fill, options) { + var stretch = 1.0; + var dx = this.size/2*stretch; + var dy = this.size/2*stretch; + var points1 = [[x, y-dy], [x, y+dy]]; + var points2 = [[x+dx, y], [x-dx, y]]; + var opts = $.extend(true, {}, this.options, {closePath:false}); + if (this.shadow) { + this.shadowRenderer.draw(ctx, points1, {closePath:false}); + this.shadowRenderer.draw(ctx, points2, {closePath:false}); + } + this.shapeRenderer.draw(ctx, points1, opts); + this.shapeRenderer.draw(ctx, points2, opts); + }; + + $.jqplot.MarkerRenderer.prototype.drawX = function(x, y, ctx, fill, options) { + var stretch = 1.0; + var dx = this.size/2*stretch; + var dy = this.size/2*stretch; + var opts = $.extend(true, {}, this.options, {closePath:false}); + var points1 = [[x-dx, y-dy], [x+dx, y+dy]]; + var points2 = [[x-dx, y+dy], [x+dx, y-dy]]; + if (this.shadow) { + this.shadowRenderer.draw(ctx, points1, {closePath:false}); + this.shadowRenderer.draw(ctx, points2, {closePath:false}); + } + this.shapeRenderer.draw(ctx, points1, opts); + this.shapeRenderer.draw(ctx, points2, opts); + }; + + $.jqplot.MarkerRenderer.prototype.drawDash = function(x, y, ctx, fill, options) { + var stretch = 1.0; + var dx = this.size/2*stretch; + var dy = this.size/2*stretch; + var points = [[x-dx, y], [x+dx, y]]; + if (this.shadow) { + this.shadowRenderer.draw(ctx, points); + } + this.shapeRenderer.draw(ctx, points, options); + }; + + $.jqplot.MarkerRenderer.prototype.drawLine = function(p1, p2, ctx, fill, options) { + var points = [p1, p2]; + if (this.shadow) { + this.shadowRenderer.draw(ctx, points); + } + this.shapeRenderer.draw(ctx, points, options); + }; + + $.jqplot.MarkerRenderer.prototype.drawSquare = function(x, y, ctx, fill, options) { + var stretch = 1.0; + var dx = this.size/2/stretch; + var dy = this.size/2*stretch; + var points = [[x-dx, y-dy], [x-dx, y+dy], [x+dx, y+dy], [x+dx, y-dy]]; + if (this.shadow) { + this.shadowRenderer.draw(ctx, points); + } + this.shapeRenderer.draw(ctx, points, options); + }; + + $.jqplot.MarkerRenderer.prototype.drawCircle = function(x, y, ctx, fill, options) { + var radius = this.size/2; + var end = 2*Math.PI; + var points = [x, y, radius, 0, end, true]; + if (this.shadow) { + this.shadowRenderer.draw(ctx, points); + } + this.shapeRenderer.draw(ctx, points, options); + }; + + $.jqplot.MarkerRenderer.prototype.draw = function(x, y, ctx, options) { + options = options || {}; + // hack here b/c shape renderer uses canvas based color style options + // and marker uses css style names. + if (options.show == null || options.show != false) { + if (options.color && !options.fillStyle) { + options.fillStyle = options.color; + } + if (options.color && !options.strokeStyle) { + options.strokeStyle = options.color; + } + switch (this.style) { + case 'diamond': + this.drawDiamond(x,y,ctx, false, options); + break; + case 'filledDiamond': + this.drawDiamond(x,y,ctx, true, options); + break; + case 'circle': + this.drawCircle(x,y,ctx, false, options); + break; + case 'filledCircle': + this.drawCircle(x,y,ctx, true, options); + break; + case 'square': + this.drawSquare(x,y,ctx, false, options); + break; + case 'filledSquare': + this.drawSquare(x,y,ctx, true, options); + break; + case 'x': + this.drawX(x,y,ctx, true, options); + break; + case 'plus': + this.drawPlus(x,y,ctx, true, options); + break; + case 'dash': + this.drawDash(x,y,ctx, true, options); + break; + case 'line': + this.drawLine(x, y, ctx, false, options); + break; + default: + this.drawDiamond(x,y,ctx, false, options); + break; + } + } + }; +})(jQuery); /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // Class: $.jqplot.DivTitleRenderer + // The default title renderer for jqPlot. This class has no options beyond the <Title> class. + $.jqplot.DivTitleRenderer = function() { + }; + + $.jqplot.DivTitleRenderer.prototype.init = function(options) { + $.extend(true, this, options); + }; + + $.jqplot.DivTitleRenderer.prototype.draw = function() { + // Memory Leaks patch + if (this._elem) { + this._elem.emptyForce(); + this._elem = null; + } + + var r = this.renderer; + var elem = document.createElement('div'); + this._elem = $(elem); + this._elem.addClass('jqplot-title'); + + if (!this.text) { + this.show = false; + this._elem.height(0); + this._elem.width(0); + } + else if (this.text) { + var color; + if (this.color) { + color = this.color; + } + else if (this.textColor) { + color = this.textColor; + } + + // don't trust that a stylesheet is present, set the position. + var styles = {position:'absolute', top:'0px', left:'0px'}; + + if (this._plotWidth) { + styles['width'] = this._plotWidth+'px'; + } + if (this.fontSize) { + styles['fontSize'] = this.fontSize; + } + if (typeof this.textAlign === 'string') { + styles['textAlign'] = this.textAlign; + } + else { + styles['textAlign'] = 'center'; + } + if (color) { + styles['color'] = color; + } + if (this.paddingBottom) { + styles['paddingBottom'] = this.paddingBottom; + } + if (this.fontFamily) { + styles['fontFamily'] = this.fontFamily; + } + + this._elem.css(styles); + if (this.escapeHtml) { + this._elem.text(this.text); + } + else { + this._elem.html(this.text); + } + + + // styletext += (this._plotWidth) ? 'width:'+this._plotWidth+'px;' : ''; + // styletext += (this.fontSize) ? 'font-size:'+this.fontSize+';' : ''; + // styletext += (this.textAlign) ? 'text-align:'+this.textAlign+';' : 'text-align:center;'; + // styletext += (color) ? 'color:'+color+';' : ''; + // styletext += (this.paddingBottom) ? 'padding-bottom:'+this.paddingBottom+';' : ''; + // this._elem = $('<div class="jqplot-title" style="'+styletext+'">'+this.text+'</div>'); + // if (this.fontFamily) { + // this._elem.css('font-family', this.fontFamily); + // } + } + + elem = null; + + return this._elem; + }; + + $.jqplot.DivTitleRenderer.prototype.pack = function() { + // nothing to do here + }; +})(jQuery); /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // Class: $.jqplot.CanvasGridRenderer + // The default jqPlot grid renderer, creating a grid on a canvas element. + // The renderer has no additional options beyond the <Grid> class. + $.jqplot.CanvasGridRenderer = function(){ + this.shadowRenderer = new $.jqplot.ShadowRenderer(); + }; + + // called with context of Grid object + $.jqplot.CanvasGridRenderer.prototype.init = function(options) { + this._ctx; + $.extend(true, this, options); + // set the shadow renderer options + var sopts = {lineJoin:'miter', lineCap:'round', fill:false, isarc:false, angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.shadowWidth, closePath:false, strokeStyle:this.shadowColor}; + this.renderer.shadowRenderer.init(sopts); + }; + + // called with context of Grid. + $.jqplot.CanvasGridRenderer.prototype.createElement = function(plot) { + var elem; + // Memory Leaks patch + if (this._elem) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { + elem = this._elem.get(0); + window.G_vmlCanvasManager.uninitElement(elem); + elem = null; + } + + this._elem.emptyForce(); + this._elem = null; + } + + elem = plot.canvasManager.getCanvas(); + + var w = this._plotDimensions.width; + var h = this._plotDimensions.height; + elem.width = w; + elem.height = h; + this._elem = $(elem); + this._elem.addClass('jqplot-grid-canvas'); + this._elem.css({ position: 'absolute', left: 0, top: 0 }); + + elem = plot.canvasManager.initCanvas(elem); + + this._top = this._offsets.top; + this._bottom = h - this._offsets.bottom; + this._left = this._offsets.left; + this._right = w - this._offsets.right; + this._width = this._right - this._left; + this._height = this._bottom - this._top; + // avoid memory leak + elem = null; + return this._elem; + }; + + $.jqplot.CanvasGridRenderer.prototype.draw = function() { + this._ctx = this._elem.get(0).getContext("2d"); + var ctx = this._ctx; + var axes = this._axes; + // Add the grid onto the grid canvas. This is the bottom most layer. + ctx.save(); + ctx.clearRect(0, 0, this._plotDimensions.width, this._plotDimensions.height); + ctx.fillStyle = this.backgroundColor || this.background; + ctx.fillRect(this._left, this._top, this._width, this._height); + + ctx.save(); + ctx.lineJoin = 'miter'; + ctx.lineCap = 'butt'; + ctx.lineWidth = this.gridLineWidth; + ctx.strokeStyle = this.gridLineColor; + var b, e, s, m; + var ax = ['xaxis', 'yaxis', 'x2axis', 'y2axis']; + for (var i=4; i>0; i--) { + var name = ax[i-1]; + var axis = axes[name]; + var ticks = axis._ticks; + var numticks = ticks.length; + if (axis.show) { + if (axis.drawBaseline) { + var bopts = {}; + if (axis.baselineWidth !== null) { + bopts.lineWidth = axis.baselineWidth; + } + if (axis.baselineColor !== null) { + bopts.strokeStyle = axis.baselineColor; + } + switch (name) { + case 'xaxis': + drawLine (this._left, this._bottom, this._right, this._bottom, bopts); + break; + case 'yaxis': + drawLine (this._left, this._bottom, this._left, this._top, bopts); + break; + case 'x2axis': + drawLine (this._left, this._bottom, this._right, this._bottom, bopts); + break; + case 'y2axis': + drawLine (this._right, this._bottom, this._right, this._top, bopts); + break; + } + } + for (var j=numticks; j>0; j--) { + var t = ticks[j-1]; + if (t.show) { + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (name) { + case 'xaxis': + // draw the grid line if we should + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(pos, this._top, pos, this._bottom); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._bottom; + e = this._bottom+s; + break; + case 'inside': + b = this._bottom-s; + e = this._bottom; + break; + case 'cross': + b = this._bottom-s; + e = this._bottom+s; + break; + default: + b = this._bottom; + e = this._bottom+s; + break; + } + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false}); + } + // draw the line + drawLine(pos, b, pos, e); + } + break; + case 'yaxis': + // draw the grid line + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(this._right, pos, this._left, pos); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._left-s; + e = this._left; + break; + case 'inside': + b = this._left; + e = this._left+s; + break; + case 'cross': + b = this._left-s; + e = this._left+s; + break; + default: + b = this._left-s; + e = this._left; + break; + } + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); + } + drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + } + break; + case 'x2axis': + // draw the grid line + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(pos, this._bottom, pos, this._top); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._top-s; + e = this._top; + break; + case 'inside': + b = this._top; + e = this._top+s; + break; + case 'cross': + b = this._top-s; + e = this._top+s; + break; + default: + b = this._top-s; + e = this._top; + break; + } + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false}); + } + drawLine(pos, b, pos, e); + } + break; + case 'y2axis': + // draw the grid line + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(this._left, pos, this._right, pos); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._right; + e = this._right+s; + break; + case 'inside': + b = this._right-s; + e = this._right; + break; + case 'cross': + b = this._right-s; + e = this._right+s; + break; + default: + b = this._right; + e = this._right+s; + break; + } + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); + } + drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + } + break; + default: + break; + } + } + } + t = null; + } + axis = null; + ticks = null; + } + // Now draw grid lines for additional y axes + ////// + // TO DO: handle yMidAxis + ////// + ax = ['y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis', 'yMidAxis']; + for (var i=7; i>0; i--) { + var axis = axes[ax[i-1]]; + var ticks = axis._ticks; + if (axis.show) { + var tn = ticks[axis.numberTicks-1]; + var t0 = ticks[0]; + var left = axis.getLeft(); + var points = [[left, tn.getTop() + tn.getHeight()/2], [left, t0.getTop() + t0.getHeight()/2 + 1.0]]; + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', fill:false, closePath:false}); + } + // draw the line + drawLine(points[0][0], points[0][1], points[1][0], points[1][1], {lineCap:'butt', strokeStyle:axis.borderColor, lineWidth:axis.borderWidth}); + // draw the tick marks + for (var j=ticks.length; j>0; j--) { + var t = ticks[j-1]; + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + if (t.showMark && t.mark) { + switch (m) { + case 'outside': + b = left; + e = left+s; + break; + case 'inside': + b = left-s; + e = left; + break; + case 'cross': + b = left-s; + e = left+s; + break; + default: + b = left; + e = left+s; + break; + } + points = [[b,pos], [e,pos]]; + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); + } + // draw the line + drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + } + t = null; + } + t0 = null; + } + axis = null; + ticks = null; + } + + ctx.restore(); + + function drawLine(bx, by, ex, ey, opts) { + ctx.save(); + opts = opts || {}; + if (opts.lineWidth == null || opts.lineWidth != 0){ + $.extend(true, ctx, opts); + ctx.beginPath(); + ctx.moveTo(bx, by); + ctx.lineTo(ex, ey); + ctx.stroke(); + ctx.restore(); + } + } + + if (this.shadow) { + var points = [[this._left, this._bottom], [this._right, this._bottom], [this._right, this._top]]; + this.renderer.shadowRenderer.draw(ctx, points); + } + // Now draw border around grid. Use axis border definitions. start at + // upper left and go clockwise. + if (this.borderWidth != 0 && this.drawBorder) { + drawLine (this._left, this._top, this._right, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth}); + drawLine (this._right, this._top, this._right, this._bottom, {lineCap:'round', strokeStyle:axes.y2axis.borderColor, lineWidth:axes.y2axis.borderWidth}); + drawLine (this._right, this._bottom, this._left, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth}); + drawLine (this._left, this._bottom, this._left, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth}); + } + // ctx.lineWidth = this.borderWidth; + // ctx.strokeStyle = this.borderColor; + // ctx.strokeRect(this._left, this._top, this._width, this._height); + + ctx.restore(); + ctx = null; + axes = null; + }; +})(jQuery); /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // class: $.jqplot.shadowRenderer + // The default jqPlot shadow renderer, rendering shadows behind shapes. + $.jqplot.ShadowRenderer = function(options){ + // Group: Properties + + // prop: angle + // Angle of the shadow in degrees. Measured counter-clockwise from the x axis. + this.angle = 45; + // prop: offset + // Pixel offset at the given shadow angle of each shadow stroke from the last stroke. + this.offset = 1; + // prop: alpha + // alpha transparency of shadow stroke. + this.alpha = 0.07; + // prop: lineWidth + // width of the shadow line stroke. + this.lineWidth = 1.5; + // prop: lineJoin + // How line segments of the shadow are joined. + this.lineJoin = 'miter'; + // prop: lineCap + // how ends of the shadow line are rendered. + this.lineCap = 'round'; + // prop; closePath + // whether line path segment is closed upon itself. + this.closePath = false; + // prop: fill + // whether to fill the shape. + this.fill = false; + // prop: depth + // how many times the shadow is stroked. Each stroke will be offset by offset at angle degrees. + this.depth = 3; + this.strokeStyle = 'rgba(0,0,0,0.1)'; + // prop: isarc + // wether the shadow is an arc or not. + this.isarc = false; + + $.extend(true, this, options); + }; + + $.jqplot.ShadowRenderer.prototype.init = function(options) { + $.extend(true, this, options); + }; + + // function: draw + // draws an transparent black (i.e. gray) shadow. + // + // ctx - canvas drawing context + // points - array of points or [x, y, radius, start angle (rad), end angle (rad)] + $.jqplot.ShadowRenderer.prototype.draw = function(ctx, points, options) { + ctx.save(); + var opts = (options != null) ? options : {}; + var fill = (opts.fill != null) ? opts.fill : this.fill; + var fillRect = (opts.fillRect != null) ? opts.fillRect : this.fillRect; + var closePath = (opts.closePath != null) ? opts.closePath : this.closePath; + var offset = (opts.offset != null) ? opts.offset : this.offset; + var alpha = (opts.alpha != null) ? opts.alpha : this.alpha; + var depth = (opts.depth != null) ? opts.depth : this.depth; + var isarc = (opts.isarc != null) ? opts.isarc : this.isarc; + var linePattern = (opts.linePattern != null) ? opts.linePattern : this.linePattern; + ctx.lineWidth = (opts.lineWidth != null) ? opts.lineWidth : this.lineWidth; + ctx.lineJoin = (opts.lineJoin != null) ? opts.lineJoin : this.lineJoin; + ctx.lineCap = (opts.lineCap != null) ? opts.lineCap : this.lineCap; + ctx.strokeStyle = opts.strokeStyle || this.strokeStyle || 'rgba(0,0,0,'+alpha+')'; + ctx.fillStyle = opts.fillStyle || this.fillStyle || 'rgba(0,0,0,'+alpha+')'; + for (var j=0; j<depth; j++) { + var ctxPattern = $.jqplot.LinePattern(ctx, linePattern); + ctx.translate(Math.cos(this.angle*Math.PI/180)*offset, Math.sin(this.angle*Math.PI/180)*offset); + ctxPattern.beginPath(); + if (isarc) { + ctx.arc(points[0], points[1], points[2], points[3], points[4], true); + } + else if (fillRect) { + if (fillRect) { + ctx.fillRect(points[0], points[1], points[2], points[3]); + } + } + else if (points && points.length){ + var move = true; + for (var i=0; i<points.length; i++) { + // skip to the first non-null point and move to it. + if (points[i][0] != null && points[i][1] != null) { + if (move) { + ctxPattern.moveTo(points[i][0], points[i][1]); + move = false; + } + else { + ctxPattern.lineTo(points[i][0], points[i][1]); + } + } + else { + move = true; + } + } + + } + if (closePath) { + ctxPattern.closePath(); + } + if (fill) { + ctx.fill(); + } + else { + ctx.stroke(); + } + } + ctx.restore(); + }; +})(jQuery); /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + // class: $.jqplot.shapeRenderer + // The default jqPlot shape renderer. Given a set of points will + // plot them and either stroke a line (fill = false) or fill them (fill = true). + // If a filled shape is desired, closePath = true must also be set to close + // the shape. + $.jqplot.ShapeRenderer = function(options){ + + this.lineWidth = 1.5; + // prop: linePattern + // line pattern 'dashed', 'dotted', 'solid', some combination + // of '-' and '.' characters such as '.-.' or a numerical array like + // [draw, skip, draw, skip, ...] such as [1, 10] to draw a dotted line, + // [1, 10, 20, 10] to draw a dot-dash line, and so on. + this.linePattern = 'solid'; + // prop: lineJoin + // How line segments of the shadow are joined. + this.lineJoin = 'miter'; + // prop: lineCap + // how ends of the shadow line are rendered. + this.lineCap = 'round'; + // prop; closePath + // whether line path segment is closed upon itself. + this.closePath = false; + // prop: fill + // whether to fill the shape. + this.fill = false; + // prop: isarc + // wether the shadow is an arc or not. + this.isarc = false; + // prop: fillRect + // true to draw shape as a filled rectangle. + this.fillRect = false; + // prop: strokeRect + // true to draw shape as a stroked rectangle. + this.strokeRect = false; + // prop: clearRect + // true to cear a rectangle. + this.clearRect = false; + // prop: strokeStyle + // css color spec for the stoke style + this.strokeStyle = '#999999'; + // prop: fillStyle + // css color spec for the fill style. + this.fillStyle = '#999999'; + + $.extend(true, this, options); + }; + + $.jqplot.ShapeRenderer.prototype.init = function(options) { + $.extend(true, this, options); + }; + + // function: draw + // draws the shape. + // + // ctx - canvas drawing context + // points - array of points for shapes or + // [x, y, width, height] for rectangles or + // [x, y, radius, start angle (rad), end angle (rad)] for circles and arcs. + $.jqplot.ShapeRenderer.prototype.draw = function(ctx, points, options) { + ctx.save(); + var opts = (options != null) ? options : {}; + var fill = (opts.fill != null) ? opts.fill : this.fill; + var closePath = (opts.closePath != null) ? opts.closePath : this.closePath; + var fillRect = (opts.fillRect != null) ? opts.fillRect : this.fillRect; + var strokeRect = (opts.strokeRect != null) ? opts.strokeRect : this.strokeRect; + var clearRect = (opts.clearRect != null) ? opts.clearRect : this.clearRect; + var isarc = (opts.isarc != null) ? opts.isarc : this.isarc; + var linePattern = (opts.linePattern != null) ? opts.linePattern : this.linePattern; + var ctxPattern = $.jqplot.LinePattern(ctx, linePattern); + ctx.lineWidth = opts.lineWidth || this.lineWidth; + ctx.lineJoin = opts.lineJoin || this.lineJoin; + ctx.lineCap = opts.lineCap || this.lineCap; + ctx.strokeStyle = (opts.strokeStyle || opts.color) || this.strokeStyle; + ctx.fillStyle = opts.fillStyle || this.fillStyle; + ctx.beginPath(); + if (isarc) { + ctx.arc(points[0], points[1], points[2], points[3], points[4], true); + if (closePath) { + ctx.closePath(); + } + if (fill) { + ctx.fill(); + } + else { + ctx.stroke(); + } + ctx.restore(); + return; + } + else if (clearRect) { + ctx.clearRect(points[0], points[1], points[2], points[3]); + ctx.restore(); + return; + } + else if (fillRect || strokeRect) { + if (fillRect) { + ctx.fillRect(points[0], points[1], points[2], points[3]); + } + if (strokeRect) { + ctx.strokeRect(points[0], points[1], points[2], points[3]); + ctx.restore(); + return; + } + } + else if (points && points.length){ + var move = true; + for (var i=0; i<points.length; i++) { + // skip to the first non-null point and move to it. + if (points[i][0] != null && points[i][1] != null) { + if (move) { + ctxPattern.moveTo(points[i][0], points[i][1]); + move = false; + } + else { + ctxPattern.lineTo(points[i][0], points[i][1]); + } + } + else { + move = true; + } + } + if (closePath) { + ctxPattern.closePath(); + } + if (fill) { + ctx.fill(); + } + else { + ctx.stroke(); + } + } + ctx.restore(); + }; +})(jQuery); /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + /** + * JavaScript printf/sprintf functions. + * + * This code has been adapted from the publicly available sprintf methods + * by Ash Searle. His original header follows: + * + * This code is unrestricted: you are free to use it however you like. + * + * The functions should work as expected, performing left or right alignment, + * truncating strings, outputting numbers with a required precision etc. + * + * For complex cases, these functions follow the Perl implementations of + * (s)printf, allowing arguments to be passed out-of-order, and to set the + * precision or length of the output based on arguments instead of fixed + * numbers. + * + * See http://perldoc.perl.org/functions/sprintf.html for more information. + * + * Implemented: + * - zero and space-padding + * - right and left-alignment, + * - base X prefix (binary, octal and hex) + * - positive number prefix + * - (minimum) width + * - precision / truncation / maximum width + * - out of order arguments + * + * Not implemented (yet): + * - vector flag + * - size (bytes, words, long-words etc.) + * + * Will not implement: + * - %n or %p (no pass-by-reference in JavaScript) + * + * @version 2007.04.27 + * @author Ash Searle + * + * You can see the original work and comments on his blog: + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + */ + + /** + * @Modifications 2009.05.26 + * @author Chris Leonello + * + * Added %p %P specifier + * Acts like %g or %G but will not add more significant digits to the output than present in the input. + * Example: + * Format: '%.3p', Input: 0.012, Output: 0.012 + * Format: '%.3g', Input: 0.012, Output: 0.0120 + * Format: '%.4p', Input: 12.0, Output: 12.0 + * Format: '%.4g', Input: 12.0, Output: 12.00 + * Format: '%.4p', Input: 4.321e-5, Output: 4.321e-5 + * Format: '%.4g', Input: 4.321e-5, Output: 4.3210e-5 + * + * Example: + * >>> $.jqplot.sprintf('%.2f, %d', 23.3452, 43.23) + * "23.35, 43" + * >>> $.jqplot.sprintf("no value: %n, decimal with thousands separator: %'d", 23.3452, 433524) + * "no value: , decimal with thousands separator: 433,524" + */ + $.jqplot.sprintf = function() { + function pad(str, len, chr, leftJustify) { + var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr); + return leftJustify ? str + padding : padding + str; + + } + + function thousand_separate(value) { + var value_str = new String(value); + for (var i=10; i>0; i--) { + if (value_str == (value_str = value_str.replace(/^(\d+)(\d{3})/, "$1"+$.jqplot.sprintf.thousandsSeparator+"$2"))) break; + } + return value_str; + } + + function justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace) { + var diff = minWidth - value.length; + if (diff > 0) { + var spchar = ' '; + if (htmlSpace) { spchar = ' '; } + if (leftJustify || !zeroPad) { + value = pad(value, minWidth, spchar, leftJustify); + } else { + value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length); + } + } + return value; + } + + function formatBaseX(value, base, prefix, leftJustify, minWidth, precision, zeroPad, htmlSpace) { + // Note: casts negative numbers to positive ones + var number = value >>> 0; + prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || ''; + value = prefix + pad(number.toString(base), precision || 0, '0', false); + return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace); + } + + function formatString(value, leftJustify, minWidth, precision, zeroPad, htmlSpace) { + if (precision != null) { + value = value.slice(0, precision); + } + return justify(value, '', leftJustify, minWidth, zeroPad, htmlSpace); + } + + var a = arguments, i = 0, format = a[i++]; + + return format.replace($.jqplot.sprintf.regex, function(substring, valueIndex, flags, minWidth, _, precision, type) { + if (substring == '%%') { return '%'; } + + // parse flags + var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false, htmlSpace = false, thousandSeparation = false; + for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) { + case ' ': positivePrefix = ' '; break; + case '+': positivePrefix = '+'; break; + case '-': leftJustify = true; break; + case '0': zeroPad = true; break; + case '#': prefixBaseX = true; break; + case '&': htmlSpace = true; break; + case '\'': thousandSeparation = true; break; + } + + // parameters may be null, undefined, empty-string or real valued + // we want to ignore null, undefined and empty-string values + + if (!minWidth) { + minWidth = 0; + } + else if (minWidth == '*') { + minWidth = +a[i++]; + } + else if (minWidth.charAt(0) == '*') { + minWidth = +a[minWidth.slice(1, -1)]; + } + else { + minWidth = +minWidth; + } + + // Note: undocumented perl feature: + if (minWidth < 0) { + minWidth = -minWidth; + leftJustify = true; + } + + if (!isFinite(minWidth)) { + throw new Error('$.jqplot.sprintf: (minimum-)width must be finite'); + } + + if (!precision) { + precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0); + } + else if (precision == '*') { + precision = +a[i++]; + } + else if (precision.charAt(0) == '*') { + precision = +a[precision.slice(1, -1)]; + } + else { + precision = +precision; + } + + // grab value using valueIndex if required? + var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++]; + + switch (type) { + case 's': { + if (value == null) { + return ''; + } + return formatString(String(value), leftJustify, minWidth, precision, zeroPad, htmlSpace); + } + case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad, htmlSpace); + case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad,htmlSpace); + case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace); + case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace); + case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace).toUpperCase(); + case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace); + case 'i': { + var number = parseInt(+value, 10); + if (isNaN(number)) { + return ''; + } + var prefix = number < 0 ? '-' : positivePrefix; + var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number)); + value = prefix + pad(number_str, precision, '0', false); + //value = prefix + pad(String(Math.abs(number)), precision, '0', false); + return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace); + } + case 'd': { + var number = Math.round(+value); + if (isNaN(number)) { + return ''; + } + var prefix = number < 0 ? '-' : positivePrefix; + var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number)); + value = prefix + pad(number_str, precision, '0', false); + return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace); + } + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + { + var number = +value; + if (isNaN(number)) { + return ''; + } + var prefix = number < 0 ? '-' : positivePrefix; + var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())]; + var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2]; + var number_str = Math.abs(number)[method](precision); + number_str = thousandSeparation ? thousand_separate(number_str): number_str; + value = prefix + number_str; + var justified = justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform](); + + if ($.jqplot.sprintf.decimalMark !== '.' && $.jqplot.sprintf.decimalMark !== $.jqplot.sprintf.thousandsSeparator) { + return justified.replace(/\./, $.jqplot.sprintf.decimalMark); + } else { + return justified; + } + } + case 'p': + case 'P': + { + // make sure number is a number + var number = +value; + if (isNaN(number)) { + return ''; + } + var prefix = number < 0 ? '-' : positivePrefix; + + var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/); + var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length; + var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0; + + if (Math.abs(number) < 1) { + if (sd + zeros <= precision) { + value = prefix + Math.abs(number).toPrecision(sd); + } + else { + if (sd <= precision - 1) { + value = prefix + Math.abs(number).toExponential(sd-1); + } + else { + value = prefix + Math.abs(number).toExponential(precision-1); + } + } + } + else { + var prec = (sd <= precision) ? sd : precision; + value = prefix + Math.abs(number).toPrecision(prec); + } + var textTransform = ['toString', 'toUpperCase']['pP'.indexOf(type) % 2]; + return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform](); + } + case 'n': return ''; + default: return substring; + } + }); + }; + + $.jqplot.sprintf.thousandsSeparator = ','; + // Specifies the decimal mark for floating point values. By default a period '.' + // is used. If you change this value to for example a comma be sure to also + // change the thousands separator or else this won't work since a simple String + // replace is used (replacing all periods with the mark specified here). + $.jqplot.sprintf.decimalMark = '.'; + + $.jqplot.sprintf.regex = /%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g; + + $.jqplot.getSignificantFigures = function(number) { + var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/); + // total significant digits + var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length; + var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0; + // exponent + var expn = parseInt(parts[1], 10); + // digits to the left of the decimal place + var dleft = (expn + 1 > 0) ? expn + 1 : 0; + // digits to the right of the decimal place + var dright = (sd <= dleft) ? 0 : sd - expn - 1; + return {significantDigits: sd, digitsLeft: dleft, digitsRight: dright, zeros: zeros, exponent: expn} ; + }; + + $.jqplot.getPrecision = function(number) { + return $.jqplot.getSignificantFigures(number).digitsRight; + }; + +})(jQuery); +/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + /** + * Class: $.jqplot.ThemeEngine + * Theme Engine provides a programatic way to change some of the more + * common jqplot styling options such as fonts, colors and grid options. + * A theme engine instance is created with each plot. The theme engine + * manages a collection of themes which can be modified, added to, or + * applied to the plot. + * + * The themeEngine class is not instantiated directly. + * When a plot is initialized, the current plot options are scanned + * an a default theme named "Default" is created. This theme is + * used as the basis for other themes added to the theme engine and + * is always available. + * + * A theme is a simple javascript object with styling parameters for + * various entities of the plot. A theme has the form: + * + * + * > { + * > _name:f "Default", + * > target: { + * > backgroundColor: "transparent" + * > }, + * > legend: { + * > textColor: null, + * > fontFamily: null, + * > fontSize: null, + * > border: null, + * > background: null + * > }, + * > title: { + * > textColor: "rgb(102, 102, 102)", + * > fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif", + * > fontSize: "19.2px", + * > textAlign: "center" + * > }, + * > seriesStyles: {}, + * > series: [{ + * > color: "#4bb2c5", + * > lineWidth: 2.5, + * > linePattern: "solid", + * > shadow: true, + * > fillColor: "#4bb2c5", + * > showMarker: true, + * > markerOptions: { + * > color: "#4bb2c5", + * > show: true, + * > style: 'filledCircle', + * > lineWidth: 1.5, + * > size: 4, + * > shadow: true + * > } + * > }], + * > grid: { + * > drawGridlines: true, + * > gridLineColor: "#cccccc", + * > gridLineWidth: 1, + * > backgroundColor: "#fffdf6", + * > borderColor: "#999999", + * > borderWidth: 2, + * > shadow: true + * > }, + * > axesStyles: { + * > label: {}, + * > ticks: {} + * > }, + * > axes: { + * > xaxis: { + * > borderColor: "#999999", + * > borderWidth: 2, + * > ticks: { + * > show: true, + * > showGridline: true, + * > showLabel: true, + * > showMark: true, + * > size: 4, + * > textColor: "", + * > whiteSpace: "nowrap", + * > fontSize: "12px", + * > fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif" + * > }, + * > label: { + * > textColor: "rgb(102, 102, 102)", + * > whiteSpace: "normal", + * > fontSize: "14.6667px", + * > fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif", + * > fontWeight: "400" + * > } + * > }, + * > yaxis: { + * > borderColor: "#999999", + * > borderWidth: 2, + * > ticks: { + * > show: true, + * > showGridline: true, + * > showLabel: true, + * > showMark: true, + * > size: 4, + * > textColor: "", + * > whiteSpace: "nowrap", + * > fontSize: "12px", + * > fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif" + * > }, + * > label: { + * > textColor: null, + * > whiteSpace: null, + * > fontSize: null, + * > fontFamily: null, + * > fontWeight: null + * > } + * > }, + * > x2axis: {... + * > }, + * > ... + * > y9axis: {... + * > } + * > } + * > } + * + * "seriesStyles" is a style object that will be applied to all series in the plot. + * It will forcibly override any styles applied on the individual series. "axesStyles" is + * a style object that will be applied to all axes in the plot. It will also forcibly + * override any styles on the individual axes. + * + * The example shown above has series options for a line series. Options for other + * series types are shown below: + * + * Bar Series: + * + * > { + * > color: "#4bb2c5", + * > seriesColors: ["#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"], + * > lineWidth: 2.5, + * > shadow: true, + * > barPadding: 2, + * > barMargin: 10, + * > barWidth: 15.09375, + * > highlightColors: ["rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)"] + * > } + * + * Pie Series: + * + * > { + * > seriesColors: ["#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"], + * > padding: 20, + * > sliceMargin: 0, + * > fill: true, + * > shadow: true, + * > startAngle: 0, + * > lineWidth: 2.5, + * > highlightColors: ["rgb(129,201,214)", "rgb(240,189,104)", "rgb(214,202,165)", "rgb(137,180,158)", "rgb(168,180,137)", "rgb(180,174,89)", "rgb(180,113,161)", "rgb(129,141,236)", "rgb(227,205,120)", "rgb(255,138,76)", "rgb(76,169,219)", "rgb(215,126,190)", "rgb(220,232,135)", "rgb(200,167,96)", "rgb(103,202,235)", "rgb(208,154,215)"] + * > } + * + * Funnel Series: + * + * > { + * > color: "#4bb2c5", + * > lineWidth: 2, + * > shadow: true, + * > padding: { + * > top: 20, + * > right: 20, + * > bottom: 20, + * > left: 20 + * > }, + * > sectionMargin: 6, + * > seriesColors: ["#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"], + * > highlightColors: ["rgb(147,208,220)", "rgb(242,199,126)", "rgb(220,210,178)", "rgb(154,191,172)", "rgb(180,191,154)", "rgb(191,186,112)", "rgb(191,133,174)", "rgb(147,157,238)", "rgb(231,212,139)", "rgb(255,154,102)", "rgb(102,181,224)", "rgb(221,144,199)", "rgb(225,235,152)", "rgb(200,167,96)", "rgb(124,210,238)", "rgb(215,169,221)"] + * > } + * + */ + $.jqplot.ThemeEngine = function(){ + // Group: Properties + // + // prop: themes + // hash of themes managed by the theme engine. + // Indexed by theme name. + this.themes = {}; + // prop: activeTheme + // Pointer to currently active theme + this.activeTheme=null; + + }; + + // called with scope of plot + $.jqplot.ThemeEngine.prototype.init = function() { + // get the Default theme from the current plot settings. + var th = new $.jqplot.Theme({_name:'Default'}); + var n, i, nn; + + for (n in th.target) { + if (n == "textColor") { + th.target[n] = this.target.css('color'); + } + else { + th.target[n] = this.target.css(n); + } + } + + if (this.title.show && this.title._elem) { + for (n in th.title) { + if (n == "textColor") { + th.title[n] = this.title._elem.css('color'); + } + else { + th.title[n] = this.title._elem.css(n); + } + } + } + + for (n in th.grid) { + th.grid[n] = this.grid[n]; + } + if (th.grid.backgroundColor == null && this.grid.background != null) { + th.grid.backgroundColor = this.grid.background; + } + if (this.legend.show && this.legend._elem) { + for (n in th.legend) { + if (n == 'textColor') { + th.legend[n] = this.legend._elem.css('color'); + } + else { + th.legend[n] = this.legend._elem.css(n); + } + } + } + var s; + + for (i=0; i<this.series.length; i++) { + s = this.series[i]; + if (s.renderer.constructor == $.jqplot.LineRenderer) { + th.series.push(new LineSeriesProperties()); + } + else if (s.renderer.constructor == $.jqplot.BarRenderer) { + th.series.push(new BarSeriesProperties()); + } + else if (s.renderer.constructor == $.jqplot.PieRenderer) { + th.series.push(new PieSeriesProperties()); + } + else if (s.renderer.constructor == $.jqplot.DonutRenderer) { + th.series.push(new DonutSeriesProperties()); + } + else if (s.renderer.constructor == $.jqplot.FunnelRenderer) { + th.series.push(new FunnelSeriesProperties()); + } + else if (s.renderer.constructor == $.jqplot.MeterGaugeRenderer) { + th.series.push(new MeterSeriesProperties()); + } + else { + th.series.push({}); + } + for (n in th.series[i]) { + th.series[i][n] = s[n]; + } + } + var a, ax; + for (n in this.axes) { + ax = this.axes[n]; + a = th.axes[n] = new AxisProperties(); + a.borderColor = ax.borderColor; + a.borderWidth = ax.borderWidth; + if (ax._ticks && ax._ticks[0]) { + for (nn in a.ticks) { + if (ax._ticks[0].hasOwnProperty(nn)) { + a.ticks[nn] = ax._ticks[0][nn]; + } + else if (ax._ticks[0]._elem){ + a.ticks[nn] = ax._ticks[0]._elem.css(nn); + } + } + } + if (ax._label && ax._label.show) { + for (nn in a.label) { + // a.label[nn] = ax._label._elem.css(nn); + if (ax._label[nn]) { + a.label[nn] = ax._label[nn]; + } + else if (ax._label._elem){ + if (nn == 'textColor') { + a.label[nn] = ax._label._elem.css('color'); + } + else { + a.label[nn] = ax._label._elem.css(nn); + } + } + } + } + } + this.themeEngine._add(th); + this.themeEngine.activeTheme = this.themeEngine.themes[th._name]; + }; + /** + * Group: methods + * + * method: get + * + * Get and return the named theme or the active theme if no name given. + * + * parameter: + * + * name - name of theme to get. + * + * returns: + * + * Theme instance of given name. + */ + $.jqplot.ThemeEngine.prototype.get = function(name) { + if (!name) { + // return the active theme + return this.activeTheme; + } + else { + return this.themes[name]; + } + }; + + function numericalOrder(a,b) { return a-b; } + + /** + * method: getThemeNames + * + * Return the list of theme names in this manager in alpha-numerical order. + * + * parameter: + * + * None + * + * returns: + * + * A the list of theme names in this manager in alpha-numerical order. + */ + $.jqplot.ThemeEngine.prototype.getThemeNames = function() { + var tn = []; + for (var n in this.themes) { + tn.push(n); + } + return tn.sort(numericalOrder); + }; + + /** + * method: getThemes + * + * Return a list of themes in alpha-numerical order by name. + * + * parameter: + * + * None + * + * returns: + * + * A list of themes in alpha-numerical order by name. + */ + $.jqplot.ThemeEngine.prototype.getThemes = function() { + var tn = []; + var themes = []; + for (var n in this.themes) { + tn.push(n); + } + tn.sort(numericalOrder); + for (var i=0; i<tn.length; i++) { + themes.push(this.themes[tn[i]]); + } + return themes; + }; + + $.jqplot.ThemeEngine.prototype.activate = function(plot, name) { + // sometimes need to redraw whole plot. + var redrawPlot = false; + if (!name && this.activeTheme && this.activeTheme._name) { + name = this.activeTheme._name; + } + if (!this.themes.hasOwnProperty(name)) { + throw new Error("No theme of that name"); + } + else { + var th = this.themes[name]; + this.activeTheme = th; + var val, checkBorderColor = false, checkBorderWidth = false; + var arr = ['xaxis', 'x2axis', 'yaxis', 'y2axis']; + + for (i=0; i<arr.length; i++) { + var ax = arr[i]; + if (th.axesStyles.borderColor != null) { + plot.axes[ax].borderColor = th.axesStyles.borderColor; + } + if (th.axesStyles.borderWidth != null) { + plot.axes[ax].borderWidth = th.axesStyles.borderWidth; + } + } + + for (var axname in plot.axes) { + var axis = plot.axes[axname]; + if (axis.show) { + var thaxis = th.axes[axname] || {}; + var thaxstyle = th.axesStyles; + var thax = $.jqplot.extend(true, {}, thaxis, thaxstyle); + val = (th.axesStyles.borderColor != null) ? th.axesStyles.borderColor : thax.borderColor; + if (thax.borderColor != null) { + axis.borderColor = thax.borderColor; + redrawPlot = true; + } + val = (th.axesStyles.borderWidth != null) ? th.axesStyles.borderWidth : thax.borderWidth; + if (thax.borderWidth != null) { + axis.borderWidth = thax.borderWidth; + redrawPlot = true; + } + if (axis._ticks && axis._ticks[0]) { + for (var nn in thax.ticks) { + // val = null; + // if (th.axesStyles.ticks && th.axesStyles.ticks[nn] != null) { + // val = th.axesStyles.ticks[nn]; + // } + // else if (thax.ticks[nn] != null){ + // val = thax.ticks[nn] + // } + val = thax.ticks[nn]; + if (val != null) { + axis.tickOptions[nn] = val; + axis._ticks = []; + redrawPlot = true; + } + } + } + if (axis._label && axis._label.show) { + for (var nn in thax.label) { + // val = null; + // if (th.axesStyles.label && th.axesStyles.label[nn] != null) { + // val = th.axesStyles.label[nn]; + // } + // else if (thax.label && thax.label[nn] != null){ + // val = thax.label[nn] + // } + val = thax.label[nn]; + if (val != null) { + axis.labelOptions[nn] = val; + redrawPlot = true; + } + } + } + + } + } + + for (var n in th.grid) { + if (th.grid[n] != null) { + plot.grid[n] = th.grid[n]; + } + } + if (!redrawPlot) { + plot.grid.draw(); + } + + if (plot.legend.show) { + for (n in th.legend) { + if (th.legend[n] != null) { + plot.legend[n] = th.legend[n]; + } + } + } + if (plot.title.show) { + for (n in th.title) { + if (th.title[n] != null) { + plot.title[n] = th.title[n]; + } + } + } + + var i; + for (i=0; i<th.series.length; i++) { + var opts = {}; + var redrawSeries = false; + for (n in th.series[i]) { + val = (th.seriesStyles[n] != null) ? th.seriesStyles[n] : th.series[i][n]; + if (val != null) { + opts[n] = val; + if (n == 'color') { + plot.series[i].renderer.shapeRenderer.fillStyle = val; + plot.series[i].renderer.shapeRenderer.strokeStyle = val; + plot.series[i][n] = val; + } + else if ((n == 'lineWidth') || (n == 'linePattern')) { + plot.series[i].renderer.shapeRenderer[n] = val; + plot.series[i][n] = val; + } + else if (n == 'markerOptions') { + merge (plot.series[i].markerOptions, val); + merge (plot.series[i].markerRenderer, val); + } + else { + plot.series[i][n] = val; + } + redrawPlot = true; + } + } + } + + if (redrawPlot) { + plot.target.empty(); + plot.draw(); + } + + for (n in th.target) { + if (th.target[n] != null) { + plot.target.css(n, th.target[n]); + } + } + } + + }; + + $.jqplot.ThemeEngine.prototype._add = function(theme, name) { + if (name) { + theme._name = name; + } + if (!theme._name) { + theme._name = Date.parse(new Date()); + } + if (!this.themes.hasOwnProperty(theme._name)) { + this.themes[theme._name] = theme; + } + else { + throw new Error("jqplot.ThemeEngine Error: Theme already in use"); + } + }; + + // method remove + // Delete the named theme, return true on success, false on failure. + + + /** + * method: remove + * + * Remove the given theme from the themeEngine. + * + * parameters: + * + * name - name of the theme to remove. + * + * returns: + * + * true on success, false on failure. + */ + $.jqplot.ThemeEngine.prototype.remove = function(name) { + if (name == 'Default') { + return false; + } + return delete this.themes[name]; + }; + + /** + * method: newTheme + * + * Create a new theme based on the default theme, adding it the themeEngine. + * + * parameters: + * + * name - name of the new theme. + * obj - optional object of styles to be applied to this new theme. + * + * returns: + * + * new Theme object. + */ + $.jqplot.ThemeEngine.prototype.newTheme = function(name, obj) { + if (typeof(name) == 'object') { + obj = obj || name; + name = null; + } + if (obj && obj._name) { + name = obj._name; + } + else { + name = name || Date.parse(new Date()); + } + // var th = new $.jqplot.Theme(name); + var th = this.copy(this.themes['Default']._name, name); + $.jqplot.extend(th, obj); + return th; + }; + + // function clone(obj) { + // return eval(obj.toSource()); + // } + + function clone(obj){ + if(obj == null || typeof(obj) != 'object'){ + return obj; + } + + var temp = new obj.constructor(); + for(var key in obj){ + temp[key] = clone(obj[key]); + } + return temp; + } + + $.jqplot.clone = clone; + + function merge(obj1, obj2) { + if (obj2 == null || typeof(obj2) != 'object') { + return; + } + for (var key in obj2) { + if (key == 'highlightColors') { + obj1[key] = clone(obj2[key]); + } + if (obj2[key] != null && typeof(obj2[key]) == 'object') { + if (!obj1.hasOwnProperty(key)) { + obj1[key] = {}; + } + merge(obj1[key], obj2[key]); + } + else { + obj1[key] = obj2[key]; + } + } + } + + $.jqplot.merge = merge; + + // Use the jQuery 1.3.2 extend function since behaviour in jQuery 1.4 seems problematic + $.jqplot.extend = function() { + // copy reference to target object + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !toString.call(target) === "[object Function]" ) { + target = {}; + } + + for ( ; i < length; i++ ){ + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( var name in options ) { + var src = target[ name ], copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging object values + if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { + target[ name ] = $.jqplot.extend( deep, + // Never move original objects, clone them + src || ( copy.length != null ? [ ] : { } ) + , copy ); + } + // Don't bring in undefined values + else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + // Return the modified object + return target; + }; + + /** + * method: rename + * + * Rename a theme. + * + * parameters: + * + * oldName - current name of the theme. + * newName - desired name of the theme. + * + * returns: + * + * new Theme object. + */ + $.jqplot.ThemeEngine.prototype.rename = function (oldName, newName) { + if (oldName == 'Default' || newName == 'Default') { + throw new Error ("jqplot.ThemeEngine Error: Cannot rename from/to Default"); + } + if (this.themes.hasOwnProperty(newName)) { + throw new Error ("jqplot.ThemeEngine Error: New name already in use."); + } + else if (this.themes.hasOwnProperty(oldName)) { + var th = this.copy (oldName, newName); + this.remove(oldName); + return th; + } + throw new Error("jqplot.ThemeEngine Error: Old name or new name invalid"); + }; + + /** + * method: copy + * + * Create a copy of an existing theme in the themeEngine, adding it the themeEngine. + * + * parameters: + * + * sourceName - name of the existing theme. + * targetName - name of the copy. + * obj - optional object of style parameter to apply to the new theme. + * + * returns: + * + * new Theme object. + */ + $.jqplot.ThemeEngine.prototype.copy = function (sourceName, targetName, obj) { + if (targetName == 'Default') { + throw new Error ("jqplot.ThemeEngine Error: Cannot copy over Default theme"); + } + if (!this.themes.hasOwnProperty(sourceName)) { + var s = "jqplot.ThemeEngine Error: Source name invalid"; + throw new Error(s); + } + if (this.themes.hasOwnProperty(targetName)) { + var s = "jqplot.ThemeEngine Error: Target name invalid"; + throw new Error(s); + } + else { + var th = clone(this.themes[sourceName]); + th._name = targetName; + $.jqplot.extend(true, th, obj); + this._add(th); + return th; + } + }; + + + $.jqplot.Theme = function(name, obj) { + if (typeof(name) == 'object') { + obj = obj || name; + name = null; + } + name = name || Date.parse(new Date()); + this._name = name; + this.target = { + backgroundColor: null + }; + this.legend = { + textColor: null, + fontFamily: null, + fontSize: null, + border: null, + background: null + }; + this.title = { + textColor: null, + fontFamily: null, + fontSize: null, + textAlign: null + }; + this.seriesStyles = {}; + this.series = []; + this.grid = { + drawGridlines: null, + gridLineColor: null, + gridLineWidth: null, + backgroundColor: null, + borderColor: null, + borderWidth: null, + shadow: null + }; + this.axesStyles = {label:{}, ticks:{}}; + this.axes = {}; + if (typeof(obj) == 'string') { + this._name = obj; + } + else if(typeof(obj) == 'object') { + $.jqplot.extend(true, this, obj); + } + }; + + var AxisProperties = function() { + this.borderColor = null; + this.borderWidth = null; + this.ticks = new AxisTicks(); + this.label = new AxisLabel(); + }; + + var AxisTicks = function() { + this.show = null; + this.showGridline = null; + this.showLabel = null; + this.showMark = null; + this.size = null; + this.textColor = null; + this.whiteSpace = null; + this.fontSize = null; + this.fontFamily = null; + }; + + var AxisLabel = function() { + this.textColor = null; + this.whiteSpace = null; + this.fontSize = null; + this.fontFamily = null; + this.fontWeight = null; + }; + + var LineSeriesProperties = function() { + this.color=null; + this.lineWidth=null; + this.linePattern=null; + this.shadow=null; + this.fillColor=null; + this.showMarker=null; + this.markerOptions = new MarkerOptions(); + }; + + var MarkerOptions = function() { + this.show = null; + this.style = null; + this.lineWidth = null; + this.size = null; + this.color = null; + this.shadow = null; + }; + + var BarSeriesProperties = function() { + this.color=null; + this.seriesColors=null; + this.lineWidth=null; + this.shadow=null; + this.barPadding=null; + this.barMargin=null; + this.barWidth=null; + this.highlightColors=null; + }; + + var PieSeriesProperties = function() { + this.seriesColors=null; + this.padding=null; + this.sliceMargin=null; + this.fill=null; + this.shadow=null; + this.startAngle=null; + this.lineWidth=null; + this.highlightColors=null; + }; + + var DonutSeriesProperties = function() { + this.seriesColors=null; + this.padding=null; + this.sliceMargin=null; + this.fill=null; + this.shadow=null; + this.startAngle=null; + this.lineWidth=null; + this.innerDiameter=null; + this.thickness=null; + this.ringMargin=null; + this.highlightColors=null; + }; + + var FunnelSeriesProperties = function() { + this.color=null; + this.lineWidth=null; + this.shadow=null; + this.padding=null; + this.sectionMargin=null; + this.seriesColors=null; + this.highlightColors=null; + }; + + var MeterSeriesProperties = function() { + this.padding=null; + this.backgroundColor=null; + this.ringColor=null; + this.tickColor=null; + this.ringWidth=null; + this.intervalColors=null; + this.intervalInnerRadius=null; + this.intervalOuterRadius=null; + this.hubRadius=null; + this.needleThickness=null; + this.needlePad=null; + }; + + +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + /** + * Class: $.jqplot.PieRenderer + * Plugin renderer to draw a pie chart. + * x values, if present, will be used as slice labels. + * y values give slice size. + * + * To use this renderer, you need to include the + * pie renderer plugin, for example: + * + * > <script type="text/javascript" src="plugins/jqplot.pieRenderer.js"></script> + * + * Properties described here are passed into the $.jqplot function + * as options on the series renderer. For example: + * + * > plot2 = $.jqplot('chart2', [s1, s2], { + * > seriesDefaults: { + * > renderer:$.jqplot.PieRenderer, + * > rendererOptions:{ + * > sliceMargin: 2, + * > startAngle: -90 + * > } + * > } + * > }); + * + * A pie plot will trigger events on the plot target + * according to user interaction. All events return the event object, + * the series index, the point (slice) index, and the point data for + * the appropriate slice. + * + * 'jqplotDataMouseOver' - triggered when user mouseing over a slice. + * 'jqplotDataHighlight' - triggered the first time user mouses over a slice, + * if highlighting is enabled. + * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of + * a highlighted slice. + * 'jqplotDataClick' - triggered when the user clicks on a slice. + * 'jqplotDataRightClick' - tiggered when the user right clicks on a slice if + * the "captureRightClick" option is set to true on the plot. + */ + $.jqplot.PieRenderer = function(){ + $.jqplot.LineRenderer.call(this); + }; + + $.jqplot.PieRenderer.prototype = new $.jqplot.LineRenderer(); + $.jqplot.PieRenderer.prototype.constructor = $.jqplot.PieRenderer; + + // called with scope of a series + $.jqplot.PieRenderer.prototype.init = function(options, plot) { + // Group: Properties + // + // prop: diameter + // Outer diameter of the pie, auto computed by default + this.diameter = null; + // prop: padding + // padding between the pie and plot edges, legend, etc. + this.padding = 20; + // prop: sliceMargin + // angular spacing between pie slices in degrees. + this.sliceMargin = 0; + // prop: fill + // true or false, wether to fil the slices. + this.fill = true; + // prop: shadowOffset + // offset of the shadow from the slice and offset of + // each succesive stroke of the shadow from the last. + this.shadowOffset = 2; + // prop: shadowAlpha + // transparency of the shadow (0 = transparent, 1 = opaque) + this.shadowAlpha = 0.07; + // prop: shadowDepth + // number of strokes to apply to the shadow, + // each stroke offset shadowOffset from the last. + this.shadowDepth = 5; + // prop: highlightMouseOver + // True to highlight slice when moused over. + // This must be false to enable highlightMouseDown to highlight when clicking on a slice. + this.highlightMouseOver = true; + // prop: highlightMouseDown + // True to highlight when a mouse button is pressed over a slice. + // This will be disabled if highlightMouseOver is true. + this.highlightMouseDown = false; + // prop: highlightColors + // an array of colors to use when highlighting a slice. + this.highlightColors = []; + // prop: dataLabels + // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices. + // Defaults to percentage of each pie slice. + this.dataLabels = 'percent'; + // prop: showDataLabels + // true to show data labels on slices. + this.showDataLabels = false; + // prop: dataLabelFormatString + // Format string for data labels. If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage. + this.dataLabelFormatString = null; + // prop: dataLabelThreshold + // Threshhold in percentage (0-100) of pie area, below which no label will be displayed. + // This applies to all label types, not just to percentage labels. + this.dataLabelThreshold = 3; + // prop: dataLabelPositionFactor + // A Multiplier (0-1) of the pie radius which controls position of label on slice. + // Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie. + this.dataLabelPositionFactor = 0.52; + // prop: dataLabelNudge + // Number of pixels to slide the label away from (+) or toward (-) the center of the pie. + this.dataLabelNudge = 2; + // prop: dataLabelCenterOn + // True to center the data label at its position. + // False to set the inside facing edge of the label at its position. + this.dataLabelCenterOn = true; + // prop: startAngle + // Angle to start drawing pie in degrees. + // According to orientation of canvas coordinate system: + // 0 = on the positive x axis + // -90 = on the positive y axis. + // 90 = on the negaive y axis. + // 180 or - 180 = on the negative x axis. + this.startAngle = 0; + this.tickRenderer = $.jqplot.PieTickRenderer; + // Used as check for conditions where pie shouldn't be drawn. + this._drawData = true; + this._type = 'pie'; + + // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver + if (options.highlightMouseDown && options.highlightMouseOver == null) { + options.highlightMouseOver = false; + } + + $.extend(true, this, options); + + if (this.sliceMargin < 0) { + this.sliceMargin = 0; + } + + this._diameter = null; + this._radius = null; + // array of [start,end] angles arrays, one for each slice. In radians. + this._sliceAngles = []; + // index of the currenty highlighted point, if any + this._highlightedPoint = null; + + // set highlight colors if none provided + if (this.highlightColors.length == 0) { + for (var i=0; i<this.seriesColors.length; i++){ + var rgba = $.jqplot.getColorComponents(this.seriesColors[i]); + var newrgb = [rgba[0], rgba[1], rgba[2]]; + var sum = newrgb[0] + newrgb[1] + newrgb[2]; + for (var j=0; j<3; j++) { + // when darkening, lowest color component can be is 60. + newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); + newrgb[j] = parseInt(newrgb[j], 10); + } + this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')'); + } + } + + this.highlightColorGenerator = new $.jqplot.ColorGenerator(this.highlightColors); + + plot.postParseOptionsHooks.addOnce(postParseOptions); + plot.postInitHooks.addOnce(postInit); + plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove); + plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown); + plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp); + plot.eventListenerHooks.addOnce('jqplotClick', handleClick); + plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick); + plot.postDrawHooks.addOnce(postPlotDraw); + }; + + $.jqplot.PieRenderer.prototype.setGridData = function(plot) { + // set gridData property. This will hold angle in radians of each data point. + var stack = []; + var td = []; + var sa = this.startAngle/180*Math.PI; + var tot = 0; + // don't know if we have any valid data yet, so set plot to not draw. + this._drawData = false; + for (var i=0; i<this.data.length; i++){ + if (this.data[i][1] != 0) { + // we have data, O.K. to draw. + this._drawData = true; + } + stack.push(this.data[i][1]); + td.push([this.data[i][0]]); + if (i>0) { + stack[i] += stack[i-1]; + } + tot += this.data[i][1]; + } + var fact = Math.PI*2/stack[stack.length - 1]; + + for (var i=0; i<stack.length; i++) { + td[i][1] = stack[i] * fact; + td[i][2] = this.data[i][1]/tot; + } + this.gridData = td; + }; + + $.jqplot.PieRenderer.prototype.makeGridData = function(data, plot) { + var stack = []; + var td = []; + var tot = 0; + var sa = this.startAngle/180*Math.PI; + // don't know if we have any valid data yet, so set plot to not draw. + this._drawData = false; + for (var i=0; i<data.length; i++){ + if (this.data[i][1] != 0) { + // we have data, O.K. to draw. + this._drawData = true; + } + stack.push(data[i][1]); + td.push([data[i][0]]); + if (i>0) { + stack[i] += stack[i-1]; + } + tot += data[i][1]; + } + var fact = Math.PI*2/stack[stack.length - 1]; + + for (var i=0; i<stack.length; i++) { + td[i][1] = stack[i] * fact; + td[i][2] = data[i][1]/tot; + } + return td; + }; + + function calcRadiusAdjustment(ang) { + return Math.sin((ang - (ang-Math.PI) / 8 / Math.PI )/2.0); + } + + function calcRPrime(ang1, ang2, sliceMargin, fill, lineWidth) { + var rprime = 0; + var ang = ang2 - ang1; + var absang = Math.abs(ang); + var sm = sliceMargin; + if (fill == false) { + sm += lineWidth; + } + + if (sm > 0 && absang > 0.01 && absang < 6.282) { + rprime = parseFloat(sm) / 2.0 / calcRadiusAdjustment(ang); + } + + return rprime; + } + + $.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) { + if (this._drawData) { + var r = this._radius; + var fill = this.fill; + var lineWidth = this.lineWidth; + var sm = this.sliceMargin; + if (this.fill == false) { + sm += this.lineWidth; + } + ctx.save(); + ctx.translate(this._center[0], this._center[1]); + + var rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth); + + var transx = rprime * Math.cos((ang1 + ang2) / 2.0); + var transy = rprime * Math.sin((ang1 + ang2) / 2.0); + + if ((ang2 - ang1) <= Math.PI) { + r -= rprime; + } + else { + r += rprime; + } + + ctx.translate(transx, transy); + + if (isShadow) { + for (var i=0, l=this.shadowDepth; i<l; i++) { + ctx.save(); + ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI)); + doDraw(r); + } + for (var i=0, l=this.shadowDepth; i<l; i++) { + ctx.restore(); + } + } + + else { + doDraw(r); + } + ctx.restore(); + } + + function doDraw (rad) { + // Fix for IE and Chrome that can't seem to draw circles correctly. + // ang2 should always be <= 2 pi since that is the way the data is converted. + // 2Pi = 6.2831853, Pi = 3.1415927 + if (ang2 > 6.282 + this.startAngle) { + ang2 = 6.282 + this.startAngle; + if (ang1 > ang2) { + ang1 = 6.281 + this.startAngle; + } + } + // Fix for IE, where it can't seem to handle 0 degree angles. Also avoids + // ugly line on unfilled pies. + if (ang1 >= ang2) { + return; + } + + ctx.beginPath(); + ctx.fillStyle = color; + ctx.strokeStyle = color; + ctx.lineWidth = lineWidth; + ctx.arc(0, 0, rad, ang1, ang2, false); + ctx.lineTo(0,0); + ctx.closePath(); + + if (fill) { + ctx.fill(); + } + else { + ctx.stroke(); + } + } + }; + + // called with scope of series + $.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options, plot) { + var i; + var opts = (options != undefined) ? options : {}; + // offset and direction of offset due to legend placement + var offx = 0; + var offy = 0; + var trans = 1; + var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors); + if (options.legendInfo && options.legendInfo.placement == 'insideGrid') { + var li = options.legendInfo; + switch (li.location) { + case 'nw': + offx = li.width + li.xoffset; + break; + case 'w': + offx = li.width + li.xoffset; + break; + case 'sw': + offx = li.width + li.xoffset; + break; + case 'ne': + offx = li.width + li.xoffset; + trans = -1; + break; + case 'e': + offx = li.width + li.xoffset; + trans = -1; + break; + case 'se': + offx = li.width + li.xoffset; + trans = -1; + break; + case 'n': + offy = li.height + li.yoffset; + break; + case 's': + offy = li.height + li.yoffset; + trans = -1; + break; + default: + break; + } + } + + var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; + var fill = (opts.fill != undefined) ? opts.fill : this.fill; + var cw = ctx.canvas.width; + var ch = ctx.canvas.height; + var w = cw - offx - 2 * this.padding; + var h = ch - offy - 2 * this.padding; + var mindim = Math.min(w,h); + var d = mindim; + + // Fixes issue #272. Thanks hugwijst! + // reset slice angles array. + this._sliceAngles = []; + + var sm = this.sliceMargin; + if (this.fill == false) { + sm += this.lineWidth; + } + + var rprime; + var maxrprime = 0; + + var ang, ang1, ang2, shadowColor; + var sa = this.startAngle / 180 * Math.PI; + + // have to pre-draw shadows, so loop throgh here and calculate some values also. + for (var i=0, l=gd.length; i<l; i++) { + ang1 = (i == 0) ? sa : gd[i-1][1] + sa; + ang2 = gd[i][1] + sa; + + this._sliceAngles.push([ang1, ang2]); + + rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth); + + if (Math.abs(ang2-ang1) > Math.PI) { + maxrprime = Math.max(rprime, maxrprime); + } + } + + if (this.diameter != null && this.diameter > 0) { + this._diameter = this.diameter - 2*maxrprime; + } + else { + this._diameter = d - 2*maxrprime; + } + + // Need to check for undersized pie. This can happen if + // plot area too small and legend is too big. + if (this._diameter < 6) { + $.jqplot.log('Diameter of pie too small, not rendering.'); + return; + } + + var r = this._radius = this._diameter/2; + + this._center = [(cw - trans * offx)/2 + trans * offx + maxrprime * Math.cos(sa), (ch - trans*offy)/2 + trans * offy + maxrprime * Math.sin(sa)]; + + if (this.shadow) { + for (var i=0, l=gd.length; i<l; i++) { + shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')'; + this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], shadowColor, true); + } + } + + for (var i=0; i<gd.length; i++) { + + this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], colorGenerator.next(), false); + + if (this.showDataLabels && gd[i][2]*100 >= this.dataLabelThreshold) { + var fstr, avgang = (this._sliceAngles[i][0] + this._sliceAngles[i][1])/2, label; + + if (this.dataLabels == 'label') { + fstr = this.dataLabelFormatString || '%s'; + label = $.jqplot.sprintf(fstr, gd[i][0]); + } + else if (this.dataLabels == 'value') { + fstr = this.dataLabelFormatString || '%d'; + label = $.jqplot.sprintf(fstr, this.data[i][1]); + } + else if (this.dataLabels == 'percent') { + fstr = this.dataLabelFormatString || '%d%%'; + label = $.jqplot.sprintf(fstr, gd[i][2]*100); + } + else if (this.dataLabels.constructor == Array) { + fstr = this.dataLabelFormatString || '%s'; + label = $.jqplot.sprintf(fstr, this.dataLabels[i]); + } + + var fact = (this._radius ) * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge; + + var x = this._center[0] + Math.cos(avgang) * fact + this.canvas._offsets.left; + var y = this._center[1] + Math.sin(avgang) * fact + this.canvas._offsets.top; + + var labelelem = $('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">' + label + '</div>').insertBefore(plot.eventCanvas._elem); + if (this.dataLabelCenterOn) { + x -= labelelem.width()/2; + y -= labelelem.height()/2; + } + else { + x -= labelelem.width() * Math.sin(avgang/2); + y -= labelelem.height()/2; + } + x = Math.round(x); + y = Math.round(y); + labelelem.css({left: x, top: y}); + } + } + }; + + $.jqplot.PieAxisRenderer = function() { + $.jqplot.LinearAxisRenderer.call(this); + }; + + $.jqplot.PieAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); + $.jqplot.PieAxisRenderer.prototype.constructor = $.jqplot.PieAxisRenderer; + + + // There are no traditional axes on a pie chart. We just need to provide + // dummy objects with properties so the plot will render. + // called with scope of axis object. + $.jqplot.PieAxisRenderer.prototype.init = function(options){ + // + this.tickRenderer = $.jqplot.PieTickRenderer; + $.extend(true, this, options); + // I don't think I'm going to need _dataBounds here. + // have to go Axis scaling in a way to fit chart onto plot area + // and provide u2p and p2u functionality for mouse cursor, etc. + // for convienence set _dataBounds to 0 and 100 and + // set min/max to 0 and 100. + this._dataBounds = {min:0, max:100}; + this.min = 0; + this.max = 100; + this.showTicks = false; + this.ticks = []; + this.showMark = false; + this.show = false; + }; + + + + + $.jqplot.PieLegendRenderer = function(){ + $.jqplot.TableLegendRenderer.call(this); + }; + + $.jqplot.PieLegendRenderer.prototype = new $.jqplot.TableLegendRenderer(); + $.jqplot.PieLegendRenderer.prototype.constructor = $.jqplot.PieLegendRenderer; + + /** + * Class: $.jqplot.PieLegendRenderer + * Legend Renderer specific to pie plots. Set by default + * when user creates a pie plot. + */ + $.jqplot.PieLegendRenderer.prototype.init = function(options) { + // Group: Properties + // + // prop: numberRows + // Maximum number of rows in the legend. 0 or null for unlimited. + this.numberRows = null; + // prop: numberColumns + // Maximum number of columns in the legend. 0 or null for unlimited. + this.numberColumns = null; + $.extend(true, this, options); + }; + + // called with context of legend + $.jqplot.PieLegendRenderer.prototype.draw = function() { + var legend = this; + if (this.show) { + var series = this._series; + + + this._elem = $(document.createElement('table')); + this._elem.addClass('jqplot-table-legend'); + + var ss = {position:'absolute'}; + if (this.background) { + ss['background'] = this.background; + } + if (this.border) { + ss['border'] = this.border; + } + if (this.fontSize) { + ss['fontSize'] = this.fontSize; + } + if (this.fontFamily) { + ss['fontFamily'] = this.fontFamily; + } + if (this.textColor) { + ss['textColor'] = this.textColor; + } + if (this.marginTop != null) { + ss['marginTop'] = this.marginTop; + } + if (this.marginBottom != null) { + ss['marginBottom'] = this.marginBottom; + } + if (this.marginLeft != null) { + ss['marginLeft'] = this.marginLeft; + } + if (this.marginRight != null) { + ss['marginRight'] = this.marginRight; + } + + this._elem.css(ss); + + // Pie charts legends don't go by number of series, but by number of data points + // in the series. Refactor things here for that. + + var pad = false, + reverse = false, + nr, + nc; + var s = series[0]; + var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors); + + if (s.show) { + var pd = s.data; + if (this.numberRows) { + nr = this.numberRows; + if (!this.numberColumns){ + nc = Math.ceil(pd.length/nr); + } + else{ + nc = this.numberColumns; + } + } + else if (this.numberColumns) { + nc = this.numberColumns; + nr = Math.ceil(pd.length/this.numberColumns); + } + else { + nr = pd.length; + nc = 1; + } + + var i, j; + var tr, td1, td2; + var lt, rs, color; + var idx = 0; + var div0, div1; + + for (i=0; i<nr; i++) { + tr = $(document.createElement('tr')); + tr.addClass('jqplot-table-legend'); + + if (reverse){ + tr.prependTo(this._elem); + } + + else{ + tr.appendTo(this._elem); + } + + for (j=0; j<nc; j++) { + if (idx < pd.length){ + lt = this.labels[idx] || pd[idx][0].toString(); + color = colorGenerator.next(); + if (!reverse){ + if (i>0){ + pad = true; + } + else{ + pad = false; + } + } + else{ + if (i == nr -1){ + pad = false; + } + else{ + pad = true; + } + } + rs = (pad) ? this.rowSpacing : '0'; + + + + td1 = $(document.createElement('td')); + td1.addClass('jqplot-table-legend jqplot-table-legend-swatch'); + td1.css({textAlign: 'center', paddingTop: rs}); + + div0 = $(document.createElement('div')); + div0.addClass('jqplot-table-legend-swatch-outline'); + div1 = $(document.createElement('div')); + div1.addClass('jqplot-table-legend-swatch'); + div1.css({backgroundColor: color, borderColor: color}); + td1.append(div0.append(div1)); + + td2 = $(document.createElement('td')); + td2.addClass('jqplot-table-legend jqplot-table-legend-label'); + td2.css('paddingTop', rs); + + if (this.escapeHtml){ + td2.text(lt); + } + else { + td2.html(lt); + } + if (reverse) { + td2.prependTo(tr); + td1.prependTo(tr); + } + else { + td1.appendTo(tr); + td2.appendTo(tr); + } + pad = true; + } + idx++; + } + } + } + } + return this._elem; + }; + + $.jqplot.PieRenderer.prototype.handleMove = function(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + plot.target.trigger('jqplotDataMouseOver', ins); + if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { + plot.target.trigger('jqplotDataHighlight', ins); + highlight (plot, ins[0], ins[1]); + } + } + else if (neighbor == null) { + unhighlight (plot); + } + }; + + + // this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]); + + // setup default renderers for axes and legend so user doesn't have to + // called with scope of plot + function preInit(target, data, options) { + options = options || {}; + options.axesDefaults = options.axesDefaults || {}; + options.legend = options.legend || {}; + options.seriesDefaults = options.seriesDefaults || {}; + // only set these if there is a pie series + var setopts = false; + if (options.seriesDefaults.renderer == $.jqplot.PieRenderer) { + setopts = true; + } + else if (options.series) { + for (var i=0; i < options.series.length; i++) { + if (options.series[i].renderer == $.jqplot.PieRenderer) { + setopts = true; + } + } + } + + if (setopts) { + options.axesDefaults.renderer = $.jqplot.PieAxisRenderer; + options.legend.renderer = $.jqplot.PieLegendRenderer; + options.legend.preDraw = true; + options.seriesDefaults.pointLabels = {show: false}; + } + } + + function postInit(target, data, options) { + for (var i=0; i<this.series.length; i++) { + if (this.series[i].renderer.constructor == $.jqplot.PieRenderer) { + // don't allow mouseover and mousedown at same time. + if (this.series[i].highlightMouseOver) { + this.series[i].highlightMouseDown = false; + } + } + } + } + + // called with scope of plot + function postParseOptions(options) { + for (var i=0; i<this.series.length; i++) { + this.series[i].seriesColors = this.seriesColors; + this.series[i].colorGenerator = $.jqplot.colorGenerator; + } + } + + function highlight (plot, sidx, pidx) { + var s = plot.series[sidx]; + var canvas = plot.plugins.pieRenderer.highlightCanvas; + canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height); + s._highlightedPoint = pidx; + plot.plugins.pieRenderer.highlightedSeriesIndex = sidx; + s.renderer.drawSlice.call(s, canvas._ctx, s._sliceAngles[pidx][0], s._sliceAngles[pidx][1], s.highlightColorGenerator.get(pidx), false); + } + + function unhighlight (plot) { + var canvas = plot.plugins.pieRenderer.highlightCanvas; + canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height); + for (var i=0; i<plot.series.length; i++) { + plot.series[i]._highlightedPoint = null; + } + plot.plugins.pieRenderer.highlightedSeriesIndex = null; + plot.target.trigger('jqplotDataUnhighlight'); + } + + function handleMove(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var evt1 = jQuery.Event('jqplotDataMouseOver'); + evt1.pageX = ev.pageX; + evt1.pageY = ev.pageY; + plot.target.trigger(evt1, ins); + if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { + var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + highlight (plot, ins[0], ins[1]); + } + } + else if (neighbor == null) { + unhighlight (plot); + } + } + + function handleMouseDown(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { + var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + highlight (plot, ins[0], ins[1]); + } + } + else if (neighbor == null) { + unhighlight (plot); + } + } + + function handleMouseUp(ev, gridpos, datapos, neighbor, plot) { + var idx = plot.plugins.pieRenderer.highlightedSeriesIndex; + if (idx != null && plot.series[idx].highlightMouseDown) { + unhighlight(plot); + } + } + + function handleClick(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var evt = jQuery.Event('jqplotDataClick'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + } + } + + function handleRightClick(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var idx = plot.plugins.pieRenderer.highlightedSeriesIndex; + if (idx != null && plot.series[idx].highlightMouseDown) { + unhighlight(plot); + } + var evt = jQuery.Event('jqplotDataRightClick'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + } + } + + // called within context of plot + // create a canvas which we can draw on. + // insert it before the eventCanvas, so eventCanvas will still capture events. + function postPlotDraw() { + // Memory Leaks patch + if (this.plugins.pieRenderer && this.plugins.pieRenderer.highlightCanvas) { + this.plugins.pieRenderer.highlightCanvas.resetCanvas(); + this.plugins.pieRenderer.highlightCanvas = null; + } + + this.plugins.pieRenderer = {highlightedSeriesIndex:null}; + this.plugins.pieRenderer.highlightCanvas = new $.jqplot.GenericCanvas(); + + // do we have any data labels? if so, put highlight canvas before those + var labels = $(this.targetId+' .jqplot-data-label'); + if (labels.length) { + $(labels[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this)); + } + // else put highlight canvas before event canvas. + else { + this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this)); + } + + var hctx = this.plugins.pieRenderer.highlightCanvas.setContext(); + this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); + } + + $.jqplot.preInitHooks.push(preInit); + + $.jqplot.PieTickRenderer = function() { + $.jqplot.AxisTickRenderer.call(this); + }; + + $.jqplot.PieTickRenderer.prototype = new $.jqplot.AxisTickRenderer(); + $.jqplot.PieTickRenderer.prototype.constructor = $.jqplot.PieTickRenderer; + +})(jQuery); + + /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + + // Class: $.jqplot.BarRenderer + // A plugin renderer for jqPlot to draw a bar plot. + // Draws series as a line. + + $.jqplot.BarRenderer = function(){ + $.jqplot.LineRenderer.call(this); + }; + + $.jqplot.BarRenderer.prototype = new $.jqplot.LineRenderer(); + $.jqplot.BarRenderer.prototype.constructor = $.jqplot.BarRenderer; + + // called with scope of series. + $.jqplot.BarRenderer.prototype.init = function(options, plot) { + // Group: Properties + // + // prop: barPadding + // Number of pixels between adjacent bars at the same axis value. + this.barPadding = 8; + // prop: barMargin + // Number of pixels between groups of bars at adjacent axis values. + this.barMargin = 10; + // prop: barDirection + // 'vertical' = up and down bars, 'horizontal' = side to side bars + this.barDirection = 'vertical'; + // prop: barWidth + // Width of the bar in pixels (auto by devaul). null = calculated automatically. + this.barWidth = null; + // prop: shadowOffset + // offset of the shadow from the slice and offset of + // each succesive stroke of the shadow from the last. + this.shadowOffset = 2; + // prop: shadowDepth + // number of strokes to apply to the shadow, + // each stroke offset shadowOffset from the last. + this.shadowDepth = 5; + // prop: shadowAlpha + // transparency of the shadow (0 = transparent, 1 = opaque) + this.shadowAlpha = 0.08; + // prop: waterfall + // true to enable waterfall plot. + this.waterfall = false; + // prop: groups + // group bars into this many groups + this.groups = 1; + // prop: varyBarColor + // true to color each bar of a series separately rather than + // have every bar of a given series the same color. + // If used for non-stacked multiple series bar plots, user should + // specify a separate 'seriesColors' array for each series. + // Otherwise, each series will set their bars to the same color array. + // This option has no Effect for stacked bar charts and is disabled. + this.varyBarColor = false; + // prop: highlightMouseOver + // True to highlight slice when moused over. + // This must be false to enable highlightMouseDown to highlight when clicking on a slice. + this.highlightMouseOver = true; + // prop: highlightMouseDown + // True to highlight when a mouse button is pressed over a slice. + // This will be disabled if highlightMouseOver is true. + this.highlightMouseDown = false; + // prop: highlightColors + // an array of colors to use when highlighting a bar. + this.highlightColors = []; + // prop: transposedData + // NOT IMPLEMENTED YET. True if this is a horizontal bar plot and + // x and y values are "transposed". Tranposed, or "swapped", data is + // required prior to rev. 894 builds of jqPlot with horizontal bars. + // Allows backward compatability of bar renderer horizontal bars with + // old style data sets. + this.transposedData = true; + this.renderer.animation = { + show: false, + direction: 'down', + speed: 3000, + _supported: true + }; + this._type = 'bar'; + + // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver + if (options.highlightMouseDown && options.highlightMouseOver == null) { + options.highlightMouseOver = false; + } + + ////// + // This is probably wrong here. + // After going back and forth on wether renderer should be the thing + // or extend the thing, it seems that it it best if it is a property + // on the thing. This should be something that is commonized + // among series renderers in the future. + ////// + $.extend(true, this, options); + + // really should probably do this + $.extend(true, this.renderer, options); + // fill is still needed to properly draw the legend. + // bars have to be filled. + this.fill = true; + + // if horizontal bar and animating, reset the default direction + if (this.barDirection === 'horizontal' && this.rendererOptions.animation && this.rendererOptions.animation.direction == null) { + this.renderer.animation.direction = 'left'; + } + + if (this.waterfall) { + this.fillToZero = false; + this.disableStack = true; + } + + if (this.barDirection == 'vertical' ) { + this._primaryAxis = '_xaxis'; + this._stackAxis = 'y'; + this.fillAxis = 'y'; + } + else { + this._primaryAxis = '_yaxis'; + this._stackAxis = 'x'; + this.fillAxis = 'x'; + } + // index of the currenty highlighted point, if any + this._highlightedPoint = null; + // total number of values for all bar series, total number of bar series, and position of this series + this._plotSeriesInfo = null; + // Array of actual data colors used for each data point. + this._dataColors = []; + this._barPoints = []; + + // set the shape renderer options + var opts = {lineJoin:'miter', lineCap:'round', fill:true, isarc:false, strokeStyle:this.color, fillStyle:this.color, closePath:this.fill}; + this.renderer.shapeRenderer.init(opts); + // set the shadow renderer options + var sopts = {lineJoin:'miter', lineCap:'round', fill:true, isarc:false, angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, depth:this.shadowDepth, closePath:this.fill}; + this.renderer.shadowRenderer.init(sopts); + + plot.postInitHooks.addOnce(postInit); + plot.postDrawHooks.addOnce(postPlotDraw); + plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove); + plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown); + plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp); + plot.eventListenerHooks.addOnce('jqplotClick', handleClick); + plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick); + }; + + // called with scope of series + function barPreInit(target, data, seriesDefaults, options) { + if (this.rendererOptions.barDirection == 'horizontal') { + this._stackAxis = 'x'; + this._primaryAxis = '_yaxis'; + } + if (this.rendererOptions.waterfall == true) { + this._data = $.extend(true, [], this.data); + var sum = 0; + var pos = (!this.rendererOptions.barDirection || this.rendererOptions.barDirection === 'vertical' || this.transposedData === false) ? 1 : 0; + for(var i=0; i<this.data.length; i++) { + sum += this.data[i][pos]; + if (i>0) { + this.data[i][pos] += this.data[i-1][pos]; + } + } + this.data[this.data.length] = (pos == 1) ? [this.data.length+1, sum] : [sum, this.data.length+1]; + this._data[this._data.length] = (pos == 1) ? [this._data.length+1, sum] : [sum, this._data.length+1]; + } + if (this.rendererOptions.groups > 1) { + this.breakOnNull = true; + var l = this.data.length; + var skip = parseInt(l/this.rendererOptions.groups, 10); + var count = 0; + for (var i=skip; i<l; i+=skip) { + this.data.splice(i+count, 0, [null, null]); + this._plotData.splice(i+count, 0, [null, null]); + this._stackData.splice(i+count, 0, [null, null]); + count++; + } + for (i=0; i<this.data.length; i++) { + if (this._primaryAxis == '_xaxis') { + this.data[i][0] = i+1; + this._plotData[i][0] = i+1; + this._stackData[i][0] = i+1; + } + else { + this.data[i][1] = i+1; + this._plotData[i][1] = i+1; + this._stackData[i][1] = i+1; + } + } + } + } + + $.jqplot.preSeriesInitHooks.push(barPreInit); + + // needs to be called with scope of series, not renderer. + $.jqplot.BarRenderer.prototype.calcSeriesNumbers = function() { + var nvals = 0; + var nseries = 0; + var paxis = this[this._primaryAxis]; + var s, series, pos; + // loop through all series on this axis + for (var i=0; i < paxis._series.length; i++) { + series = paxis._series[i]; + if (series === this) { + pos = i; + } + // is the series rendered as a bar? + if (series.renderer.constructor == $.jqplot.BarRenderer) { + // gridData may not be computed yet, use data length insted + nvals += series.data.length; + nseries += 1; + } + } + // return total number of values for all bar series, total number of bar series, and position of this series + return [nvals, nseries, pos]; + }; + + $.jqplot.BarRenderer.prototype.setBarWidth = function() { + // need to know how many data values we have on the approprate axis and figure it out. + var i; + var nvals = 0; + var nseries = 0; + var paxis = this[this._primaryAxis]; + var s, series, pos; + var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this); + nvals = temp[0]; + nseries = temp[1]; + var nticks = paxis.numberTicks; + var nbins = (nticks-1)/2; + // so, now we have total number of axis values. + if (paxis.name == 'xaxis' || paxis.name == 'x2axis') { + if (this._stack) { + this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals * nseries - this.barMargin; + } + else { + this.barWidth = ((paxis._offsets.max - paxis._offsets.min)/nbins - this.barPadding * (nseries-1) - this.barMargin*2)/nseries; + // this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals - this.barPadding - this.barMargin/nseries; + } + } + else { + if (this._stack) { + this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals * nseries - this.barMargin; + } + else { + this.barWidth = ((paxis._offsets.min - paxis._offsets.max)/nbins - this.barPadding * (nseries-1) - this.barMargin*2)/nseries; + // this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals - this.barPadding - this.barMargin/nseries; + } + } + return [nvals, nseries]; + }; + + function computeHighlightColors (colors) { + var ret = []; + for (var i=0; i<colors.length; i++){ + var rgba = $.jqplot.getColorComponents(colors[i]); + var newrgb = [rgba[0], rgba[1], rgba[2]]; + var sum = newrgb[0] + newrgb[1] + newrgb[2]; + for (var j=0; j<3; j++) { + // when darkening, lowest color component can be is 60. + newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); + newrgb[j] = parseInt(newrgb[j], 10); + } + ret.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')'); + } + return ret; + } + + function getStart(sidx, didx, comp, plot, axis) { + // check if sign change + var seriesIndex = sidx, + prevSeriesIndex = sidx - 1, + start, + prevVal, + aidx = (axis === 'x') ? 0 : 1; + + // is this not the first series? + if (seriesIndex > 0) { + prevVal = plot.series[prevSeriesIndex]._plotData[didx][aidx]; + + // is there a sign change + if ((comp * prevVal) < 0) { + start = getStart(prevSeriesIndex, didx, comp, plot, axis); + } + + // no sign change. + else { + start = plot.series[prevSeriesIndex].gridData[didx][aidx]; + } + + } + + // if first series, return value at 0 + else { + + start = (aidx === 0) ? plot.series[seriesIndex]._xaxis.series_u2p(0) : plot.series[seriesIndex]._yaxis.series_u2p(0); + } + + return start; + } + + + $.jqplot.BarRenderer.prototype.draw = function(ctx, gridData, options, plot) { + var i; + // Ughhh, have to make a copy of options b/c it may be modified later. + var opts = $.extend({}, options); + var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; + var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; + var fill = (opts.fill != undefined) ? opts.fill : this.fill; + var xaxis = this.xaxis; + var yaxis = this.yaxis; + var xp = this._xaxis.series_u2p; + var yp = this._yaxis.series_u2p; + var pointx, pointy; + // clear out data colors. + this._dataColors = []; + this._barPoints = []; + + if (this.barWidth == null) { + this.renderer.setBarWidth.call(this); + } + + var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this); + var nvals = temp[0]; + var nseries = temp[1]; + var pos = temp[2]; + var points = []; + + if (this._stack) { + this._barNudge = 0; + } + else { + this._barNudge = (-Math.abs(nseries/2 - 0.5) + pos) * (this.barWidth + this.barPadding); + } + if (showLine) { + var negativeColors = new $.jqplot.ColorGenerator(this.negativeSeriesColors); + var positiveColors = new $.jqplot.ColorGenerator(this.seriesColors); + var negativeColor = negativeColors.get(this.index); + if (! this.useNegativeColors) { + negativeColor = opts.fillStyle; + } + var positiveColor = opts.fillStyle; + var base; + var xstart; + var ystart; + + if (this.barDirection == 'vertical') { + for (var i=0; i<gridData.length; i++) { + if (!this._stack && this.data[i][1] == null) { + continue; + } + points = []; + base = gridData[i][0] + this._barNudge; + + // stacked + if (this._stack && this._prevGridData.length) { + ystart = getStart(this.index, i, this._plotData[i][1], plot, 'y'); + } + + // not stacked + else { + if (this.fillToZero) { + ystart = this._yaxis.series_u2p(0); + } + else if (this.waterfall && i > 0 && i < this.gridData.length-1) { + ystart = this.gridData[i-1][1]; + } + else if (this.waterfall && i == 0 && i < this.gridData.length-1) { + if (this._yaxis.min <= 0 && this._yaxis.max >= 0) { + ystart = this._yaxis.series_u2p(0); + } + else if (this._yaxis.min > 0) { + ystart = ctx.canvas.height; + } + else { + ystart = 0; + } + } + else if (this.waterfall && i == this.gridData.length - 1) { + if (this._yaxis.min <= 0 && this._yaxis.max >= 0) { + ystart = this._yaxis.series_u2p(0); + } + else if (this._yaxis.min > 0) { + ystart = ctx.canvas.height; + } + else { + ystart = 0; + } + } + else { + ystart = ctx.canvas.height; + } + } + if ((this.fillToZero && this._plotData[i][1] < 0) || (this.waterfall && this._data[i][1] < 0)) { + if (this.varyBarColor && !this._stack) { + if (this.useNegativeColors) { + opts.fillStyle = negativeColors.next(); + } + else { + opts.fillStyle = positiveColors.next(); + } + } + else { + opts.fillStyle = negativeColor; + } + } + else { + if (this.varyBarColor && !this._stack) { + opts.fillStyle = positiveColors.next(); + } + else { + opts.fillStyle = positiveColor; + } + } + + if (!this.fillToZero || this._plotData[i][1] >= 0) { + points.push([base-this.barWidth/2, ystart]); + points.push([base-this.barWidth/2, gridData[i][1]]); + points.push([base+this.barWidth/2, gridData[i][1]]); + points.push([base+this.barWidth/2, ystart]); + } + // for negative bars make sure points are always ordered clockwise + else { + points.push([base-this.barWidth/2, gridData[i][1]]); + points.push([base-this.barWidth/2, ystart]); + points.push([base+this.barWidth/2, ystart]); + points.push([base+this.barWidth/2, gridData[i][1]]); + } + this._barPoints.push(points); + // now draw the shadows if not stacked. + // for stacked plots, they are predrawn by drawShadow + if (shadow && !this._stack) { + var sopts = $.extend(true, {}, opts); + // need to get rid of fillStyle on shadow. + delete sopts.fillStyle; + this.renderer.shadowRenderer.draw(ctx, points, sopts); + } + var clr = opts.fillStyle || this.color; + this._dataColors.push(clr); + this.renderer.shapeRenderer.draw(ctx, points, opts); + } + } + + else if (this.barDirection == 'horizontal'){ + for (var i=0; i<gridData.length; i++) { + if (!this._stack && this.data[i][0] == null) { + continue; + } + points = []; + base = gridData[i][1] - this._barNudge; + xstart; + + if (this._stack && this._prevGridData.length) { + xstart = getStart(this.index, i, this._plotData[i][0], plot, 'x'); + } + // not stacked + else { + if (this.fillToZero) { + xstart = this._xaxis.series_u2p(0); + } + else if (this.waterfall && i > 0 && i < this.gridData.length-1) { + xstart = this.gridData[i-1][0]; + } + else if (this.waterfall && i == 0 && i < this.gridData.length-1) { + if (this._xaxis.min <= 0 && this._xaxis.max >= 0) { + xstart = this._xaxis.series_u2p(0); + } + else if (this._xaxis.min > 0) { + xstart = 0; + } + else { + xstart = 0; + } + } + else if (this.waterfall && i == this.gridData.length - 1) { + if (this._xaxis.min <= 0 && this._xaxis.max >= 0) { + xstart = this._xaxis.series_u2p(0); + } + else if (this._xaxis.min > 0) { + xstart = 0; + } + else { + xstart = ctx.canvas.width; + } + } + else { + xstart = 0; + } + } + if ((this.fillToZero && this._plotData[i][1] < 0) || (this.waterfall && this._data[i][1] < 0)) { + if (this.varyBarColor && !this._stack) { + if (this.useNegativeColors) { + opts.fillStyle = negativeColors.next(); + } + else { + opts.fillStyle = positiveColors.next(); + } + } + } + else { + if (this.varyBarColor && !this._stack) { + opts.fillStyle = positiveColors.next(); + } + else { + opts.fillStyle = positiveColor; + } + } + + + if (!this.fillToZero || this._plotData[i][0] >= 0) { + points.push([xstart, base + this.barWidth / 2]); + points.push([xstart, base - this.barWidth / 2]); + points.push([gridData[i][0], base - this.barWidth / 2]); + points.push([gridData[i][0], base + this.barWidth / 2]); + } + else { + points.push([gridData[i][0], base + this.barWidth / 2]); + points.push([gridData[i][0], base - this.barWidth / 2]); + points.push([xstart, base - this.barWidth / 2]); + points.push([xstart, base + this.barWidth / 2]); + } + + this._barPoints.push(points); + // now draw the shadows if not stacked. + // for stacked plots, they are predrawn by drawShadow + if (shadow && !this._stack) { + var sopts = $.extend(true, {}, opts); + delete sopts.fillStyle; + this.renderer.shadowRenderer.draw(ctx, points, sopts); + } + var clr = opts.fillStyle || this.color; + this._dataColors.push(clr); + this.renderer.shapeRenderer.draw(ctx, points, opts); + } + } + } + + if (this.highlightColors.length == 0) { + this.highlightColors = $.jqplot.computeHighlightColors(this._dataColors); + } + + else if (typeof(this.highlightColors) == 'string') { + var temp = this.highlightColors; + this.highlightColors = []; + for (var i=0; i<this._dataColors.length; i++) { + this.highlightColors.push(temp); + } + } + + }; + + + // for stacked plots, shadows will be pre drawn by drawShadow. + $.jqplot.BarRenderer.prototype.drawShadow = function(ctx, gridData, options, plot) { + var i; + var opts = (options != undefined) ? options : {}; + var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; + var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; + var fill = (opts.fill != undefined) ? opts.fill : this.fill; + var xaxis = this.xaxis; + var yaxis = this.yaxis; + var xp = this._xaxis.series_u2p; + var yp = this._yaxis.series_u2p; + var pointx, points, pointy, nvals, nseries, pos; + + if (this._stack && this.shadow) { + if (this.barWidth == null) { + this.renderer.setBarWidth.call(this); + } + + var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this); + nvals = temp[0]; + nseries = temp[1]; + pos = temp[2]; + + if (this._stack) { + this._barNudge = 0; + } + else { + this._barNudge = (-Math.abs(nseries/2 - 0.5) + pos) * (this.barWidth + this.barPadding); + } + if (showLine) { + + if (this.barDirection == 'vertical') { + for (var i=0; i<gridData.length; i++) { + if (this.data[i][1] == null) { + continue; + } + points = []; + var base = gridData[i][0] + this._barNudge; + var ystart; + + if (this._stack && this._prevGridData.length) { + ystart = getStart(this.index, i, this._plotData[i][1], plot, 'y'); + } + else { + if (this.fillToZero) { + ystart = this._yaxis.series_u2p(0); + } + else { + ystart = ctx.canvas.height; + } + } + + points.push([base-this.barWidth/2, ystart]); + points.push([base-this.barWidth/2, gridData[i][1]]); + points.push([base+this.barWidth/2, gridData[i][1]]); + points.push([base+this.barWidth/2, ystart]); + this.renderer.shadowRenderer.draw(ctx, points, opts); + } + } + + else if (this.barDirection == 'horizontal'){ + for (var i=0; i<gridData.length; i++) { + if (this.data[i][0] == null) { + continue; + } + points = []; + var base = gridData[i][1] - this._barNudge; + var xstart; + + if (this._stack && this._prevGridData.length) { + xstart = getStart(this.index, i, this._plotData[i][0], plot, 'x'); + } + else { + if (this.fillToZero) { + xstart = this._xaxis.series_u2p(0); + } + else { + xstart = 0; + } + } + + points.push([xstart, base+this.barWidth/2]); + points.push([gridData[i][0], base+this.barWidth/2]); + points.push([gridData[i][0], base-this.barWidth/2]); + points.push([xstart, base-this.barWidth/2]); + this.renderer.shadowRenderer.draw(ctx, points, opts); + } + } + } + + } + }; + + function postInit(target, data, options) { + for (var i=0; i<this.series.length; i++) { + if (this.series[i].renderer.constructor == $.jqplot.BarRenderer) { + // don't allow mouseover and mousedown at same time. + if (this.series[i].highlightMouseOver) { + this.series[i].highlightMouseDown = false; + } + } + } + } + + // called within context of plot + // create a canvas which we can draw on. + // insert it before the eventCanvas, so eventCanvas will still capture events. + function postPlotDraw() { + // Memory Leaks patch + if (this.plugins.barRenderer && this.plugins.barRenderer.highlightCanvas) { + + this.plugins.barRenderer.highlightCanvas.resetCanvas(); + this.plugins.barRenderer.highlightCanvas = null; + } + + this.plugins.barRenderer = {highlightedSeriesIndex:null}; + this.plugins.barRenderer.highlightCanvas = new $.jqplot.GenericCanvas(); + + this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-barRenderer-highlight-canvas', this._plotDimensions, this)); + this.plugins.barRenderer.highlightCanvas.setContext(); + this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); + } + + function highlight (plot, sidx, pidx, points) { + var s = plot.series[sidx]; + var canvas = plot.plugins.barRenderer.highlightCanvas; + canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height); + s._highlightedPoint = pidx; + plot.plugins.barRenderer.highlightedSeriesIndex = sidx; + var opts = {fillStyle: s.highlightColors[pidx]}; + s.renderer.shapeRenderer.draw(canvas._ctx, points, opts); + canvas = null; + } + + function unhighlight (plot) { + var canvas = plot.plugins.barRenderer.highlightCanvas; + canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height); + for (var i=0; i<plot.series.length; i++) { + plot.series[i]._highlightedPoint = null; + } + plot.plugins.barRenderer.highlightedSeriesIndex = null; + plot.target.trigger('jqplotDataUnhighlight'); + canvas = null; + } + + + function handleMove(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var evt1 = jQuery.Event('jqplotDataMouseOver'); + evt1.pageX = ev.pageX; + evt1.pageY = ev.pageY; + plot.target.trigger(evt1, ins); + if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { + var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points); + } + } + else if (neighbor == null) { + unhighlight (plot); + } + } + + function handleMouseDown(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { + var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points); + } + } + else if (neighbor == null) { + unhighlight (plot); + } + } + + function handleMouseUp(ev, gridpos, datapos, neighbor, plot) { + var idx = plot.plugins.barRenderer.highlightedSeriesIndex; + if (idx != null && plot.series[idx].highlightMouseDown) { + unhighlight(plot); + } + } + + function handleClick(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var evt = jQuery.Event('jqplotDataClick'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + } + } + + function handleRightClick(ev, gridpos, datapos, neighbor, plot) { + if (neighbor) { + var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; + var idx = plot.plugins.barRenderer.highlightedSeriesIndex; + if (idx != null && plot.series[idx].highlightMouseDown) { + unhighlight(plot); + } + var evt = jQuery.Event('jqplotDataRightClick'); + evt.which = ev.which; + evt.pageX = ev.pageX; + evt.pageY = ev.pageY; + plot.target.trigger(evt, ins); + } + } + + +})(jQuery); /** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + /** + * class: $.jqplot.CategoryAxisRenderer + * A plugin for jqPlot to render a category style axis, with equal pixel spacing between y data values of a series. + * + * To use this renderer, include the plugin in your source + * > <script type="text/javascript" language="javascript" src="plugins/jqplot.categoryAxisRenderer.js"></script> + * + * and supply the appropriate options to your plot + * + * > {axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer}}} + **/ + $.jqplot.CategoryAxisRenderer = function(options) { + $.jqplot.LinearAxisRenderer.call(this); + // prop: sortMergedLabels + // True to sort tick labels when labels are created by merging + // x axis values from multiple series. That is, say you have + // two series like: + // > line1 = [[2006, 4], [2008, 9], [2009, 16]]; + // > line2 = [[2006, 3], [2007, 7], [2008, 6]]; + // If no label array is specified, tick labels will be collected + // from the x values of the series. With sortMergedLabels + // set to true, tick labels will be: + // > [2006, 2007, 2008, 2009] + // With sortMergedLabels set to false, tick labels will be: + // > [2006, 2008, 2009, 2007] + // + // Note, this property is specified on the renderOptions for the + // axes when creating a plot: + // > axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer, rendererOptions:{sortMergedLabels:true}}} + this.sortMergedLabels = false; + }; + + $.jqplot.CategoryAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer(); + $.jqplot.CategoryAxisRenderer.prototype.constructor = $.jqplot.CategoryAxisRenderer; + + $.jqplot.CategoryAxisRenderer.prototype.init = function(options){ + this.groups = 1; + this.groupLabels = []; + this._groupLabels = []; + this._grouped = false; + this._barsPerGroup = null; + this.reverse = false; + // prop: tickRenderer + // A class of a rendering engine for creating the ticks labels displayed on the plot, + // See <$.jqplot.AxisTickRenderer>. + // this.tickRenderer = $.jqplot.AxisTickRenderer; + // this.labelRenderer = $.jqplot.AxisLabelRenderer; + $.extend(true, this, {tickOptions:{formatString:'%d'}}, options); + var db = this._dataBounds; + // Go through all the series attached to this axis and find + // the min/max bounds for this axis. + for (var i=0; i<this._series.length; i++) { + var s = this._series[i]; + if (s.groups) { + this.groups = s.groups; + } + var d = s.data; + + for (var j=0; j<d.length; j++) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + if (d[j][0] < db.min || db.min == null) { + db.min = d[j][0]; + } + if (d[j][0] > db.max || db.max == null) { + db.max = d[j][0]; + } + } + else { + if (d[j][1] < db.min || db.min == null) { + db.min = d[j][1]; + } + if (d[j][1] > db.max || db.max == null) { + db.max = d[j][1]; + } + } + } + } + + if (this.groupLabels.length) { + this.groups = this.groupLabels.length; + } + }; + + + $.jqplot.CategoryAxisRenderer.prototype.createTicks = function() { + // we're are operating on an axis here + var ticks = this._ticks; + var userTicks = this.ticks; + var name = this.name; + // databounds were set on axis initialization. + var db = this._dataBounds; + var dim, interval; + var min, max; + var pos1, pos2; + var tt, i; + + // if we already have ticks, use them. + if (userTicks.length) { + // adjust with blanks if we have groups + if (this.groups > 1 && !this._grouped) { + var l = userTicks.length; + var skip = parseInt(l/this.groups, 10); + var count = 0; + for (var i=skip; i<l; i+=skip) { + userTicks.splice(i+count, 0, ' '); + count++; + } + this._grouped = true; + } + this.min = 0.5; + this.max = userTicks.length + 0.5; + var range = this.max - this.min; + this.numberTicks = 2*userTicks.length + 1; + for (i=0; i<userTicks.length; i++){ + tt = this.min + 2 * i * range / (this.numberTicks-1); + // need a marker before and after the tick + var t = new this.tickRenderer(this.tickOptions); + t.showLabel = false; + // t.showMark = true; + t.setTick(tt, this.name); + this._ticks.push(t); + var t = new this.tickRenderer(this.tickOptions); + t.label = userTicks[i]; + // t.showLabel = true; + t.showMark = false; + t.showGridline = false; + t.setTick(tt+0.5, this.name); + this._ticks.push(t); + } + // now add the last tick at the end + var t = new this.tickRenderer(this.tickOptions); + t.showLabel = false; + // t.showMark = true; + t.setTick(tt+1, this.name); + this._ticks.push(t); + } + + // we don't have any ticks yet, let's make some! + else { + if (name == 'xaxis' || name == 'x2axis') { + dim = this._plotDimensions.width; + } + else { + dim = this._plotDimensions.height; + } + + // if min, max and number of ticks specified, user can't specify interval. + if (this.min != null && this.max != null && this.numberTicks != null) { + this.tickInterval = null; + } + + // if max, min, and interval specified and interval won't fit, ignore interval. + if (this.min != null && this.max != null && this.tickInterval != null) { + if (parseInt((this.max-this.min)/this.tickInterval, 10) != (this.max-this.min)/this.tickInterval) { + this.tickInterval = null; + } + } + + // find out how many categories are in the lines and collect labels + var labels = []; + var numcats = 0; + var min = 0.5; + var max, val; + var isMerged = false; + for (var i=0; i<this._series.length; i++) { + var s = this._series[i]; + for (var j=0; j<s.data.length; j++) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + val = s.data[j][0]; + } + else { + val = s.data[j][1]; + } + if ($.inArray(val, labels) == -1) { + isMerged = true; + numcats += 1; + labels.push(val); + } + } + } + + if (isMerged && this.sortMergedLabels) { + labels.sort(function(a,b) { return a - b; }); + } + + // keep a reference to these tick labels to use for redrawing plot (see bug #57) + this.ticks = labels; + + // now bin the data values to the right lables. + for (var i=0; i<this._series.length; i++) { + var s = this._series[i]; + for (var j=0; j<s.data.length; j++) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + val = s.data[j][0]; + } + else { + val = s.data[j][1]; + } + // for category axis, force the values into category bins. + // we should have the value in the label array now. + var idx = $.inArray(val, labels)+1; + if (this.name == 'xaxis' || this.name == 'x2axis') { + s.data[j][0] = idx; + } + else { + s.data[j][1] = idx; + } + } + } + + // adjust with blanks if we have groups + if (this.groups > 1 && !this._grouped) { + var l = labels.length; + var skip = parseInt(l/this.groups, 10); + var count = 0; + for (var i=skip; i<l; i+=skip+1) { + labels[i] = ' '; + } + this._grouped = true; + } + + max = numcats + 0.5; + if (this.numberTicks == null) { + this.numberTicks = 2*numcats + 1; + } + + var range = max - min; + this.min = min; + this.max = max; + var track = 0; + + // todo: adjust this so more ticks displayed. + var maxVisibleTicks = parseInt(3+dim/10, 10); + var skip = parseInt(numcats/maxVisibleTicks, 10); + + if (this.tickInterval == null) { + + this.tickInterval = range / (this.numberTicks-1); + + } + // if tickInterval is specified, we will ignore any computed maximum. + for (var i=0; i<this.numberTicks; i++){ + tt = this.min + i * this.tickInterval; + var t = new this.tickRenderer(this.tickOptions); + // if even tick, it isn't a category, it's a divider + if (i/2 == parseInt(i/2, 10)) { + t.showLabel = false; + t.showMark = true; + } + else { + if (skip>0 && track<skip) { + t.showLabel = false; + track += 1; + } + else { + t.showLabel = true; + track = 0; + } + t.label = t.formatter(t.formatString, labels[(i-1)/2]); + t.showMark = false; + t.showGridline = false; + } + t.setTick(tt, this.name); + this._ticks.push(t); + } + } + + }; + + // called with scope of axis + $.jqplot.CategoryAxisRenderer.prototype.draw = function(ctx, plot) { + if (this.show) { + // populate the axis label and value properties. + // createTicks is a method on the renderer, but + // call it within the scope of the axis. + this.renderer.createTicks.call(this); + // fill a div with axes labels in the right direction. + // Need to pregenerate each axis to get it's bounds and + // position it and the labels correctly on the plot. + var dim=0; + var temp; + // Added for theming. + if (this._elem) { + // this._elem.empty(); + // Memory Leaks patch + this._elem.emptyForce(); + } + + this._elem = this._elem || $('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>'); + + if (this.name == 'xaxis' || this.name == 'x2axis') { + this._elem.width(this._plotDimensions.width); + } + else { + this._elem.height(this._plotDimensions.height); + } + + // create a _label object. + this.labelOptions.axis = this.name; + this._label = new this.labelRenderer(this.labelOptions); + if (this._label.show) { + var elem = this._label.draw(ctx, plot); + elem.appendTo(this._elem); + } + + var t = this._ticks; + for (var i=0; i<t.length; i++) { + var tick = t[i]; + if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { + var elem = tick.draw(ctx, plot); + elem.appendTo(this._elem); + } + } + + this._groupLabels = []; + // now make group labels + for (var i=0; i<this.groupLabels.length; i++) + { + var elem = $('<div style="position:absolute;" class="jqplot-'+this.name+'-groupLabel"></div>'); + elem.html(this.groupLabels[i]); + this._groupLabels.push(elem); + elem.appendTo(this._elem); + } + } + return this._elem; + }; + + // called with scope of axis + $.jqplot.CategoryAxisRenderer.prototype.set = function() { + var dim = 0; + var temp; + var w = 0; + var h = 0; + var lshow = (this._label == null) ? false : this._label.show; + if (this.show) { + var t = this._ticks; + for (var i=0; i<t.length; i++) { + var tick = t[i]; + if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + temp = tick._elem.outerHeight(true); + } + else { + temp = tick._elem.outerWidth(true); + } + if (temp > dim) { + dim = temp; + } + } + } + + var dim2 = 0; + for (var i=0; i<this._groupLabels.length; i++) { + var l = this._groupLabels[i]; + if (this.name == 'xaxis' || this.name == 'x2axis') { + temp = l.outerHeight(true); + } + else { + temp = l.outerWidth(true); + } + if (temp > dim2) { + dim2 = temp; + } + } + + if (lshow) { + w = this._label._elem.outerWidth(true); + h = this._label._elem.outerHeight(true); + } + if (this.name == 'xaxis') { + dim += dim2 + h; + this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'}); + } + else if (this.name == 'x2axis') { + dim += dim2 + h; + this._elem.css({'height':dim+'px', left:'0px', top:'0px'}); + } + else if (this.name == 'yaxis') { + dim += dim2 + w; + this._elem.css({'width':dim+'px', left:'0px', top:'0px'}); + if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { + this._label._elem.css('width', w+'px'); + } + } + else { + dim += dim2 + w; + this._elem.css({'width':dim+'px', right:'0px', top:'0px'}); + if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { + this._label._elem.css('width', w+'px'); + } + } + } + }; + + // called with scope of axis + $.jqplot.CategoryAxisRenderer.prototype.pack = function(pos, offsets) { + var ticks = this._ticks; + var max = this.max; + var min = this.min; + var offmax = offsets.max; + var offmin = offsets.min; + var lshow = (this._label == null) ? false : this._label.show; + var i; + + for (var p in pos) { + this._elem.css(p, pos[p]); + } + + this._offsets = offsets; + // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left. + var pixellength = offmax - offmin; + var unitlength = max - min; + + if (!this.reverse) { + // point to unit and unit to point conversions references to Plot DOM element top left corner. + + this.u2p = function(u){ + return (u - min) * pixellength / unitlength + offmin; + }; + + this.p2u = function(p){ + return (p - offmin) * unitlength / pixellength + min; + }; + + if (this.name == 'xaxis' || this.name == 'x2axis'){ + this.series_u2p = function(u){ + return (u - min) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + min; + }; + } + + else { + this.series_u2p = function(u){ + return (u - max) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + max; + }; + } + } + + else { + // point to unit and unit to point conversions references to Plot DOM element top left corner. + + this.u2p = function(u){ + return offmin + (max - u) * pixellength / unitlength; + }; + + this.p2u = function(p){ + return min + (p - offmin) * unitlength / pixellength; + }; + + if (this.name == 'xaxis' || this.name == 'x2axis'){ + this.series_u2p = function(u){ + return (max - u) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + max; + }; + } + + else { + this.series_u2p = function(u){ + return (min - u) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + min; + }; + } + + } + + + if (this.show) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + for (i=0; i<ticks.length; i++) { + var t = ticks[i]; + if (t.show && t.showLabel) { + var shim; + + if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { + // will need to adjust auto positioning based on which axis this is. + var temp = (this.name == 'xaxis') ? 1 : -1; + switch (t.labelPosition) { + case 'auto': + // position at end + if (temp * t.angle < 0) { + shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + } + // position at start + else { + shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; + } + break; + case 'end': + shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + break; + case 'start': + shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; + break; + case 'middle': + shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + break; + default: + shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + break; + } + } + else { + shim = -t.getWidth()/2; + } + var val = this.u2p(t.value) + shim + 'px'; + t._elem.css('left', val); + t.pack(); + } + } + + var labeledge=['bottom', 0]; + if (lshow) { + var w = this._label._elem.outerWidth(true); + this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px'); + if (this.name == 'xaxis') { + this._label._elem.css('bottom', '0px'); + labeledge = ['bottom', this._label._elem.outerHeight(true)]; + } + else { + this._label._elem.css('top', '0px'); + labeledge = ['top', this._label._elem.outerHeight(true)]; + } + this._label.pack(); + } + + // draw the group labels + var step = parseInt(this._ticks.length/this.groups, 10); + for (i=0; i<this._groupLabels.length; i++) { + var mid = 0; + var count = 0; + for (var j=i*step; j<=(i+1)*step; j++) { + if (this._ticks[j]._elem && this._ticks[j].label != " ") { + var t = this._ticks[j]._elem; + var p = t.position(); + mid += p.left + t.outerWidth(true)/2; + count++; + } + } + mid = mid/count; + this._groupLabels[i].css({'left':(mid - this._groupLabels[i].outerWidth(true)/2)}); + this._groupLabels[i].css(labeledge[0], labeledge[1]); + } + } + else { + for (i=0; i<ticks.length; i++) { + var t = ticks[i]; + if (t.show && t.showLabel) { + var shim; + if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { + // will need to adjust auto positioning based on which axis this is. + var temp = (this.name == 'yaxis') ? 1 : -1; + switch (t.labelPosition) { + case 'auto': + // position at end + case 'end': + if (temp * t.angle < 0) { + shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; + } + else { + shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; + } + break; + case 'start': + if (t.angle > 0) { + shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; + } + else { + shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; + } + break; + case 'middle': + // if (t.angle > 0) { + // shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; + // } + // else { + // shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; + // } + shim = -t.getHeight()/2; + break; + default: + shim = -t.getHeight()/2; + break; + } + } + else { + shim = -t.getHeight()/2; + } + + var val = this.u2p(t.value) + shim + 'px'; + t._elem.css('top', val); + t.pack(); + } + } + + var labeledge=['left', 0]; + if (lshow) { + var h = this._label._elem.outerHeight(true); + this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px'); + if (this.name == 'yaxis') { + this._label._elem.css('left', '0px'); + labeledge = ['left', this._label._elem.outerWidth(true)]; + } + else { + this._label._elem.css('right', '0px'); + labeledge = ['right', this._label._elem.outerWidth(true)]; + } + this._label.pack(); + } + + // draw the group labels, position top here, do left after label position. + var step = parseInt(this._ticks.length/this.groups, 10); + for (i=0; i<this._groupLabels.length; i++) { + var mid = 0; + var count = 0; + for (var j=i*step; j<=(i+1)*step; j++) { + if (this._ticks[j]._elem && this._ticks[j].label != " ") { + var t = this._ticks[j]._elem; + var p = t.position(); + mid += p.top + t.outerHeight()/2; + count++; + } + } + mid = mid/count; + this._groupLabels[i].css({'top':mid - this._groupLabels[i].outerHeight()/2}); + this._groupLabels[i].css(labeledge[0], labeledge[1]); + + } + } + } + }; + + +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + * included jsDate library by Chris Leonello: + * + * Copyright (c) 2010-2013 Chris Leonello + * + * jsDate is currently available for use in all personal or commercial projects + * under both the MIT and GPL version 2.0 licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * jsDate borrows many concepts and ideas from the Date Instance + * Methods by Ken Snyder along with some parts of Ken's actual code. + * + * Ken's origianl Date Instance Methods and copyright notice: + * + * Ken Snyder (ken d snyder at gmail dot com) + * 2008-09-10 + * version 2.0.2 (http://kendsnyder.com/sandbox/date/) + * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/) + * + * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js. + * Larry has generously given permission to adapt his code for inclusion + * into jqPlot. + * + * Larry's original code can be found here: + * + * https://github.com/lsiden/export-jqplot-to-png + * + * + */ + +(function($) { + // This code is a modified version of the canvastext.js code, copyright below: + // + // This code is released to the public domain by Jim Studt, 2007. + // He may keep some sort of up to date copy at http://www.federated.com/~jim/canvastext/ + // + $.jqplot.CanvasTextRenderer = function(options){ + this.fontStyle = 'normal'; // normal, italic, oblique [not implemented] + this.fontVariant = 'normal'; // normal, small caps [not implemented] + this.fontWeight = 'normal'; // normal, bold, bolder, lighter, 100 - 900 + this.fontSize = '10px'; + this.fontFamily = 'sans-serif'; + this.fontStretch = 1.0; + this.fillStyle = '#666666'; + this.angle = 0; + this.textAlign = 'start'; + this.textBaseline = 'alphabetic'; + this.text; + this.width; + this.height; + this.pt2px = 1.28; + + $.extend(true, this, options); + this.normalizedFontSize = this.normalizeFontSize(this.fontSize); + this.setHeight(); + }; + + $.jqplot.CanvasTextRenderer.prototype.init = function(options) { + $.extend(true, this, options); + this.normalizedFontSize = this.normalizeFontSize(this.fontSize); + this.setHeight(); + }; + + // convert css spec into point size + // returns float + $.jqplot.CanvasTextRenderer.prototype.normalizeFontSize = function(sz) { + sz = String(sz); + var n = parseFloat(sz); + if (sz.indexOf('px') > -1) { + return n/this.pt2px; + } + else if (sz.indexOf('pt') > -1) { + return n; + } + else if (sz.indexOf('em') > -1) { + return n*12; + } + else if (sz.indexOf('%') > -1) { + return n*12/100; + } + // default to pixels; + else { + return n/this.pt2px; + } + }; + + + $.jqplot.CanvasTextRenderer.prototype.fontWeight2Float = function(w) { + // w = normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 + // return values adjusted for Hershey font. + if (Number(w)) { + return w/400; + } + else { + switch (w) { + case 'normal': + return 1; + break; + case 'bold': + return 1.75; + break; + case 'bolder': + return 2.25; + break; + case 'lighter': + return 0.75; + break; + default: + return 1; + break; + } + } + }; + + $.jqplot.CanvasTextRenderer.prototype.getText = function() { + return this.text; + }; + + $.jqplot.CanvasTextRenderer.prototype.setText = function(t, ctx) { + this.text = t; + this.setWidth(ctx); + return this; + }; + + $.jqplot.CanvasTextRenderer.prototype.getWidth = function(ctx) { + return this.width; + }; + + $.jqplot.CanvasTextRenderer.prototype.setWidth = function(ctx, w) { + if (!w) { + this.width = this.measure(ctx, this.text); + } + else { + this.width = w; + } + return this; + }; + + // return height in pixels. + $.jqplot.CanvasTextRenderer.prototype.getHeight = function(ctx) { + return this.height; + }; + + // w - height in pt + // set heigh in px + $.jqplot.CanvasTextRenderer.prototype.setHeight = function(w) { + if (!w) { + //height = this.fontSize /0.75; + this.height = this.normalizedFontSize * this.pt2px; + } + else { + this.height = w; + } + return this; + }; + + $.jqplot.CanvasTextRenderer.prototype.letter = function (ch) + { + return this.letters[ch]; + }; + + $.jqplot.CanvasTextRenderer.prototype.ascent = function() + { + return this.normalizedFontSize; + }; + + $.jqplot.CanvasTextRenderer.prototype.descent = function() + { + return 7.0*this.normalizedFontSize/25.0; + }; + + $.jqplot.CanvasTextRenderer.prototype.measure = function(ctx, str) + { + var total = 0; + var len = str.length; + + for (var i = 0; i < len; i++) { + var c = this.letter(str.charAt(i)); + if (c) { + total += c.width * this.normalizedFontSize / 25.0 * this.fontStretch; + } + } + return total; + }; + + $.jqplot.CanvasTextRenderer.prototype.draw = function(ctx,str) + { + var x = 0; + // leave room at bottom for descenders. + var y = this.height*0.72; + var total = 0; + var len = str.length; + var mag = this.normalizedFontSize / 25.0; + + ctx.save(); + var tx, ty; + + // 1st quadrant + if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) { + tx = 0; + ty = -Math.sin(this.angle) * this.width; + } + // 4th quadrant + else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) { + tx = Math.sin(this.angle) * this.height; + ty = 0; + } + // 2nd quadrant + else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) { + tx = -Math.cos(this.angle) * this.width; + ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height; + } + // 3rd quadrant + else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) { + tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width; + ty = -Math.cos(this.angle) * this.height; + } + + ctx.strokeStyle = this.fillStyle; + ctx.fillStyle = this.fillStyle; + ctx.translate(tx, ty); + ctx.rotate(this.angle); + ctx.lineCap = "round"; + // multiplier was 2.0 + var fact = (this.normalizedFontSize > 30) ? 2.0 : 2 + (30 - this.normalizedFontSize)/20; + ctx.lineWidth = fact * mag * this.fontWeight2Float(this.fontWeight); + + for ( var i = 0; i < len; i++) { + var c = this.letter( str.charAt(i)); + if ( !c) { + continue; + } + + ctx.beginPath(); + + var penUp = 1; + var needStroke = 0; + for ( var j = 0; j < c.points.length; j++) { + var a = c.points[j]; + if ( a[0] == -1 && a[1] == -1) { + penUp = 1; + continue; + } + if ( penUp) { + ctx.moveTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag); + penUp = false; + } else { + ctx.lineTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag); + } + } + ctx.stroke(); + x += c.width*mag*this.fontStretch; + } + ctx.restore(); + return total; + }; + + $.jqplot.CanvasTextRenderer.prototype.letters = { + ' ': { width: 16, points: [] }, + '!': { width: 10, points: [[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] }, + '"': { width: 16, points: [[4,21],[4,14],[-1,-1],[12,21],[12,14]] }, + '#': { width: 21, points: [[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]] }, + '$': { width: 20, points: [[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] }, + '%': { width: 24, points: [[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]] }, + '&': { width: 26, points: [[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]] }, + '\'': { width: 10, points: [[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]] }, + '(': { width: 14, points: [[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]] }, + ')': { width: 14, points: [[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]] }, + '*': { width: 16, points: [[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]] }, + '+': { width: 26, points: [[13,18],[13,0],[-1,-1],[4,9],[22,9]] }, + ',': { width: 10, points: [[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] }, + '-': { width: 18, points: [[6,9],[12,9]] }, + '.': { width: 10, points: [[5,2],[4,1],[5,0],[6,1],[5,2]] }, + '/': { width: 22, points: [[20,25],[2,-7]] }, + '0': { width: 20, points: [[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]] }, + '1': { width: 20, points: [[6,17],[8,18],[11,21],[11,0]] }, + '2': { width: 20, points: [[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]] }, + '3': { width: 20, points: [[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] }, + '4': { width: 20, points: [[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]] }, + '5': { width: 20, points: [[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] }, + '6': { width: 20, points: [[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]] }, + '7': { width: 20, points: [[17,21],[7,0],[-1,-1],[3,21],[17,21]] }, + '8': { width: 20, points: [[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]] }, + '9': { width: 20, points: [[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]] }, + ':': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] }, + ';': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] }, + '<': { width: 24, points: [[20,18],[4,9],[20,0]] }, + '=': { width: 26, points: [[4,12],[22,12],[-1,-1],[4,6],[22,6]] }, + '>': { width: 24, points: [[4,18],[20,9],[4,0]] }, + '?': { width: 18, points: [[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]] }, + '@': { width: 27, points: [[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]] }, + 'A': { width: 18, points: [[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]] }, + 'B': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]] }, + 'C': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]] }, + 'D': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]] }, + 'E': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]] }, + 'F': { width: 18, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]] }, + 'G': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]] }, + 'H': { width: 22, points: [[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]] }, + 'I': { width: 8, points: [[4,21],[4,0]] }, + 'J': { width: 16, points: [[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]] }, + 'K': { width: 21, points: [[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]] }, + 'L': { width: 17, points: [[4,21],[4,0],[-1,-1],[4,0],[16,0]] }, + 'M': { width: 24, points: [[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]] }, + 'N': { width: 22, points: [[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]] }, + 'O': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]] }, + 'P': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]] }, + 'Q': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]] }, + 'R': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]] }, + 'S': { width: 20, points: [[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] }, + 'T': { width: 16, points: [[8,21],[8,0],[-1,-1],[1,21],[15,21]] }, + 'U': { width: 22, points: [[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]] }, + 'V': { width: 18, points: [[1,21],[9,0],[-1,-1],[17,21],[9,0]] }, + 'W': { width: 24, points: [[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]] }, + 'X': { width: 20, points: [[3,21],[17,0],[-1,-1],[17,21],[3,0]] }, + 'Y': { width: 18, points: [[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]] }, + 'Z': { width: 20, points: [[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]] }, + '[': { width: 14, points: [[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]] }, + '\\': { width: 14, points: [[0,21],[14,-3]] }, + ']': { width: 14, points: [[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]] }, + '^': { width: 16, points: [[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]] }, + '_': { width: 16, points: [[0,-2],[16,-2]] }, + '`': { width: 10, points: [[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]] }, + 'a': { width: 19, points: [[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] }, + 'b': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] }, + 'c': { width: 18, points: [[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] }, + 'd': { width: 19, points: [[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] }, + 'e': { width: 18, points: [[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] }, + 'f': { width: 12, points: [[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]] }, + 'g': { width: 19, points: [[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] }, + 'h': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] }, + 'i': { width: 8, points: [[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]] }, + 'j': { width: 10, points: [[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]] }, + 'k': { width: 17, points: [[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]] }, + 'l': { width: 8, points: [[4,21],[4,0]] }, + 'm': { width: 30, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]] }, + 'n': { width: 19, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] }, + 'o': { width: 19, points: [[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]] }, + 'p': { width: 19, points: [[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] }, + 'q': { width: 19, points: [[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] }, + 'r': { width: 13, points: [[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]] }, + 's': { width: 17, points: [[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]] }, + 't': { width: 12, points: [[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]] }, + 'u': { width: 19, points: [[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]] }, + 'v': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0]] }, + 'w': { width: 22, points: [[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]] }, + 'x': { width: 17, points: [[3,14],[14,0],[-1,-1],[14,14],[3,0]] }, + 'y': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]] }, + 'z': { width: 17, points: [[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]] }, + '{': { width: 14, points: [[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]] }, + '|': { width: 8, points: [[4,25],[4,-7]] }, + '}': { width: 14, points: [[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]] }, + '~': { width: 24, points: [[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]] } + }; + + $.jqplot.CanvasFontRenderer = function(options) { + options = options || {}; + if (!options.pt2px) { + options.pt2px = 1.5; + } + $.jqplot.CanvasTextRenderer.call(this, options); + }; + + $.jqplot.CanvasFontRenderer.prototype = new $.jqplot.CanvasTextRenderer({}); + $.jqplot.CanvasFontRenderer.prototype.constructor = $.jqplot.CanvasFontRenderer; + + $.jqplot.CanvasFontRenderer.prototype.measure = function(ctx, str) + { + // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily; + var fstyle = this.fontSize+' '+this.fontFamily; + ctx.save(); + ctx.font = fstyle; + var w = ctx.measureText(str).width; + ctx.restore(); + return w; + }; + + $.jqplot.CanvasFontRenderer.prototype.draw = function(ctx, str) + { + var x = 0; + // leave room at bottom for descenders. + var y = this.height*0.72; + //var y = 12; + + ctx.save(); + var tx, ty; + + // 1st quadrant + if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) { + tx = 0; + ty = -Math.sin(this.angle) * this.width; + } + // 4th quadrant + else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) { + tx = Math.sin(this.angle) * this.height; + ty = 0; + } + // 2nd quadrant + else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) { + tx = -Math.cos(this.angle) * this.width; + ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height; + } + // 3rd quadrant + else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) { + tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width; + ty = -Math.cos(this.angle) * this.height; + } + ctx.strokeStyle = this.fillStyle; + ctx.fillStyle = this.fillStyle; + // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily; + var fstyle = this.fontSize+' '+this.fontFamily; + ctx.font = fstyle; + ctx.translate(tx, ty); + ctx.rotate(this.angle); + ctx.fillText(str, x, y); + // ctx.strokeText(str, x, y); + + ctx.restore(); + }; + +})(jQuery);/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ +(function($) { + /** + * Class: $.jqplot.CanvasAxisTickRenderer + * Renderer to draw axis ticks with a canvas element to support advanced + * featrues such as rotated text. This renderer uses a separate rendering engine + * to draw the text on the canvas. Two modes of rendering the text are available. + * If the browser has native font support for canvas fonts (currently Mozila 3.5 + * and Safari 4), you can enable text rendering with the canvas fillText method. + * You do so by setting the "enableFontSupport" option to true. + * + * Browsers lacking native font support will have the text drawn on the canvas + * using the Hershey font metrics. Even if the "enableFontSupport" option is true + * non-supporting browsers will still render with the Hershey font. + */ + $.jqplot.CanvasAxisTickRenderer = function(options) { + // Group: Properties + + // prop: mark + // tick mark on the axis. One of 'inside', 'outside', 'cross', '' or null. + this.mark = 'outside'; + // prop: showMark + // wether or not to show the mark on the axis. + this.showMark = true; + // prop: showGridline + // wether or not to draw the gridline on the grid at this tick. + this.showGridline = true; + // prop: isMinorTick + // if this is a minor tick. + this.isMinorTick = false; + // prop: angle + // angle of text, measured clockwise from x axis. + this.angle = 0; + // prop: markSize + // Length of the tick marks in pixels. For 'cross' style, length + // will be stoked above and below axis, so total length will be twice this. + this.markSize = 4; + // prop: show + // wether or not to show the tick (mark and label). + this.show = true; + // prop: showLabel + // wether or not to show the label. + this.showLabel = true; + // prop: labelPosition + // 'auto', 'start', 'middle' or 'end'. + // Whether tick label should be positioned so the start, middle, or end + // of the tick mark. + this.labelPosition = 'auto'; + this.label = ''; + this.value = null; + this._styles = {}; + // prop: formatter + // A class of a formatter for the tick text. + // The default $.jqplot.DefaultTickFormatter uses sprintf. + this.formatter = $.jqplot.DefaultTickFormatter; + // prop: formatString + // string passed to the formatter. + this.formatString = ''; + // prop: prefix + // String to prepend to the tick label. + // Prefix is prepended to the formatted tick label. + this.prefix = ''; + // prop: fontFamily + // css spec for the font-family css attribute. + this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif'; + // prop: fontSize + // CSS spec for font size. + this.fontSize = '10pt'; + // prop: fontWeight + // CSS spec for fontWeight + this.fontWeight = 'normal'; + // prop: fontStretch + // Multiplier to condense or expand font width. + // Applies only to browsers which don't support canvas native font rendering. + this.fontStretch = 1.0; + // prop: textColor + // css spec for the color attribute. + this.textColor = '#666666'; + // prop: enableFontSupport + // true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+. + // If true, tick label will be drawn with canvas tag native support for fonts. + // If false, tick label will be drawn with Hershey font metrics. + this.enableFontSupport = true; + // prop: pt2px + // Point to pixel scaling factor, used for computing height of bounding box + // around a label. The labels text renderer has a default setting of 1.4, which + // should be suitable for most fonts. Leave as null to use default. If tops of + // letters appear clipped, increase this. If bounding box seems too big, decrease. + // This is an issue only with the native font renderering capabilities of Mozilla + // 3.5 and Safari 4 since they do not provide a method to determine the font height. + this.pt2px = null; + + this._elem; + this._ctx; + this._plotWidth; + this._plotHeight; + this._plotDimensions = {height:null, width:null}; + + $.extend(true, this, options); + + var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily}; + if (this.pt2px) { + ropts.pt2px = this.pt2px; + } + + if (this.enableFontSupport) { + if ($.jqplot.support_canvas_text()) { + this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts); + } + + else { + this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); + } + } + else { + this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); + } + }; + + $.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) { + $.extend(true, this, options); + this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily}); + }; + + // return width along the x axis + // will check first to see if an element exists. + // if not, will return the computed text box width. + $.jqplot.CanvasAxisTickRenderer.prototype.getWidth = function(ctx) { + if (this._elem) { + return this._elem.outerWidth(true); + } + else { + var tr = this._textRenderer; + var l = tr.getWidth(ctx); + var h = tr.getHeight(ctx); + var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l); + return w; + } + }; + + // return height along the y axis. + $.jqplot.CanvasAxisTickRenderer.prototype.getHeight = function(ctx) { + if (this._elem) { + return this._elem.outerHeight(true); + } + else { + var tr = this._textRenderer; + var l = tr.getWidth(ctx); + var h = tr.getHeight(ctx); + var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l); + return w; + } + }; + + $.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad = function() { + var a = this.angle * Math.PI/180; + return a; + }; + + + $.jqplot.CanvasAxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) { + this.value = value; + if (isMinor) { + this.isMinorTick = true; + } + return this; + }; + + $.jqplot.CanvasAxisTickRenderer.prototype.draw = function(ctx, plot) { + if (!this.label) { + this.label = this.prefix + this.formatter(this.formatString, this.value); + } + + // Memory Leaks patch + if (this._elem) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { + window.G_vmlCanvasManager.uninitElement(this._elem.get(0)); + } + + this._elem.emptyForce(); + this._elem = null; + } + + // create a canvas here, but can't draw on it untill it is appended + // to dom for IE compatability. + + var elem = plot.canvasManager.getCanvas(); + + this._textRenderer.setText(this.label, ctx); + var w = this.getWidth(ctx); + var h = this.getHeight(ctx); + // canvases seem to need to have width and heigh attributes directly set. + elem.width = w; + elem.height = h; + elem.style.width = w; + elem.style.height = h; + elem.style.textAlign = 'left'; + elem.style.position = 'absolute'; + + elem = plot.canvasManager.initCanvas(elem); + + this._elem = $(elem); + this._elem.css(this._styles); + this._elem.addClass('jqplot-'+this.axis+'-tick'); + + elem = null; + return this._elem; + }; + + $.jqplot.CanvasAxisTickRenderer.prototype.pack = function() { + this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label); + }; + +})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/jqplot.axisLabelRenderer.js b/libs/jqplot/jqplot.axisLabelRenderer.js index 8a0286883b..2ce8efede5 100644 --- a/libs/jqplot/jqplot.axisLabelRenderer.js +++ b/libs/jqplot/jqplot.axisLabelRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can diff --git a/libs/jqplot/jqplot.axisTickRenderer.js b/libs/jqplot/jqplot.axisTickRenderer.js index b198112719..97354b42a8 100644 --- a/libs/jqplot/jqplot.axisTickRenderer.js +++ b/libs/jqplot/jqplot.axisTickRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -63,7 +64,7 @@ // prop: showLabel // wether or not to show the label. this.showLabel = true; - this.label = ''; + this.label = null; this.value = null; this._styles = {}; // prop: formatter @@ -73,6 +74,10 @@ // String to prepend to the tick label. // Prefix is prepended to the formatted tick label. this.prefix = ''; + // prop: suffix + // String to append to the tick label. + // Suffix is appended to the formatted tick label. + this.suffix = ''; // prop: formatString // string passed to the formatter. this.formatString = ''; @@ -85,6 +90,9 @@ // prop: textColor // css spec for the color attribute. this.textColor; + // prop: escapeHTML + // true to escape HTML entities in the label. + this.escapeHTML = false; this._elem; this._breakTick = false; @@ -108,8 +116,8 @@ }; $.jqplot.AxisTickRenderer.prototype.draw = function() { - if (!this.label) { - this.label = this.prefix + this.formatter(this.formatString, this.value); + if (this.label === null) { + this.label = this.prefix + this.formatter(this.formatString, this.value) + this.suffix; } var style = {position: 'absolute'}; if (Number(this.label)) { @@ -124,7 +132,14 @@ this._elem = $(document.createElement('div')); this._elem.addClass("jqplot-"+this.axis+"-tick"); - this._elem.text(this.label); + + if (!this.escapeHTML) { + this._elem.html(this.label); + } + else { + this._elem.text(this.label); + } + this._elem.css(style); for (var s in this._styles) { @@ -157,6 +172,19 @@ return String(val); } }; + + $.jqplot.PercentTickFormatter = function (format, val) { + if (typeof val == 'number') { + val = 100 * val; + if (!format) { + format = $.jqplot.config.defaultTickFormatString; + } + return $.jqplot.sprintf(format, val); + } + else { + return String(val); + } + }; $.jqplot.AxisTickRenderer.prototype.pack = function() { }; diff --git a/libs/jqplot/jqplot.canvasGridRenderer.js b/libs/jqplot/jqplot.canvasGridRenderer.js index 0ef0cc3372..832a3b75a1 100644 --- a/libs/jqplot/jqplot.canvasGridRenderer.js +++ b/libs/jqplot/jqplot.canvasGridRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -49,7 +50,7 @@ var elem; // Memory Leaks patch if (this._elem) { - if ($.jqplot.use_excanvas) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { elem = this._elem.get(0); window.G_vmlCanvasManager.uninitElement(elem); elem = null; @@ -92,236 +93,260 @@ ctx.fillStyle = this.backgroundColor || this.background; ctx.fillRect(this._left, this._top, this._width, this._height); - if (true) { - ctx.save(); - ctx.lineJoin = 'miter'; - ctx.lineCap = 'butt'; - ctx.lineWidth = this.gridLineWidth; - ctx.strokeStyle = this.gridLineColor; - var b, e, s, m; - var ax = ['xaxis', 'yaxis', 'x2axis', 'y2axis']; - for (var i=4; i>0; i--) { - var name = ax[i-1]; - var axis = axes[name]; - var ticks = axis._ticks; - if (axis.show) { - for (var j=ticks.length; j>0; j--) { - var t = ticks[j-1]; - if (t.show) { - var pos = Math.round(axis.u2p(t.value)) + 0.5; - switch (name) { - case 'xaxis': - // draw the grid line - if (t.showGridline && this.drawGridlines) { - drawLine(pos, this._top, pos, this._bottom); - } - - // draw the mark - if (t.showMark && t.mark) { - s = t.markSize; - m = t.mark; - var pos = Math.round(axis.u2p(t.value)) + 0.5; - switch (m) { - case 'outside': - b = this._bottom; - e = this._bottom+s; - break; - case 'inside': - b = this._bottom-s; - e = this._bottom; - break; - case 'cross': - b = this._bottom-s; - e = this._bottom+s; - break; - default: - b = this._bottom; - e = this._bottom+s; - break; - } - // draw the shadow - if (this.shadow) { - this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false}); - } - // draw the line - drawLine(pos, b, pos, e); - } - break; - case 'yaxis': - // draw the grid line - if (t.showGridline && this.drawGridlines) { - drawLine(this._right, pos, this._left, pos); - } - // draw the mark - if (t.showMark && t.mark) { - s = t.markSize; - m = t.mark; - var pos = Math.round(axis.u2p(t.value)) + 0.5; - switch (m) { - case 'outside': - b = this._left-s; - e = this._left; - break; - case 'inside': - b = this._left; - e = this._left+s; - break; - case 'cross': - b = this._left-s; - e = this._left+s; - break; - default: - b = this._left-s; - e = this._left; - break; - } - // draw the shadow - if (this.shadow) { - this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); - } - drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + ctx.save(); + ctx.lineJoin = 'miter'; + ctx.lineCap = 'butt'; + ctx.lineWidth = this.gridLineWidth; + ctx.strokeStyle = this.gridLineColor; + var b, e, s, m; + var ax = ['xaxis', 'yaxis', 'x2axis', 'y2axis']; + for (var i=4; i>0; i--) { + var name = ax[i-1]; + var axis = axes[name]; + var ticks = axis._ticks; + var numticks = ticks.length; + if (axis.show) { + if (axis.drawBaseline) { + var bopts = {}; + if (axis.baselineWidth !== null) { + bopts.lineWidth = axis.baselineWidth; + } + if (axis.baselineColor !== null) { + bopts.strokeStyle = axis.baselineColor; + } + switch (name) { + case 'xaxis': + drawLine (this._left, this._bottom, this._right, this._bottom, bopts); + break; + case 'yaxis': + drawLine (this._left, this._bottom, this._left, this._top, bopts); + break; + case 'x2axis': + drawLine (this._left, this._bottom, this._right, this._bottom, bopts); + break; + case 'y2axis': + drawLine (this._right, this._bottom, this._right, this._top, bopts); + break; + } + } + for (var j=numticks; j>0; j--) { + var t = ticks[j-1]; + if (t.show) { + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (name) { + case 'xaxis': + // draw the grid line if we should + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(pos, this._top, pos, this._bottom); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._bottom; + e = this._bottom+s; + break; + case 'inside': + b = this._bottom-s; + e = this._bottom; + break; + case 'cross': + b = this._bottom-s; + e = this._bottom+s; + break; + default: + b = this._bottom; + e = this._bottom+s; + break; } - break; - case 'x2axis': - // draw the grid line - if (t.showGridline && this.drawGridlines) { - drawLine(pos, this._bottom, pos, this._top); + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false}); } - // draw the mark - if (t.showMark && t.mark) { - s = t.markSize; - m = t.mark; - var pos = Math.round(axis.u2p(t.value)) + 0.5; - switch (m) { - case 'outside': - b = this._top-s; - e = this._top; - break; - case 'inside': - b = this._top; - e = this._top+s; - break; - case 'cross': - b = this._top-s; - e = this._top+s; - break; - default: - b = this._top-s; - e = this._top; - break; - } - // draw the shadow - if (this.shadow) { - this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false}); - } - drawLine(pos, b, pos, e); + // draw the line + drawLine(pos, b, pos, e); + } + break; + case 'yaxis': + // draw the grid line + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(this._right, pos, this._left, pos); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._left-s; + e = this._left; + break; + case 'inside': + b = this._left; + e = this._left+s; + break; + case 'cross': + b = this._left-s; + e = this._left+s; + break; + default: + b = this._left-s; + e = this._left; + break; + } + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); } - break; - case 'y2axis': - // draw the grid line - if (t.showGridline && this.drawGridlines) { - drawLine(this._left, pos, this._right, pos); + drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + } + break; + case 'x2axis': + // draw the grid line + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(pos, this._bottom, pos, this._top); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._top-s; + e = this._top; + break; + case 'inside': + b = this._top; + e = this._top+s; + break; + case 'cross': + b = this._top-s; + e = this._top+s; + break; + default: + b = this._top-s; + e = this._top; + break; + } + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false}); } - // draw the mark - if (t.showMark && t.mark) { - s = t.markSize; - m = t.mark; - var pos = Math.round(axis.u2p(t.value)) + 0.5; - switch (m) { - case 'outside': - b = this._right; - e = this._right+s; - break; - case 'inside': - b = this._right-s; - e = this._right; - break; - case 'cross': - b = this._right-s; - e = this._right+s; - break; - default: - b = this._right; - e = this._right+s; - break; - } - // draw the shadow - if (this.shadow) { - this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); - } - drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + drawLine(pos, b, pos, e); + } + break; + case 'y2axis': + // draw the grid line + if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) { + drawLine(this._left, pos, this._right, pos); + } + // draw the mark + if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) { + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + switch (m) { + case 'outside': + b = this._right; + e = this._right+s; + break; + case 'inside': + b = this._right-s; + e = this._right; + break; + case 'cross': + b = this._right-s; + e = this._right+s; + break; + default: + b = this._right; + e = this._right+s; + break; + } + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); } - break; - default: - break; - } + drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + } + break; + default: + break; } } - t = null; } - axis = null; - ticks = null; + t = null; } - // Now draw grid lines for additional y axes - ax = ['y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis']; - for (var i=7; i>0; i--) { - var axis = axes[ax[i-1]]; - var ticks = axis._ticks; - if (axis.show) { - var tn = ticks[axis.numberTicks-1]; - var t0 = ticks[0]; - var left = axis.getLeft(); - var points = [[left, tn.getTop() + tn.getHeight()/2], [left, t0.getTop() + t0.getHeight()/2 + 1.0]]; - // draw the shadow - if (this.shadow) { - this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', fill:false, closePath:false}); - } - // draw the line - drawLine(points[0][0], points[0][1], points[1][0], points[1][1], {lineCap:'butt', strokeStyle:axis.borderColor, lineWidth:axis.borderWidth}); - // draw the tick marks - for (var j=ticks.length; j>0; j--) { - var t = ticks[j-1]; - s = t.markSize; - m = t.mark; - var pos = Math.round(axis.u2p(t.value)) + 0.5; - if (t.showMark && t.mark) { - switch (m) { - case 'outside': - b = left; - e = left+s; - break; - case 'inside': - b = left-s; - e = left; - break; - case 'cross': - b = left-s; - e = left+s; - break; - default: - b = left; - e = left+s; - break; - } - points = [[b,pos], [e,pos]]; - // draw the shadow - if (this.shadow) { - this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); - } - // draw the line - drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); + axis = null; + ticks = null; + } + // Now draw grid lines for additional y axes + ////// + // TO DO: handle yMidAxis + ////// + ax = ['y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis', 'yMidAxis']; + for (var i=7; i>0; i--) { + var axis = axes[ax[i-1]]; + var ticks = axis._ticks; + if (axis.show) { + var tn = ticks[axis.numberTicks-1]; + var t0 = ticks[0]; + var left = axis.getLeft(); + var points = [[left, tn.getTop() + tn.getHeight()/2], [left, t0.getTop() + t0.getHeight()/2 + 1.0]]; + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', fill:false, closePath:false}); + } + // draw the line + drawLine(points[0][0], points[0][1], points[1][0], points[1][1], {lineCap:'butt', strokeStyle:axis.borderColor, lineWidth:axis.borderWidth}); + // draw the tick marks + for (var j=ticks.length; j>0; j--) { + var t = ticks[j-1]; + s = t.markSize; + m = t.mark; + var pos = Math.round(axis.u2p(t.value)) + 0.5; + if (t.showMark && t.mark) { + switch (m) { + case 'outside': + b = left; + e = left+s; + break; + case 'inside': + b = left-s; + e = left; + break; + case 'cross': + b = left-s; + e = left+s; + break; + default: + b = left; + e = left+s; + break; } - t = null; + points = [[b,pos], [e,pos]]; + // draw the shadow + if (this.shadow) { + this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false}); + } + // draw the line + drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor}); } - t0 = null; + t = null; } - axis = null; - ticks = null; + t0 = null; } - - ctx.restore(); + axis = null; + ticks = null; } + ctx.restore(); + function drawLine(bx, by, ex, ey, opts) { ctx.save(); opts = opts || {}; diff --git a/libs/jqplot/jqplot.core.js b/libs/jqplot/jqplot.core.js index 98cc66b24c..9f9cd19af7 100644 --- a/libs/jqplot/jqplot.core.js +++ b/libs/jqplot/jqplot.core.js @@ -5,11 +5,12 @@ * * About: Version * - * @VERSION + * version: @VERSION + * revision: @REVISION * * About: Copyright & License * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT and GPL version 2.0 licenses. This means that you can * choose the license that best suits your project and use it accordingly. @@ -89,11 +90,11 @@ for ( var i = 0, elem; (elem = $(this)[i]) != null; i++ ) { // Remove element nodes and prevent memory leaks if ( elem.nodeType === 1 ) { - jQuery.cleanData( elem.getElementsByTagName("*") ); + $.cleanData( elem.getElementsByTagName("*") ); } // Remove any remaining nodes - if ($.jqplot_use_excanvas) { + if ($.jqplot.use_excanvas) { elem.outerHTML = ""; } else { @@ -114,34 +115,60 @@ parent.removeChild( parent.firstChild ); } }; - - // // Memory Leaks patch : garbage collector - // $.gcInit = function() { - // var gc = $("<div id='gc_jqPlotSalsaGarbage' style='display:none;visibility:hidden;'></div>"); - // $("body").append(gc); - // $._gc = gc; - // }; - - // $.gcCollect = function(elem) { - // $._gc.append(elem); - // }; - - // $.gcClear = function() { - // if ($.browser.msie) { - // $._gc.children().each(function() { - // this.outerHTML = ""; - // }); - // } - - // $._gc.empty(); - // }; - - // $(document).ready(function() { - // $.gcInit(); - // }); + + $.fn.jqplot = function() { + var datas = []; + var options = []; + // see how many data arrays we have + for (var i=0, l=arguments.length; i<l; i++) { + if ($.isArray(arguments[i])) { + datas.push(arguments[i]); + } + else if ($.isPlainObject(arguments[i])) { + options.push(arguments[i]); + } + } + + return this.each(function(index) { + var tid, + plot, + $this = $(this), + dl = datas.length, + ol = options.length, + data, + opts; + + if (index < dl) { + data = datas[index]; + } + else { + data = dl ? datas[dl-1] : null; + } + + if (index < ol) { + opts = options[index]; + } + else { + opts = ol ? options[ol-1] : null; + } + + // does el have an id? + // if not assign it one. + tid = $this.attr('id'); + if (tid === undefined) { + tid = 'jqplot_target_' + $.jqplot.targetCounter++; + $this.attr('id', tid); + } + + plot = $.jqplot(tid, data, opts); + + $this.data('jqplot', plot); + }); + }; + /** - * Class: $.jqplot + * Namespace: $.jqplot * jQuery function called by the user to create a plot. * * Parameters: @@ -165,23 +192,27 @@ */ $.jqplot = function(target, data, options) { - var _data, _options; - - if (options == null) { - if (jQuery.isArray(data)) { + var _data = null, _options = null; + + if (arguments.length === 3) { + _data = data; + _options = options; + } + + else if (arguments.length === 2) { + if ($.isArray(data)) { _data = data; - _options = null; } - - else if (typeof(data) === 'object') { - _data = null; + + else if ($.isPlainObject(data)) { _options = data; } } - else { - _data = data; - _options = options; + + if (_data === null && _options !== null && _options.data) { + _data = _options.data; } + var plot = new jqPlot(); // remove any error class that may be stuck on target. $('#'+target).removeClass('jqplot-error'); @@ -213,6 +244,11 @@ } }; + $.jqplot.version = "@VERSION"; + $.jqplot.revision = "@REVISION"; + + $.jqplot.targetCounter = 1; + // canvas manager to reuse canvases on the plot. // Should help solve problem of canvases not being freed and // problem of waiting forever for firefox to decide to free memory. @@ -270,7 +306,7 @@ }; this.freeCanvas = function(idx) { - if ($.jqplot.use_excanvas) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { // excanvas can't be reused, but properly unset window.G_vmlCanvasManager.uninitElement($.jqplot.CanvasManager.canvases[idx]); $.jqplot.CanvasManager.canvases[idx] = null; @@ -295,11 +331,12 @@ // Convienence function that won't hang IE or FF without FireBug. $.jqplot.log = function() { if (window.console) { - console.log.apply(console, arguments); + window.console.log.apply(window.console, arguments); } }; $.jqplot.config = { + addDomReference: false, enablePlugins:false, defaultHeight:300, defaultWidth:400, @@ -315,7 +352,12 @@ catchErrors: false, defaultTickFormatString: "%.1f", defaultColors: [ "#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"], - defaultNegativeColors: [ "#498991", "#C08840", "#9F9274", "#546D61", "#646C4A", "#6F6621", "#6E3F5F", "#4F64B0", "#A89050", "#C45923", "#187399", "#945381", "#959E5C", "#C7AF7B", "#478396", "#907294"] + defaultNegativeColors: [ "#498991", "#C08840", "#9F9274", "#546D61", "#646C4A", "#6F6621", "#6E3F5F", "#4F64B0", "#A89050", "#C45923", "#187399", "#945381", "#959E5C", "#C7AF7B", "#478396", "#907294"], + dashLength: 4, + gapLength: 4, + dotGapLength: 2.5, + srcLocation: 'jqplot/src/', + pluginLocation: 'jqplot/src/plugins/' }; @@ -342,12 +384,18 @@ $.jqplot.support_canvas_text = function() { if (typeof $.jqplot.support_canvas_text.result == 'undefined') { - $.jqplot.support_canvas_text.result = !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function'); + if (window.G_vmlCanvasManager !== undefined && window.G_vmlCanvasManager._version > 887) { + $.jqplot.support_canvas_text.result = true; + } + else { + $.jqplot.support_canvas_text.result = !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function'); + } + } return $.jqplot.support_canvas_text.result; }; - $.jqplot.use_excanvas = ($.browser.msie && !$.jqplot.support_canvas()) ? true : false; + $.jqplot.use_excanvas = ((!$.support.boxModel || !$.support.objectAll || !$support.leadingWhitespace) && !$.jqplot.support_canvas()) ? true : false; /** * @@ -509,16 +557,13 @@ this.showLabel = true; // prop: min // minimum value of the axis (in data units, not pixels). - this.min=null; + this.min = null; // prop: max // maximum value of the axis (in data units, not pixels). - this.max=null; + this.max = null; // prop: autoscale - // Autoscale the axis min and max values to provide sensible tick spacing. - // If axis min or max are set, autoscale will be turned off. - // The numberTicks, tickInterval and pad options do work with - // autoscale, although tickInterval has not been tested yet. - // padMin and padMax do nothing when autoscale is on. + // DEPRECATED + // the default scaling algorithm produces superior results. this.autoscale = false; // prop: pad // Padding to extend the range above and below the data bounds. @@ -562,8 +607,19 @@ this.showTickMarks = true; // prop: showMinorTicks // Wether or not to show minor ticks. This is renderer dependent. - // The default <$.jqplot.LinearAxisRenderer> does not have minor ticks. this.showMinorTicks = true; + // prop: drawMajorGridlines + // True to draw gridlines for major axis ticks. + this.drawMajorGridlines = true; + // prop: drawMinorGridlines + // True to draw gridlines for minor ticks. + this.drawMinorGridlines = false; + // prop: drawMajorTickMarks + // True to draw tick marks for major axis ticks. + this.drawMajorTickMarks = true; + // prop: drawMinorTickMarks + // True to draw tick marks for minor ticks. This is renderer dependent. + this.drawMinorTickMarks = true; // prop: useSeriesColor // Use the color of the first series associated with this axis for the // tick marks and line bordering this axis. @@ -575,6 +631,9 @@ // prop: borderColor // color of the border adjacent to the axis. Defaults to grid border color. this.borderColor = null; + // prop: scaleToHiddenSeries + // True to include hidden series when computing axes bounds and scaling. + this.scaleToHiddenSeries = false; // minimum and maximum values on the axis. this._dataBounds = {min:null, max:null}; // statistics (min, max, mean) as well as actual data intervals for each series attached to axis. @@ -609,7 +668,9 @@ Axis.prototype.constructor = Axis; Axis.prototype.init = function() { - this.renderer = new this.renderer(); + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } // set the axis name this.tickOptions.axis = this.name; // if showMark or showLabel tick options not specified, use value of axis option. @@ -712,62 +773,69 @@ var db = this._dataBounds; db.min = null; db.max = null; + var l, s, d; // check for when to force min 0 on bar series plots. var doforce = (this.show) ? true : false; for (var i=0; i<this._series.length; i++) { - var s = this._series[i]; - var d = s._plotData; - var minyidx = 1, maxyidx = 1; + s = this._series[i]; + if (s.show || this.scaleToHiddenSeries) { + d = s._plotData; + if (s._type === 'line' && s.renderer.bands.show && this.name.charAt(0) !== 'x') { + d = [[0, s.renderer.bands._min], [1, s.renderer.bands._max]]; + } - if (s._type != null && s._type == 'ohlc') { - minyidx = 3; - maxyidx = 2; - } - - for (var j=0; j<d.length; j++) { - if (this.name == 'xaxis' || this.name == 'x2axis') { - if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) { - db.min = d[j][0]; - } - if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) { - db.max = d[j][0]; - } - } - else { - if ((d[j][minyidx] != null && d[j][minyidx] < db.min) || db.min == null) { - db.min = d[j][minyidx]; - } - if ((d[j][maxyidx] != null && d[j][maxyidx] > db.max) || db.max == null) { - db.max = d[j][maxyidx]; - } - } - } + var minyidx = 1, maxyidx = 1; - // Hack to not pad out bottom of bar plots unless user has specified a padding. - // every series will have a chance to set doforce to false. once it is set to - // false, it cannot be reset to true. - // If any series attached to axis is not a bar, wont force 0. - if (doforce && s.renderer.constructor !== $.jqplot.BarRenderer) { - doforce = false; - } + if (s._type != null && s._type == 'ohlc') { + minyidx = 3; + maxyidx = 2; + } + + for (var j=0, l=d.length; j<l; j++) { + if (this.name == 'xaxis' || this.name == 'x2axis') { + if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) { + db.min = d[j][0]; + } + if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) { + db.max = d[j][0]; + } + } + else { + if ((d[j][minyidx] != null && d[j][minyidx] < db.min) || db.min == null) { + db.min = d[j][minyidx]; + } + if ((d[j][maxyidx] != null && d[j][maxyidx] > db.max) || db.max == null) { + db.max = d[j][maxyidx]; + } + } + } - else if (doforce && this._options.hasOwnProperty('forceTickAt0') && this._options.forceTickAt0 == false) { - doforce = false; - } + // Hack to not pad out bottom of bar plots unless user has specified a padding. + // every series will have a chance to set doforce to false. once it is set to + // false, it cannot be reset to true. + // If any series attached to axis is not a bar, wont force 0. + if (doforce && s.renderer.constructor !== $.jqplot.BarRenderer) { + doforce = false; + } - else if (doforce && s.renderer.constructor === $.jqplot.BarRenderer) { - if (s.barDirection == 'vertical' && this.name != 'xaxis' && this.name != 'x2axis') { - if (this._options.pad != null || this._options.padMin != null) { - doforce = false; - } + else if (doforce && this._options.hasOwnProperty('forceTickAt0') && this._options.forceTickAt0 == false) { + doforce = false; } - else if (s.barDirection == 'horizontal' && (this.name == 'xaxis' || this.name == 'x2axis')) { - if (this._options.pad != null || this._options.padMin != null) { - doforce = false; + else if (doforce && s.renderer.constructor === $.jqplot.BarRenderer) { + if (s.barDirection == 'vertical' && this.name != 'xaxis' && this.name != 'x2axis') { + if (this._options.pad != null || this._options.padMin != null) { + doforce = false; + } + } + + else if (s.barDirection == 'horizontal' && (this.name == 'xaxis' || this.name == 'x2axis')) { + if (this._options.pad != null || this._options.padMin != null) { + doforce = false; + } } - } + } } } @@ -868,7 +936,9 @@ // CSS style for the margin which will override any style sheet setting. // The default will be taken from the stylesheet. this.marginLeft = null; - + // prop: escapeHtml + // True to escape special characters with their html entity equivalents + // in legend text. "<" becomes < and so on, so html tags are not rendered. this.escapeHtml = false; this._series = []; @@ -987,15 +1057,17 @@ }; Legend.prototype.init = function() { - this.renderer = new this.renderer(); + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } this.renderer.init.call(this, this.rendererOptions); }; - Legend.prototype.draw = function(offsets) { + Legend.prototype.draw = function(offsets, plot) { for (var i=0; i<$.jqplot.preDrawLegendHooks.length; i++){ $.jqplot.preDrawLegendHooks[i].call(this, offsets); } - return this.renderer.draw.call(this, offsets); + return this.renderer.draw.call(this, offsets, plot); }; Legend.prototype.pack = function(offsets) { @@ -1040,13 +1112,19 @@ // prop: rendererOptions // renderer specific options passed to the renderer. this.rendererOptions = {}; + // prop: escapeHtml + // True to escape special characters with their html entity equivalents + // in title text. "<" becomes < and so on, so html tags are not rendered. + this.escapeHtml = false; } Title.prototype = new $.jqplot.ElemContainer(); Title.prototype.constructor = Title; Title.prototype.init = function() { - this.renderer = new this.renderer(); + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } this.renderer.init.call(this, this.rendererOptions); }; @@ -1065,7 +1143,8 @@ * by the Plot oject. Series properties can be set or overriden by the * options passed in from the user. */ - function Series() { + function Series(options) { + options = options || {}; $.jqplot.ElemContainer.call(this); // Group: Properties // Properties will be assigned from a series array at the top level of the @@ -1078,7 +1157,7 @@ // > {yaxis: 'y2axis', shadow: false, label:'bad line'} // > ] // > } - + // prop: show // wether or not to draw the series. this.show = true; @@ -1109,6 +1188,10 @@ // prop: color // css color spec for the series this.color; + // prop: negativeColor + // css color spec used for filled (area) plots that are filled to zero and + // the "useNegativeColors" option is true. + this.negativeColor; // prop: lineWidth // width of the line in pixels. May have different meanings depending on renderer. this.lineWidth = 2.5; @@ -1118,8 +1201,12 @@ // prop: lineCap // Canvas lineCap style at ends of line. this.lineCap = 'round'; - // prop: shadow - // wether or not to draw a shadow on the line + // prop: linePattern + // line pattern 'dashed', 'dotted', 'solid', some combination + // of '-' and '.' characters such as '.-.' or a numerical array like + // [draw, skip, draw, skip, ...] such as [1, 10] to draw a dotted line, + // [1, 10, 20, 10] to draw a dot-dash line, and so on. + this.linePattern = 'solid'; this.shadow = true; // prop: shadowAngle // Shadow angle in degrees @@ -1230,8 +1317,8 @@ this.index = index; this.gridBorderWidth = gridbw; var d = this.data; - var temp = [], i; - for (i=0; i<d.length; i++) { + var temp = [], i, l; + for (i=0, l=d.length; i<l; i++) { if (! this.breakOnNull) { if (d[i] == null || d[i][0] == null || d[i][1] == null) { continue; @@ -1250,6 +1337,18 @@ } } this.data = temp; + + // parse the renderer options and apply default colors if not provided + // Set color even if not shown, so series don't change colors when other + // series on plot shown/hidden. + if (!this.color) { + this.color = plot.colorGenerator.get(this.index); + } + if (!this.negativeColor) { + this.negativeColor = plot.negativeColorGenerator.get(this.index); + } + + if (!this.fillColor) { this.fillColor = this.color; } @@ -1258,7 +1357,9 @@ var comp = $.jqplot.getColorComponents(comp); this.fillColor = 'rgba('+comp[0]+','+comp[1]+','+comp[2]+','+this.fillAlpha+')'; } - this.renderer = new this.renderer(); + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } this.renderer.init.call(this, this.rendererOptions, plot); this.markerRenderer = new this.markerRenderer(); if (!this.markerOptions.color) { @@ -1302,11 +1403,16 @@ data = this._plotData; } gridData = options.gridData || this.renderer.makeGridData.call(this, data, plot); + + if (this._type === 'line' && this.renderer.smooth && this.renderer._smoothedData.length) { + gridData = this.renderer._smoothedData; + } + this.renderer.draw.call(this, sctx, gridData, options, plot); } for (j=0; j<$.jqplot.postDrawSeriesHooks.length; j++) { - $.jqplot.postDrawSeriesHooks[j].call(this, sctx, options); + $.jqplot.postDrawSeriesHooks[j].call(this, sctx, options, plot); } sctx = opts = plot = j = data = gridData = null; @@ -1338,7 +1444,7 @@ } gridData = options.gridData || this.renderer.makeGridData.call(this, data, plot); - this.renderer.drawShadow.call(this, sctx, gridData, options); + this.renderer.drawShadow.call(this, sctx, gridData, options, plot); } for (j=0; j<$.jqplot.postDrawSeriesShadowHooks.length; j++) { @@ -1350,7 +1456,7 @@ }; // toggles series display on plot, e.g. show/hide series - Series.prototype.toggleDisplay = function(ev) { + Series.prototype.toggleDisplay = function(ev, callback) { var s, speed; if (ev.data.series) { s = ev.data.series; @@ -1358,38 +1464,53 @@ else { s = this; } + if (ev.data.speed) { speed = ev.data.speed; } if (speed) { - if (s.canvas._elem.is(':hidden')) { + // this can be tricky because series may not have a canvas element if replotting. + if (s.canvas._elem.is(':hidden') || !s.show) { + s.show = true; + + s.canvas._elem.removeClass('jqplot-series-hidden'); if (s.shadowCanvas._elem) { s.shadowCanvas._elem.fadeIn(speed); } - s.canvas._elem.fadeIn(speed); + s.canvas._elem.fadeIn(speed, callback); s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).fadeIn(speed); } else { + s.show = false; + + s.canvas._elem.addClass('jqplot-series-hidden'); if (s.shadowCanvas._elem) { s.shadowCanvas._elem.fadeOut(speed); } - s.canvas._elem.fadeOut(speed); + s.canvas._elem.fadeOut(speed, callback); s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).fadeOut(speed); } } else { - if (s.canvas._elem.is(':hidden')) { + // this can be tricky because series may not have a canvas element if replotting. + if (s.canvas._elem.is(':hidden') || !s.show) { + s.show = true; + + s.canvas._elem.removeClass('jqplot-series-hidden'); if (s.shadowCanvas._elem) { s.shadowCanvas._elem.show(); } - s.canvas._elem.show(); + s.canvas._elem.show(0, callback); s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).show(); } else { + s.show = false; + + s.canvas._elem.addClass('jqplot-series-hidden'); if (s.shadowCanvas._elem) { s.shadowCanvas._elem.hide(); } - s.canvas._elem.hide(); + s.canvas._elem.hide(0, callback); s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).hide(); } } @@ -1474,7 +1595,9 @@ Grid.prototype.constructor = Grid; Grid.prototype.init = function() { - this.renderer = new this.renderer(); + if ($.isFunction(this.renderer)) { + this.renderer = new this.renderer(); + } this.renderer.init.call(this, this.rendererOptions); }; @@ -1503,23 +1626,6 @@ } var elem; - // if (this._elem) { - // // Memory Leaks patch - // if ($.jqplot.use_excanvas) { - // window.G_vmlCanvasManager.uninitElement(this._elem.get(0)); - // } - // } - // else { - // // don't use the canvas manager with excanvas. - // if ($.jqplot.use_excanvas) { - // elem = document.createElement('canvas'); - // } - // else { - // elem = plot.canvasManager.getCanvas(); - // } - - // } - elem = plot.canvasManager.getCanvas(); // if new plotDimensions supplied, use them. @@ -1548,7 +1654,7 @@ // Memory Leaks patch $.jqplot.GenericCanvas.prototype.resetCanvas = function() { if (this._elem) { - if ($.jqplot.use_excanvas) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { window.G_vmlCanvasManager.uninitElement(this._elem.get(0)); } @@ -1561,22 +1667,27 @@ $.jqplot.HooksManager = function () { this.hooks =[]; + this.args = []; }; - $.jqplot.HooksManager.prototype.addOnce = function(fn) { - var havehook = false, i; - for (i=0; i<this.hooks.length; i++) { - if (this.hooks[i][0] == fn) { + $.jqplot.HooksManager.prototype.addOnce = function(fn, args) { + args = args || []; + var havehook = false; + for (var i=0, l=this.hooks.length; i<l; i++) { + if (this.hooks[i] == fn) { havehook = true; } } if (!havehook) { this.hooks.push(fn); + this.args.push(args); } }; - $.jqplot.HooksManager.prototype.add = function(fn) { + $.jqplot.HooksManager.prototype.add = function(fn, args) { + args = args || []; this.hooks.push(fn); + this.args.push(args); }; $.jqplot.EventListenerManager = function () { @@ -1585,7 +1696,7 @@ $.jqplot.EventListenerManager.prototype.addOnce = function(ev, fn) { var havehook = false, h, i; - for (i=0; i<this.hooks.length; i++) { + for (var i=0, l=this.hooks.length; i<l; i++) { h = this.hooks[i]; if (h[0] == ev && h[1] == fn) { havehook = true; @@ -1600,6 +1711,9 @@ this.hooks.push([ev, fn]); }; + + var _axisNames = ['yMidAxis', 'xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis']; + /** * Class: jqPlot * Plot object returned by call to $.jqplot. Handles parsing user options, @@ -1615,6 +1729,25 @@ // > title: 'A Plot' // > } // + + // prop: animate + // True to animate the series on initial plot draw (renderer dependent). + // Actual animation functionality must be supported in the renderer. + this.animate = false; + // prop: animateReplot + // True to animate series after a call to the replot() method. + // Use with caution! Replots can happen very frequently under + // certain circumstances (e.g. resizing, dragging points) and + // animation in these situations can cause problems. + this.animateReplot = false; + // prop: axes + // up to 4 axes are supported, each with it's own options, + // See <Axis> for axis specific options. + this.axes = {xaxis: new Axis('xaxis'), yaxis: new Axis('yaxis'), x2axis: new Axis('x2axis'), y2axis: new Axis('y2axis'), y3axis: new Axis('y3axis'), y4axis: new Axis('y4axis'), y5axis: new Axis('y5axis'), y6axis: new Axis('y6axis'), y7axis: new Axis('y7axis'), y8axis: new Axis('y8axis'), y9axis: new Axis('y9axis'), yMidAxis: new Axis('yMidAxis')}; + this.baseCanvas = new $.jqplot.GenericCanvas(); + // true to intercept right click events and fire a 'jqplotRightClick' event. + // this will also block the context menu. + this.captureRightClick = false; // prop: data // user's data. Data should *NOT* be specified in the options object, // but be passed in as the second argument to the $.jqplot() function. @@ -1622,16 +1755,72 @@ // The data should be in the form of an array of 2D or 1D arrays like // > [ [[x1, y1], [x2, y2],...], [y1, y2, ...] ]. this.data = []; - // prop dataRenderer + // prop: dataRenderer // A callable which can be used to preprocess data passed into the plot. // Will be called with 2 arguments, the plot data and a reference to the plot. this.dataRenderer; - // prop dataRendererOptions + // prop: dataRendererOptions // Options that will be passed to the dataRenderer. // Can be of any type. this.dataRendererOptions; - // prop noDataIndicator + this.defaults = { + // prop: axesDefaults + // default options that will be applied to all axes. + // see <Axis> for axes options. + axesDefaults: {}, + axes: {xaxis:{}, yaxis:{}, x2axis:{}, y2axis:{}, y3axis:{}, y4axis:{}, y5axis:{}, y6axis:{}, y7axis:{}, y8axis:{}, y9axis:{}, yMidAxis:{}}, + // prop: seriesDefaults + // default options that will be applied to all series. + // see <Series> for series options. + seriesDefaults: {}, + series:[] + }; + // prop: defaultAxisStart + // 1-D data series are internally converted into 2-D [x,y] data point arrays + // by jqPlot. This is the default starting value for the missing x or y value. + // The added data will be a monotonically increasing series (e.g. [1, 2, 3, ...]) + // starting at this value. + this.defaultAxisStart = 1; + // this.doCustomEventBinding = true; + // prop: drawIfHidden + // True to execute the draw method even if the plot target is hidden. + // Generally, this should be false. Most plot elements will not be sized/ + // positioned correclty if renderered into a hidden container. To render into + // a hidden container, call the replot method when the container is shown. + this.drawIfHidden = false; + this.eventCanvas = new $.jqplot.GenericCanvas(); + // prop: fillBetween + // Fill between 2 line series in a plot. + // Options object: + // { + // series1: first index (0 based) of series in fill + // series2: second index (0 based) of series in fill + // color: color of fill [default fillColor of series1] + // baseSeries: fill will be drawn below this series (0 based index) + // fill: false to turn off fill [default true]. + // } + this.fillBetween = { + series1: null, + series2: null, + color: null, + baseSeries: 0, + fill: true + }; + // prop; fontFamily + // css spec for the font-family attribute. Default for the entire plot. + this.fontFamily; + // prop: fontSize + // css spec for the font-size attribute. Default for the entire plot. + this.fontSize; + // prop: grid + // See <Grid> for grid specific options. + this.grid = new Grid(); + // prop: legend + // see <$.jqplot.TableLegendRenderer> + this.legend = new Legend(); + // prop: noDataIndicator // Options to set up a mock plot with a data loading indicator if no data is specified. + this.negativeSeriesColors = $.jqplot.config.defaultNegativeColors; this.noDataIndicator = { show: false, indicator: 'Loading Data...', @@ -1650,100 +1839,50 @@ } } }; - // The id of the dom element to render the plot into - this.targetId = null; - // the jquery object for the dom target. - this.target = null; - this.defaults = { - // prop: axesDefaults - // default options that will be applied to all axes. - // see <Axis> for axes options. - axesDefaults: {}, - axes: {xaxis:{}, yaxis:{}, x2axis:{}, y2axis:{}, y3axis:{}, y4axis:{}, y5axis:{}, y6axis:{}, y7axis:{}, y8axis:{}, y9axis:{}}, - // prop: seriesDefaults - // default options that will be applied to all series. - // see <Series> for series options. - seriesDefaults: {}, - series:[] - }; + // container to hold all of the merged options. Convienence for plugins. + this.options = {}; + this.previousSeriesStack = []; + // Namespece to hold plugins. Generally non-renderer plugins add themselves to here. + this.plugins = {}; // prop: series // Array of series object options. // see <Series> for series specific options. this.series = []; - // prop: axes - // up to 4 axes are supported, each with it's own options, - // See <Axis> for axis specific options. - this.axes = {xaxis: new Axis('xaxis'), yaxis: new Axis('yaxis'), x2axis: new Axis('x2axis'), y2axis: new Axis('y2axis'), y3axis: new Axis('y3axis'), y4axis: new Axis('y4axis'), y5axis: new Axis('y5axis'), y6axis: new Axis('y6axis'), y7axis: new Axis('y7axis'), y8axis: new Axis('y8axis'), y9axis: new Axis('y9axis')}; - // prop: grid - // See <Grid> for grid specific options. - this.grid = new Grid(); - // prop: legend - // see <$.jqplot.TableLegendRenderer> - this.legend = new Legend(); - this.baseCanvas = new $.jqplot.GenericCanvas(); // array of series indicies. Keep track of order // which series canvases are displayed, lowest // to highest, back to front. this.seriesStack = []; - this.previousSeriesStack = []; - this.eventCanvas = new $.jqplot.GenericCanvas(); - this._width = null; - this._height = null; - this._plotDimensions = {height:null, width:null}; - this._gridPadding = {top:null, right:null, bottom:null, left:null}; - this._defaultGridPadding = {top:10, right:10, bottom:23, left:10}; - // a shortcut for axis syncTicks options. Not implemented yet. - this.syncXTicks = true; - // a shortcut for axis syncTicks options. Not implemented yet. - this.syncYTicks = true; // prop: seriesColors // Ann array of CSS color specifications that will be applied, in order, // to the series in the plot. Colors will wrap around so, if their // are more series than colors, colors will be reused starting at the // beginning. For pie charts, this specifies the colors of the slices. this.seriesColors = $.jqplot.config.defaultColors; - this.negativeSeriesColors = $.jqplot.config.defaultNegativeColors; // prop: sortData // false to not sort the data passed in by the user. // Many bar, stakced and other graphs as well as many plugins depend on // having sorted data. this.sortData = true; - var seriesColorsIndex = 0; + // prop: stackSeries + // true or false, creates a stack or "mountain" plot. + // Not all series renderers may implement this option. + this.stackSeries = false; + // a shortcut for axis syncTicks options. Not implemented yet. + this.syncXTicks = true; + // a shortcut for axis syncTicks options. Not implemented yet. + this.syncYTicks = true; + // the jquery object for the dom target. + this.target = null; + // The id of the dom element to render the plot into + this.targetId = null; // prop textColor // css spec for the css color attribute. Default for the entire plot. this.textColor; - // prop; fontFamily - // css spec for the font-family attribute. Default for the entire plot. - this.fontFamily; - // prop: fontSize - // css spec for the font-size attribute. Default for the entire plot. - this.fontSize; // prop: title // Title object. See <Title> for specific options. As a shortcut, you // can specify the title option as just a string like: title: 'My Plot' // and this will create a new title object with the specified text. this.title = new Title(); - // container to hold all of the merged options. Convienence for plugins. - this.options = {}; - // prop: stackSeries - // true or false, creates a stack or "mountain" plot. - // Not all series renderers may implement this option. - this.stackSeries = false; - // prop: defaultAxisStart - // 1-D data series are internally converted into 2-D [x,y] data point arrays - // by jqPlot. This is the default starting value for the missing x or y value. - // The added data will be a monotonically increasing series (e.g. [1, 2, 3, ...]) - // starting at this value. - this.defaultAxisStart = 1; - // array to hold the cumulative stacked series data. - // used to ajust the individual series data, which won't have access to other - // series data. - this._stackData = []; - // array that holds the data to be plotted. This will be the series data - // merged with the the appropriate data from _stackData according to the stackAxis. - this._plotData = []; - // Namespece to hold plugins. Generally non-renderer plugins add themselves to here. - this.plugins = {}; // Count how many times the draw method has been called while the plot is visible. // Mostly used to test if plot has never been dran (=0), has been successfully drawn // into a visible container once (=1) or draw more than once into a visible container. @@ -1751,21 +1890,25 @@ // After plot has been visibly drawn once, it generally doesn't need redrawn if its // container is hidden and shown. this._drawCount = 0; - // this.doCustomEventBinding = true; - // prop: drawIfHidden - // True to execute the draw method even if the plot target is hidden. - // Generally, this should be false. Most plot elements will not be sized/ - // positioned correclty if renderered into a hidden container. To render into - // a hidden container, call the replot method when the container is shown. - this.drawIfHidden = false; - // true to intercept right click events and fire a 'jqplotRightClick' event. - // this will also block the context menu. - this.captureRightClick = false; - this.themeEngine = new $.jqplot.ThemeEngine(); // sum of y values for all series in plot. // used in mekko chart. this._sumy = 0; this._sumx = 0; + // array to hold the cumulative stacked series data. + // used to ajust the individual series data, which won't have access to other + // series data. + this._stackData = []; + // array that holds the data to be plotted. This will be the series data + // merged with the the appropriate data from _stackData according to the stackAxis. + this._plotData = []; + this._width = null; + this._height = null; + this._plotDimensions = {height:null, width:null}; + this._gridPadding = {top:null, right:null, bottom:null, left:null}; + this._defaultGridPadding = {top:10, right:10, bottom:23, left:10}; + + this._addDomReference = $.jqplot.config.addDomReference; + this.preInitHooks = new $.jqplot.HooksManager(); this.postInitHooks = new $.jqplot.HooksManager(); this.preParseOptionsHooks = new $.jqplot.HooksManager(); @@ -1784,10 +1927,15 @@ this.preDrawSeriesShadowHooks = new $.jqplot.HooksManager(); this.postDrawSeriesShadowHooks = new $.jqplot.HooksManager(); - this.colorGenerator = $.jqplot.ColorGenerator; + this.colorGenerator = new $.jqplot.ColorGenerator(); + this.negativeColorGenerator = new $.jqplot.ColorGenerator(); this.canvasManager = new $.jqplot.CanvasManager(); + + this.themeEngine = new $.jqplot.ThemeEngine(); + var seriesColorsIndex = 0; + // Group: methods // // method: init @@ -1805,6 +1953,13 @@ this.targetId = '#'+target; this.target = $('#'+target); + + ////// + // Add a reference to plot + ////// + if (this._addDomReference) { + this.target.data('jqplot', this); + } // remove any error class that may be stuck on target. this.target.removeClass('jqplot-error'); if (!this.target.get(0)) { @@ -1854,6 +2009,10 @@ else { this._width = w = this.target.width(); } + + for (var i=0, l=_axisNames.length; i<l; i++) { + this.axes[_axisNames[i]] = new Axis(_axisNames[i]); + } this._plotDimensions.height = this._height; this._plotDimensions.width = this._width; @@ -1866,7 +2025,7 @@ throw "Canvas dimension not set"; } - if (options.dataRenderer && jQuery.isFunction(options.dataRenderer)) { + if (options.dataRenderer && $.isFunction(options.dataRenderer)) { if (options.dataRendererOptions) { this.dataRendererOptions = options.dataRendererOptions; } @@ -1874,17 +2033,14 @@ data = this.dataRenderer(data, this, this.dataRendererOptions); } - if (options.noDataIndicator && jQuery.isPlainObject(options.noDataIndicator)) { + if (options.noDataIndicator && $.isPlainObject(options.noDataIndicator)) { $.extend(true, this.noDataIndicator, options.noDataIndicator); } - if (data == null || jQuery.isArray(data) == false || data.length == 0 || jQuery.isArray(data[0]) == false || data[0].length == 0) { + if (data == null || $.isArray(data) == false || data.length == 0 || $.isArray(data[0]) == false || data[0].length == 0) { if (this.noDataIndicator.show == false) { - throw{ - name: "DataError", - message: "No data to plot." - }; + throw "No Data"; } else { @@ -1921,7 +2077,8 @@ } } - this.data = data; + // make a copy of the data + this.data = $.extend(true, [], data); this.parseOptions(options); @@ -1939,6 +2096,7 @@ this.legend.init(); this._sumy = 0; this._sumx = 0; + this.computePlotData(); for (var i=0; i<this.series.length; i++) { // set default stacking order for series canvases this.seriesStack.push(i); @@ -1946,27 +2104,39 @@ this.series[i].shadowCanvas._plotDimensions = this._plotDimensions; this.series[i].canvas._plotDimensions = this._plotDimensions; for (var j=0; j<$.jqplot.preSeriesInitHooks.length; j++) { - $.jqplot.preSeriesInitHooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this); + $.jqplot.preSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); } for (var j=0; j<this.preSeriesInitHooks.hooks.length; j++) { - this.preSeriesInitHooks.hooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this); + this.preSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); } - this.populatePlotData(this.series[i], i); + // this.populatePlotData(this.series[i], i); this.series[i]._plotDimensions = this._plotDimensions; this.series[i].init(i, this.grid.borderWidth, this); for (var j=0; j<$.jqplot.postSeriesInitHooks.length; j++) { - $.jqplot.postSeriesInitHooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this); + $.jqplot.postSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); } for (var j=0; j<this.postSeriesInitHooks.hooks.length; j++) { - this.postSeriesInitHooks.hooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this); + this.postSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); } this._sumy += this.series[i]._sumy; this._sumx += this.series[i]._sumx; } - for (var name in this.axes) { - this.axes[name]._plotDimensions = this._plotDimensions; - this.axes[name].init(); + var name, + axis; + for (var i=0, l=_axisNames.length; i<l; i++) { + name = _axisNames[i]; + axis = this.axes[name]; + axis._plotDimensions = this._plotDimensions; + axis.init(); + if (this.axes[name].borderColor == null) { + if (name.charAt(0) !== 'x' && axis.useSeriesColor === true && axis.show) { + axis.borderColor = axis._series[0].color; + } + else { + axis.borderColor = this.grid.borderColor; + } + } } if (this.sortData) { @@ -1978,11 +2148,11 @@ this.legend._series = this.series; for (var i=0; i<$.jqplot.postInitHooks.length; i++) { - $.jqplot.postInitHooks[i].call(this, target, data, options); + $.jqplot.postInitHooks[i].call(this, target, this.data, options); } for (var i=0; i<this.postInitHooks.hooks.length; i++) { - this.postInitHooks.hooks[i].call(this, target, data, options); + this.postInitHooks.hooks[i].call(this, target, this.data, options); } }; @@ -1998,7 +2168,7 @@ if (ax === true) { ax = this.axes; } - if (jQuery.isArray(ax)) { + if ($.isArray(ax)) { for (var i = 0; i < ax.length; i++) { this.axes[ax[i]].resetScale(opts[ax[i]]); } @@ -2012,50 +2182,180 @@ // method: reInitialize // reinitialize plot for replotting. // not called directly. - this.reInitialize = function () { + this.reInitialize = function (data, opts) { // Plot should be visible and have a height and width. // If plot doesn't have height and width for some // reason, set it by other means. Plot must not have // a display:none attribute, however. + + var options = $.extend(true, {}, this.options, opts); + + var target = this.targetId.substr(1); + var tdata = (data == null) ? this.data : data; + + for (var i=0; i<$.jqplot.preInitHooks.length; i++) { + $.jqplot.preInitHooks[i].call(this, target, tdata, options); + } + + for (var i=0; i<this.preInitHooks.hooks.length; i++) { + this.preInitHooks.hooks[i].call(this, target, tdata, options); + } - // - // Wont have options here - /* - if (!this.target.height()) { - var h; - if (options && options.height) { - h = parseInt(options.height, 10); - } - else if (this.target.attr('data-height')) { - h = parseInt(this.target.attr('data-height'), 10); + this._height = this.target.height(); + this._width = this.target.width(); + + if (this._height <=0 || this._width <=0 || !this._height || !this._width) { + throw "Target dimension not set"; + } + + this._plotDimensions.height = this._height; + this._plotDimensions.width = this._width; + this.grid._plotDimensions = this._plotDimensions; + this.title._plotDimensions = this._plotDimensions; + this.baseCanvas._plotDimensions = this._plotDimensions; + this.eventCanvas._plotDimensions = this._plotDimensions; + this.legend._plotDimensions = this._plotDimensions; + + var name, + t, + j, + axis; + + for (var i=0, l=_axisNames.length; i<l; i++) { + name = _axisNames[i]; + axis = this.axes[name]; + + // Memory Leaks patch : clear ticks elements + t = axis._ticks; + for (var j = 0, tlen = t.length; j < tlen; j++) { + var el = t[j]._elem; + if (el) { + // if canvas renderer + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { + window.G_vmlCanvasManager.uninitElement(el.get(0)); + } + el.emptyForce(); + el = null; + t._elem = null; + } } - else { - h = parseInt($.jqplot.config.defaultHeight, 10); + t = null; + + delete axis.ticks; + delete axis._ticks; + this.axes[name] = new Axis(name); + this.axes[name]._plotWidth = this._width; + this.axes[name]._plotHeight = this._height; + } + + if (data) { + if (options.dataRenderer && $.isFunction(options.dataRenderer)) { + if (options.dataRendererOptions) { + this.dataRendererOptions = options.dataRendererOptions; + } + this.dataRenderer = options.dataRenderer; + data = this.dataRenderer(data, this, this.dataRendererOptions); } - this._height = h; - this.target.css('height', h+'px'); + + // make a copy of the data + this.data = $.extend(true, [], data); } - else { - this._height = this.target.height(); + + if (opts) { + this.parseOptions(options); } - if (!this.target.width()) { - var w; - if (options && options.width) { - w = parseInt(options.width, 10); + + this.title._plotWidth = this._width; + + if (this.textColor) { + this.target.css('color', this.textColor); + } + if (this.fontFamily) { + this.target.css('font-family', this.fontFamily); + } + if (this.fontSize) { + this.target.css('font-size', this.fontSize); + } + + this.title.init(); + this.legend.init(); + this._sumy = 0; + this._sumx = 0; + + this.seriesStack = []; + this.previousSeriesStack = []; + + this.computePlotData(); + for (var i=0, l=this.series.length; i<l; i++) { + // set default stacking order for series canvases + this.seriesStack.push(i); + this.previousSeriesStack.push(i); + this.series[i].shadowCanvas._plotDimensions = this._plotDimensions; + this.series[i].canvas._plotDimensions = this._plotDimensions; + for (var j=0; j<$.jqplot.preSeriesInitHooks.length; j++) { + $.jqplot.preSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); } - else if (this.target.attr('data-width')) { - w = parseInt(this.target.attr('data-width'), 10); + for (var j=0; j<this.preSeriesInitHooks.hooks.length; j++) { + this.preSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); } - else { - w = parseInt($.jqplot.config.defaultWidth, 10); + // this.populatePlotData(this.series[i], i); + this.series[i]._plotDimensions = this._plotDimensions; + this.series[i].init(i, this.grid.borderWidth, this); + for (var j=0; j<$.jqplot.postSeriesInitHooks.length; j++) { + $.jqplot.postSeriesInitHooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); } - this._width = w; - this.target.css('width', w+'px'); + for (var j=0; j<this.postSeriesInitHooks.hooks.length; j++) { + this.postSeriesInitHooks.hooks[j].call(this.series[i], target, this.data, this.options.seriesDefaults, this.options.series[i], this); + } + this._sumy += this.series[i]._sumy; + this._sumx += this.series[i]._sumx; } - else { - this._width = this.target.width(); + + for (var i=0, l=_axisNames.length; i<l; i++) { + name = _axisNames[i]; + axis = this.axes[name]; + + axis._plotDimensions = this._plotDimensions; + axis.init(); + if (axis.borderColor == null) { + if (name.charAt(0) !== 'x' && axis.useSeriesColor === true && axis.show) { + axis.borderColor = axis._series[0].color; + } + else { + axis.borderColor = this.grid.borderColor; + } + } } - */ + + if (this.sortData) { + sortData(this.series); + } + this.grid.init(); + this.grid._axes = this.axes; + + this.legend._series = this.series; + + for (var i=0, l=$.jqplot.postInitHooks.length; i<l; i++) { + $.jqplot.postInitHooks[i].call(this, target, this.data, options); + } + + for (var i=0, l=this.postInitHooks.hooks.length; i<l; i++) { + this.postInitHooks.hooks[i].call(this, target, this.data, options); + } + }; + + + + // method: quickInit + // + // Quick reinitialization plot for replotting. + // Does not parse options ore recreate axes and series. + // not called directly. + this.quickInit = function () { + // Plot should be visible and have a height and width. + // If plot doesn't have height and width for some + // reason, set it by other means. Plot must not have + // a display:none attribute, however. this._height = this.target.height(); this._width = this.target.width(); @@ -2091,23 +2391,30 @@ this._sumy = 0; this._sumx = 0; + this.computePlotData(); for (var i=0; i<this.series.length; i++) { - this.populatePlotData(this.series[i], i); + // this.populatePlotData(this.series[i], i); + if (this.series[i]._type === 'line' && this.series[i].renderer.bands.show) { + this.series[i].renderer.initBands.call(this.series[i], this.series[i].renderer.options, this); + } this.series[i]._plotDimensions = this._plotDimensions; this.series[i].canvas._plotDimensions = this._plotDimensions; //this.series[i].init(i, this.grid.borderWidth); this._sumy += this.series[i]._sumy; this._sumx += this.series[i]._sumx; } + + var name; - for (var name in this.axes) { + for (var j=0; j<12; j++) { + name = _axisNames[j]; // Memory Leaks patch : clear ticks elements var t = this.axes[name]._ticks; for (var i = 0; i < t.length; i++) { var el = t[i]._elem; if (el) { // if canvas renderer - if ($.jqplot.use_excanvas) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { window.G_vmlCanvasManager.uninitElement(el.get(0)); } el.emptyForce(); @@ -2119,7 +2426,7 @@ this.axes[name]._plotDimensions = this._plotDimensions; this.axes[name]._ticks = []; - this.axes[name].renderer.init.call(this.axes[name], {}); + // this.axes[name].renderer.init.call(this.axes[name], {}); } if (this.sortData) { @@ -2135,10 +2442,6 @@ function sortData(series) { var d, sd, pd, ppd, ret; for (var i=0; i<series.length; i++) { - // d = series[i].data; - // sd = series[i]._stackData; - // pd = series[i]._plotData; - // ppd = series[i]._prevPlotData; var check; var bat = [series[i].data, series[i]._stackData, series[i]._plotData, series[i]._prevPlotData]; for (var n=0; n<4; n++) { @@ -2153,9 +2456,6 @@ } if (check) { d.sort(function(a,b) { return a[1] - b[1]; }); - // sd.sort(function(a,b) { return a[1] - b[1]; }); - // pd.sort(function(a,b) { return a[1] - b[1]; }); - // ppd.sort(function(a,b) { return a[1] - b[1]; }); } } else { @@ -2167,15 +2467,87 @@ } if (check) { d.sort(function(a,b) { return a[0] - b[0]; }); - // sd.sort(function(a,b) { return a[0] - b[0]; }); - // pd.sort(function(a,b) { return a[0] - b[0]; }); - // ppd.sort(function(a,b) { return a[0] - b[0]; }); } } } } } + + this.computePlotData = function() { + this._plotData = []; + this._stackData = []; + var series, + index, + l; + + + for (index=0, l=this.series.length; index<l; index++) { + series = this.series[index]; + this._plotData.push([]); + this._stackData.push([]); + var cd = series.data; + this._plotData[index] = $.extend(true, [], cd); + this._stackData[index] = $.extend(true, [], cd); + series._plotData = this._plotData[index]; + series._stackData = this._stackData[index]; + var plotValues = {x:[], y:[]}; + + if (this.stackSeries && !series.disableStack) { + series._stack = true; + /////////////////////////// + // have to check for nulls + /////////////////////////// + var sidx = (series._stackAxis === 'x') ? 0 : 1; + + for (var k=0, cdl=cd.length; k<cdl; k++) { + var temp = cd[k][sidx]; + if (temp == null) { + temp = 0; + } + this._plotData[index][k][sidx] = temp; + this._stackData[index][k][sidx] = temp; + + if (index > 0) { + for (var j=index; j--;) { + var prevval = this._plotData[j][k][sidx]; + // only need to sum up the stack axis column of data + // and only sum if it is of same sign. + // if previous series isn't same sign, keep looking + // at earlier series untill we find one of same sign. + if (temp * prevval >= 0) { + this._plotData[index][k][sidx] += prevval; + this._stackData[index][k][sidx] += prevval; + break; + } + } + } + } + + } + else { + for (var i=0; i<series.data.length; i++) { + plotValues.x.push(series.data[i][0]); + plotValues.y.push(series.data[i][1]); + } + this._stackData.push(series.data); + this.series[index]._stackData = series.data; + this._plotData.push(series.data); + series._plotData = series.data; + series._plotValues = plotValues; + } + if (index>0) { + series._prevPlotData = this.series[index-1]._plotData; + } + series._sumy = 0; + series._sumx = 0; + for (i=series.data.length-1; i>-1; i--) { + series._sumy += series.data[i][1]; + series._sumx += series.data[i][0]; + } + } + + }; // populate the _stackData and _plotData arrays for the plot and the series. this.populatePlotData = function(series, index) { @@ -2187,21 +2559,29 @@ var plotValues = {x:[], y:[]}; if (this.stackSeries && !series.disableStack) { series._stack = true; - var sidx = series._stackAxis == 'x' ? 0 : 1; - var idx = sidx ? 0 : 1; + var sidx = (series._stackAxis === 'x') ? 0 : 1; + // var idx = sidx ? 0 : 1; // push the current data into stackData //this._stackData.push(this.series[i].data); var temp = $.extend(true, [], series.data); // create the data that will be plotted for this series var plotdata = $.extend(true, [], series.data); + var tempx, tempy, dval, stackval, comparator; // for first series, nothing to add to stackData. for (var j=0; j<index; j++) { var cd = this.series[j].data; for (var k=0; k<cd.length; k++) { - temp[k][0] += cd[k][0]; - temp[k][1] += cd[k][1]; + dval = cd[k]; + tempx = (dval[0] != null) ? dval[0] : 0; + tempy = (dval[1] != null) ? dval[1] : 0; + temp[k][0] += tempx; + temp[k][1] += tempy; + stackval = (sidx) ? tempy : tempx; // only need to sum up the stack axis column of data - plotdata[k][sidx] += cd[k][sidx]; + // and only sum if it is of same sign. + if (series.data[k][sidx] * stackval >= 0) { + plotdata[k][sidx] += stackval; + } } } for (var i=0; i<plotdata.length; i++) { @@ -2235,13 +2615,6 @@ series._sumx += series.data[i][0]; } }; - - // this.setData = function(seriesIndex, newdata) { - // // if newdata is null, assume all data is passed in as first argument - // if (newdata == null) { - - // } - // }; // function to safely return colors from the color array and wrap around at the end. this.getNextSeriesColor = (function(t) { @@ -2267,25 +2640,45 @@ $.jqplot.preParseOptionsHooks[i].call(this, options); } this.options = $.extend(true, {}, this.defaults, options); - this.stackSeries = this.options.stackSeries; - if (this.options.seriesColors) { - this.seriesColors = this.options.seriesColors; + var opts = this.options; + this.animate = opts.animate; + this.animateReplot = opts.animateReplot; + this.stackSeries = opts.stackSeries; + if ($.isPlainObject(opts.fillBetween)) { + + var temp = ['series1', 'series2', 'color', 'baseSeries', 'fill'], + tempi; + + for (var i=0, l=temp.length; i<l; i++) { + tempi = temp[i]; + if (opts.fillBetween[tempi] != null) { + this.fillBetween[tempi] = opts.fillBetween[tempi]; + } + } } - if (this.options.negativeSeriesColors) { - this.negativeSeriesColors = this.options.negativeSeriesColors; + + if (opts.seriesColors) { + this.seriesColors = opts.seriesColors; + } + if (opts.negativeSeriesColors) { + this.negativeSeriesColors = opts.negativeSeriesColors; } - if (this.options.captureRightClick) { - this.captureRightClick = this.options.captureRightClick; + if (opts.captureRightClick) { + this.captureRightClick = opts.captureRightClick; } this.defaultAxisStart = (options && options.defaultAxisStart != null) ? options.defaultAxisStart : this.defaultAxisStart; - var cg = new this.colorGenerator(this.seriesColors); + this.colorGenerator.setColors(this.seriesColors); + this.negativeColorGenerator.setColors(this.negativeSeriesColors); + // var cg = new this.colorGenerator(this.seriesColors); + // var ncg = new this.colorGenerator(this.negativeSeriesColors); // this._gridPadding = this.options.gridPadding; - $.extend(true, this._gridPadding, this.options.gridPadding); - this.sortData = (this.options.sortData != null) ? this.options.sortData : this.sortData; - for (var n in this.axes) { + $.extend(true, this._gridPadding, opts.gridPadding); + this.sortData = (opts.sortData != null) ? opts.sortData : this.sortData; + for (var i=0; i<12; i++) { + var n = _axisNames[i]; var axis = this.axes[n]; - axis._options = $.extend(true, {}, this.options.axesDefaults, this.options.axes[n]); - $.extend(true, axis, this.options.axesDefaults, this.options.axes[n]); + axis._options = $.extend(true, {}, opts.axesDefaults, opts.axes[n]); + $.extend(true, axis, opts.axesDefaults, opts.axes[n]); axis._plotWidth = this._width; axis._plotHeight = this._height; } @@ -2300,13 +2693,13 @@ // return data as an array of point arrays, // in form [[x1,y1...], [x2,y2...], ...] var temp = []; - var i; + var i, l; dir = dir || 'vertical'; - if (!jQuery.isArray(data[0])) { + if (!$.isArray(data[0])) { // we have a series of scalars. One line with just y values. // turn the scalar list of data into a data array of form: // [[1, data[0]], [2, data[1]], ...] - for (i=0; i<data.length; i++) { + for (i=0, l=data.length; i<l; i++) { if (dir == 'vertical') { temp.push([start + i, data[i]]); } @@ -2322,18 +2715,26 @@ return temp; }; + var colorIndex = 0; + this.series = []; for (var i=0; i<this.data.length; i++) { - var temp = new Series(); + var sopts = $.extend(true, {index: i}, {seriesColors:this.seriesColors, negativeSeriesColors:this.negativeSeriesColors}, this.options.seriesDefaults, this.options.series[i], {rendererOptions:{animation:{show: this.animate}}}); + // pass in options in case something needs set prior to initialization. + var temp = new Series(sopts); for (var j=0; j<$.jqplot.preParseSeriesOptionsHooks.length; j++) { $.jqplot.preParseSeriesOptionsHooks[j].call(temp, this.options.seriesDefaults, this.options.series[i]); } for (var j=0; j<this.preParseSeriesOptionsHooks.hooks.length; j++) { this.preParseSeriesOptionsHooks.hooks[j].call(temp, this.options.seriesDefaults, this.options.series[i]); } - $.extend(true, temp, {seriesColors:this.seriesColors, negativeSeriesColors:this.negativeSeriesColors}, this.options.seriesDefaults, this.options.series[i]); + // Now go back and apply the options to the series. Really should just do this during initializaiton, but don't want to + // mess up preParseSeriesOptionsHooks at this point. + $.extend(true, temp, sopts); var dir = 'vertical'; if (temp.renderer === $.jqplot.BarRenderer && temp.rendererOptions && temp.rendererOptions.barDirection == 'horizontal') { dir = 'horizontal'; + temp._stackAxis = 'x'; + temp._primaryAxis = '_yaxis'; } temp.data = normalizeData(this.data[i], dir, this.defaultAxisStart); switch (temp.xaxis) { @@ -2353,11 +2754,24 @@ temp._xaxis.show = true; temp._yaxis.show = true; } - - // parse the renderer options and apply default colors if not provided - if (!temp.color && temp.show != false) { - temp.color = cg.next(); + else { + if (temp._xaxis.scaleToHiddenSeries) { + temp._xaxis.show = true; + } + if (temp._yaxis.scaleToHiddenSeries) { + temp._yaxis.show = true; + } } + + // // parse the renderer options and apply default colors if not provided + // if (!temp.color && temp.show != false) { + // temp.color = cg.next(); + // colorIndex = cg.getIndex() - 1;; + // } + // if (!temp.negativeColor && temp.show != false) { + // temp.negativeColor = ncg.get(colorIndex); + // ncg.setIndex(colorIndex); + // } if (!temp.label) { temp.label = 'Series '+ (i+1).toString(); } @@ -2375,19 +2789,12 @@ // copy the grid and title options into this object. $.extend(true, this.grid, this.options.grid); // if axis border properties aren't set, set default. - for (var n in this.axes) { + for (var i=0, l=_axisNames.length; i<l; i++) { + var n = _axisNames[i]; var axis = this.axes[n]; if (axis.borderWidth == null) { axis.borderWidth =this.grid.borderWidth; } - if (axis.borderColor == null) { - if (n != 'xaxis' && n != 'x2axis' && axis.useSeriesColor === true && axis.show) { - axis.borderColor = axis._series[0].color; - } - else { - axis.borderColor = this.grid.borderColor; - } - } } if (typeof this.options.title == 'string') { @@ -2411,6 +2818,15 @@ // Releases all resources occupied by the plot this.destroy = function() { this.canvasManager.freeAllCanvases(); + if (this.eventCanvas && this.eventCanvas._elem) { + this.eventCanvas._elem.unbind(); + } + // Couple of posts on Stack Overflow indicate that empty() doesn't + // always cear up the dom and release memory. Sometimes setting + // innerHTML property to null is needed. Particularly on IE, may + // have to directly set it to null, bypassing $. + this.target.empty(); + this.target[0].innerHTML = ''; }; @@ -2428,39 +2844,27 @@ // optionally pass in list of axes to reset (e.g. ['xaxis', 'y2axis']) (default: false). this.replot = function(options) { var opts = options || {}; - var clear = opts.clear || true; + var data = opts.data || null; + var clear = (opts.clear === false) ? false : true; var resetAxes = opts.resetAxes || false; + delete opts.data; + delete opts.clear; + delete opts.resetAxes; + this.target.trigger('jqplotPreReplot'); if (clear) { - this.canvasManager.freeAllCanvases(); - // Memory Leaks patch - // this.target.find("table.jqplot-table-legend,table.jqplot-legend").each( function() { - // $(this).unbind(); - - // $(this).find(".jqplot-seriesToggle").each( function() { - // $(this).unbind(); - // }); - // $.gcCollect(this); - // }); - - // this.target.find(".jqplot-title").each( function() { - // $(this).unbind(); - // $.gcCollect(this); - // }); - - // $.gcClear(); - - this.eventCanvas._elem.unbind(); - this.target.unbind(); - - // Couple of posts on Stack Overflow indicate that empty() doesn't - // always cear up the dom and release memory. Sometimes setting - // innerHTML property to null is needed. Particularly on IE, may - // have to directly set it to null, bypassing jQuery. - this.target.empty(); + this.destroy(); } - this.reInitialize(); + // if have data or other options, full reinit. + // otherwise, quickinit. + if (data || !$.isEmptyObject(opts)) { + this.reInitialize(data, opts); + } + else { + this.quickInit(); + } + if (resetAxes) { this.resetAxesScale(resetAxes, opts.axes); } @@ -2483,21 +2887,23 @@ clear = (clear != null) ? clear : true; this.target.trigger('jqplotPreRedraw'); if (clear) { - // Couple of posts on Stack Overflow indicate that empty() doesn't - // always cear up the dom and release memory. Sometimes setting - // innerHTML property to null is needed. Particularly on IE, may - // have to directly set it to null, bypassing jQuery. + this.canvasManager.freeAllCanvases(); + this.eventCanvas._elem.unbind(); + // Dont think I bind any events to the target, this shouldn't be necessary. + // It will remove user's events. + // this.target.unbind(); this.target.empty(); } for (var ax in this.axes) { this.axes[ax]._ticks = []; } - for (var i=0; i<this.series.length; i++) { - this.populatePlotData(this.series[i], i); - } + this.computePlotData(); + // for (var i=0; i<this.series.length; i++) { + // this.populatePlotData(this.series[i], i); + // } this._sumy = 0; this._sumx = 0; - for (i=0; i<this.series.length; i++) { + for (var i=0, tsl = this.series.length; i<tsl; i++) { this._sumy += this.series[i]._sumy; this._sumx += this.series[i]._sumx; } @@ -2511,12 +2917,15 @@ this.draw = function(){ if (this.drawIfHidden || this.target.is(':visible')) { this.target.trigger('jqplotPreDraw'); - var i, j; - for (i=0; i<$.jqplot.preDrawHooks.length; i++) { + var i, + j, + l, + tempseries; + for (i=0, l=$.jqplot.preDrawHooks.length; i<l; i++) { $.jqplot.preDrawHooks[i].call(this); } - for (i=0; i<this.preDrawHooks.hooks.length; i++) { - this.preDrawHooks.hooks[i].call(this); + for (i=0, l=this.preDrawHooks.length; i<l; i++) { + this.preDrawHooks.hooks[i].apply(this, this.preDrawSeriesHooks.args[i]); } // create an underlying canvas to be used for special features. this.target.append(this.baseCanvas.createElement({left:0, right:0, top:0, bottom:0}, 'jqplot-base-canvas', null, this)); @@ -2525,7 +2934,8 @@ this.title.pack({top:0, left:0}); // make room for the legend between the grid and the edge. - var legendElem = this.legend.draw(); + // pass a dummy offsets object and a reference to the plot. + var legendElem = this.legend.draw({}, this); var gridPadding = {top:0, left:0, bottom:0, right:0}; @@ -2557,7 +2967,10 @@ } var ax = this.axes; - for (var name in ax) { + var name; + // draw the yMidAxis first, so xaxis of pyramid chart can adjust itself if needed. + for (i=0; i<12; i++) { + name = _axisNames[i]; this.target.append(ax[name].draw(this.baseCanvas._ctx, this)); ax[name].set(); } @@ -2586,6 +2999,21 @@ } // end of gridPadding adjustments. + + // if user passed in gridDimensions option, check against calculated gridPadding + if (this.options.gridDimensions && $.isPlainObject(this.options.gridDimensions)) { + var gdw = parseInt(this.options.gridDimensions.width, 10) || 0; + var gdh = parseInt(this.options.gridDimensions.height, 10) || 0; + var widthAdj = (this._width - gridPadding.left - gridPadding.right - gdw)/2; + var heightAdj = (this._height - gridPadding.top - gridPadding.bottom - gdh)/2; + + if (heightAdj >= 0 && widthAdj >= 0) { + gridPadding.top += heightAdj; + gridPadding.bottom += heightAdj; + gridPadding.left += widthAdj; + gridPadding.right += widthAdj; + } + } var arr = ['top', 'bottom', 'left', 'right']; for (var n in arr) { if (this._gridPadding[arr[n]] == null && gridPadding[arr[n]] > 0) { @@ -2596,36 +3024,47 @@ } } - var legendPadding = (this.legend.placement == 'outsideGrid') ? {top:this.title.getHeight(), left: 0, right: 0, bottom: 0} : this._gridPadding; - + var legendPadding = this._gridPadding; + + if (this.legend.placement === 'outsideGrid') { + legendPadding = {top:this.title.getHeight(), left: 0, right: 0, bottom: 0}; + if (this.legend.location === 's') { + legendPadding.left = this._gridPadding.left; + legendPadding.right = this._gridPadding.right; + } + } + ax.xaxis.pack({position:'absolute', bottom:this._gridPadding.bottom - ax.xaxis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right}); ax.yaxis.pack({position:'absolute', top:0, left:this._gridPadding.left - ax.yaxis.getWidth(), height:this._height}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top}); ax.x2axis.pack({position:'absolute', top:this._gridPadding.top - ax.x2axis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right}); for (i=8; i>0; i--) { ax[ra[i-1]].pack({position:'absolute', top:0, right:this._gridPadding.right - rapad[i-1]}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top}); } - // ax.y2axis.pack({position:'absolute', top:0, right:0}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top}); + var ltemp = (this._width - this._gridPadding.left - this._gridPadding.right)/2.0 + this._gridPadding.left - ax.yMidAxis.getWidth()/2.0; + ax.yMidAxis.pack({position:'absolute', top:0, left:ltemp, zIndex:9, textAlign: 'center'}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top}); this.target.append(this.grid.createElement(this._gridPadding, this)); this.grid.draw(); + var series = this.series; + var seriesLength = series.length; // put the shadow canvases behind the series canvases so shadows don't overlap on stacked bars. - for (i=0; i<this.series.length; i++) { + for (i=0, l=seriesLength; i<l; i++) { // draw series in order of stacking. This affects only // order in which canvases are added to dom. j = this.seriesStack[i]; - this.target.append(this.series[j].shadowCanvas.createElement(this._gridPadding, 'jqplot-series-shadowCanvas', null, this)); - this.series[j].shadowCanvas.setContext(); - this.series[j].shadowCanvas._elem.data('seriesIndex', j); + this.target.append(series[j].shadowCanvas.createElement(this._gridPadding, 'jqplot-series-shadowCanvas', null, this)); + series[j].shadowCanvas.setContext(); + series[j].shadowCanvas._elem.data('seriesIndex', j); } - for (i=0; i<this.series.length; i++) { + for (i=0, l=seriesLength; i<l; i++) { // draw series in order of stacking. This affects only // order in which canvases are added to dom. j = this.seriesStack[i]; - this.target.append(this.series[j].canvas.createElement(this._gridPadding, 'jqplot-series-canvas', null, this)); - this.series[j].canvas.setContext(); - this.series[j].canvas._elem.data('seriesIndex', j); + this.target.append(series[j].canvas.createElement(this._gridPadding, 'jqplot-series-canvas', null, this)); + series[j].canvas.setContext(); + series[j].canvas._elem.data('seriesIndex', j); } // Need to use filled canvas to capture events in IE. // Also, canvas seems to block selection of other elements in document on FF. @@ -2650,41 +3089,102 @@ } else { // draw series before legend this.drawSeries(); - if (this.series.length) { - $(this.series[this.series.length-1].canvas._elem).after(legendElem); + if (seriesLength) { + $(series[seriesLength-1].canvas._elem).after(legendElem); } this.legend.pack(legendPadding); } // register event listeners on the overlay canvas - for (var i=0; i<$.jqplot.eventListenerHooks.length; i++) { + for (var i=0, l=$.jqplot.eventListenerHooks.length; i<l; i++) { // in the handler, this will refer to the eventCanvas dom element. // make sure there are references back into plot objects. this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]); } // register event listeners on the overlay canvas - for (var i=0; i<this.eventListenerHooks.hooks.length; i++) { + for (var i=0, l=this.eventListenerHooks.hooks.length; i<l; i++) { // in the handler, this will refer to the eventCanvas dom element. // make sure there are references back into plot objects. this.eventCanvas._elem.bind(this.eventListenerHooks.hooks[i][0], {plot:this}, this.eventListenerHooks.hooks[i][1]); } - for (var i=0; i<$.jqplot.postDrawHooks.length; i++) { + var fb = this.fillBetween; + if (fb.fill && fb.series1 !== fb.series2 && fb.series1 < seriesLength && fb.series2 < seriesLength && series[fb.series1]._type === 'line' && series[fb.series2]._type === 'line') { + this.doFillBetweenLines(); + } + + for (var i=0, l=$.jqplot.postDrawHooks.length; i<l; i++) { $.jqplot.postDrawHooks[i].call(this); } - for (var i=0; i<this.postDrawHooks.hooks.length; i++) { - this.postDrawHooks.hooks[i].call(this); + for (var i=0, l=this.postDrawHooks.hooks.length; i<l; i++) { + this.postDrawHooks.hooks[i].apply(this, this.postDrawHooks.args[i]); } if (this.target.is(':visible')) { this._drawCount += 1; } + + var temps, + tempr, + sel, + _els; + // ughh. ideally would hide all series then show them. + for (i=0, l=seriesLength; i<l; i++) { + temps = series[i]; + tempr = temps.renderer; + sel = '.jqplot-point-label.jqplot-series-'+i; + if (tempr.animation && tempr.animation._supported && tempr.animation.show && (this._drawCount < 2 || this.animateReplot)) { + _els = this.target.find(sel); + _els.stop(true, true).hide(); + temps.canvas._elem.stop(true, true).hide(); + temps.shadowCanvas._elem.stop(true, true).hide(); + temps.canvas._elem.jqplotEffect('blind', {mode: 'show', direction: tempr.animation.direction}, tempr.animation.speed); + temps.shadowCanvas._elem.jqplotEffect('blind', {mode: 'show', direction: tempr.animation.direction}, tempr.animation.speed); + _els.fadeIn(tempr.animation.speed*0.8); + } + } + _els = null; this.target.trigger('jqplotPostDraw', [this]); } }; + + jqPlot.prototype.doFillBetweenLines = function () { + var fb = this.fillBetween; + var sid1 = fb.series1; + var sid2 = fb.series2; + // first series should always be lowest index + var id1 = (sid1 < sid2) ? sid1 : sid2; + var id2 = (sid2 > sid1) ? sid2 : sid1; + + var series1 = this.series[id1]; + var series2 = this.series[id2]; + + if (series2.renderer.smooth) { + var tempgd = series2.renderer._smoothedData.slice(0).reverse(); + } + else { + var tempgd = series2.gridData.slice(0).reverse(); + } + + if (series1.renderer.smooth) { + var gd = series1.renderer._smoothedData.concat(tempgd); + } + else { + var gd = series1.gridData.concat(tempgd); + } + + var color = (fb.color !== null) ? fb.color : this.series[sid1].fillColor; + var baseSeries = (fb.baseSeries !== null) ? fb.baseSeries : id1; + + // now apply a fill to the shape on the lower series shadow canvas, + // so it is behind both series. + var sr = this.series[baseSeries].renderer.shapeRenderer; + var opts = {fillStyle: color, fill: true, closePath: true}; + sr.draw(series1.shadowCanvas._ctx, gd, opts); + }; this.bindCustomEvents = function() { this.eventCanvas._elem.bind('click', {plot:this}, this.onClick); @@ -2708,8 +3208,8 @@ var plot = ev.data.plot; var go = plot.eventCanvas._elem.offset(); var gridPos = {x:ev.pageX - go.left, y:ev.pageY - go.top}; - var dataPos = {xaxis:null, yaxis:null, x2axis:null, y2axis:null, y3axis:null, y4axis:null, y5axis:null, y6axis:null, y7axis:null, y8axis:null, y9axis:null}; - var an = ['xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis']; + var dataPos = {xaxis:null, yaxis:null, x2axis:null, y2axis:null, y3axis:null, y4axis:null, y5axis:null, y6axis:null, y7axis:null, y8axis:null, y9axis:null, yMidAxis:null}; + var an = ['xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis', 'yMidAxis']; var ax = plot.axes; var n, axis; for (n=11; n>0; n--) { @@ -2727,11 +3227,12 @@ function checkIntersection(gridpos, plot) { var series = plot.series; var i, j, k, s, r, x, y, theta, sm, sa, minang, maxang; - var d0, d, p, pp, points, bw; + var d0, d, p, pp, points, bw, hp; var threshold, t; for (k=plot.seriesStack.length-1; k>=0; k--) { i = plot.seriesStack[k]; s = series[i]; + hp = s._highlightThreshold; switch (s.renderer.constructor) { case $.jqplot.BarRenderer: x = gridpos.x; @@ -2744,6 +3245,17 @@ } } break; + case $.jqplot.PyramidRenderer: + x = gridpos.x; + y = gridpos.y; + for (j=0; j<s._barPoints.length; j++) { + points = s._barPoints[j]; + p = s.gridData[j]; + if (x > points[0][0] + hp[0][0] && x < points[2][0] + hp[2][0] && y > points[2][1] && y < points[0][1]) { + return {seriesIndex:s.index, pointIndex:j, gridData:p, data:s.data[j], points:s._barPoints[j]}; + } + } + break; case $.jqplot.DonutRenderer: sa = s.startAngle/180*Math.PI; @@ -2891,7 +3403,7 @@ y = gridpos.y; r = s.renderer; if (s.show) { - if (s.fill) { + if ((s.fill || (s.renderer.bands.show && s.renderer.bands.fill)) && (!plot.plugins.highlighter || !plot.plugins.highlighter.show)) { // first check if it is in bounding box var inside = false; if (x>s._boundingBox[0][0] && x<s._boundingBox[1][0] && y>s._boundingBox[1][1] && y<s._boundingBox[0][1]) { @@ -2920,6 +3432,7 @@ break; } + else { t = s.markerRenderer.size/2+s.neighborThreshold; threshold = (t > 0) ? t : 0; @@ -3018,7 +3531,7 @@ var positions = getEventPosition(ev); var p = ev.data.plot; var neighbor = checkIntersection(positions.gridPos, p); - var evt = jQuery.Event('jqplotClick'); + var evt = $.Event('jqplotClick'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); @@ -3030,7 +3543,7 @@ var positions = getEventPosition(ev); var p = ev.data.plot; var neighbor = checkIntersection(positions.gridPos, p); - var evt = jQuery.Event('jqplotDblClick'); + var evt = $.Event('jqplotDblClick'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); @@ -3040,7 +3553,7 @@ var positions = getEventPosition(ev); var p = ev.data.plot; var neighbor = checkIntersection(positions.gridPos, p); - var evt = jQuery.Event('jqplotMouseDown'); + var evt = $.Event('jqplotMouseDown'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); @@ -3048,7 +3561,7 @@ this.onMouseUp = function(ev) { var positions = getEventPosition(ev); - var evt = jQuery.Event('jqplotMouseUp'); + var evt = $.Event('jqplotMouseUp'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, ev.data.plot]); @@ -3060,13 +3573,13 @@ var neighbor = checkIntersection(positions.gridPos, p); if (p.captureRightClick) { if (ev.which == 3) { - var evt = jQuery.Event('jqplotRightClick'); + var evt = $.Event('jqplotRightClick'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); } else { - var evt = jQuery.Event('jqplotMouseUp'); + var evt = $.Event('jqplotMouseUp'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); @@ -3078,7 +3591,7 @@ var positions = getEventPosition(ev); var p = ev.data.plot; var neighbor = checkIntersection(positions.gridPos, p); - var evt = jQuery.Event('jqplotMouseMove'); + var evt = $.Event('jqplotMouseMove'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]); @@ -3087,18 +3600,20 @@ this.onMouseEnter = function(ev) { var positions = getEventPosition(ev); var p = ev.data.plot; - var evt = jQuery.Event('jqplotMouseEnter'); + var evt = $.Event('jqplotMouseEnter'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; + evt.relatedTarget = ev.relatedTarget; $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, p]); }; this.onMouseLeave = function(ev) { var positions = getEventPosition(ev); var p = ev.data.plot; - var evt = jQuery.Event('jqplotMouseLeave'); + var evt = $.Event('jqplotMouseLeave'); evt.pageX = ev.pageX; evt.pageY = ev.pageY; + evt.relatedTarget = ev.relatedTarget; $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, p]); }; @@ -3256,7 +3771,7 @@ // conpute a highlight color or array of highlight colors from given colors. $.jqplot.computeHighlightColors = function(colors) { var ret; - if (jQuery.isArray(colors)) { + if ($.isArray(colors)) { ret = []; for (var i=0; i<colors.length; i++){ var rgba = $.jqplot.getColorComponents(colors[i]); @@ -3264,10 +3779,14 @@ var sum = newrgb[0] + newrgb[1] + newrgb[2]; for (var j=0; j<3; j++) { // when darkening, lowest color component can be is 60. - newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); + newrgb[j] = (sum > 660) ? newrgb[j] * 0.85 : 0.73 * newrgb[j] + 90; newrgb[j] = parseInt(newrgb[j], 10); + (newrgb[j] > 255) ? 255 : newrgb[j]; } - ret.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')'); + // newrgb[3] = (rgba[3] > 0.4) ? rgba[3] * 0.4 : rgba[3] * 1.5; + // newrgb[3] = (rgba[3] > 0.5) ? 0.8 * rgba[3] - .1 : rgba[3] + 0.2; + newrgb[3] = 0.3 + 0.35 * rgba[3]; + ret.push('rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+newrgb[3]+')'); } } else { @@ -3276,10 +3795,16 @@ var sum = newrgb[0] + newrgb[1] + newrgb[2]; for (var j=0; j<3; j++) { // when darkening, lowest color component can be is 60. - newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); + // newrgb[j] = (sum > 570) ? newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]); + // newrgb[j] = parseInt(newrgb[j], 10); + newrgb[j] = (sum > 660) ? newrgb[j] * 0.85 : 0.73 * newrgb[j] + 90; newrgb[j] = parseInt(newrgb[j], 10); + (newrgb[j] > 255) ? 255 : newrgb[j]; } - ret = 'rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')'; + // newrgb[3] = (rgba[3] > 0.4) ? rgba[3] * 0.4 : rgba[3] * 1.5; + // newrgb[3] = (rgba[3] > 0.5) ? 0.8 * rgba[3] - .1 : rgba[3] + 0.2; + newrgb[3] = 0.3 + 0.35 * rgba[3]; + ret = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+newrgb[3]+')'; } return ret; }; @@ -3321,6 +3846,14 @@ this.reset = function() { idx = 0; }; + + this.getIndex = function() { + return idx; + }; + + this.setIndex = function(index) { + idx = index; + }; }; // convert a hex color string to rgb string. @@ -3397,7 +3930,155 @@ return ret; }; - $.jqplot.colorKeywordMap = {aliceblue: 'rgb(240, 248, 255)', antiquewhite: 'rgb(250, 235, 215)', aqua: 'rgb( 0, 255, 255)', aquamarine: 'rgb(127, 255, 212)', azure: 'rgb(240, 255, 255)', beige: 'rgb(245, 245, 220)', bisque: 'rgb(255, 228, 196)', black: 'rgb( 0, 0, 0)', blanchedalmond: 'rgb(255, 235, 205)', blue: 'rgb( 0, 0, 255)', blueviolet: 'rgb(138, 43, 226)', brown: 'rgb(165, 42, 42)', burlywood: 'rgb(222, 184, 135)', cadetblue: 'rgb( 95, 158, 160)', chartreuse: 'rgb(127, 255, 0)', chocolate: 'rgb(210, 105, 30)', coral: 'rgb(255, 127, 80)', cornflowerblue: 'rgb(100, 149, 237)', cornsilk: 'rgb(255, 248, 220)', crimson: 'rgb(220, 20, 60)', cyan: 'rgb( 0, 255, 255)', darkblue: 'rgb( 0, 0, 139)', darkcyan: 'rgb( 0, 139, 139)', darkgoldenrod: 'rgb(184, 134, 11)', darkgray: 'rgb(169, 169, 169)', darkgreen: 'rgb( 0, 100, 0)', darkgrey: 'rgb(169, 169, 169)', darkkhaki: 'rgb(189, 183, 107)', darkmagenta: 'rgb(139, 0, 139)', darkolivegreen: 'rgb( 85, 107, 47)', darkorange: 'rgb(255, 140, 0)', darkorchid: 'rgb(153, 50, 204)', darkred: 'rgb(139, 0, 0)', darksalmon: 'rgb(233, 150, 122)', darkseagreen: 'rgb(143, 188, 143)', darkslateblue: 'rgb( 72, 61, 139)', darkslategray: 'rgb( 47, 79, 79)', darkslategrey: 'rgb( 47, 79, 79)', darkturquoise: 'rgb( 0, 206, 209)', darkviolet: 'rgb(148, 0, 211)', deeppink: 'rgb(255, 20, 147)', deepskyblue: 'rgb( 0, 191, 255)', dimgray: 'rgb(105, 105, 105)', dimgrey: 'rgb(105, 105, 105)', dodgerblue: 'rgb( 30, 144, 255)', firebrick: 'rgb(178, 34, 34)', floralwhite: 'rgb(255, 250, 240)', forestgreen: 'rgb( 34, 139, 34)', fuchsia: 'rgb(255, 0, 255)', gainsboro: 'rgb(220, 220, 220)', ghostwhite: 'rgb(248, 248, 255)', gold: 'rgb(255, 215, 0)', goldenrod: 'rgb(218, 165, 32)', gray: 'rgb(128, 128, 128)', grey: 'rgb(128, 128, 128)', green: 'rgb( 0, 128, 0)', greenyellow: 'rgb(173, 255, 47)', honeydew: 'rgb(240, 255, 240)', hotpink: 'rgb(255, 105, 180)', indianred: 'rgb(205, 92, 92)', indigo: 'rgb( 75, 0, 130)', ivory: 'rgb(255, 255, 240)', khaki: 'rgb(240, 230, 140)', lavender: 'rgb(230, 230, 250)', lavenderblush: 'rgb(255, 240, 245)', lawngreen: 'rgb(124, 252, 0)', lemonchiffon: 'rgb(255, 250, 205)', lightblue: 'rgb(173, 216, 230)', lightcoral: 'rgb(240, 128, 128)', lightcyan: 'rgb(224, 255, 255)', lightgoldenrodyellow: 'rgb(250, 250, 210)', lightgray: 'rgb(211, 211, 211)', lightgreen: 'rgb(144, 238, 144)', lightgrey: 'rgb(211, 211, 211)', lightpink: 'rgb(255, 182, 193)', lightsalmon: 'rgb(255, 160, 122)', lightseagreen: 'rgb( 32, 178, 170)', lightskyblue: 'rgb(135, 206, 250)', lightslategray: 'rgb(119, 136, 153)', lightslategrey: 'rgb(119, 136, 153)', lightsteelblue: 'rgb(176, 196, 222)', lightyellow: 'rgb(255, 255, 224)', lime: 'rgb( 0, 255, 0)', limegreen: 'rgb( 50, 205, 50)', linen: 'rgb(250, 240, 230)', magenta: 'rgb(255, 0, 255)', maroon: 'rgb(128, 0, 0)', mediumaquamarine: 'rgb(102, 205, 170)', mediumblue: 'rgb( 0, 0, 205)', mediumorchid: 'rgb(186, 85, 211)', mediumpurple: 'rgb(147, 112, 219)', mediumseagreen: 'rgb( 60, 179, 113)', mediumslateblue: 'rgb(123, 104, 238)', mediumspringgreen: 'rgb( 0, 250, 154)', mediumturquoise: 'rgb( 72, 209, 204)', mediumvioletred: 'rgb(199, 21, 133)', midnightblue: 'rgb( 25, 25, 112)', mintcream: 'rgb(245, 255, 250)', mistyrose: 'rgb(255, 228, 225)', moccasin: 'rgb(255, 228, 181)', navajowhite: 'rgb(255, 222, 173)', navy: 'rgb( 0, 0, 128)', oldlace: 'rgb(253, 245, 230)', olive: 'rgb(128, 128, 0)', olivedrab: 'rgb(107, 142, 35)', orange: 'rgb(255, 165, 0)', orangered: 'rgb(255, 69, 0)', orchid: 'rgb(218, 112, 214)', palegoldenrod: 'rgb(238, 232, 170)', palegreen: 'rgb(152, 251, 152)', paleturquoise: 'rgb(175, 238, 238)', palevioletred: 'rgb(219, 112, 147)', papayawhip: 'rgb(255, 239, 213)', peachpuff: 'rgb(255, 218, 185)', peru: 'rgb(205, 133, 63)', pink: 'rgb(255, 192, 203)', plum: 'rgb(221, 160, 221)', powderblue: 'rgb(176, 224, 230)', purple: 'rgb(128, 0, 128)', red: 'rgb(255, 0, 0)', rosybrown: 'rgb(188, 143, 143)', royalblue: 'rgb( 65, 105, 225)', saddlebrown: 'rgb(139, 69, 19)', salmon: 'rgb(250, 128, 114)', sandybrown: 'rgb(244, 164, 96)', seagreen: 'rgb( 46, 139, 87)', seashell: 'rgb(255, 245, 238)', sienna: 'rgb(160, 82, 45)', silver: 'rgb(192, 192, 192)', skyblue: 'rgb(135, 206, 235)', slateblue: 'rgb(106, 90, 205)', slategray: 'rgb(112, 128, 144)', slategrey: 'rgb(112, 128, 144)', snow: 'rgb(255, 250, 250)', springgreen: 'rgb( 0, 255, 127)', steelblue: 'rgb( 70, 130, 180)', tan: 'rgb(210, 180, 140)', teal: 'rgb( 0, 128, 128)', thistle: 'rgb(216, 191, 216)', tomato: 'rgb(255, 99, 71)', turquoise: 'rgb( 64, 224, 208)', violet: 'rgb(238, 130, 238)', wheat: 'rgb(245, 222, 179)', white: 'rgb(255, 255, 255)', whitesmoke: 'rgb(245, 245, 245)', yellow: 'rgb(255, 255, 0)', yellowgreen: 'rgb(154, 205, 50)'}; + $.jqplot.colorKeywordMap = { + aliceblue: 'rgb(240, 248, 255)', + antiquewhite: 'rgb(250, 235, 215)', + aqua: 'rgb( 0, 255, 255)', + aquamarine: 'rgb(127, 255, 212)', + azure: 'rgb(240, 255, 255)', + beige: 'rgb(245, 245, 220)', + bisque: 'rgb(255, 228, 196)', + black: 'rgb( 0, 0, 0)', + blanchedalmond: 'rgb(255, 235, 205)', + blue: 'rgb( 0, 0, 255)', + blueviolet: 'rgb(138, 43, 226)', + brown: 'rgb(165, 42, 42)', + burlywood: 'rgb(222, 184, 135)', + cadetblue: 'rgb( 95, 158, 160)', + chartreuse: 'rgb(127, 255, 0)', + chocolate: 'rgb(210, 105, 30)', + coral: 'rgb(255, 127, 80)', + cornflowerblue: 'rgb(100, 149, 237)', + cornsilk: 'rgb(255, 248, 220)', + crimson: 'rgb(220, 20, 60)', + cyan: 'rgb( 0, 255, 255)', + darkblue: 'rgb( 0, 0, 139)', + darkcyan: 'rgb( 0, 139, 139)', + darkgoldenrod: 'rgb(184, 134, 11)', + darkgray: 'rgb(169, 169, 169)', + darkgreen: 'rgb( 0, 100, 0)', + darkgrey: 'rgb(169, 169, 169)', + darkkhaki: 'rgb(189, 183, 107)', + darkmagenta: 'rgb(139, 0, 139)', + darkolivegreen: 'rgb( 85, 107, 47)', + darkorange: 'rgb(255, 140, 0)', + darkorchid: 'rgb(153, 50, 204)', + darkred: 'rgb(139, 0, 0)', + darksalmon: 'rgb(233, 150, 122)', + darkseagreen: 'rgb(143, 188, 143)', + darkslateblue: 'rgb( 72, 61, 139)', + darkslategray: 'rgb( 47, 79, 79)', + darkslategrey: 'rgb( 47, 79, 79)', + darkturquoise: 'rgb( 0, 206, 209)', + darkviolet: 'rgb(148, 0, 211)', + deeppink: 'rgb(255, 20, 147)', + deepskyblue: 'rgb( 0, 191, 255)', + dimgray: 'rgb(105, 105, 105)', + dimgrey: 'rgb(105, 105, 105)', + dodgerblue: 'rgb( 30, 144, 255)', + firebrick: 'rgb(178, 34, 34)', + floralwhite: 'rgb(255, 250, 240)', + forestgreen: 'rgb( 34, 139, 34)', + fuchsia: 'rgb(255, 0, 255)', + gainsboro: 'rgb(220, 220, 220)', + ghostwhite: 'rgb(248, 248, 255)', + gold: 'rgb(255, 215, 0)', + goldenrod: 'rgb(218, 165, 32)', + gray: 'rgb(128, 128, 128)', + grey: 'rgb(128, 128, 128)', + green: 'rgb( 0, 128, 0)', + greenyellow: 'rgb(173, 255, 47)', + honeydew: 'rgb(240, 255, 240)', + hotpink: 'rgb(255, 105, 180)', + indianred: 'rgb(205, 92, 92)', + indigo: 'rgb( 75, 0, 130)', + ivory: 'rgb(255, 255, 240)', + khaki: 'rgb(240, 230, 140)', + lavender: 'rgb(230, 230, 250)', + lavenderblush: 'rgb(255, 240, 245)', + lawngreen: 'rgb(124, 252, 0)', + lemonchiffon: 'rgb(255, 250, 205)', + lightblue: 'rgb(173, 216, 230)', + lightcoral: 'rgb(240, 128, 128)', + lightcyan: 'rgb(224, 255, 255)', + lightgoldenrodyellow: 'rgb(250, 250, 210)', + lightgray: 'rgb(211, 211, 211)', + lightgreen: 'rgb(144, 238, 144)', + lightgrey: 'rgb(211, 211, 211)', + lightpink: 'rgb(255, 182, 193)', + lightsalmon: 'rgb(255, 160, 122)', + lightseagreen: 'rgb( 32, 178, 170)', + lightskyblue: 'rgb(135, 206, 250)', + lightslategray: 'rgb(119, 136, 153)', + lightslategrey: 'rgb(119, 136, 153)', + lightsteelblue: 'rgb(176, 196, 222)', + lightyellow: 'rgb(255, 255, 224)', + lime: 'rgb( 0, 255, 0)', + limegreen: 'rgb( 50, 205, 50)', + linen: 'rgb(250, 240, 230)', + magenta: 'rgb(255, 0, 255)', + maroon: 'rgb(128, 0, 0)', + mediumaquamarine: 'rgb(102, 205, 170)', + mediumblue: 'rgb( 0, 0, 205)', + mediumorchid: 'rgb(186, 85, 211)', + mediumpurple: 'rgb(147, 112, 219)', + mediumseagreen: 'rgb( 60, 179, 113)', + mediumslateblue: 'rgb(123, 104, 238)', + mediumspringgreen: 'rgb( 0, 250, 154)', + mediumturquoise: 'rgb( 72, 209, 204)', + mediumvioletred: 'rgb(199, 21, 133)', + midnightblue: 'rgb( 25, 25, 112)', + mintcream: 'rgb(245, 255, 250)', + mistyrose: 'rgb(255, 228, 225)', + moccasin: 'rgb(255, 228, 181)', + navajowhite: 'rgb(255, 222, 173)', + navy: 'rgb( 0, 0, 128)', + oldlace: 'rgb(253, 245, 230)', + olive: 'rgb(128, 128, 0)', + olivedrab: 'rgb(107, 142, 35)', + orange: 'rgb(255, 165, 0)', + orangered: 'rgb(255, 69, 0)', + orchid: 'rgb(218, 112, 214)', + palegoldenrod: 'rgb(238, 232, 170)', + palegreen: 'rgb(152, 251, 152)', + paleturquoise: 'rgb(175, 238, 238)', + palevioletred: 'rgb(219, 112, 147)', + papayawhip: 'rgb(255, 239, 213)', + peachpuff: 'rgb(255, 218, 185)', + peru: 'rgb(205, 133, 63)', + pink: 'rgb(255, 192, 203)', + plum: 'rgb(221, 160, 221)', + powderblue: 'rgb(176, 224, 230)', + purple: 'rgb(128, 0, 128)', + red: 'rgb(255, 0, 0)', + rosybrown: 'rgb(188, 143, 143)', + royalblue: 'rgb( 65, 105, 225)', + saddlebrown: 'rgb(139, 69, 19)', + salmon: 'rgb(250, 128, 114)', + sandybrown: 'rgb(244, 164, 96)', + seagreen: 'rgb( 46, 139, 87)', + seashell: 'rgb(255, 245, 238)', + sienna: 'rgb(160, 82, 45)', + silver: 'rgb(192, 192, 192)', + skyblue: 'rgb(135, 206, 235)', + slateblue: 'rgb(106, 90, 205)', + slategray: 'rgb(112, 128, 144)', + slategrey: 'rgb(112, 128, 144)', + snow: 'rgb(255, 250, 250)', + springgreen: 'rgb( 0, 255, 127)', + steelblue: 'rgb( 70, 130, 180)', + tan: 'rgb(210, 180, 140)', + teal: 'rgb( 0, 128, 128)', + thistle: 'rgb(216, 191, 216)', + tomato: 'rgb(255, 99, 71)', + turquoise: 'rgb( 64, 224, 208)', + violet: 'rgb(238, 130, 238)', + wheat: 'rgb(245, 222, 179)', + white: 'rgb(255, 255, 255)', + whitesmoke: 'rgb(245, 245, 245)', + yellow: 'rgb(255, 255, 0)', + yellowgreen: 'rgb(154, 205, 50)' + }; })(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/jqplot.divTitleRenderer.js b/libs/jqplot/jqplot.divTitleRenderer.js index 79d7d3e42c..4f0a30b7a0 100644 --- a/libs/jqplot/jqplot.divTitleRenderer.js +++ b/libs/jqplot/jqplot.divTitleRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -72,7 +73,7 @@ if (this.fontSize) { styles['fontSize'] = this.fontSize; } - if (this.textAlign) { + if (typeof this.textAlign === 'string') { styles['textAlign'] = this.textAlign; } else { @@ -89,7 +90,12 @@ } this._elem.css(styles); - this._elem.text(this.text); + if (this.escapeHtml) { + this._elem.text(this.text); + } + else { + this._elem.html(this.text); + } // styletext += (this._plotWidth) ? 'width:'+this._plotWidth+'px;' : ''; diff --git a/libs/jqplot/jqplot.linePattern.js b/libs/jqplot/jqplot.linePattern.js new file mode 100644 index 0000000000..9fdd9ef236 --- /dev/null +++ b/libs/jqplot/jqplot.linePattern.js @@ -0,0 +1,149 @@ +/** + * jqPlot + * Pure JavaScript plotting plugin using jQuery + * + * Version: @VERSION + * Revision: @REVISION + * + * Copyright (c) 2009-2013 Chris Leonello + * jqPlot is currently available for use in all personal or commercial projects + * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL + * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * Although not required, the author would appreciate an email letting him + * know of any substantial use of jqPlot. You can reach the author at: + * chris at jqplot dot com or see http://www.jqplot.com/info.php . + * + * If you are feeling kind and generous, consider supporting the project by + * making a donation at: http://www.jqplot.com/donate.php . + * + * sprintf functions contained in jqplot.sprintf.js by Ash Searle: + * + * version 2007.04.27 + * author Ash Searle + * http://hexmen.com/blog/2007/03/printf-sprintf/ + * http://hexmen.com/js/sprintf.js + * The author (Ash Searle) has placed this code in the public domain: + * "This code is unrestricted: you are free to use it however you like." + * + */ + + /** + * The following dashed line support contributed by Cory Sharp. + * After I implemented an inferior method, Cory responded with a generous + * contribution of code and input which proved a more powerful and + * elegant solution. + */ + +(function($) { + + var dotlen = 0.1; + + $.jqplot.LinePattern = function (ctx, pattern) { + + var defaultLinePatterns = { + dotted: [ dotlen, $.jqplot.config.dotGapLength ], + dashed: [ $.jqplot.config.dashLength, $.jqplot.config.gapLength ], + solid: null + }; + + if (typeof pattern === 'string') { + if (pattern[0] === '.' || pattern[0] === '-') { + var s = pattern; + pattern = []; + for (var i=0, imax=s.length; i<imax; i++) { + if (s[i] === '.') { + pattern.push( dotlen ); + } + else if (s[i] === '-') { + pattern.push( $.jqplot.config.dashLength ); + } + else { + continue; + } + pattern.push( $.jqplot.config.gapLength ); + } + } + else { + pattern = defaultLinePatterns[pattern]; + } + } + + if (!(pattern && pattern.length)) { + return ctx; + } + + var patternIndex = 0; + var patternDistance = pattern[0]; + var px = 0; + var py = 0; + var pathx0 = 0; + var pathy0 = 0; + + var moveTo = function (x, y) { + ctx.moveTo( x, y ); + px = x; + py = y; + pathx0 = x; + pathy0 = y; + }; + + var lineTo = function (x, y) { + var scale = ctx.lineWidth; + var dx = x - px; + var dy = y - py; + var dist = Math.sqrt(dx*dx+dy*dy); + if ((dist > 0) && (scale > 0)) { + dx /= dist; + dy /= dist; + while (true) { + var dp = scale * patternDistance; + if (dp < dist) { + px += dp * dx; + py += dp * dy; + if ((patternIndex & 1) == 0) { + ctx.lineTo( px, py ); + } + else { + ctx.moveTo( px, py ); + } + dist -= dp; + patternIndex++; + if (patternIndex >= pattern.length) { + patternIndex = 0; + } + patternDistance = pattern[patternIndex]; + } + else { + px = x; + py = y; + if ((patternIndex & 1) == 0) { + ctx.lineTo( px, py ); + } + else { + ctx.moveTo( px, py ); + } + patternDistance -= dist / scale; + break; + } + } + } + }; + + var beginPath = function () { + ctx.beginPath(); + }; + + var closePath = function () { + lineTo( pathx0, pathy0 ); + }; + + return { + moveTo: moveTo, + lineTo: lineTo, + beginPath: beginPath, + closePath: closePath + }; + }; +})(jQuery);
\ No newline at end of file diff --git a/libs/jqplot/jqplot.lineRenderer.js b/libs/jqplot/jqplot.lineRenderer.js index ad722661bb..c4c18d4ca5 100644 --- a/libs/jqplot/jqplot.lineRenderer.js +++ b/libs/jqplot/jqplot.lineRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -38,8 +39,94 @@ // called with scope of series. $.jqplot.LineRenderer.prototype.init = function(options, plot) { + // Group: Properties + // options = options || {}; this._type='line'; + this.renderer.animation = { + show: false, + direction: 'left', + speed: 2500, + _supported: true + }; + // prop: smooth + // True to draw a smoothed (interpolated) line through the data points + // with automatically computed number of smoothing points. + // Set to an integer number > 2 to specify number of smoothing points + // to use between each data point. + this.renderer.smooth = false; // true or a number > 2 for smoothing. + this.renderer.tension = null; // null to auto compute or a number typically > 6. Fewer points requires higher tension. + // prop: constrainSmoothing + // True to use a more accurate smoothing algorithm that will + // not overshoot any data points. False to allow overshoot but + // produce a smoother looking line. + this.renderer.constrainSmoothing = true; + // this is smoothed data in grid coordinates, like gridData + this.renderer._smoothedData = []; + // this is smoothed data in plot units (plot coordinates), like plotData. + this.renderer._smoothedPlotData = []; + this.renderer._hiBandGridData = []; + this.renderer._lowBandGridData = []; + this.renderer._hiBandSmoothedData = []; + this.renderer._lowBandSmoothedData = []; + + // prop: bandData + // Data used to draw error bands or confidence intervals above/below a line. + // + // bandData can be input in 3 forms. jqPlot will figure out which is the + // low band line and which is the high band line for all forms: + // + // A 2 dimensional array like [[yl1, yl2, ...], [yu1, yu2, ...]] where + // [yl1, yl2, ...] are y values of the lower line and + // [yu1, yu2, ...] are y values of the upper line. + // In this case there must be the same number of y data points as data points + // in the series and the bands will inherit the x values of the series. + // + // A 2 dimensional array like [[[xl1, yl1], [xl2, yl2], ...], [[xh1, yh1], [xh2, yh2], ...]] + // where [xl1, yl1] are x,y data points for the lower line and + // [xh1, yh1] are x,y data points for the high line. + // x values do not have to correspond to the x values of the series and can + // be of any arbitrary length. + // + // Can be of form [[yl1, yu1], [yl2, yu2], [yl3, yu3], ...] where + // there must be 3 or more arrays and there must be the same number of arrays + // as there are data points in the series. In this case, + // [yl1, yu1] specifies the lower and upper y values for the 1st + // data point and so on. The bands will inherit the x + // values from the series. + this.renderer.bandData = []; + + // Group: bands + // Banding around line, e.g error bands or confidence intervals. + this.renderer.bands = { + // prop: show + // true to show the bands. If bandData or interval is + // supplied, show will be set to true by default. + show: false, + hiData: [], + lowData: [], + // prop: color + // color of lines at top and bottom of bands [default: series color]. + color: this.color, + // prop: showLines + // True to show lines at top and bottom of bands [default: false]. + showLines: false, + // prop: fill + // True to fill area between bands [default: true]. + fill: true, + // prop: fillColor + // css color spec for filled area. [default: series color]. + fillColor: null, + _min: null, + _max: null, + // prop: interval + // User specified interval above and below line for bands [default: '3%'']. + // Can be a value like 3 or a string like '3%' + // or an upper/lower array like [1, -2] or ['2%', '-1.5%'] + interval: '3%' + }; + + var lopts = {highlightMouseOver: options.highlightMouseOver, highlightMouseDown: options.highlightMouseDown, highlightColor: options.highlightColor}; delete (options.highlightMouseOver); @@ -47,26 +134,60 @@ delete (options.highlightColor); $.extend(true, this.renderer, options); + + this.renderer.options = options; + + // if we are given some band data, and bands aren't explicity set to false in options, turn them on. + if (this.renderer.bandData.length > 1 && (!options.bands || options.bands.show == null)) { + this.renderer.bands.show = true; + } + + // if we are given an interval, and bands aren't explicity set to false in options, turn them on. + else if (options.bands && options.bands.show == null && options.bands.interval != null) { + this.renderer.bands.show = true; + } + + // if plot is filled, turn off bands. + if (this.fill) { + this.renderer.bands.show = false; + } + + if (this.renderer.bands.show) { + this.renderer.initBands.call(this, this.renderer.options, plot); + } + + + // smoothing is not compatible with stacked lines, disable + if (this._stack) { + this.renderer.smooth = false; + } + // set the shape renderer options - var opts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.fillColor, lineWidth:this.lineWidth, closePath:this.fill}; + var opts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.fillColor, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill}; this.renderer.shapeRenderer.init(opts); + + var shadow_offset = options.shadowOffset; // set the shadow renderer options - // scale the shadowOffset to the width of the line. - if (this.lineWidth > 2.5) { - var shadow_offset = this.shadowOffset* (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6); - // var shadow_offset = this.shadowOffset; - } - // for skinny lines, don't make such a big shadow. - else { - var shadow_offset = this.shadowOffset*Math.atan((this.lineWidth/2.5))/0.785398163; + if (shadow_offset == null) { + // scale the shadowOffset to the width of the line. + if (this.lineWidth > 2.5) { + shadow_offset = 1.25 * (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6); + // var shadow_offset = this.shadowOffset; + } + // for skinny lines, don't make such a big shadow. + else { + shadow_offset = 1.25 * Math.atan((this.lineWidth/2.5))/0.785398163; + } } - var sopts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.lineWidth, closePath:this.fill}; + + var sopts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill}; this.renderer.shadowRenderer.init(sopts); this._areaPoints = []; this._boundingBox = [[],[]]; - if (!this.isTrendline && this.fill) { - + if (!this.isTrendline && this.fill || this.renderer.bands.show) { + // Group: Properties + // // prop: highlightMouseOver // True to highlight area on a filled plot when moused over. // This must be false to enable highlightMouseDown to highlight when clicking on an area on a filled plot. @@ -86,7 +207,8 @@ $.extend(true, this, {highlightMouseOver: lopts.highlightMouseOver, highlightMouseDown: lopts.highlightMouseDown, highlightColor: lopts.highlightColor}); if (!this.highlightColor) { - this.highlightColor = $.jqplot.computeHighlightColors(this.fillColor); + var fc = (this.renderer.bands.show) ? this.renderer.bands.fillColor : this.fillColor; + this.highlightColor = $.jqplot.computeHighlightColors(fc); } // turn off (disable) the highlighter plugin if (this.highlighter) { @@ -106,8 +228,448 @@ } }; + + $.jqplot.LineRenderer.prototype.initBands = function(options, plot) { + // use bandData if no data specified in bands option + //var bd = this.renderer.bandData; + var bd = options.bandData || []; + var bands = this.renderer.bands; + bands.hiData = []; + bands.lowData = []; + var data = this.data; + bands._max = null; + bands._min = null; + // If 2 arrays, and each array greater than 2 elements, assume it is hi and low data bands of y values. + if (bd.length == 2) { + // Do we have an array of x,y values? + // like [[[1,1], [2,4], [3,3]], [[1,3], [2,6], [3,5]]] + if ($.isArray(bd[0][0])) { + // since an arbitrary array of points, spin through all of them to determine max and min lines. + + var p; + var bdminidx = 0, bdmaxidx = 0; + for (var i = 0, l = bd[0].length; i<l; i++) { + p = bd[0][i]; + if ((p[1] != null && p[1] > bands._max) || bands._max == null) { + bands._max = p[1]; + } + if ((p[1] != null && p[1] < bands._min) || bands._min == null) { + bands._min = p[1]; + } + } + for (var i = 0, l = bd[1].length; i<l; i++) { + p = bd[1][i]; + if ((p[1] != null && p[1] > bands._max) || bands._max == null) { + bands._max = p[1]; + bdmaxidx = 1; + } + if ((p[1] != null && p[1] < bands._min) || bands._min == null) { + bands._min = p[1]; + bdminidx = 1; + } + } + + if (bdmaxidx === bdminidx) { + bands.show = false; + } + + bands.hiData = bd[bdmaxidx]; + bands.lowData = bd[bdminidx]; + } + // else data is arrays of y values + // like [[1,4,3], [3,6,5]] + // must have same number of band data points as points in series + else if (bd[0].length === data.length && bd[1].length === data.length) { + var hi = (bd[0][0] > bd[1][0]) ? 0 : 1; + var low = (hi) ? 0 : 1; + for (var i=0, l=data.length; i < l; i++) { + bands.hiData.push([data[i][0], bd[hi][i]]); + bands.lowData.push([data[i][0], bd[low][i]]); + } + } + + // we don't have proper data array, don't show bands. + else { + bands.show = false; + } + } + + // if more than 2 arrays, have arrays of [ylow, yhi] values. + // note, can't distinguish case of [[ylow, yhi], [ylow, yhi]] from [[ylow, ylow], [yhi, yhi]] + // this is assumed to be of the latter form. + else if (bd.length > 2 && !$.isArray(bd[0][0])) { + var hi = (bd[0][0] > bd[0][1]) ? 0 : 1; + var low = (hi) ? 0 : 1; + for (var i=0, l=bd.length; i<l; i++) { + bands.hiData.push([data[i][0], bd[i][hi]]); + bands.lowData.push([data[i][0], bd[i][low]]); + } + } + + // don't have proper data, auto calculate + else { + var intrv = bands.interval; + var a = null; + var b = null; + var afunc = null; + var bfunc = null; + + if ($.isArray(intrv)) { + a = intrv[0]; + b = intrv[1]; + } + else { + a = intrv; + } + + if (isNaN(a)) { + // we have a string + if (a.charAt(a.length - 1) === '%') { + afunc = 'multiply'; + a = parseFloat(a)/100 + 1; + } + } + + else { + a = parseFloat(a); + afunc = 'add'; + } + + if (b !== null && isNaN(b)) { + // we have a string + if (b.charAt(b.length - 1) === '%') { + bfunc = 'multiply'; + b = parseFloat(b)/100 + 1; + } + } + + else if (b !== null) { + b = parseFloat(b); + bfunc = 'add'; + } + + if (a !== null) { + if (b === null) { + b = -a; + bfunc = afunc; + if (bfunc === 'multiply') { + b += 2; + } + } + + // make sure a always applies to hi band. + if (a < b) { + var temp = a; + a = b; + b = temp; + temp = afunc; + afunc = bfunc; + bfunc = temp; + } + + for (var i=0, l = data.length; i < l; i++) { + switch (afunc) { + case 'add': + bands.hiData.push([data[i][0], data[i][1] + a]); + break; + case 'multiply': + bands.hiData.push([data[i][0], data[i][1] * a]); + break; + } + switch (bfunc) { + case 'add': + bands.lowData.push([data[i][0], data[i][1] + b]); + break; + case 'multiply': + bands.lowData.push([data[i][0], data[i][1] * b]); + break; + } + } + } + + else { + bands.show = false; + } + } + + var hd = bands.hiData; + var ld = bands.lowData; + for (var i = 0, l = hd.length; i<l; i++) { + if ((hd[i][1] != null && hd[i][1] > bands._max) || bands._max == null) { + bands._max = hd[i][1]; + } + } + for (var i = 0, l = ld.length; i<l; i++) { + if ((ld[i][1] != null && ld[i][1] < bands._min) || bands._min == null) { + bands._min = ld[i][1]; + } + } + + // one last check for proper data + // these don't apply any more since allowing arbitrary x,y values + // if (bands.hiData.length != bands.lowData.length) { + // bands.show = false; + // } + + // if (bands.hiData.length != this.data.length) { + // bands.show = false; + // } + + if (bands.fillColor === null) { + var c = $.jqplot.getColorComponents(bands.color); + // now adjust alpha to differentiate fill + c[3] = c[3] * 0.5; + bands.fillColor = 'rgba(' + c[0] +', '+ c[1] +', '+ c[2] +', '+ c[3] + ')'; + } + }; + + function getSteps (d, f) { + return (3.4182054+f) * Math.pow(d, -0.3534992); + } + + function computeSteps (d1, d2) { + var s = Math.sqrt(Math.pow((d2[0]- d1[0]), 2) + Math.pow ((d2[1] - d1[1]), 2)); + return 5.7648 * Math.log(s) + 7.4456; + } + + function tanh (x) { + var a = (Math.exp(2*x) - 1) / (Math.exp(2*x) + 1); + return a; + } + + ////////// + // computeConstrainedSmoothedData + // An implementation of the constrained cubic spline interpolation + // method as presented in: + // + // Kruger, CJC, Constrained Cubic Spine Interpolation for Chemical Engineering Applications + // http://www.korf.co.uk/spline.pdf + // + // The implementation below borrows heavily from the sample Visual Basic + // implementation by CJC Kruger found in http://www.korf.co.uk/spline.xls + // + ///////// + + // called with scope of series + function computeConstrainedSmoothedData (gd) { + var smooth = this.renderer.smooth; + var dim = this.canvas.getWidth(); + var xp = this._xaxis.series_p2u; + var yp = this._yaxis.series_p2u; + var steps =null; + var _steps = null; + var dist = gd.length/dim; + var _smoothedData = []; + var _smoothedPlotData = []; + + if (!isNaN(parseFloat(smooth))) { + steps = parseFloat(smooth); + } + else { + steps = getSteps(dist, 0.5); + } + + var yy = []; + var xx = []; + + for (var i=0, l = gd.length; i<l; i++) { + yy.push(gd[i][1]); + xx.push(gd[i][0]); + } + + function dxx(x1, x0) { + if (x1 - x0 == 0) { + return Math.pow(10,10); + } + else { + return x1 - x0; + } + } + + var A, B, C, D; + // loop through each line segment. Have # points - 1 line segments. Nmber segments starting at 1. + var nmax = gd.length - 1; + for (var num = 1, gdl = gd.length; num<gdl; num++) { + var gxx = []; + var ggxx = []; + // point at each end of segment. + for (var j = 0; j < 2; j++) { + var i = num - 1 + j; // point number, 0 to # points. + + if (i == 0 || i == nmax) { + gxx[j] = Math.pow(10, 10); + } + else if (yy[i+1] - yy[i] == 0 || yy[i] - yy[i-1] == 0) { + gxx[j] = 0; + } + else if (((xx[i+1] - xx[i]) / (yy[i+1] - yy[i]) + (xx[i] - xx[i-1]) / (yy[i] - yy[i-1])) == 0 ) { + gxx[j] = 0; + } + else if ( (yy[i+1] - yy[i]) * (yy[i] - yy[i-1]) < 0 ) { + gxx[j] = 0; + } + + else { + gxx[j] = 2 / (dxx(xx[i + 1], xx[i]) / (yy[i + 1] - yy[i]) + dxx(xx[i], xx[i - 1]) / (yy[i] - yy[i - 1])); + } + } + + // Reset first derivative (slope) at first and last point + if (num == 1) { + // First point has 0 2nd derivative + gxx[0] = 3 / 2 * (yy[1] - yy[0]) / dxx(xx[1], xx[0]) - gxx[1] / 2; + } + else if (num == nmax) { + // Last point has 0 2nd derivative + gxx[1] = 3 / 2 * (yy[nmax] - yy[nmax - 1]) / dxx(xx[nmax], xx[nmax - 1]) - gxx[0] / 2; + } + + // Calc second derivative at points + ggxx[0] = -2 * (gxx[1] + 2 * gxx[0]) / dxx(xx[num], xx[num - 1]) + 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2); + ggxx[1] = 2 * (2 * gxx[1] + gxx[0]) / dxx(xx[num], xx[num - 1]) - 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2); + + // Calc constants for cubic interpolation + D = 1 / 6 * (ggxx[1] - ggxx[0]) / dxx(xx[num], xx[num - 1]); + C = 1 / 2 * (xx[num] * ggxx[0] - xx[num - 1] * ggxx[1]) / dxx(xx[num], xx[num - 1]); + B = (yy[num] - yy[num - 1] - C * (Math.pow(xx[num], 2) - Math.pow(xx[num - 1], 2)) - D * (Math.pow(xx[num], 3) - Math.pow(xx[num - 1], 3))) / dxx(xx[num], xx[num - 1]); + A = yy[num - 1] - B * xx[num - 1] - C * Math.pow(xx[num - 1], 2) - D * Math.pow(xx[num - 1], 3); + + var increment = (xx[num] - xx[num - 1]) / steps; + var temp, tempx; + + for (var j = 0, l = steps; j < l; j++) { + temp = []; + tempx = xx[num - 1] + j * increment; + temp.push(tempx); + temp.push(A + B * tempx + C * Math.pow(tempx, 2) + D * Math.pow(tempx, 3)); + _smoothedData.push(temp); + _smoothedPlotData.push([xp(temp[0]), yp(temp[1])]); + } + } + + _smoothedData.push(gd[i]); + _smoothedPlotData.push([xp(gd[i][0]), yp(gd[i][1])]); + + return [_smoothedData, _smoothedPlotData]; + } + + /////// + // computeHermiteSmoothedData + // A hermite spline smoothing of the plot data. + // This implementation is derived from the one posted + // by krypin on the jqplot-users mailing list: + // + // http://groups.google.com/group/jqplot-users/browse_thread/thread/748be6a445723cea?pli=1 + // + // with a blog post: + // + // http://blog.statscollector.com/a-plugin-renderer-for-jqplot-to-draw-a-hermite-spline/ + // + // and download of the original plugin: + // + // http://blog.statscollector.com/wp-content/uploads/2010/02/jqplot.hermiteSplineRenderer.js + ////////// + + // called with scope of series + function computeHermiteSmoothedData (gd) { + var smooth = this.renderer.smooth; + var tension = this.renderer.tension; + var dim = this.canvas.getWidth(); + var xp = this._xaxis.series_p2u; + var yp = this._yaxis.series_p2u; + var steps =null; + var _steps = null; + var a = null; + var a1 = null; + var a2 = null; + var slope = null; + var slope2 = null; + var temp = null; + var t, s, h1, h2, h3, h4; + var TiX, TiY, Ti1X, Ti1Y; + var pX, pY, p; + var sd = []; + var spd = []; + var dist = gd.length/dim; + var min, max, stretch, scale, shift; + var _smoothedData = []; + var _smoothedPlotData = []; + if (!isNaN(parseFloat(smooth))) { + steps = parseFloat(smooth); + } + else { + steps = getSteps(dist, 0.5); + } + if (!isNaN(parseFloat(tension))) { + tension = parseFloat(tension); + } + + for (var i=0, l = gd.length-1; i < l; i++) { + + if (tension === null) { + slope = Math.abs((gd[i+1][1] - gd[i][1]) / (gd[i+1][0] - gd[i][0])); + + min = 0.3; + max = 0.6; + stretch = (max - min)/2.0; + scale = 2.5; + shift = -1.4; + + temp = slope/scale + shift; + + a1 = stretch * tanh(temp) - stretch * tanh(shift) + min; + + // if have both left and right line segments, will use minimum tension. + if (i > 0) { + slope2 = Math.abs((gd[i][1] - gd[i-1][1]) / (gd[i][0] - gd[i-1][0])); + } + temp = slope2/scale + shift; + + a2 = stretch * tanh(temp) - stretch * tanh(shift) + min; + + a = (a1 + a2)/2.0; + + } + else { + a = tension; + } + for (t=0; t < steps; t++) { + s = t / steps; + h1 = (1 + 2*s)*Math.pow((1-s),2); + h2 = s*Math.pow((1-s),2); + h3 = Math.pow(s,2)*(3-2*s); + h4 = Math.pow(s,2)*(s-1); + + if (gd[i-1]) { + TiX = a * (gd[i+1][0] - gd[i-1][0]); + TiY = a * (gd[i+1][1] - gd[i-1][1]); + } else { + TiX = a * (gd[i+1][0] - gd[i][0]); + TiY = a * (gd[i+1][1] - gd[i][1]); + } + if (gd[i+2]) { + Ti1X = a * (gd[i+2][0] - gd[i][0]); + Ti1Y = a * (gd[i+2][1] - gd[i][1]); + } else { + Ti1X = a * (gd[i+1][0] - gd[i][0]); + Ti1Y = a * (gd[i+1][1] - gd[i][1]); + } + + pX = h1*gd[i][0] + h3*gd[i+1][0] + h2*TiX + h4*Ti1X; + pY = h1*gd[i][1] + h3*gd[i+1][1] + h2*TiY + h4*Ti1Y; + p = [pX, pY]; + + _smoothedData.push(p); + _smoothedPlotData.push([xp(pX), yp(pY)]); + } + } + _smoothedData.push(gd[l]); + _smoothedPlotData.push([xp(gd[l][0]), yp(gd[l][1])]); + + return [_smoothedData, _smoothedPlotData]; + } - // Method: setGridData + // setGridData // converts the user data values to grid coordinates and stores them // in the gridData array. // Called with scope of a series. @@ -119,16 +681,26 @@ var pdata = this._prevPlotData; this.gridData = []; this._prevGridData = []; - for (var i=0; i<this.data.length; i++) { + this.renderer._smoothedData = []; + this.renderer._smoothedPlotData = []; + this.renderer._hiBandGridData = []; + this.renderer._lowBandGridData = []; + this.renderer._hiBandSmoothedData = []; + this.renderer._lowBandSmoothedData = []; + var bands = this.renderer.bands; + var hasNull = false; + for (var i=0, l=data.length; i < l; i++) { // if not a line series or if no nulls in data, push the converted point onto the array. if (data[i][0] != null && data[i][1] != null) { this.gridData.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]); } // else if there is a null, preserve it. else if (data[i][0] == null) { + hasNull = true; this.gridData.push([null, yp.call(this._yaxis, data[i][1])]); } else if (data[i][1] == null) { + hasNull = true; this.gridData.push([xp.call(this._xaxis, data[i][0]), null]); } // if not a line series or if no nulls in data, push the converted point onto the array. @@ -143,9 +715,59 @@ this._prevGridData.push([xp.call(this._xaxis, pdata[i][0]), null]); } } + + // don't do smoothing or bands on broken lines. + if (hasNull) { + this.renderer.smooth = false; + if (this._type === 'line') { + bands.show = false; + } + } + + if (this._type === 'line' && bands.show) { + for (var i=0, l=bands.hiData.length; i<l; i++) { + this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]); + } + for (var i=0, l=bands.lowData.length; i<l; i++) { + this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]); + } + } + + // calculate smoothed data if enough points and no nulls + if (this._type === 'line' && this.renderer.smooth && this.gridData.length > 2) { + var ret; + if (this.renderer.constrainSmoothing) { + ret = computeConstrainedSmoothedData.call(this, this.gridData); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + else { + ret = computeHermiteSmoothedData.call(this, this.gridData); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + } }; - // Method: makeGridData + // makeGridData // converts any arbitrary data values to grid coordinates and // returns them. This method exists so that plugins can use a series' // linerenderer to generate grid data points without overwriting the @@ -157,6 +779,14 @@ var yp = this._yaxis.series_u2p; var gd = []; var pgd = []; + this.renderer._smoothedData = []; + this.renderer._smoothedPlotData = []; + this.renderer._hiBandGridData = []; + this.renderer._lowBandGridData = []; + this.renderer._hiBandSmoothedData = []; + this.renderer._lowBandSmoothedData = []; + var bands = this.renderer.bands; + var hasNull = false; for (var i=0; i<data.length; i++) { // if not a line series or if no nulls in data, push the converted point onto the array. if (data[i][0] != null && data[i][1] != null) { @@ -164,20 +794,72 @@ } // else if there is a null, preserve it. else if (data[i][0] == null) { + hasNull = true; gd.push([null, yp.call(this._yaxis, data[i][1])]); } else if (data[i][1] == null) { + hasNull = true; gd.push([xp.call(this._xaxis, data[i][0]), null]); } } + + // don't do smoothing or bands on broken lines. + if (hasNull) { + this.renderer.smooth = false; + if (this._type === 'line') { + bands.show = false; + } + } + + if (this._type === 'line' && bands.show) { + for (var i=0, l=bands.hiData.length; i<l; i++) { + this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]); + } + for (var i=0, l=bands.lowData.length; i<l; i++) { + this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]); + } + } + + if (this._type === 'line' && this.renderer.smooth && gd.length > 2) { + var ret; + if (this.renderer.constrainSmoothing) { + ret = computeConstrainedSmoothedData.call(this, gd); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + else { + ret = computeHermiteSmoothedData.call(this, gd); + this.renderer._smoothedData = ret[0]; + this.renderer._smoothedPlotData = ret[1]; + + if (bands.show) { + ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData); + this.renderer._hiBandSmoothedData = ret[0]; + ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData); + this.renderer._lowBandSmoothedData = ret[0]; + } + + ret = null; + } + } return gd; }; // called within scope of series. - $.jqplot.LineRenderer.prototype.draw = function(ctx, gd, options) { + $.jqplot.LineRenderer.prototype.draw = function(ctx, gd, options, plot) { var i; - var opts = (options != undefined) ? options : {}; + // get a copy of the options, so we don't modify the original object. + var opts = $.extend(true, {}, options); var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine; var fill = (opts.fill != undefined) ? opts.fill : this.fill; @@ -188,10 +870,9 @@ if (showLine) { // if we fill, we'll have to add points to close the curve. if (fill) { - if (this.fillToZero) { + if (this.fillToZero) { // have to break line up into shapes at axis crossings - var negativeColors = new $.jqplot.ColorGenerator(this.negativeSeriesColors); - var negativeColor = negativeColors.get(this.index); + var negativeColor = this.negativeColor; if (! this.useNegativeColors) { negativeColor = opts.fillStyle; } @@ -206,9 +887,12 @@ if (this.index == 0 || !this._stack) { var tempgd = []; + var pd = (this.renderer.smooth) ? this.renderer._smoothedPlotData : this._plotData; this._areaPoints = []; var pyzero = this._yaxis.series_u2p(this.fillToValue); var pxzero = this._xaxis.series_u2p(this.fillToValue); + + opts.closePath = true; if (this.fillAxis == 'y') { tempgd.push([gd[0][0], pyzero]); @@ -218,8 +902,8 @@ tempgd.push(gd[i]); this._areaPoints.push(gd[i]); // do we have an axis crossing? - if (this._plotData[i][1] * this._plotData[i+1][1] < 0) { - if (this._plotData[i][1] < 0) { + if (pd[i][1] * pd[i+1][1] < 0) { + if (pd[i][1] < 0) { isnegative = true; opts.fillStyle = negativeColor; } @@ -241,7 +925,7 @@ // this._areaPoints = [[xintercept, pyzero]]; } } - if (this._plotData[gd.length-1][1] < 0) { + if (pd[gd.length-1][1] < 0) { isnegative = true; opts.fillStyle = negativeColor; } @@ -254,7 +938,7 @@ tempgd.push([gd[gd.length-1][0], pyzero]); this._areaPoints.push([gd[gd.length-1][0], pyzero]); } - // now draw this shape and shadow. + // now draw the last area. if (shadow) { this.renderer.shadowRenderer.draw(ctx, tempgd, opts); } @@ -323,6 +1007,9 @@ // } // now draw the markers if (this.markerRenderer.show) { + if (this.renderer.smooth) { + fasgd = this.gridData; + } for (i=0; i<fasgd.length; i++) { this.markerRenderer.draw(fasgd[i][0], fasgd[i][1], ctx, opts.markerOptions); } @@ -330,6 +1017,32 @@ } } else { + + if (this.renderer.bands.show) { + var bdat; + var bopts = $.extend(true, {}, opts); + if (this.renderer.bands.showLines) { + bdat = (this.renderer.smooth) ? this.renderer._hiBandSmoothedData : this.renderer._hiBandGridData; + this.renderer.shapeRenderer.draw(ctx, bdat, opts); + bdat = (this.renderer.smooth) ? this.renderer._lowBandSmoothedData : this.renderer._lowBandGridData; + this.renderer.shapeRenderer.draw(ctx, bdat, bopts); + } + + if (this.renderer.bands.fill) { + if (this.renderer.smooth) { + bdat = this.renderer._hiBandSmoothedData.concat(this.renderer._lowBandSmoothedData.reverse()); + } + else { + bdat = this.renderer._hiBandGridData.concat(this.renderer._lowBandGridData.reverse()); + } + this._areaPoints = bdat; + bopts.closePath = true; + bopts.fill = true; + bopts.fillStyle = this.renderer.bands.fillColor; + this.renderer.shapeRenderer.draw(ctx, bdat, bopts); + } + } + if (shadow) { this.renderer.shadowRenderer.draw(ctx, gd, opts); } @@ -354,10 +1067,19 @@ ymin = p[1]; } } + + if (this.type === 'line' && this.renderer.bands.show) { + ymax = this._yaxis.series_u2p(this.renderer.bands._min); + ymin = this._yaxis.series_u2p(this.renderer.bands._max); + } + this._boundingBox = [[xmin, ymax], [xmax, ymin]]; // now draw the markers if (this.markerRenderer.show && !fill) { + if (this.renderer.smooth) { + gd = this.gridData; + } for (i=0; i<gd.length; i++) { if (gd[i][0] != null && gd[i][1] != null) { this.markerRenderer.draw(gd[i][0], gd[i][1], ctx, opts.markerOptions); @@ -384,7 +1106,6 @@ } } } - this.target.bind('mouseout', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); } // called within context of plot @@ -402,6 +1123,7 @@ this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-lineRenderer-highlight-canvas', this._plotDimensions, this)); this.plugins.lineRenderer.highlightCanvas.setContext(); + this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); } function highlight (plot, sidx, pidx, points) { @@ -411,6 +1133,10 @@ s._highlightedPoint = pidx; plot.plugins.lineRenderer.highlightedSeriesIndex = sidx; var opts = {fillStyle: s.highlightColor}; + if (s.type === 'line' && s.renderer.bands.show) { + opts.fill = true; + opts.closePath = true; + } s.renderer.shapeRenderer.draw(canvas._ctx, points, opts); canvas = null; } @@ -436,6 +1162,7 @@ plot.target.trigger(evt1, ins); if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) { var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -452,6 +1179,7 @@ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) { var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -474,6 +1202,7 @@ if (neighbor) { var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; var evt = jQuery.Event('jqplotDataClick'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -488,6 +1217,7 @@ unhighlight(plot); } var evt = jQuery.Event('jqplotDataRightClick'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); diff --git a/libs/jqplot/jqplot.linearAxisRenderer.js b/libs/jqplot/jqplot.linearAxisRenderer.js index 525103ba47..959854edea 100644 --- a/libs/jqplot/jqplot.linearAxisRenderer.js +++ b/libs/jqplot/jqplot.linearAxisRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -30,7 +31,6 @@ (function($) { // class: $.jqplot.LinearAxisRenderer // The default jqPlot axis renderer, creating a numeric axis. - // The renderer has no additional options beyond the <Axis> object. $.jqplot.LinearAxisRenderer = function() { }; @@ -48,6 +48,15 @@ // prop: breakTickLabel // Label to use at the axis break if breakPoints are specified. this.breakTickLabel = "≈"; + // prop: drawBaseline + // True to draw the axis baseline. + this.drawBaseline = true; + // prop: baselineWidth + // width of the baseline in pixels. + this.baselineWidth = null; + // prop: baselineColor + // CSS color spec for the baseline. + this.baselineColor = null; // prop: forceTickAt0 // This will ensure that there is always a tick mark at 0. // If data range is strictly positive or negative, @@ -66,8 +75,24 @@ // This has know effect when any of the following options // are set: autoscale, min, max, numberTicks or tickInterval. this.forceTickAt100 = false; + // prop: tickInset + // Controls the amount to inset the first and last ticks from + // the edges of the grid, in multiples of the tick interval. + // 0 is no inset, 0.5 is one half a tick interval, 1 is a full + // tick interval, etc. + this.tickInset = 0; + // prop: minorTicks + // Number of ticks to add between "major" ticks. + // Major ticks are ticks supplied by user or auto computed. + // Minor ticks cannot be created by user. + this.minorTicks = 0; + // prop: alignTicks + // true to align tick marks across opposed axes + // such as from the y2axis to yaxis. + this.alignTicks = false; this._autoFormatString = ''; this._overrideFormatString = false; + this._scalefact = 1.0; $.extend(true, this, options); if (this.breakPoints) { if (!$.isArray(this.breakPoints)) { @@ -77,6 +102,9 @@ this.breakPoints = null; } } + if (this.numberTicks != null && this.numberTicks < 2) { + this.numberTicks = 2; + } this.resetDataBounds(); }; @@ -86,7 +114,7 @@ // populate the axis label and value properties. // createTicks is a method on the renderer, but // call it within the scope of the axis. - this.renderer.createTicks.call(this); + this.renderer.createTicks.call(this, plot); // fill a div with axes labels in the right direction. // Need to pregenerate each axis to get it's bounds and // position it and the labels correctly on the plot. @@ -102,7 +130,7 @@ this._elem = $(document.createElement('div')); this._elem.addClass('jqplot-axis jqplot-'+this.name); - this._elem.css('posiiton', 'absolute'); + this._elem.css('position', 'absolute'); if (this.name == 'xaxis' || this.name == 'x2axis') { @@ -137,10 +165,10 @@ // called with scope of an axis $.jqplot.LinearAxisRenderer.prototype.reset = function() { - this.min = this._min; - this.max = this._max; - this.tickInterval = this._tickInterval; - this.numberTicks = this._numberTicks; + this.min = this._options.min; + this.max = this._options.max; + this.tickInterval = this._options.tickInterval; + this.numberTicks = this._options.numberTicks; this._autoFormatString = ''; if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) { this.tickOptions.formatString = ''; @@ -206,14 +234,15 @@ }; // called with scope of axis - $.jqplot.LinearAxisRenderer.prototype.createTicks = function() { + $.jqplot.LinearAxisRenderer.prototype.createTicks = function(plot) { // we're are operating on an axis here var ticks = this._ticks; var userTicks = this.ticks; var name = this.name; // databounds were set on axis initialization. var db = this._dataBounds; - var dim, interval; + var dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height; + var interval; var min, max; var pos1, pos2; var tt, i; @@ -222,6 +251,9 @@ var userMax = this.max; var userNT = this.numberTicks; var userTI = this.tickInterval; + + var threshold = 30; + this._scalefact = (Math.max(dim, threshold+1) - threshold)/300.0; // if we already have ticks, use them. // ticks must be in order of increasing value. @@ -231,7 +263,7 @@ for (i=0; i<userTicks.length; i++){ var ut = userTicks[i]; var t = new this.tickRenderer(this.tickOptions); - if (ut.constructor == Array) { + if ($.isArray(ut)) { t.value = ut[0]; if (this.breakPoints) { if (ut[0] == this.breakPoints[0]) { @@ -255,6 +287,12 @@ t.setTick(ut[0], this.name); this._ticks.push(t); } + + else if ($.isPlainObject(ut)) { + $.extend(true, t, ut); + t.axis = this.name; + this._ticks.push(t); + } else { t.value = ut; @@ -288,19 +326,19 @@ else { dim = this._plotDimensions.height; } - - // // if min, max and number of ticks specified, user can't specify interval. - // if (!this.autoscale && this.min != null && this.max != null && this.numberTicks != null) { - // console.log('doing this'); - // this.tickInterval = null; - // } - - // if max, min, and interval specified and interval won't fit, ignore interval. - // if (this.min != null && this.max != null && this.tickInterval != null) { - // if (parseInt((this.max-this.min)/this.tickInterval, 10) != (this.max-this.min)/this.tickInterval) { - // this.tickInterval = null; - // } - // } + + var _numberTicks = this.numberTicks; + + // if aligning this axis, use number of ticks from previous axis. + // Do I need to reset somehow if alignTicks is changed and then graph is replotted?? + if (this.alignTicks) { + if (this.name === 'x2axis' && plot.axes.xaxis.show) { + _numberTicks = plot.axes.xaxis.numberTicks; + } + else if (this.name.charAt(0) === 'y' && this.name !== 'yaxis' && this.name !== 'yMidAxis' && plot.axes.yaxis.show) { + _numberTicks = plot.axes.yaxis.numberTicks; + } + } min = ((this.min != null) ? this.min : db.min); max = ((this.max != null) ? this.max : db.max); @@ -309,14 +347,12 @@ var rmin, rmax; var temp; - // Doing complete autoscaling - if (this.min == null && this.max == null && this.numberTicks == null && this.tickInterval == null && !this.autoscale) { - // check to see if we can override tick format string with autocalculated one - if (this.tickOptions == null || !this.tickOptions.formatString) { - this._overrideFormatString = true; - } - + if (this.tickOptions == null || !this.tickOptions.formatString) { + this._overrideFormatString = true; + } + // Doing complete autoscaling + if (this.min == null || this.max == null && this.tickInterval == null && !this.autoscale) { // Check if user must have tick at 0 or 100 and ensure they are in range. // The autoscaling algorithm will always place ticks at 0 and 100 if they are in range. if (this.forceTickAt0) { @@ -337,37 +373,42 @@ } } - // console.log(this.name); - var threshold = 30; - var tdim = Math.max(dim, threshold+1); - var scalefact = (tdim-threshold)/300.0; - // scalefact = 1; - var ret = $.jqplot.LinearTickGenerator(min, max, scalefact); + var keepMin = false, + keepMax = false; + + if (this.min != null) { + keepMin = true; + } + + else if (this.max != null) { + keepMax = true; + } + + // var threshold = 30; + // var tdim = Math.max(dim, threshold+1); + // this._scalefact = (tdim-threshold)/300.0; + var ret = $.jqplot.LinearTickGenerator(min, max, this._scalefact, _numberTicks, keepMin, keepMax); // calculate a padded max and min, points should be less than these // so that they aren't too close to the edges of the plot. // User can adjust how much padding is allowed with pad, padMin and PadMax options. - var tumin = min + range*(this.padMin - 1); - var tumax = max - range*(this.padMax - 1); + // If min or max is set, don't pad that end of axis. + var tumin = (this.min != null) ? min : min + range*(this.padMin - 1); + var tumax = (this.max != null) ? max : max - range*(this.padMax - 1); - if (min <=tumin || max >= tumax) { - tumin = min - range*(this.padMin - 1); - tumax = max + range*(this.padMax - 1); - ret = $.jqplot.LinearTickGenerator(tumin, tumax, scalefact); + // if they're equal, we shouldn't have to do anything, right? + // if (min <=tumin || max >= tumax) { + if (min <tumin || max > tumax) { + tumin = (this.min != null) ? min : min - range*(this.padMin - 1); + tumax = (this.max != null) ? max : max + range*(this.padMax - 1); + ret = $.jqplot.LinearTickGenerator(tumin, tumax, this._scalefact, _numberTicks, keepMin, keepMax); } - - // if (ret[2] > max_number_ticks) { - // ret[4] = Math.ceil(r[2]/max_number_ticks) * ret[4]; - - // } - this.min = ret[0]; this.max = ret[1]; + // if numberTicks specified, it should return the same. this.numberTicks = ret[2]; this._autoFormatString = ret[3]; - //this.tickInterval = Math.abs(this.max - this.min)/(this.numberTicks - 1); this.tickInterval = ret[4]; - // console.log('numberticks: %s, interval: %s', ret[2], ret[4]); } // User has specified some axis scale related option, can use auto algorithm @@ -521,23 +562,40 @@ this.max = this.min + rrange; } } + + // Compute a somewhat decent format string if it is needed. + // get precision of interval and determine a format string. + var sf = $.jqplot.getSignificantFigures(this.tickInterval); + + var fstr; + + // if we have only a whole number, use integer formatting + if (sf.digitsLeft >= sf.significantDigits) { + fstr = '%d'; + } + + else { + var temp = Math.max(0, 5 - sf.digitsLeft); + temp = Math.min(temp, sf.digitsRight); + fstr = '%.'+ temp + 'f'; + } + + this._autoFormatString = fstr; } // Use the default algorithm which pads each axis to make the chart // centered nicely on the grid. else { + rmin = (this.min != null) ? this.min : min - range*(this.padMin - 1); rmax = (this.max != null) ? this.max : max + range*(this.padMax - 1); - this.min = rmin; - this.max = rmax; - range = this.max - this.min; + range = rmax - rmin; if (this.numberTicks == null){ // if tickInterval is specified by user, we will ignore computed maximum. // max will be equal or greater to fit even # of ticks. if (this.tickInterval != null) { - this.numberTicks = Math.ceil((this.max - this.min)/this.tickInterval)+1; - this.max = this.min + this.tickInterval*(this.numberTicks-1); + this.numberTicks = Math.ceil((rmax - rmin)/this.tickInterval)+1; } else if (dim > 100) { this.numberTicks = parseInt(3+(dim-100)/75, 10); @@ -550,6 +608,35 @@ if (this.tickInterval == null) { this.tickInterval = range / (this.numberTicks-1); } + + if (this.max == null) { + rmax = rmin + this.tickInterval*(this.numberTicks - 1); + } + if (this.min == null) { + rmin = rmax - this.tickInterval*(this.numberTicks - 1); + } + + // get precision of interval and determine a format string. + var sf = $.jqplot.getSignificantFigures(this.tickInterval); + + var fstr; + + // if we have only a whole number, use integer formatting + if (sf.digitsLeft >= sf.significantDigits) { + fstr = '%d'; + } + + else { + var temp = Math.max(0, 5 - sf.digitsLeft); + temp = Math.min(temp, sf.digitsRight); + fstr = '%.'+ temp + 'f'; + } + + + this._autoFormatString = fstr; + + this.min = rmin; + this.max = rmax; } if (this.renderer.constructor == $.jqplot.LinearAxisRenderer && this._autoFormatString == '') { @@ -633,16 +720,32 @@ this.tickOptions.formatString = this._autoFormatString; } + var t, to; for (var i=0; i<this.numberTicks; i++){ tt = this.min + i * this.tickInterval; - var t = new this.tickRenderer(this.tickOptions); + t = new this.tickRenderer(this.tickOptions); // var t = new $.jqplot.AxisTickRenderer(this.tickOptions); t.setTick(tt, this.name); this._ticks.push(t); + + if (i < this.numberTicks - 1) { + for (var j=0; j<this.minorTicks; j++) { + tt += this.tickInterval/(this.minorTicks+1); + to = $.extend(true, {}, this.tickOptions, {name:this.name, value:tt, label:'', isMinorTick:true}); + t = new this.tickRenderer(to); + this._ticks.push(t); + } + } t = null; } } + + if (this.tickInset) { + this.min = this.min - this.tickInset * this.tickInterval; + this.max = this.max + this.tickInset * this.tickInterval; + } + ticks = null; }; diff --git a/libs/jqplot/jqplot.markerRenderer.js b/libs/jqplot/jqplot.markerRenderer.js index b11ecf601c..26780a4328 100644 --- a/libs/jqplot/jqplot.markerRenderer.js +++ b/libs/jqplot/jqplot.markerRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can diff --git a/libs/jqplot/jqplot.shadowRenderer.js b/libs/jqplot/jqplot.shadowRenderer.js index a8fc02728a..f40e429d32 100644 --- a/libs/jqplot/jqplot.shadowRenderer.js +++ b/libs/jqplot/jqplot.shadowRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -81,33 +82,41 @@ ctx.save(); var opts = (options != null) ? options : {}; var fill = (opts.fill != null) ? opts.fill : this.fill; + var fillRect = (opts.fillRect != null) ? opts.fillRect : this.fillRect; var closePath = (opts.closePath != null) ? opts.closePath : this.closePath; var offset = (opts.offset != null) ? opts.offset : this.offset; var alpha = (opts.alpha != null) ? opts.alpha : this.alpha; var depth = (opts.depth != null) ? opts.depth : this.depth; var isarc = (opts.isarc != null) ? opts.isarc : this.isarc; + var linePattern = (opts.linePattern != null) ? opts.linePattern : this.linePattern; ctx.lineWidth = (opts.lineWidth != null) ? opts.lineWidth : this.lineWidth; ctx.lineJoin = (opts.lineJoin != null) ? opts.lineJoin : this.lineJoin; ctx.lineCap = (opts.lineCap != null) ? opts.lineCap : this.lineCap; ctx.strokeStyle = opts.strokeStyle || this.strokeStyle || 'rgba(0,0,0,'+alpha+')'; ctx.fillStyle = opts.fillStyle || this.fillStyle || 'rgba(0,0,0,'+alpha+')'; for (var j=0; j<depth; j++) { + var ctxPattern = $.jqplot.LinePattern(ctx, linePattern); ctx.translate(Math.cos(this.angle*Math.PI/180)*offset, Math.sin(this.angle*Math.PI/180)*offset); - ctx.beginPath(); + ctxPattern.beginPath(); if (isarc) { ctx.arc(points[0], points[1], points[2], points[3], points[4], true); } + else if (fillRect) { + if (fillRect) { + ctx.fillRect(points[0], points[1], points[2], points[3]); + } + } else if (points && points.length){ var move = true; for (var i=0; i<points.length; i++) { // skip to the first non-null point and move to it. if (points[i][0] != null && points[i][1] != null) { if (move) { - ctx.moveTo(points[i][0], points[i][1]); + ctxPattern.moveTo(points[i][0], points[i][1]); move = false; } else { - ctx.lineTo(points[i][0], points[i][1]); + ctxPattern.lineTo(points[i][0], points[i][1]); } } else { @@ -117,7 +126,7 @@ } if (closePath) { - ctx.closePath(); + ctxPattern.closePath(); } if (fill) { ctx.fill(); diff --git a/libs/jqplot/jqplot.shapeRenderer.js b/libs/jqplot/jqplot.shapeRenderer.js index 6a96577fe5..9253e5a982 100644 --- a/libs/jqplot/jqplot.shapeRenderer.js +++ b/libs/jqplot/jqplot.shapeRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -36,6 +37,12 @@ $.jqplot.ShapeRenderer = function(options){ this.lineWidth = 1.5; + // prop: linePattern + // line pattern 'dashed', 'dotted', 'solid', some combination + // of '-' and '.' characters such as '.-.' or a numerical array like + // [draw, skip, draw, skip, ...] such as [1, 10] to draw a dotted line, + // [1, 10, 20, 10] to draw a dot-dash line, and so on. + this.linePattern = 'solid'; // prop: lineJoin // How line segments of the shadow are joined. this.lineJoin = 'miter'; @@ -90,6 +97,8 @@ var strokeRect = (opts.strokeRect != null) ? opts.strokeRect : this.strokeRect; var clearRect = (opts.clearRect != null) ? opts.clearRect : this.clearRect; var isarc = (opts.isarc != null) ? opts.isarc : this.isarc; + var linePattern = (opts.linePattern != null) ? opts.linePattern : this.linePattern; + var ctxPattern = $.jqplot.LinePattern(ctx, linePattern); ctx.lineWidth = opts.lineWidth || this.lineWidth; ctx.lineJoin = opts.lineJoin || this.lineJoin; ctx.lineCap = opts.lineCap || this.lineCap; @@ -131,11 +140,11 @@ // skip to the first non-null point and move to it. if (points[i][0] != null && points[i][1] != null) { if (move) { - ctx.moveTo(points[i][0], points[i][1]); + ctxPattern.moveTo(points[i][0], points[i][1]); move = false; } else { - ctx.lineTo(points[i][0], points[i][1]); + ctxPattern.lineTo(points[i][0], points[i][1]); } } else { @@ -143,7 +152,7 @@ } } if (closePath) { - ctx.closePath(); + ctxPattern.closePath(); } if (fill) { ctx.fill(); diff --git a/libs/jqplot/jqplot.sprintf.js b/libs/jqplot/jqplot.sprintf.js index 5a9112a2d1..689a5a4dd9 100644 --- a/libs/jqplot/jqplot.sprintf.js +++ b/libs/jqplot/jqplot.sprintf.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -83,6 +84,12 @@ * Format: '%.4g', Input: 12.0, Output: 12.00 * Format: '%.4p', Input: 4.321e-5, Output: 4.321e-5 * Format: '%.4g', Input: 4.321e-5, Output: 4.3210e-5 + * + * Example: + * >>> $.jqplot.sprintf('%.2f, %d', 23.3452, 43.23) + * "23.35, 43" + * >>> $.jqplot.sprintf("no value: %n, decimal with thousands separator: %'d", 23.3452, 433524) + * "no value: , decimal with thousands separator: 433,524" */ $.jqplot.sprintf = function() { function pad(str, len, chr, leftJustify) { @@ -91,13 +98,13 @@ } - function thousand_separate(value) { - var value_str = new String(value); - for (var i=10; i>0; i--) { - if (value_str == (value_str = value_str.replace(/^(\d+)(\d{3})/, "$1"+$.jqplot.sprintf.thousandsSeparator+"$2"))) break; - } - return value_str; - } + function thousand_separate(value) { + var value_str = new String(value); + for (var i=10; i>0; i--) { + if (value_str == (value_str = value_str.replace(/^(\d+)(\d{3})/, "$1"+$.jqplot.sprintf.thousandsSeparator+"$2"))) break; + } + return value_str; + } function justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace) { var diff = minWidth - value.length; @@ -142,7 +149,7 @@ case '0': zeroPad = true; break; case '#': prefixBaseX = true; break; case '&': htmlSpace = true; break; - case '\'': thousandSeparation = true; break; + case '\'': thousandSeparation = true; break; } // parameters may be null, undefined, empty-string or real valued @@ -207,7 +214,7 @@ } var prefix = number < 0 ? '-' : positivePrefix; var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number)); - value = prefix + pad(number_str, precision, '0', false); + value = prefix + pad(number_str, precision, '0', false); //value = prefix + pad(String(Math.abs(number)), precision, '0', false); return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace); } @@ -218,7 +225,7 @@ } var prefix = number < 0 ? '-' : positivePrefix; var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number)); - value = prefix + pad(number_str, precision, '0', false); + value = prefix + pad(number_str, precision, '0', false); return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace); } case 'e': @@ -238,7 +245,13 @@ var number_str = Math.abs(number)[method](precision); number_str = thousandSeparation ? thousand_separate(number_str): number_str; value = prefix + number_str; - return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform](); + var justified = justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform](); + + if ($.jqplot.sprintf.decimalMark !== '.' && $.jqplot.sprintf.decimalMark !== $.jqplot.sprintf.thousandsSeparator) { + return justified.replace(/\./, $.jqplot.sprintf.decimalMark); + } else { + return justified; + } } case 'p': case 'P': @@ -280,8 +293,31 @@ }); }; - $.jqplot.sprintf.thousandsSeparator = ','; + $.jqplot.sprintf.thousandsSeparator = ','; + // Specifies the decimal mark for floating point values. By default a period '.' + // is used. If you change this value to for example a comma be sure to also + // change the thousands separator or else this won't work since a simple String + // replace is used (replacing all periods with the mark specified here). + $.jqplot.sprintf.decimalMark = '.'; $.jqplot.sprintf.regex = /%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g; + $.jqplot.getSignificantFigures = function(number) { + var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/); + // total significant digits + var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length; + var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0; + // exponent + var expn = parseInt(parts[1], 10); + // digits to the left of the decimal place + var dleft = (expn + 1 > 0) ? expn + 1 : 0; + // digits to the right of the decimal place + var dright = (sd <= dleft) ? 0 : sd - expn - 1; + return {significantDigits: sd, digitsLeft: dleft, digitsRight: dright, zeros: zeros, exponent: expn} ; + }; + + $.jqplot.getPrecision = function(number) { + return $.jqplot.getSignificantFigures(number).digitsRight; + }; + })(jQuery); diff --git a/libs/jqplot/jqplot.tableLegendRenderer.js b/libs/jqplot/jqplot.tableLegendRenderer.js index 3dd8991c8c..f2685cead1 100644 --- a/libs/jqplot/jqplot.tableLegendRenderer.js +++ b/libs/jqplot/jqplot.tableLegendRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -60,10 +61,11 @@ if (this.showSwatches) { td = $(document.createElement('td')); - td.addClass('jqplot-table-legend'); + td.addClass('jqplot-table-legend jqplot-table-legend-swatch'); td.css({textAlign: 'center', paddingTop: rs}); div0 = $(document.createElement('div')); + div0.addClass('jqplot-table-legend-swatch-outline'); div1 = $(document.createElement('div')); div1.addClass('jqplot-table-legend-swatch'); div1.css({backgroundColor: color, borderColor: color}); @@ -76,7 +78,7 @@ } if (this.showLabels) { td = $(document.createElement('td')); - td.addClass('jqplot-table-legend'); + td.addClass('jqplot-table-legend jqplot-table-legend-label'); td.css('paddingTop', rs); tr.append(td); diff --git a/libs/jqplot/jqplot.themeEngine.js b/libs/jqplot/jqplot.themeEngine.js index 2c28ea4cd0..ba773b1741 100644 --- a/libs/jqplot/jqplot.themeEngine.js +++ b/libs/jqplot/jqplot.themeEngine.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -68,6 +69,7 @@ * > series: [{ * > color: "#4bb2c5", * > lineWidth: 2.5, + * > linePattern: "solid", * > shadow: true, * > fillColor: "#4bb2c5", * > showMarker: true, @@ -507,8 +509,8 @@ plot.series[i].renderer.shapeRenderer.strokeStyle = val; plot.series[i][n] = val; } - else if (n == 'lineWidth') { - plot.series[i].renderer.shapeRenderer.lineWidth = val; + else if ((n == 'lineWidth') || (n == 'linePattern')) { + plot.series[i].renderer.shapeRenderer[n] = val; plot.series[i][n] = val; } else if (n == 'markerOptions') { @@ -835,6 +837,7 @@ var LineSeriesProperties = function() { this.color=null; this.lineWidth=null; + this.linePattern=null; this.shadow=null; this.fillColor=null; this.showMarker=null; diff --git a/libs/jqplot/plugins/jqplot.barRenderer.js b/libs/jqplot/plugins/jqplot.barRenderer.js index 5f043e40ad..109845e047 100644 --- a/libs/jqplot/plugins/jqplot.barRenderer.js +++ b/libs/jqplot/plugins/jqplot.barRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -92,6 +93,19 @@ // prop: highlightColors // an array of colors to use when highlighting a bar. this.highlightColors = []; + // prop: transposedData + // NOT IMPLEMENTED YET. True if this is a horizontal bar plot and + // x and y values are "transposed". Tranposed, or "swapped", data is + // required prior to rev. 894 builds of jqPlot with horizontal bars. + // Allows backward compatability of bar renderer horizontal bars with + // old style data sets. + this.transposedData = true; + this.renderer.animation = { + show: false, + direction: 'down', + speed: 3000, + _supported: true + }; this._type = 'bar'; // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver @@ -99,10 +113,25 @@ options.highlightMouseOver = false; } + ////// + // This is probably wrong here. + // After going back and forth on wether renderer should be the thing + // or extend the thing, it seems that it it best if it is a property + // on the thing. This should be something that is commonized + // among series renderers in the future. + ////// $.extend(true, this, options); + + // really should probably do this + $.extend(true, this.renderer, options); // fill is still needed to properly draw the legend. // bars have to be filled. this.fill = true; + + // if horizontal bar and animating, reset the default direction + if (this.barDirection === 'horizontal' && this.rendererOptions.animation && this.rendererOptions.animation.direction == null) { + this.renderer.animation.direction = 'left'; + } if (this.waterfall) { this.fillToZero = false; @@ -152,7 +181,7 @@ if (this.rendererOptions.waterfall == true) { this._data = $.extend(true, [], this.data); var sum = 0; - var pos = (!this.rendererOptions.barDirection || this.rendererOptions.barDirection == 'vertical') ? 1 : 0; + var pos = (!this.rendererOptions.barDirection || this.rendererOptions.barDirection === 'vertical' || this.transposedData === false) ? 1 : 0; for(var i=0; i<this.data.length; i++) { sum += this.data[i][pos]; if (i>0) { @@ -169,14 +198,20 @@ var count = 0; for (var i=skip; i<l; i+=skip) { this.data.splice(i+count, 0, [null, null]); + this._plotData.splice(i+count, 0, [null, null]); + this._stackData.splice(i+count, 0, [null, null]); count++; } for (i=0; i<this.data.length; i++) { if (this._primaryAxis == '_xaxis') { this.data[i][0] = i+1; + this._plotData[i][0] = i+1; + this._stackData[i][0] = i+1; } else { this.data[i][1] = i+1; + this._plotData[i][1] = i+1; + this._stackData[i][1] = i+1; } } } @@ -256,8 +291,42 @@ } return ret; } + + function getStart(sidx, didx, comp, plot, axis) { + // check if sign change + var seriesIndex = sidx, + prevSeriesIndex = sidx - 1, + start, + prevVal, + aidx = (axis === 'x') ? 0 : 1; + + // is this not the first series? + if (seriesIndex > 0) { + prevVal = plot.series[prevSeriesIndex]._plotData[didx][aidx]; + + // is there a sign change + if ((comp * prevVal) < 0) { + start = getStart(prevSeriesIndex, didx, comp, plot, axis); + } + + // no sign change. + else { + start = plot.series[prevSeriesIndex].gridData[didx][aidx]; + } + + } + + // if first series, return value at 0 + else { + + start = (aidx === 0) ? plot.series[seriesIndex]._xaxis.series_u2p(0) : plot.series[seriesIndex]._yaxis.series_u2p(0); + } + + return start; + } + - $.jqplot.BarRenderer.prototype.draw = function(ctx, gridData, options) { + $.jqplot.BarRenderer.prototype.draw = function(ctx, gridData, options, plot) { var i; // Ughhh, have to make a copy of options b/c it may be modified later. var opts = $.extend({}, options); @@ -303,18 +372,18 @@ if (this.barDirection == 'vertical') { for (var i=0; i<gridData.length; i++) { - if (this.data[i][1] == null) { + if (!this._stack && this.data[i][1] == null) { continue; } points = []; base = gridData[i][0] + this._barNudge; - ystart; // stacked if (this._stack && this._prevGridData.length) { - ystart = this._prevGridData[i][1]; + ystart = getStart(this.index, i, this._plotData[i][1], plot, 'y'); } - // not stacked and first series in stack + + // not stacked else { if (this.fillToZero) { ystart = this._yaxis.series_u2p(0); @@ -400,7 +469,7 @@ else if (this.barDirection == 'horizontal'){ for (var i=0; i<gridData.length; i++) { - if (this.data[i][0] == null) { + if (!this._stack && this.data[i][0] == null) { continue; } points = []; @@ -408,15 +477,15 @@ xstart; if (this._stack && this._prevGridData.length) { - xstart = this._prevGridData[i][0]; + xstart = getStart(this.index, i, this._plotData[i][0], plot, 'x'); } - // not stacked and first series in stack + // not stacked else { if (this.fillToZero) { xstart = this._xaxis.series_u2p(0); } else if (this.waterfall && i > 0 && i < this.gridData.length-1) { - xstart = this.gridData[i-1][1]; + xstart = this.gridData[i-1][0]; } else if (this.waterfall && i == 0 && i < this.gridData.length-1) { if (this._xaxis.min <= 0 && this._xaxis.max >= 0) { @@ -426,7 +495,7 @@ xstart = 0; } else { - xstart = ctx.canvas.width; + xstart = 0; } } else if (this.waterfall && i == this.gridData.length - 1) { @@ -463,10 +532,20 @@ } } - points.push([xstart, base+this.barWidth/2]); - points.push([xstart, base-this.barWidth/2]); - points.push([gridData[i][0], base-this.barWidth/2]); - points.push([gridData[i][0], base+this.barWidth/2]); + + if (!this.fillToZero || this._plotData[i][0] >= 0) { + points.push([xstart, base + this.barWidth / 2]); + points.push([xstart, base - this.barWidth / 2]); + points.push([gridData[i][0], base - this.barWidth / 2]); + points.push([gridData[i][0], base + this.barWidth / 2]); + } + else { + points.push([gridData[i][0], base + this.barWidth / 2]); + points.push([gridData[i][0], base - this.barWidth / 2]); + points.push([xstart, base - this.barWidth / 2]); + points.push([xstart, base + this.barWidth / 2]); + } + this._barPoints.push(points); // now draw the shadows if not stacked. // for stacked plots, they are predrawn by drawShadow @@ -477,13 +556,13 @@ } var clr = opts.fillStyle || this.color; this._dataColors.push(clr); - this.renderer.shapeRenderer.draw(ctx, points, opts); - } + this.renderer.shapeRenderer.draw(ctx, points, opts); + } } } if (this.highlightColors.length == 0) { - this.highlightColors = computeHighlightColors(this._dataColors); + this.highlightColors = $.jqplot.computeHighlightColors(this._dataColors); } else if (typeof(this.highlightColors) == 'string') { @@ -498,7 +577,7 @@ // for stacked plots, shadows will be pre drawn by drawShadow. - $.jqplot.BarRenderer.prototype.drawShadow = function(ctx, gridData, options) { + $.jqplot.BarRenderer.prototype.drawShadow = function(ctx, gridData, options, plot) { var i; var opts = (options != undefined) ? options : {}; var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow; @@ -538,7 +617,7 @@ var ystart; if (this._stack && this._prevGridData.length) { - ystart = this._prevGridData[i][1]; + ystart = getStart(this.index, i, this._plotData[i][1], plot, 'y'); } else { if (this.fillToZero) { @@ -567,10 +646,15 @@ var xstart; if (this._stack && this._prevGridData.length) { - xstart = this._prevGridData[i][0]; + xstart = getStart(this.index, i, this._plotData[i][0], plot, 'x'); } else { - xstart = 0; + if (this.fillToZero) { + xstart = this._xaxis.series_u2p(0); + } + else { + xstart = 0; + } } points.push([xstart, base+this.barWidth/2]); @@ -594,7 +678,6 @@ } } } - this.target.bind('mouseout', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); } // called within context of plot @@ -613,6 +696,7 @@ this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-barRenderer-highlight-canvas', this._plotDimensions, this)); this.plugins.barRenderer.highlightCanvas.setContext(); + this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); } function highlight (plot, sidx, pidx, points) { @@ -647,6 +731,7 @@ plot.target.trigger(evt1, ins); if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -663,6 +748,7 @@ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -685,6 +771,7 @@ if (neighbor) { var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; var evt = jQuery.Event('jqplotDataClick'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -699,6 +786,7 @@ unhighlight(plot); } var evt = jQuery.Event('jqplotDataRightClick'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); diff --git a/libs/jqplot/plugins/jqplot.canvasAxisTickRenderer.js b/libs/jqplot/plugins/jqplot.canvasAxisTickRenderer.js index 2e59e87925..8688f71aea 100644 --- a/libs/jqplot/plugins/jqplot.canvasAxisTickRenderer.js +++ b/libs/jqplot/plugins/jqplot.canvasAxisTickRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -132,12 +133,7 @@ } if (this.enableFontSupport) { - - function support_canvas_text() { - return !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function'); - } - - if (support_canvas_text()) { + if ($.jqplot.support_canvas_text()) { this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts); } @@ -149,9 +145,6 @@ this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); } }; - - $.jqplot.CanvasAxisTickRenderer.prototype = new $.jqplot.ElemContainer(); - $.jqplot.CanvasAxisTickRenderer.prototype.constructor = $.jqplot.CanvasAxisTickRenderer; $.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) { $.extend(true, this, options); @@ -209,7 +202,7 @@ // Memory Leaks patch if (this._elem) { - if ($.jqplot.use_excanvas) { + if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) { window.G_vmlCanvasManager.uninitElement(this._elem.get(0)); } diff --git a/libs/jqplot/plugins/jqplot.canvasTextRenderer.js b/libs/jqplot/plugins/jqplot.canvasTextRenderer.js index 95c19b303f..fd99e852df 100644 --- a/libs/jqplot/plugins/jqplot.canvasTextRenderer.js +++ b/libs/jqplot/plugins/jqplot.canvasTextRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -25,8 +26,36 @@ * http://hexmen.com/js/sprintf.js * The author (Ash Searle) has placed this code in the public domain: * "This code is unrestricted: you are free to use it however you like." + * + * included jsDate library by Chris Leonello: + * + * Copyright (c) 2010-2013 Chris Leonello + * + * jsDate is currently available for use in all personal or commercial projects + * under both the MIT and GPL version 2.0 licenses. This means that you can + * choose the license that best suits your project and use it accordingly. + * + * jsDate borrows many concepts and ideas from the Date Instance + * Methods by Ken Snyder along with some parts of Ken's actual code. + * + * Ken's origianl Date Instance Methods and copyright notice: + * + * Ken Snyder (ken d snyder at gmail dot com) + * 2008-09-10 + * version 2.0.2 (http://kendsnyder.com/sandbox/date/) + * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/) + * + * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js. + * Larry has generously given permission to adapt his code for inclusion + * into jqPlot. + * + * Larry's original code can be found here: + * + * https://github.com/lsiden/export-jqplot-to-png + * * */ + (function($) { // This code is a modified version of the canvastext.js code, copyright below: // diff --git a/libs/jqplot/plugins/jqplot.categoryAxisRenderer.js b/libs/jqplot/plugins/jqplot.categoryAxisRenderer.js index e9dc176c55..33914c3fdc 100644 --- a/libs/jqplot/plugins/jqplot.categoryAxisRenderer.js +++ b/libs/jqplot/plugins/jqplot.categoryAxisRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -69,6 +70,7 @@ this._groupLabels = []; this._grouped = false; this._barsPerGroup = null; + this.reverse = false; // prop: tickRenderer // A class of a rendering engine for creating the ticks labels displayed on the plot, // See <$.jqplot.AxisTickRenderer>. @@ -259,7 +261,7 @@ var track = 0; // todo: adjust this so more ticks displayed. - var maxVisibleTicks = parseInt(3+dim/20, 10); + var maxVisibleTicks = parseInt(3+dim/10, 10); var skip = parseInt(numcats/maxVisibleTicks, 10); if (this.tickInterval == null) { @@ -328,7 +330,7 @@ this.labelOptions.axis = this.name; this._label = new this.labelRenderer(this.labelOptions); if (this._label.show) { - var elem = this._label.draw(ctx); + var elem = this._label.draw(ctx, plot); elem.appendTo(this._elem); } @@ -440,32 +442,67 @@ var pixellength = offmax - offmin; var unitlength = max - min; - // point to unit and unit to point conversions references to Plot DOM element top left corner. - this.p2u = function(p){ - return (p - offmin) * unitlength / pixellength + min; - }; - - this.u2p = function(u){ - return (u - min) * pixellength / unitlength + offmin; - }; - - if (this.name == 'xaxis' || this.name == 'x2axis'){ - this.series_u2p = function(u){ - return (u - min) * pixellength / unitlength; + if (!this.reverse) { + // point to unit and unit to point conversions references to Plot DOM element top left corner. + + this.u2p = function(u){ + return (u - min) * pixellength / unitlength + offmin; }; - this.series_p2u = function(p){ - return p * unitlength / pixellength + min; + + this.p2u = function(p){ + return (p - offmin) * unitlength / pixellength + min; }; + + if (this.name == 'xaxis' || this.name == 'x2axis'){ + this.series_u2p = function(u){ + return (u - min) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + min; + }; + } + + else { + this.series_u2p = function(u){ + return (u - max) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + max; + }; + } } - + else { - this.series_u2p = function(u){ - return (u - max) * pixellength / unitlength; + // point to unit and unit to point conversions references to Plot DOM element top left corner. + + this.u2p = function(u){ + return offmin + (max - u) * pixellength / unitlength; }; - this.series_p2u = function(p){ - return p * unitlength / pixellength + max; + + this.p2u = function(p){ + return min + (p - offmin) * unitlength / pixellength; }; + + if (this.name == 'xaxis' || this.name == 'x2axis'){ + this.series_u2p = function(u){ + return (max - u) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + max; + }; + } + + else { + this.series_u2p = function(u){ + return (min - u) * pixellength / unitlength; + }; + this.series_p2u = function(p){ + return p * unitlength / pixellength + min; + }; + } + } + if (this.show) { if (this.name == 'xaxis' || this.name == 'x2axis') { diff --git a/libs/jqplot/plugins/jqplot.pieRenderer.js b/libs/jqplot/plugins/jqplot.pieRenderer.js index 141059bd6c..50ffdb9f6a 100644 --- a/libs/jqplot/plugins/jqplot.pieRenderer.js +++ b/libs/jqplot/plugins/jqplot.pieRenderer.js @@ -3,8 +3,9 @@ * Pure JavaScript plotting plugin using jQuery * * Version: @VERSION + * Revision: @REVISION * - * Copyright (c) 2009-2011 Chris Leonello + * Copyright (c) 2009-2013 Chris Leonello * jqPlot is currently available for use in all personal or commercial projects * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can @@ -122,7 +123,7 @@ // Format string for data labels. If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage. this.dataLabelFormatString = null; // prop: dataLabelThreshold - // Threshhold in percentage (0 - 100) of pie area, below which no label will be displayed. + // Threshhold in percentage (0-100) of pie area, below which no label will be displayed. // This applies to all label types, not just to percentage labels. this.dataLabelThreshold = 3; // prop: dataLabelPositionFactor @@ -670,17 +671,18 @@ td1 = $(document.createElement('td')); - td1.addClass('jqplot-table-legend'); + td1.addClass('jqplot-table-legend jqplot-table-legend-swatch'); td1.css({textAlign: 'center', paddingTop: rs}); div0 = $(document.createElement('div')); + div0.addClass('jqplot-table-legend-swatch-outline'); div1 = $(document.createElement('div')); div1.addClass('jqplot-table-legend-swatch'); div1.css({backgroundColor: color, borderColor: color}); td1.append(div0.append(div1)); td2 = $(document.createElement('td')); - td2.addClass('jqplot-table-legend'); + td2.addClass('jqplot-table-legend jqplot-table-legend-label'); td2.css('paddingTop', rs); if (this.escapeHtml){ @@ -761,14 +763,13 @@ } } } - this.target.bind('mouseout', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); } // called with scope of plot function postParseOptions(options) { for (var i=0; i<this.series.length; i++) { this.series[i].seriesColors = this.seriesColors; - this.series[i].colorGenerator = this.colorGenerator; + this.series[i].colorGenerator = $.jqplot.colorGenerator; } } @@ -800,6 +801,7 @@ plot.target.trigger(evt1, ins); if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -816,6 +818,7 @@ var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) { var evt = jQuery.Event('jqplotDataHighlight'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -838,6 +841,7 @@ if (neighbor) { var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data]; var evt = jQuery.Event('jqplotDataClick'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -852,6 +856,7 @@ unhighlight(plot); } var evt = jQuery.Event('jqplotDataRightClick'); + evt.which = ev.which; evt.pageX = ev.pageX; evt.pageY = ev.pageY; plot.target.trigger(evt, ins); @@ -882,6 +887,7 @@ } var hctx = this.plugins.pieRenderer.highlightCanvas.setContext(); + this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); }); } $.jqplot.preInitHooks.push(preInit); |