jquery_cheats 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/app/assets/javascripts/jquery_cheats/jquery_cheats.js +1 -1
- data/app/assets/javascripts/jquery_cheats/replacementContextMenu.js +62 -0
- data/jquery_cheats.gemspec +2 -2
- data/lib/jquery_cheats/jquery_cheats.rb +58 -0
- data/vendor/assets/javascripts/jqplot/excanvas.js +1438 -0
- data/vendor/assets/javascripts/jqplot/jquery.jqplot.js +10901 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.BezierCurveRenderer.js +312 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.BezierCurveRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.barRenderer.js +747 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.barRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.blockRenderer.js +234 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.blockRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.bubbleRenderer.js +754 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.bubbleRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js +202 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisTickRenderer.js +242 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasOverlay.js +864 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasOverlay.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasTextRenderer.js +448 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.canvasTextRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.categoryAxisRenderer.js +636 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.categoryAxisRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.ciParser.js +115 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.ciParser.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.cursor.js +1093 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.cursor.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.dateAxisRenderer.js +702 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.dateAxisRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.donutRenderer.js +800 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.donutRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.dragable.js +224 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.dragable.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.enhancedLegendRenderer.js +241 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.funnelRenderer.js +938 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.funnelRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.highlighter.js +454 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.highlighter.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.json2.js +475 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.json2.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.logAxisRenderer.js +528 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.logAxisRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoAxisRenderer.js +610 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoRenderer.js +436 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.mekkoRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.meterGaugeRenderer.js +1029 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.meterGaugeRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.ohlcRenderer.js +372 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.ohlcRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pieRenderer.js +899 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pieRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pointLabels.js +362 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pointLabels.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidAxisRenderer.js +730 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidGridRenderer.js +423 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidGridRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidRenderer.js +490 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.pyramidRenderer.min.js +57 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.trendline.js +222 -0
- data/vendor/assets/javascripts/jqplot/plugins/jqplot.trendline.min.js +57 -0
- data/vendor/assets/javascripts/jquery_cheats/spinjs/spin.min.js +1 -1
- data/vendor/assets/stylesheets/jquery.jqplot.css +259 -0
- metadata +66 -3
@@ -0,0 +1,57 @@
|
|
1
|
+
/**
|
2
|
+
* jqPlot
|
3
|
+
* Pure JavaScript plotting plugin using jQuery
|
4
|
+
*
|
5
|
+
* Version: 1.0.0b2_r1012
|
6
|
+
*
|
7
|
+
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
+
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
+
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
+
* choose the license that best suits your project and use it accordingly.
|
12
|
+
*
|
13
|
+
* Although not required, the author would appreciate an email letting him
|
14
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
+
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
+
*
|
17
|
+
* If you are feeling kind and generous, consider supporting the project by
|
18
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
+
*
|
20
|
+
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
+
*
|
22
|
+
* version 2007.04.27
|
23
|
+
* author Ash Searle
|
24
|
+
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
+
* http://hexmen.com/js/sprintf.js
|
26
|
+
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
+
* "This code is unrestricted: you are free to use it however you like."
|
28
|
+
*
|
29
|
+
* included jsDate library by Chris Leonello:
|
30
|
+
*
|
31
|
+
* Copyright (c) 2010-2011 Chris Leonello
|
32
|
+
*
|
33
|
+
* jsDate is currently available for use in all personal or commercial projects
|
34
|
+
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
35
|
+
* choose the license that best suits your project and use it accordingly.
|
36
|
+
*
|
37
|
+
* jsDate borrows many concepts and ideas from the Date Instance
|
38
|
+
* Methods by Ken Snyder along with some parts of Ken's actual code.
|
39
|
+
*
|
40
|
+
* Ken's origianl Date Instance Methods and copyright notice:
|
41
|
+
*
|
42
|
+
* Ken Snyder (ken d snyder at gmail dot com)
|
43
|
+
* 2008-09-10
|
44
|
+
* version 2.0.2 (http://kendsnyder.com/sandbox/date/)
|
45
|
+
* Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
|
46
|
+
*
|
47
|
+
* jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
|
48
|
+
* Larry has generously given permission to adapt his code for inclusion
|
49
|
+
* into jqPlot.
|
50
|
+
*
|
51
|
+
* Larry's original code can be found here:
|
52
|
+
*
|
53
|
+
* https://github.com/lsiden/export-jqplot-to-png
|
54
|
+
*
|
55
|
+
*
|
56
|
+
*/
|
57
|
+
(function(j){j.jqplot.Cursor=function(q){this.style="crosshair";this.previousCursor="auto";this.show=j.jqplot.config.enablePlugins;this.showTooltip=true;this.followMouse=false;this.tooltipLocation="se";this.tooltipOffset=6;this.showTooltipGridPosition=false;this.showTooltipUnitPosition=true;this.showTooltipDataPosition=false;this.tooltipFormatString="%.4P, %.4P";this.useAxesFormatters=true;this.tooltipAxisGroups=[];this.zoom=false;this.zoomProxy=false;this.zoomTarget=false;this.looseZoom=true;this.clickReset=false;this.dblClickReset=true;this.showVerticalLine=false;this.showHorizontalLine=false;this.constrainZoomTo="none";this.shapeRenderer=new j.jqplot.ShapeRenderer();this._zoom={start:[],end:[],started:false,zooming:false,isZoomed:false,axes:{start:{},end:{}},gridpos:{},datapos:{}};this._tooltipElem;this.zoomCanvas;this.cursorCanvas;this.intersectionThreshold=2;this.showCursorLegend=false;this.cursorLegendFormatString=j.jqplot.Cursor.cursorLegendFormatString;this._oldHandlers={onselectstart:null,ondrag:null,onmousedown:null};this.constrainOutsideZoom=true;this.showTooltipOutsideZoom=false;this.onGrid=false;j.extend(true,this,q)};j.jqplot.Cursor.cursorLegendFormatString="%s x:%s, y:%s";j.jqplot.Cursor.init=function(t,s,r){var q=r||{};this.plugins.cursor=new j.jqplot.Cursor(q.cursor);var u=this.plugins.cursor;if(u.show){j.jqplot.eventListenerHooks.push(["jqplotMouseEnter",b]);j.jqplot.eventListenerHooks.push(["jqplotMouseLeave",f]);j.jqplot.eventListenerHooks.push(["jqplotMouseMove",i]);if(u.showCursorLegend){r.legend=r.legend||{};r.legend.renderer=j.jqplot.CursorLegendRenderer;r.legend.formatString=this.plugins.cursor.cursorLegendFormatString;r.legend.show=true}if(u.zoom){j.jqplot.eventListenerHooks.push(["jqplotMouseDown",a]);if(u.clickReset){j.jqplot.eventListenerHooks.push(["jqplotClick",k])}if(u.dblClickReset){j.jqplot.eventListenerHooks.push(["jqplotDblClick",c])}}this.resetZoom=function(){var x=this.axes;if(!u.zoomProxy){for(var w in x){x[w].reset();x[w]._ticks=[];if(u._zoom.axes[w]!==undefined){x[w]._autoFormatString=u._zoom.axes[w].tickFormatString}}this.redraw()}else{var v=this.plugins.cursor.zoomCanvas._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height);v=null}this.plugins.cursor._zoom.isZoomed=false;this.target.trigger("jqplotResetZoom",[this,this.plugins.cursor])};if(u.showTooltipDataPosition){u.showTooltipUnitPosition=false;u.showTooltipGridPosition=false;if(q.cursor.tooltipFormatString==undefined){u.tooltipFormatString=j.jqplot.Cursor.cursorLegendFormatString}}}};j.jqplot.Cursor.postDraw=function(){var x=this.plugins.cursor;if(x.zoomCanvas){x.zoomCanvas.resetCanvas();x.zoomCanvas=null}if(x.cursorCanvas){x.cursorCanvas.resetCanvas();x.cursorCanvas=null}if(x._tooltipElem){x._tooltipElem.emptyForce();x._tooltipElem=null}if(x.zoom){x.zoomCanvas=new j.jqplot.GenericCanvas();this.eventCanvas._elem.before(x.zoomCanvas.createElement(this._gridPadding,"jqplot-zoom-canvas",this._plotDimensions,this));x.zoomCanvas.setContext()}var v=document.createElement("div");x._tooltipElem=j(v);v=null;x._tooltipElem.addClass("jqplot-cursor-tooltip");x._tooltipElem.css({position:"absolute",display:"none"});if(x.zoomCanvas){x.zoomCanvas._elem.before(x._tooltipElem)}else{this.eventCanvas._elem.before(x._tooltipElem)}if(x.showVerticalLine||x.showHorizontalLine){x.cursorCanvas=new j.jqplot.GenericCanvas();this.eventCanvas._elem.before(x.cursorCanvas.createElement(this._gridPadding,"jqplot-cursor-canvas",this._plotDimensions,this));x.cursorCanvas.setContext()}if(x.showTooltipUnitPosition){if(x.tooltipAxisGroups.length===0){var t=this.series;var u;var q=[];for(var r=0;r<t.length;r++){u=t[r];var w=u.xaxis+","+u.yaxis;if(j.inArray(w,q)==-1){q.push(w)}}for(var r=0;r<q.length;r++){x.tooltipAxisGroups.push(q[r].split(","))}}}};j.jqplot.Cursor.zoomProxy=function(v,r){var q=v.plugins.cursor;var u=r.plugins.cursor;q.zoomTarget=true;q.zoom=true;q.style="auto";q.dblClickReset=false;u.zoom=true;u.zoomProxy=true;r.target.bind("jqplotZoom",t);r.target.bind("jqplotResetZoom",s);function t(x,w,z,y,A){q.doZoom(w,z,v,A)}function s(w,x,y){v.resetZoom()}};j.jqplot.Cursor.prototype.resetZoom=function(u,v){var t=u.axes;var s=v._zoom.axes;if(!u.plugins.cursor.zoomProxy&&v._zoom.isZoomed){for(var r in t){t[r].reset();t[r]._ticks=[];t[r]._autoFormatString=s[r].tickFormatString}u.redraw();v._zoom.isZoomed=false}else{var q=v.zoomCanvas._ctx;q.clearRect(0,0,q.canvas.width,q.canvas.height);q=null}u.target.trigger("jqplotResetZoom",[u,v])};j.jqplot.Cursor.resetZoom=function(q){q.resetZoom()};j.jqplot.Cursor.prototype.doZoom=function(G,t,C,u){var I=u;var F=C.axes;var r=I._zoom.axes;var w=r.start;var s=r.end;var B,E,z,D,v,x,q,H,J;var A=C.plugins.cursor.zoomCanvas._ctx;if((I.constrainZoomTo=="none"&&Math.abs(G.x-I._zoom.start[0])>6&&Math.abs(G.y-I._zoom.start[1])>6)||(I.constrainZoomTo=="x"&&Math.abs(G.x-I._zoom.start[0])>6)||(I.constrainZoomTo=="y"&&Math.abs(G.y-I._zoom.start[1])>6)){if(!C.plugins.cursor.zoomProxy){for(var y in t){if(I._zoom.axes[y]==undefined){I._zoom.axes[y]={};I._zoom.axes[y].numberTicks=F[y].numberTicks;I._zoom.axes[y].tickInterval=F[y].tickInterval;I._zoom.axes[y].daTickInterval=F[y].daTickInterval;I._zoom.axes[y].min=F[y].min;I._zoom.axes[y].max=F[y].max;I._zoom.axes[y].tickFormatString=(F[y].tickOptions!=null)?F[y].tickOptions.formatString:""}if((I.constrainZoomTo=="none")||(I.constrainZoomTo=="x"&&y.charAt(0)=="x")||(I.constrainZoomTo=="y"&&y.charAt(0)=="y")){z=t[y];if(z!=null){if(z>w[y]){v=w[y];x=z}else{D=w[y]-z;v=z;x=w[y]}q=F[y];H=null;if(q.alignTicks){if(q.name==="x2axis"&&C.axes.xaxis.show){H=C.axes.xaxis.numberTicks}else{if(q.name.charAt(0)==="y"&&q.name!=="yaxis"&&q.name!=="yMidAxis"&&C.axes.yaxis.show){H=C.axes.yaxis.numberTicks}}}if(this.looseZoom&&(F[y].renderer.constructor===j.jqplot.LinearAxisRenderer||F[y].renderer.constructor===j.jqplot.LogAxisRenderer)){J=j.jqplot.LinearTickGenerator(v,x,q._scalefact,H);if(F[y].tickInset&&J[0]<F[y].min+F[y].tickInset*F[y].tickInterval){J[0]+=J[4];J[2]-=1}if(F[y].tickInset&&J[1]>F[y].max-F[y].tickInset*F[y].tickInterval){J[1]-=J[4];J[2]-=1}if(F[y].renderer.constructor===j.jqplot.LogAxisRenderer&&J[0]<F[y].min){J[0]+=J[4];J[2]-=1}F[y].min=J[0];F[y].max=J[1];F[y]._autoFormatString=J[3];F[y].numberTicks=J[2];F[y].tickInterval=J[4];F[y].daTickInterval=[J[4]/1000,"seconds"]}else{F[y].min=v;F[y].max=x;F[y].tickInterval=null;F[y].numberTicks=null;F[y].daTickInterval=null}F[y]._ticks=[]}}}A.clearRect(0,0,A.canvas.width,A.canvas.height);C.redraw();I._zoom.isZoomed=true;A=null}C.target.trigger("jqplotZoom",[G,t,C,u])}};j.jqplot.preInitHooks.push(j.jqplot.Cursor.init);j.jqplot.postDrawHooks.push(j.jqplot.Cursor.postDraw);function e(E,r,B){var G=B.plugins.cursor;var w="";var K=false;if(G.showTooltipGridPosition){w=E.x+", "+E.y;K=true}if(G.showTooltipUnitPosition){var D;for(var C=0;C<G.tooltipAxisGroups.length;C++){D=G.tooltipAxisGroups[C];if(K){w+="<br />"}if(G.useAxesFormatters){var A=B.axes[D[0]]._ticks[0].formatter;var q=B.axes[D[1]]._ticks[0].formatter;var H=B.axes[D[0]]._ticks[0].formatString;var v=B.axes[D[1]]._ticks[0].formatString;w+=A(H,r[D[0]])+", "+q(v,r[D[1]])}else{w+=j.jqplot.sprintf(G.tooltipFormatString,r[D[0]],r[D[1]])}K=true}}if(G.showTooltipDataPosition){var u=B.series;var J=d(B,E.x,E.y);var K=false;for(var C=0;C<u.length;C++){if(u[C].show){var y=u[C].index;var t=u[C].label.toString();var F=j.inArray(y,J.indices);var z=undefined;var x=undefined;if(F!=-1){var I=J.data[F].data;if(G.useAxesFormatters){var A=u[C]._xaxis._ticks[0].formatter;var q=u[C]._yaxis._ticks[0].formatter;var H=u[C]._xaxis._ticks[0].formatString;var v=u[C]._yaxis._ticks[0].formatString;z=A(H,I[0]);x=q(v,I[1])}else{z=I[0];x=I[1]}if(K){w+="<br />"}w+=j.jqplot.sprintf(G.tooltipFormatString,t,z,x);K=true}}}}G._tooltipElem.html(w)}function g(C,A){var E=A.plugins.cursor;var z=E.cursorCanvas._ctx;z.clearRect(0,0,z.canvas.width,z.canvas.height);if(E.showVerticalLine){E.shapeRenderer.draw(z,[[C.x,0],[C.x,z.canvas.height]])}if(E.showHorizontalLine){E.shapeRenderer.draw(z,[[0,C.y],[z.canvas.width,C.y]])}var G=d(A,C.x,C.y);if(E.showCursorLegend){var r=j(A.targetId+" td.jqplot-cursor-legend-label");for(var B=0;B<r.length;B++){var v=j(r[B]).data("seriesIndex");var t=A.series[v];var s=t.label.toString();var D=j.inArray(v,G.indices);var x=undefined;var w=undefined;if(D!=-1){var H=G.data[D].data;if(E.useAxesFormatters){var y=t._xaxis._ticks[0].formatter;var q=t._yaxis._ticks[0].formatter;var F=t._xaxis._ticks[0].formatString;var u=t._yaxis._ticks[0].formatString;x=y(F,H[0]);w=q(u,H[1])}else{x=H[0];w=H[1]}}if(A.legend.escapeHtml){j(r[B]).text(j.jqplot.sprintf(E.cursorLegendFormatString,s,x,w))}else{j(r[B]).html(j.jqplot.sprintf(E.cursorLegendFormatString,s,x,w))}}}z=null}function d(A,F,E){var B={indices:[],data:[]};var G,w,u,C,v,q,t;var z;var D=A.plugins.cursor;for(var w=0;w<A.series.length;w++){G=A.series[w];q=G.renderer;if(G.show){z=D.intersectionThreshold;if(G.showMarker){z+=G.markerRenderer.size/2}for(var v=0;v<G.gridData.length;v++){t=G.gridData[v];if(D.showVerticalLine){if(Math.abs(F-t[0])<=z){B.indices.push(w);B.data.push({seriesIndex:w,pointIndex:v,gridData:t,data:G.data[v]})}}}}}return B}function n(r,t){var v=t.plugins.cursor;var s=v._tooltipElem;switch(v.tooltipLocation){case"nw":var q=r.x+t._gridPadding.left-s.outerWidth(true)-v.tooltipOffset;var u=r.y+t._gridPadding.top-v.tooltipOffset-s.outerHeight(true);break;case"n":var q=r.x+t._gridPadding.left-s.outerWidth(true)/2;var u=r.y+t._gridPadding.top-v.tooltipOffset-s.outerHeight(true);break;case"ne":var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top-v.tooltipOffset-s.outerHeight(true);break;case"e":var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top-s.outerHeight(true)/2;break;case"se":var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top+v.tooltipOffset;break;case"s":var q=r.x+t._gridPadding.left-s.outerWidth(true)/2;var u=r.y+t._gridPadding.top+v.tooltipOffset;break;case"sw":var q=r.x+t._gridPadding.left-s.outerWidth(true)-v.tooltipOffset;var u=r.y+t._gridPadding.top+v.tooltipOffset;break;case"w":var q=r.x+t._gridPadding.left-s.outerWidth(true)-v.tooltipOffset;var u=r.y+t._gridPadding.top-s.outerHeight(true)/2;break;default:var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top+v.tooltipOffset;break}s.css("left",q);s.css("top",u);s=null}function m(u){var s=u._gridPadding;var v=u.plugins.cursor;var t=v._tooltipElem;switch(v.tooltipLocation){case"nw":var r=s.left+v.tooltipOffset;var q=s.top+v.tooltipOffset;t.css("left",r);t.css("top",q);break;case"n":var r=(s.left+(u._plotDimensions.width-s.right))/2-t.outerWidth(true)/2;var q=s.top+v.tooltipOffset;t.css("left",r);t.css("top",q);break;case"ne":var r=s.right+v.tooltipOffset;var q=s.top+v.tooltipOffset;t.css({right:r,top:q});break;case"e":var r=s.right+v.tooltipOffset;var q=(s.top+(u._plotDimensions.height-s.bottom))/2-t.outerHeight(true)/2;t.css({right:r,top:q});break;case"se":var r=s.right+v.tooltipOffset;var q=s.bottom+v.tooltipOffset;t.css({right:r,bottom:q});break;case"s":var r=(s.left+(u._plotDimensions.width-s.right))/2-t.outerWidth(true)/2;var q=s.bottom+v.tooltipOffset;t.css({left:r,bottom:q});break;case"sw":var r=s.left+v.tooltipOffset;var q=s.bottom+v.tooltipOffset;t.css({left:r,bottom:q});break;case"w":var r=s.left+v.tooltipOffset;var q=(s.top+(u._plotDimensions.height-s.bottom))/2-t.outerHeight(true)/2;t.css({left:r,top:q});break;default:var r=s.right-v.tooltipOffset;var q=s.bottom+v.tooltipOffset;t.css({right:r,bottom:q});break}t=null}function k(r,q,v,u,t){r.preventDefault();r.stopImmediatePropagation();var w=t.plugins.cursor;if(w.clickReset){w.resetZoom(t,w)}var s=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(s&&!s().isCollapsed){s().collapse()}}return false}function c(r,q,v,u,t){r.preventDefault();r.stopImmediatePropagation();var w=t.plugins.cursor;if(w.dblClickReset){w.resetZoom(t,w)}var s=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(s&&!s().isCollapsed){s().collapse()}}return false}function f(w,t,q,z,u){var v=u.plugins.cursor;v.onGrid=false;if(v.show){j(w.target).css("cursor",v.previousCursor);if(v.showTooltip&&!(v._zoom.zooming&&v.showTooltipOutsideZoom&&!v.constrainOutsideZoom)){v._tooltipElem.hide()}if(v.zoom){v._zoom.gridpos=t;v._zoom.datapos=q}if(v.showVerticalLine||v.showHorizontalLine){var B=v.cursorCanvas._ctx;B.clearRect(0,0,B.canvas.width,B.canvas.height);B=null}if(v.showCursorLegend){var A=j(u.targetId+" td.jqplot-cursor-legend-label");for(var s=0;s<A.length;s++){var y=j(A[s]).data("seriesIndex");var r=u.series[y];var x=r.label.toString();if(u.legend.escapeHtml){j(A[s]).text(j.jqplot.sprintf(v.cursorLegendFormatString,x,undefined,undefined))}else{j(A[s]).html(j.jqplot.sprintf(v.cursorLegendFormatString,x,undefined,undefined))}}}}}function b(r,q,u,t,s){var v=s.plugins.cursor;v.onGrid=true;if(v.show){v.previousCursor=r.target.style.cursor;r.target.style.cursor=v.style;if(v.showTooltip){e(q,u,s);if(v.followMouse){n(q,s)}else{m(s)}v._tooltipElem.show()}if(v.showVerticalLine||v.showHorizontalLine){g(q,s)}}}function i(r,q,u,t,s){var v=s.plugins.cursor;if(v.show){if(v.showTooltip){e(q,u,s);if(v.followMouse){n(q,s)}}if(v.showVerticalLine||v.showHorizontalLine){g(q,s)}}}function o(y){var x=y.data.plot;var t=x.eventCanvas._elem.offset();var w={x:y.pageX-t.left,y:y.pageY-t.top};var u={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 v=["xaxis","yaxis","x2axis","y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis","yMidAxis"];var q=x.axes;var r,s;for(r=11;r>0;r--){s=v[r-1];if(q[s].show){u[s]=q[s].series_p2u(w[s.charAt(0)])}}return{offsets:t,gridPos:w,dataPos:u}}function h(z){var x=z.data.plot;var y=x.plugins.cursor;if(y.show&&y.zoom&&y._zoom.started&&!y.zoomTarget){var B=y.zoomCanvas._ctx;var v=o(z);var w=v.gridPos;var t=v.dataPos;y._zoom.gridpos=w;y._zoom.datapos=t;y._zoom.zooming=true;var u=w.x;var s=w.y;var A=B.canvas.height;var q=B.canvas.width;if(y.showTooltip&&!y.onGrid&&y.showTooltipOutsideZoom){e(w,t,x);if(y.followMouse){n(w,x)}}if(y.constrainZoomTo=="x"){y._zoom.end=[u,A]}else{if(y.constrainZoomTo=="y"){y._zoom.end=[q,s]}else{y._zoom.end=[u,s]}}var r=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(r&&!r().isCollapsed){r().collapse()}}l.call(y);B=null}}function a(w,s,r,x,t){var v=t.plugins.cursor;j(document).one("mouseup.jqplot_cursor",{plot:t},p);var u=t.axes;if(document.onselectstart!=undefined){v._oldHandlers.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!=undefined){v._oldHandlers.ondrag=document.ondrag;document.ondrag=function(){return false}}if(document.onmousedown!=undefined){v._oldHandlers.onmousedown=document.onmousedown;document.onmousedown=function(){return false}}if(v.zoom){if(!v.zoomProxy){var y=v.zoomCanvas._ctx;y.clearRect(0,0,y.canvas.width,y.canvas.height);y=null}if(v.constrainZoomTo=="x"){v._zoom.start=[s.x,0]}else{if(v.constrainZoomTo=="y"){v._zoom.start=[0,s.y]}else{v._zoom.start=[s.x,s.y]}}v._zoom.started=true;for(var q in r){v._zoom.axes.start[q]=r[q]}j(document).bind("mousemove.jqplotCursor",{plot:t},h)}}function p(y){var v=y.data.plot;var x=v.plugins.cursor;if(x.zoom&&x._zoom.zooming&&!x.zoomTarget){var u=x._zoom.gridpos.x;var r=x._zoom.gridpos.y;var t=x._zoom.datapos;var z=x.zoomCanvas._ctx.canvas.height;var q=x.zoomCanvas._ctx.canvas.width;var w=v.axes;if(x.constrainOutsideZoom&&!x.onGrid){if(u<0){u=0}else{if(u>q){u=q}}if(r<0){r=0}else{if(r>z){r=z}}for(var s in t){if(t[s]){if(s.charAt(0)=="x"){t[s]=w[s].series_p2u(u)}else{t[s]=w[s].series_p2u(r)}}}}if(x.constrainZoomTo=="x"){r=z}else{if(x.constrainZoomTo=="y"){u=q}}x._zoom.end=[u,r];x._zoom.gridpos={x:u,y:r};x.doZoom(x._zoom.gridpos,t,v,x)}x._zoom.started=false;x._zoom.zooming=false;j(document).unbind("mousemove.jqplotCursor",h);if(document.onselectstart!=undefined&&x._oldHandlers.onselectstart!=null){document.onselectstart=x._oldHandlers.onselectstart;x._oldHandlers.onselectstart=null}if(document.ondrag!=undefined&&x._oldHandlers.ondrag!=null){document.ondrag=x._oldHandlers.ondrag;x._oldHandlers.ondrag=null}if(document.onmousedown!=undefined&&x._oldHandlers.onmousedown!=null){document.onmousedown=x._oldHandlers.onmousedown;x._oldHandlers.onmousedown=null}}function l(){var y=this._zoom.start;var u=this._zoom.end;var s=this.zoomCanvas._ctx;var r,v,x,q;if(u[0]>y[0]){r=y[0];q=u[0]-y[0]}else{r=u[0];q=y[0]-u[0]}if(u[1]>y[1]){v=y[1];x=u[1]-y[1]}else{v=u[1];x=y[1]-u[1]}s.fillStyle="rgba(0,0,0,0.2)";s.strokeStyle="#999999";s.lineWidth=1;s.clearRect(0,0,s.canvas.width,s.canvas.height);s.fillRect(0,0,s.canvas.width,s.canvas.height);s.clearRect(r,v,q,x);s.strokeRect(r,v,q,x);s=null}j.jqplot.CursorLegendRenderer=function(q){j.jqplot.TableLegendRenderer.call(this,q);this.formatString="%s"};j.jqplot.CursorLegendRenderer.prototype=new j.jqplot.TableLegendRenderer();j.jqplot.CursorLegendRenderer.prototype.constructor=j.jqplot.CursorLegendRenderer;j.jqplot.CursorLegendRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}if(this.show){var w=this._series,A;var r=document.createElement("div");this._elem=j(r);r=null;this._elem.addClass("jqplot-legend jqplot-cursor-legend");this._elem.css("position","absolute");var q=false;for(var x=0;x<w.length;x++){A=w[x];if(A.show&&A.showLabel){var v=j.jqplot.sprintf(this.formatString,A.label.toString());if(v){var t=A.color;if(A._stack&&!A.fill){t=""}z.call(this,v,t,q,x);q=true}for(var u=0;u<j.jqplot.addLegendRowHooks.length;u++){var y=j.jqplot.addLegendRowHooks[u].call(this,A);if(y){z.call(this,y.label,y.color,q);q=true}}}}w=A=null;delete w;delete A}function z(D,C,F,s){var B=(F)?this.rowSpacing:"0";var E=j('<tr class="jqplot-legend jqplot-cursor-legend"></tr>').appendTo(this._elem);E.data("seriesIndex",s);j('<td class="jqplot-legend jqplot-cursor-legend-swatch" style="padding-top:'+B+';"><div style="border:1px solid #cccccc;padding:0.2em;"><div class="jqplot-cursor-legend-swatch" style="background-color:'+C+';"></div></div></td>').appendTo(E);var G=j('<td class="jqplot-legend jqplot-cursor-legend-label" style="vertical-align:middle;padding-top:'+B+';"></td>');G.appendTo(E);G.data("seriesIndex",s);if(this.escapeHtml){G.text(D)}else{G.html(D)}E=null;G=null}return this._elem}})(jQuery);
|
@@ -0,0 +1,702 @@
|
|
1
|
+
/**
|
2
|
+
* jqPlot
|
3
|
+
* Pure JavaScript plotting plugin using jQuery
|
4
|
+
*
|
5
|
+
* Version: 1.0.0b2_r1012
|
6
|
+
*
|
7
|
+
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
+
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
+
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
+
* choose the license that best suits your project and use it accordingly.
|
12
|
+
*
|
13
|
+
* Although not required, the author would appreciate an email letting him
|
14
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
+
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
+
*
|
17
|
+
* If you are feeling kind and generous, consider supporting the project by
|
18
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
+
*
|
20
|
+
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
+
*
|
22
|
+
* version 2007.04.27
|
23
|
+
* author Ash Searle
|
24
|
+
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
+
* http://hexmen.com/js/sprintf.js
|
26
|
+
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
+
* "This code is unrestricted: you are free to use it however you like."
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
(function($) {
|
31
|
+
/**
|
32
|
+
* Class: $.jqplot.DateAxisRenderer
|
33
|
+
* A plugin for a jqPlot to render an axis as a series of date values.
|
34
|
+
* This renderer has no options beyond those supplied by the <Axis> class.
|
35
|
+
* It supplies it's own tick formatter, so the tickOptions.formatter option
|
36
|
+
* should not be overridden.
|
37
|
+
*
|
38
|
+
* Thanks to Ken Synder for his enhanced Date instance methods which are
|
39
|
+
* included with this code <http://kendsnyder.com/sandbox/date/>.
|
40
|
+
*
|
41
|
+
* To use this renderer, include the plugin in your source
|
42
|
+
* > <script type="text/javascript" language="javascript" src="plugins/jqplot.dateAxisRenderer.js"></script>
|
43
|
+
*
|
44
|
+
* and supply the appropriate options to your plot
|
45
|
+
*
|
46
|
+
* > {axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}}}
|
47
|
+
*
|
48
|
+
* Dates can be passed into the axis in almost any recognizable value and
|
49
|
+
* will be parsed. They will be rendered on the axis in the format
|
50
|
+
* specified by tickOptions.formatString. e.g. tickOptions.formatString = '%Y-%m-%d'.
|
51
|
+
*
|
52
|
+
* Accecptable format codes
|
53
|
+
* are:
|
54
|
+
*
|
55
|
+
* > Code Result Description
|
56
|
+
* > == Years ==
|
57
|
+
* > %Y 2008 Four-digit year
|
58
|
+
* > %y 08 Two-digit year
|
59
|
+
* > == Months ==
|
60
|
+
* > %m 09 Two-digit month
|
61
|
+
* > %#m 9 One or two-digit month
|
62
|
+
* > %B September Full month name
|
63
|
+
* > %b Sep Abbreviated month name
|
64
|
+
* > == Days ==
|
65
|
+
* > %d 05 Two-digit day of month
|
66
|
+
* > %#d 5 One or two-digit day of month
|
67
|
+
* > %e 5 One or two-digit day of month
|
68
|
+
* > %A Sunday Full name of the day of the week
|
69
|
+
* > %a Sun Abbreviated name of the day of the week
|
70
|
+
* > %w 0 Number of the day of the week (0 = Sunday, 6 = Saturday)
|
71
|
+
* > %o th The ordinal suffix string following the day of the month
|
72
|
+
* > == Hours ==
|
73
|
+
* > %H 23 Hours in 24-hour format (two digits)
|
74
|
+
* > %#H 3 Hours in 24-hour integer format (one or two digits)
|
75
|
+
* > %I 11 Hours in 12-hour format (two digits)
|
76
|
+
* > %#I 3 Hours in 12-hour integer format (one or two digits)
|
77
|
+
* > %p PM AM or PM
|
78
|
+
* > == Minutes ==
|
79
|
+
* > %M 09 Minutes (two digits)
|
80
|
+
* > %#M 9 Minutes (one or two digits)
|
81
|
+
* > == Seconds ==
|
82
|
+
* > %S 02 Seconds (two digits)
|
83
|
+
* > %#S 2 Seconds (one or two digits)
|
84
|
+
* > %s 1206567625723 Unix timestamp (Seconds past 1970-01-01 00:00:00)
|
85
|
+
* > == Milliseconds ==
|
86
|
+
* > %N 008 Milliseconds (three digits)
|
87
|
+
* > %#N 8 Milliseconds (one to three digits)
|
88
|
+
* > == Timezone ==
|
89
|
+
* > %O 360 difference in minutes between local time and GMT
|
90
|
+
* > %Z Mountain Standard Time Name of timezone as reported by browser
|
91
|
+
* > %G -06:00 Hours and minutes between GMT
|
92
|
+
* > == Shortcuts ==
|
93
|
+
* > %F 2008-03-26 %Y-%m-%d
|
94
|
+
* > %T 05:06:30 %H:%M:%S
|
95
|
+
* > %X 05:06:30 %H:%M:%S
|
96
|
+
* > %x 03/26/08 %m/%d/%y
|
97
|
+
* > %D 03/26/08 %m/%d/%y
|
98
|
+
* > %#c Wed Mar 26 15:31:00 2008 %a %b %e %H:%M:%S %Y
|
99
|
+
* > %v 3-Sep-2008 %e-%b-%Y
|
100
|
+
* > %R 15:31 %H:%M
|
101
|
+
* > %r 3:31:00 PM %I:%M:%S %p
|
102
|
+
* > == Characters ==
|
103
|
+
* > %n \n Newline
|
104
|
+
* > %t \t Tab
|
105
|
+
* > %% % Percent Symbol
|
106
|
+
*/
|
107
|
+
$.jqplot.DateAxisRenderer = function() {
|
108
|
+
$.jqplot.LinearAxisRenderer.call(this);
|
109
|
+
this.date = new $.jsDate();
|
110
|
+
};
|
111
|
+
|
112
|
+
var second = 1000;
|
113
|
+
var minute = 60 * second;
|
114
|
+
var hour = 60 * minute;
|
115
|
+
var day = 24 * hour;
|
116
|
+
var week = 7 * day;
|
117
|
+
|
118
|
+
// these are less definitive
|
119
|
+
var month = 30.4368499 * day;
|
120
|
+
var year = 365.242199 * day;
|
121
|
+
|
122
|
+
var daysInMonths = [31,28,31,30,31,30,31,30,31,30,31,30];
|
123
|
+
// array of consistent nice intervals. Longer intervals
|
124
|
+
// will depend on days in month, days in year, etc.
|
125
|
+
var niceFormatStrings = ['%M:%S.%#N', '%M:%S.%#N', '%M:%S.%#N', '%M:%S', '%M:%S', '%M:%S', '%M:%S', '%H:%M:%S', '%H:%M:%S', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%a %H:%M', '%a %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%v', '%v', '%v', '%v', '%v', '%v', '%v'];
|
126
|
+
var niceIntervals = [0.1*second, 0.2*second, 0.5*second, second, 2*second, 5*second, 10*second, 15*second, 30*second, minute, 2*minute, 5*minute, 10*minute, 15*minute, 30*minute, hour, 2*hour, 4*hour, 6*hour, 8*hour, 12*hour, day, 2*day, 3*day, 4*day, 5*day, week, 2*week];
|
127
|
+
|
128
|
+
var niceMonthlyIntervals = [];
|
129
|
+
|
130
|
+
function bestDateInterval(min, max, titarget) {
|
131
|
+
// iterate through niceIntervals to find one closest to titarget
|
132
|
+
var badness = Number.MAX_VALUE;
|
133
|
+
var temp, bestTi, bestfmt;
|
134
|
+
for (var i=0, l=niceIntervals.length; i < l; i++) {
|
135
|
+
temp = Math.abs(titarget - niceIntervals[i]);
|
136
|
+
if (temp < badness) {
|
137
|
+
badness = temp;
|
138
|
+
bestTi = niceIntervals[i];
|
139
|
+
bestfmt = niceFormatStrings[i];
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
return [bestTi, bestfmt];
|
144
|
+
}
|
145
|
+
|
146
|
+
$.jqplot.DateAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
|
147
|
+
$.jqplot.DateAxisRenderer.prototype.constructor = $.jqplot.DateAxisRenderer;
|
148
|
+
|
149
|
+
$.jqplot.DateTickFormatter = function(format, val) {
|
150
|
+
if (!format) {
|
151
|
+
format = '%Y/%m/%d';
|
152
|
+
}
|
153
|
+
return $.jsDate.strftime(val, format);
|
154
|
+
};
|
155
|
+
|
156
|
+
$.jqplot.DateAxisRenderer.prototype.init = function(options){
|
157
|
+
// prop: tickRenderer
|
158
|
+
// A class of a rendering engine for creating the ticks labels displayed on the plot,
|
159
|
+
// See <$.jqplot.AxisTickRenderer>.
|
160
|
+
// this.tickRenderer = $.jqplot.AxisTickRenderer;
|
161
|
+
// this.labelRenderer = $.jqplot.AxisLabelRenderer;
|
162
|
+
this.tickOptions.formatter = $.jqplot.DateTickFormatter;
|
163
|
+
// prop: tickInset
|
164
|
+
// Controls the amount to inset the first and last ticks from
|
165
|
+
// the edges of the grid, in multiples of the tick interval.
|
166
|
+
// 0 is no inset, 0.5 is one half a tick interval, 1 is a full
|
167
|
+
// tick interval, etc.
|
168
|
+
this.tickInset = 0;
|
169
|
+
// prop: drawBaseline
|
170
|
+
// True to draw the axis baseline.
|
171
|
+
this.drawBaseline = true;
|
172
|
+
// prop: baselineWidth
|
173
|
+
// width of the baseline in pixels.
|
174
|
+
this.baselineWidth = null;
|
175
|
+
// prop: baselineColor
|
176
|
+
// CSS color spec for the baseline.
|
177
|
+
this.baselineColor = null;
|
178
|
+
this.daTickInterval = null;
|
179
|
+
this._daTickInterval = null;
|
180
|
+
|
181
|
+
$.extend(true, this, options);
|
182
|
+
|
183
|
+
var db = this._dataBounds,
|
184
|
+
stats,
|
185
|
+
sum,
|
186
|
+
s,
|
187
|
+
d,
|
188
|
+
pd,
|
189
|
+
sd,
|
190
|
+
intv;
|
191
|
+
|
192
|
+
// Go through all the series attached to this axis and find
|
193
|
+
// the min/max bounds for this axis.
|
194
|
+
for (var i=0; i<this._series.length; i++) {
|
195
|
+
stats = {intervals:[], frequencies:{}, sortedIntervals:[], min:null, max:null, mean:null};
|
196
|
+
sum = 0;
|
197
|
+
s = this._series[i];
|
198
|
+
d = s.data;
|
199
|
+
pd = s._plotData;
|
200
|
+
sd = s._stackData;
|
201
|
+
intv = 0;
|
202
|
+
|
203
|
+
for (var j=0; j<d.length; j++) {
|
204
|
+
if (this.name == 'xaxis' || this.name == 'x2axis') {
|
205
|
+
d[j][0] = new $.jsDate(d[j][0]).getTime();
|
206
|
+
pd[j][0] = new $.jsDate(d[j][0]).getTime();
|
207
|
+
sd[j][0] = new $.jsDate(d[j][0]).getTime();
|
208
|
+
if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) {
|
209
|
+
db.min = d[j][0];
|
210
|
+
}
|
211
|
+
if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) {
|
212
|
+
db.max = d[j][0];
|
213
|
+
}
|
214
|
+
if (j>0) {
|
215
|
+
intv = Math.abs(d[j][0] - d[j-1][0]);
|
216
|
+
stats.intervals.push(intv);
|
217
|
+
if (stats.frequencies.hasOwnProperty(intv)) {
|
218
|
+
stats.frequencies[intv] += 1;
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
stats.frequencies[intv] = 1;
|
222
|
+
}
|
223
|
+
}
|
224
|
+
sum += intv;
|
225
|
+
|
226
|
+
}
|
227
|
+
else {
|
228
|
+
d[j][1] = new $.jsDate(d[j][1]).getTime();
|
229
|
+
pd[j][1] = new $.jsDate(d[j][1]).getTime();
|
230
|
+
sd[j][1] = new $.jsDate(d[j][1]).getTime();
|
231
|
+
if ((d[j][1] != null && d[j][1] < db.min) || db.min == null) {
|
232
|
+
db.min = d[j][1];
|
233
|
+
}
|
234
|
+
if ((d[j][1] != null && d[j][1] > db.max) || db.max == null) {
|
235
|
+
db.max = d[j][1];
|
236
|
+
}
|
237
|
+
if (j>0) {
|
238
|
+
intv = Math.abs(d[j][1] - d[j-1][1]);
|
239
|
+
stats.intervals.push(intv);
|
240
|
+
if (stats.frequencies.hasOwnProperty(intv)) {
|
241
|
+
stats.frequencies[intv] += 1;
|
242
|
+
}
|
243
|
+
else {
|
244
|
+
stats.frequencies[intv] = 1;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
sum += intv;
|
249
|
+
}
|
250
|
+
|
251
|
+
if (s.renderer.bands) {
|
252
|
+
if (s.renderer.bands.hiData.length) {
|
253
|
+
var bd = s.renderer.bands.hiData;
|
254
|
+
for (var j=0, l=bd.length; j < l; j++) {
|
255
|
+
if (this.name === 'xaxis' || this.name === 'x2axis') {
|
256
|
+
bd[j][0] = new $.jsDate(bd[j][0]).getTime();
|
257
|
+
if ((bd[j][0] != null && bd[j][0] > db.max) || db.max == null) {
|
258
|
+
db.max = bd[j][0];
|
259
|
+
}
|
260
|
+
}
|
261
|
+
else {
|
262
|
+
bd[j][1] = new $.jsDate(bd[j][1]).getTime();
|
263
|
+
if ((bd[j][1] != null && bd[j][1] > db.max) || db.max == null) {
|
264
|
+
db.max = bd[j][1];
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}
|
269
|
+
if (s.renderer.bands.lowData.length) {
|
270
|
+
var bd = s.renderer.bands.lowData;
|
271
|
+
for (var j=0, l=bd.length; j < l; j++) {
|
272
|
+
if (this.name === 'xaxis' || this.name === 'x2axis') {
|
273
|
+
bd[j][0] = new $.jsDate(bd[j][0]).getTime();
|
274
|
+
if ((bd[j][0] != null && bd[j][0] < db.min) || db.min == null) {
|
275
|
+
db.min = bd[j][0];
|
276
|
+
}
|
277
|
+
}
|
278
|
+
else {
|
279
|
+
bd[j][1] = new $.jsDate(bd[j][1]).getTime();
|
280
|
+
if ((bd[j][1] != null && bd[j][1] < db.min) || db.min == null) {
|
281
|
+
db.min = bd[j][1];
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
var tempf = 0,
|
289
|
+
tempn=0;
|
290
|
+
for (var n in stats.frequencies) {
|
291
|
+
stats.sortedIntervals.push({interval:n, frequency:stats.frequencies[n]});
|
292
|
+
}
|
293
|
+
stats.sortedIntervals.sort(function(a, b){
|
294
|
+
return b.frequency - a.frequency;
|
295
|
+
});
|
296
|
+
|
297
|
+
stats.min = $.jqplot.arrayMin(stats.intervals);
|
298
|
+
stats.max = $.jqplot.arrayMax(stats.intervals);
|
299
|
+
stats.mean = sum/d.length;
|
300
|
+
this._intervalStats.push(stats);
|
301
|
+
stats = sum = s = d = pd = sd = null;
|
302
|
+
}
|
303
|
+
db = null;
|
304
|
+
|
305
|
+
};
|
306
|
+
|
307
|
+
// called with scope of an axis
|
308
|
+
$.jqplot.DateAxisRenderer.prototype.reset = function() {
|
309
|
+
this.min = this._options.min;
|
310
|
+
this.max = this._options.max;
|
311
|
+
this.tickInterval = this._options.tickInterval;
|
312
|
+
this.numberTicks = this._options.numberTicks;
|
313
|
+
this._autoFormatString = '';
|
314
|
+
if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
|
315
|
+
this.tickOptions.formatString = '';
|
316
|
+
}
|
317
|
+
this.daTickInterval = this._daTickInterval;
|
318
|
+
// this._ticks = this.__ticks;
|
319
|
+
};
|
320
|
+
|
321
|
+
$.jqplot.DateAxisRenderer.prototype.createTicks = function(plot) {
|
322
|
+
// we're are operating on an axis here
|
323
|
+
var ticks = this._ticks;
|
324
|
+
var userTicks = this.ticks;
|
325
|
+
var name = this.name;
|
326
|
+
// databounds were set on axis initialization.
|
327
|
+
var db = this._dataBounds;
|
328
|
+
var iv = this._intervalStats;
|
329
|
+
var dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height;
|
330
|
+
var interval;
|
331
|
+
var min, max;
|
332
|
+
var pos1, pos2;
|
333
|
+
var tt, i;
|
334
|
+
var threshold = 30;
|
335
|
+
var insetMult = 1;
|
336
|
+
|
337
|
+
var tickInterval = this.tickInterval;
|
338
|
+
|
339
|
+
// if we already have ticks, use them.
|
340
|
+
// ticks must be in order of increasing value.
|
341
|
+
|
342
|
+
min = ((this.min != null) ? new $.jsDate(this.min).getTime() : db.min);
|
343
|
+
max = ((this.max != null) ? new $.jsDate(this.max).getTime() : db.max);
|
344
|
+
|
345
|
+
// see if we're zooming. if we are, don't use the min and max we're given,
|
346
|
+
// but compute some nice ones. They will be reset later.
|
347
|
+
|
348
|
+
var cursor = plot.plugins.cursor;
|
349
|
+
|
350
|
+
if (cursor && cursor._zoom && cursor._zoom.zooming) {
|
351
|
+
this.min = null;
|
352
|
+
this.max = null;
|
353
|
+
}
|
354
|
+
|
355
|
+
var range = max - min;
|
356
|
+
|
357
|
+
if (this.tickOptions == null || !this.tickOptions.formatString) {
|
358
|
+
this._overrideFormatString = true;
|
359
|
+
}
|
360
|
+
|
361
|
+
if (userTicks.length) {
|
362
|
+
// ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
|
363
|
+
for (i=0; i<userTicks.length; i++){
|
364
|
+
var ut = userTicks[i];
|
365
|
+
var t = new this.tickRenderer(this.tickOptions);
|
366
|
+
if (ut.constructor == Array) {
|
367
|
+
t.value = new $.jsDate(ut[0]).getTime();
|
368
|
+
t.label = ut[1];
|
369
|
+
if (!this.showTicks) {
|
370
|
+
t.showLabel = false;
|
371
|
+
t.showMark = false;
|
372
|
+
}
|
373
|
+
else if (!this.showTickMarks) {
|
374
|
+
t.showMark = false;
|
375
|
+
}
|
376
|
+
t.setTick(t.value, this.name);
|
377
|
+
this._ticks.push(t);
|
378
|
+
}
|
379
|
+
|
380
|
+
else {
|
381
|
+
t.value = new $.jsDate(ut).getTime();
|
382
|
+
if (!this.showTicks) {
|
383
|
+
t.showLabel = false;
|
384
|
+
t.showMark = false;
|
385
|
+
}
|
386
|
+
else if (!this.showTickMarks) {
|
387
|
+
t.showMark = false;
|
388
|
+
}
|
389
|
+
t.setTick(t.value, this.name);
|
390
|
+
this._ticks.push(t);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
this.numberTicks = userTicks.length;
|
394
|
+
this.min = this._ticks[0].value;
|
395
|
+
this.max = this._ticks[this.numberTicks-1].value;
|
396
|
+
this.daTickInterval = [(this.max - this.min) / (this.numberTicks - 1)/1000, 'seconds'];
|
397
|
+
}
|
398
|
+
|
399
|
+
////////
|
400
|
+
// We don't have any ticks yet, let's make some!
|
401
|
+
////////
|
402
|
+
|
403
|
+
// if user specified min and max are null, we set those to make best ticks.
|
404
|
+
else if (this.min == null && this.max == null) {
|
405
|
+
var opts = $.extend(true, {}, this.tickOptions, {name: this.name, value: null});
|
406
|
+
// want to find a nice interval
|
407
|
+
var nttarget,
|
408
|
+
titarget;
|
409
|
+
|
410
|
+
// if no tickInterval or numberTicks options specified, make a good guess.
|
411
|
+
if (!this.tickInterval && !this.numberTicks) {
|
412
|
+
var tdim = Math.max(dim, threshold+1);
|
413
|
+
// how many ticks to put on the axis?
|
414
|
+
// date labels tend to be long. If ticks not rotated,
|
415
|
+
// don't use too many and have a high spacing factor.
|
416
|
+
// If we are rotating ticks, use a lower factor.
|
417
|
+
var spacingFactor = 115;
|
418
|
+
if (this.tickRenderer === $.jqplot.CanvasAxisTickRenderer && this.tickOptions.angle) {
|
419
|
+
spacingFactor = 115 - 40 * Math.abs(Math.sin(this.tickOptions.angle/180*Math.PI));
|
420
|
+
}
|
421
|
+
|
422
|
+
nttarget = Math.ceil((tdim-threshold)/spacingFactor + 1);
|
423
|
+
titarget = (max - min) / (nttarget - 1);
|
424
|
+
}
|
425
|
+
|
426
|
+
// If tickInterval is specified, we'll try to honor it.
|
427
|
+
// Not gauranteed to get this interval, but we'll get as close as
|
428
|
+
// we can.
|
429
|
+
// tickInterval will be used before numberTicks, that is if
|
430
|
+
// both are specified, numberTicks will be ignored.
|
431
|
+
else if (this.tickInterval) {
|
432
|
+
titarget = this.tickInterval;
|
433
|
+
}
|
434
|
+
|
435
|
+
// if numberTicks specified, try to honor it.
|
436
|
+
// Not gauranteed, but will try to get close.
|
437
|
+
else if (this.numberTicks) {
|
438
|
+
nttarget = this.numberTicks;
|
439
|
+
titarget = (max - min) / (nttarget - 1);
|
440
|
+
}
|
441
|
+
|
442
|
+
// If we can use an interval of 2 weeks or less, pick best one
|
443
|
+
if (titarget <= 19*day) {
|
444
|
+
var ret = bestDateInterval(min, max, titarget);
|
445
|
+
var tempti = ret[0];
|
446
|
+
this._autoFormatString = ret[1];
|
447
|
+
|
448
|
+
min = Math.floor(min/tempti) * tempti;
|
449
|
+
min = new $.jsDate(min);
|
450
|
+
min = min.getTime() + min.getUtcOffset();
|
451
|
+
|
452
|
+
nttarget = Math.ceil((max - min) / tempti) + 1;
|
453
|
+
this.min = min;
|
454
|
+
this.max = min + (nttarget - 1) * tempti;
|
455
|
+
|
456
|
+
// if max is less than max, add an interval
|
457
|
+
if (this.max < max) {
|
458
|
+
this.max += tempti;
|
459
|
+
nttarget += 1;
|
460
|
+
}
|
461
|
+
this.tickInterval = tempti;
|
462
|
+
this.numberTicks = nttarget;
|
463
|
+
|
464
|
+
for (var i=0; i<nttarget; i++) {
|
465
|
+
opts.value = this.min + i * tempti;
|
466
|
+
t = new this.tickRenderer(opts);
|
467
|
+
|
468
|
+
if (this._overrideFormatString && this._autoFormatString != '') {
|
469
|
+
t.formatString = this._autoFormatString;
|
470
|
+
}
|
471
|
+
if (!this.showTicks) {
|
472
|
+
t.showLabel = false;
|
473
|
+
t.showMark = false;
|
474
|
+
}
|
475
|
+
else if (!this.showTickMarks) {
|
476
|
+
t.showMark = false;
|
477
|
+
}
|
478
|
+
this._ticks.push(t);
|
479
|
+
}
|
480
|
+
|
481
|
+
insetMult = this.tickInterval;
|
482
|
+
}
|
483
|
+
|
484
|
+
// should we use a monthly interval?
|
485
|
+
else if (titarget <= 9 * month) {
|
486
|
+
|
487
|
+
this._autoFormatString = '%v';
|
488
|
+
|
489
|
+
// how many months in an interval?
|
490
|
+
var intv = Math.round(titarget/month);
|
491
|
+
if (intv < 1) {
|
492
|
+
intv = 1;
|
493
|
+
}
|
494
|
+
else if (intv > 6) {
|
495
|
+
intv = 6;
|
496
|
+
}
|
497
|
+
|
498
|
+
// figure out the starting month and ending month.
|
499
|
+
var mstart = new $.jsDate(min).setDate(1).setHours(0,0,0,0);
|
500
|
+
|
501
|
+
// See if max ends exactly on a month
|
502
|
+
var tempmend = new $.jsDate(max);
|
503
|
+
var mend = new $.jsDate(max).setDate(1).setHours(0,0,0,0);
|
504
|
+
|
505
|
+
if (tempmend.getTime() !== mend.getTime()) {
|
506
|
+
mend = mend.add(1, 'month');
|
507
|
+
}
|
508
|
+
|
509
|
+
var nmonths = mend.diff(mstart, 'month');
|
510
|
+
|
511
|
+
nttarget = Math.ceil(nmonths/intv) + 1;
|
512
|
+
|
513
|
+
this.min = mstart.getTime();
|
514
|
+
this.max = mstart.clone().add((nttarget - 1) * intv, 'month').getTime();
|
515
|
+
this.numberTicks = nttarget;
|
516
|
+
|
517
|
+
for (var i=0; i<nttarget; i++) {
|
518
|
+
if (i === 0) {
|
519
|
+
opts.value = mstart.getTime();
|
520
|
+
}
|
521
|
+
else {
|
522
|
+
opts.value = mstart.add(intv, 'month').getTime();
|
523
|
+
}
|
524
|
+
t = new this.tickRenderer(opts);
|
525
|
+
|
526
|
+
if (this._overrideFormatString && this._autoFormatString != '') {
|
527
|
+
t.formatString = this._autoFormatString;
|
528
|
+
}
|
529
|
+
if (!this.showTicks) {
|
530
|
+
t.showLabel = false;
|
531
|
+
t.showMark = false;
|
532
|
+
}
|
533
|
+
else if (!this.showTickMarks) {
|
534
|
+
t.showMark = false;
|
535
|
+
}
|
536
|
+
this._ticks.push(t);
|
537
|
+
}
|
538
|
+
|
539
|
+
insetMult = intv * month;
|
540
|
+
}
|
541
|
+
|
542
|
+
// use yearly intervals
|
543
|
+
else {
|
544
|
+
|
545
|
+
this._autoFormatString = '%v';
|
546
|
+
|
547
|
+
// how many years in an interval?
|
548
|
+
var intv = Math.round(titarget/year);
|
549
|
+
if (intv < 1) {
|
550
|
+
intv = 1;
|
551
|
+
}
|
552
|
+
|
553
|
+
// figure out the starting and ending years.
|
554
|
+
var mstart = new $.jsDate(min).setMonth(0, 1).setHours(0,0,0,0);
|
555
|
+
var mend = new $.jsDate(max).add(1, 'year').setMonth(0, 1).setHours(0,0,0,0);
|
556
|
+
|
557
|
+
var nyears = mend.diff(mstart, 'year');
|
558
|
+
|
559
|
+
nttarget = Math.ceil(nyears/intv) + 1;
|
560
|
+
|
561
|
+
this.min = mstart.getTime();
|
562
|
+
this.max = mstart.clone().add((nttarget - 1) * intv, 'year').getTime();
|
563
|
+
this.numberTicks = nttarget;
|
564
|
+
|
565
|
+
for (var i=0; i<nttarget; i++) {
|
566
|
+
if (i === 0) {
|
567
|
+
opts.value = mstart.getTime();
|
568
|
+
}
|
569
|
+
else {
|
570
|
+
opts.value = mstart.add(intv, 'year').getTime();
|
571
|
+
}
|
572
|
+
t = new this.tickRenderer(opts);
|
573
|
+
|
574
|
+
if (this._overrideFormatString && this._autoFormatString != '') {
|
575
|
+
t.formatString = this._autoFormatString;
|
576
|
+
}
|
577
|
+
if (!this.showTicks) {
|
578
|
+
t.showLabel = false;
|
579
|
+
t.showMark = false;
|
580
|
+
}
|
581
|
+
else if (!this.showTickMarks) {
|
582
|
+
t.showMark = false;
|
583
|
+
}
|
584
|
+
this._ticks.push(t);
|
585
|
+
}
|
586
|
+
|
587
|
+
insetMult = intv * year;
|
588
|
+
}
|
589
|
+
}
|
590
|
+
|
591
|
+
////////
|
592
|
+
// Some option(s) specified, work around that.
|
593
|
+
////////
|
594
|
+
|
595
|
+
else {
|
596
|
+
if (name == 'xaxis' || name == 'x2axis') {
|
597
|
+
dim = this._plotDimensions.width;
|
598
|
+
}
|
599
|
+
else {
|
600
|
+
dim = this._plotDimensions.height;
|
601
|
+
}
|
602
|
+
|
603
|
+
// if min, max and number of ticks specified, user can't specify interval.
|
604
|
+
if (this.min != null && this.max != null && this.numberTicks != null) {
|
605
|
+
this.tickInterval = null;
|
606
|
+
}
|
607
|
+
|
608
|
+
// if user specified a tick interval, convert to usable.
|
609
|
+
if (this.tickInterval != null)
|
610
|
+
{
|
611
|
+
// if interval is a number or can be converted to one, use it.
|
612
|
+
// Assume it is in SECONDS!!!
|
613
|
+
if (Number(this.tickInterval)) {
|
614
|
+
this.daTickInterval = [Number(this.tickInterval), 'seconds'];
|
615
|
+
}
|
616
|
+
// else, parse out something we can build from.
|
617
|
+
else if (typeof this.tickInterval == "string") {
|
618
|
+
var parts = this.tickInterval.split(' ');
|
619
|
+
if (parts.length == 1) {
|
620
|
+
this.daTickInterval = [1, parts[0]];
|
621
|
+
}
|
622
|
+
else if (parts.length == 2) {
|
623
|
+
this.daTickInterval = [parts[0], parts[1]];
|
624
|
+
}
|
625
|
+
}
|
626
|
+
}
|
627
|
+
|
628
|
+
// if min and max are same, space them out a bit
|
629
|
+
if (min == max) {
|
630
|
+
var adj = 24*60*60*500; // 1/2 day
|
631
|
+
min -= adj;
|
632
|
+
max += adj;
|
633
|
+
}
|
634
|
+
|
635
|
+
range = max - min;
|
636
|
+
|
637
|
+
var optNumTicks = 2 + parseInt(Math.max(0, dim-100)/100, 10);
|
638
|
+
|
639
|
+
|
640
|
+
var rmin, rmax;
|
641
|
+
|
642
|
+
rmin = (this.min != null) ? new $.jsDate(this.min).getTime() : min - range/2*(this.padMin - 1);
|
643
|
+
rmax = (this.max != null) ? new $.jsDate(this.max).getTime() : max + range/2*(this.padMax - 1);
|
644
|
+
this.min = rmin;
|
645
|
+
this.max = rmax;
|
646
|
+
range = this.max - this.min;
|
647
|
+
|
648
|
+
if (this.numberTicks == null){
|
649
|
+
// if tickInterval is specified by user, we will ignore computed maximum.
|
650
|
+
// max will be equal or greater to fit even # of ticks.
|
651
|
+
if (this.daTickInterval != null) {
|
652
|
+
var nc = new $.jsDate(this.max).diff(this.min, this.daTickInterval[1], true);
|
653
|
+
this.numberTicks = Math.ceil(nc/this.daTickInterval[0]) +1;
|
654
|
+
// this.max = new $.jsDate(this.min).add(this.numberTicks-1, this.daTickInterval[1]).getTime();
|
655
|
+
this.max = new $.jsDate(this.min).add((this.numberTicks-1) * this.daTickInterval[0], this.daTickInterval[1]).getTime();
|
656
|
+
}
|
657
|
+
else if (dim > 200) {
|
658
|
+
this.numberTicks = parseInt(3+(dim-200)/100, 10);
|
659
|
+
}
|
660
|
+
else {
|
661
|
+
this.numberTicks = 2;
|
662
|
+
}
|
663
|
+
}
|
664
|
+
|
665
|
+
insetMult = range / (this.numberTicks-1)/1000;
|
666
|
+
|
667
|
+
if (this.daTickInterval == null) {
|
668
|
+
this.daTickInterval = [insetMult, 'seconds'];
|
669
|
+
}
|
670
|
+
|
671
|
+
|
672
|
+
for (var i=0; i<this.numberTicks; i++){
|
673
|
+
var min = new $.jsDate(this.min);
|
674
|
+
tt = min.add(i*this.daTickInterval[0], this.daTickInterval[1]).getTime();
|
675
|
+
var t = new this.tickRenderer(this.tickOptions);
|
676
|
+
// var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
|
677
|
+
if (!this.showTicks) {
|
678
|
+
t.showLabel = false;
|
679
|
+
t.showMark = false;
|
680
|
+
}
|
681
|
+
else if (!this.showTickMarks) {
|
682
|
+
t.showMark = false;
|
683
|
+
}
|
684
|
+
t.setTick(tt, this.name);
|
685
|
+
this._ticks.push(t);
|
686
|
+
}
|
687
|
+
}
|
688
|
+
|
689
|
+
if (this.tickInset) {
|
690
|
+
this.min = this.min - this.tickInset * insetMult;
|
691
|
+
this.max = this.max + this.tickInset * insetMult;
|
692
|
+
}
|
693
|
+
|
694
|
+
if (this._daTickInterval == null) {
|
695
|
+
this._daTickInterval = this.daTickInterval;
|
696
|
+
}
|
697
|
+
|
698
|
+
ticks = null;
|
699
|
+
};
|
700
|
+
|
701
|
+
})(jQuery);
|
702
|
+
|