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(e){e.jqplot.FunnelRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.FunnelRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.FunnelRenderer.prototype.constructor=e.jqplot.FunnelRenderer;e.jqplot.FunnelRenderer.prototype.init=function(p,t){this.padding={top:20,right:20,bottom:20,left:20};this.sectionMargin=6;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.widthRatio=0.2;this.lineWidth=2;this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this._type="funnel";this.tickRenderer=e.jqplot.FunnelTickRenderer;if(p.highlightMouseDown&&p.highlightMouseOver==null){p.highlightMouseOver=false}e.extend(true,this,p);this._highlightedPoint=null;this._bases=[];this._atot;this._areas=[];this._lengths=[];this._angle;this._dataIndices=[];this._unorderedData=e.extend(true,[],this.data);var o=e.extend(true,[],this.data);for(var r=0;r<o.length;r++){o[r].push(r)}this.data.sort(function(v,u){return u[1]-v[1]});o.sort(function(v,u){return u[1]-v[1]});for(var r=0;r<o.length;r++){this._dataIndices.push(o[r][2])}if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var q=e.jqplot.getColorComponents(this.seriesColors[r]);var m=[q[0],q[1],q[2]];var s=m[0]+m[1]+m[2];for(var n=0;n<3;n++){m[n]=(s>570)?m[n]*0.8:m[n]+0.4*(255-m[n]);m[n]=parseInt(m[n],10)}this.highlightColors.push("rgb("+m[0]+","+m[1]+","+m[2]+")")}}t.postParseOptionsHooks.addOnce(k);t.postInitHooks.addOnce(g);t.eventListenerHooks.addOnce("jqplotMouseMove",a);t.eventListenerHooks.addOnce("jqplotMouseDown",b);t.eventListenerHooks.addOnce("jqplotMouseUp",j);t.eventListenerHooks.addOnce("jqplotClick",f);t.eventListenerHooks.addOnce("jqplotRightClick",l);t.postDrawHooks.addOnce(h)};e.jqplot.FunnelRenderer.prototype.setGridData=function(o){var n=0;var p=[];for(var m=0;m<this.data.length;m++){n+=this.data[m][1];p.push([this.data[m][0],this.data[m][1]])}for(var m=0;m<p.length;m++){p[m][1]=p[m][1]/n}this._bases=new Array(p.length+1);this._lengths=new Array(p.length);this.gridData=p};e.jqplot.FunnelRenderer.prototype.makeGridData=function(o,p){var n=0;var q=[];for(var m=0;m<this.data.length;m++){n+=this.data[m][1];q.push([this.data[m][0],this.data[m][1]])}for(var m=0;m<q.length;m++){q[m][1]=q[m][1]/n}this._bases=new Array(q.length+1);this._lengths=new Array(q.length);return q};e.jqplot.FunnelRenderer.prototype.drawSection=function(n,p,o,s){var t=this.fill;var m=this.lineWidth;n.save();if(s){for(var r=0;r<this.shadowDepth;r++){n.save();n.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));q()}}else{q()}function q(){n.beginPath();n.fillStyle=o;n.strokeStyle=o;n.lineWidth=m;n.moveTo(p[0][0],p[0][1]);for(var u=1;u<4;u++){n.lineTo(p[u][0],p[u][1])}n.closePath();if(t){n.fill()}else{n.stroke()}}if(s){for(var r=0;r<this.shadowDepth;r++){n.restore()}}n.restore()};e.jqplot.FunnelRenderer.prototype.draw=function(G,B,J,p){var Y;var L=(J!=undefined)?J:{};var w=0;var u=0;var R=1;this._areas=[];if(J.legendInfo&&J.legendInfo.placement=="insideGrid"){var O=J.legendInfo;switch(O.location){case"nw":w=O.width+O.xoffset;break;case"w":w=O.width+O.xoffset;break;case"sw":w=O.width+O.xoffset;break;case"ne":w=O.width+O.xoffset;R=-1;break;case"e":w=O.width+O.xoffset;R=-1;break;case"se":w=O.width+O.xoffset;R=-1;break;case"n":u=O.height+O.yoffset;break;case"s":u=O.height+O.yoffset;R=-1;break;default:break}}var t=(R==1)?this.padding.left+w:this.padding.left;var F=(R==1)?this.padding.top+u:this.padding.top;var M=(R==-1)?this.padding.right+w:this.padding.right;var o=(R==-1)?this.padding.bottom+u:this.padding.bottom;var P=(L.shadow!=undefined)?L.shadow:this.shadow;var q=(L.showLine!=undefined)?L.showLine:this.showLine;var C=(L.fill!=undefined)?L.fill:this.fill;var H=G.canvas.width;var N=G.canvas.height;this._bases[0]=H-t-M;var I=this._length=N-F-o;var r=this._bases[0]*this.widthRatio;this._atot=I/2*(this._bases[0]+this._bases[0]*this.widthRatio);this._angle=Math.atan((this._bases[0]-r)/2/I);for(Y=0;Y<B.length;Y++){this._areas.push(B[Y][1]*this._atot)}var E,aa,W,Q=0;var n=0.0001;for(Y=0;Y<this._areas.length;Y++){E=this._areas[Y]/this._bases[Y];aa=999999;this._lengths[Y]=E;W=0;while(aa>this._lengths[Y]*n&&W<100){this._lengths[Y]=this._areas[Y]/(this._bases[Y]-this._lengths[Y]*Math.tan(this._angle));aa=Math.abs(this._lengths[Y]-E);this._bases[Y+1]=this._bases[Y]-(2*this._lengths[Y]*Math.tan(this._angle));E=this._lengths[Y];W++}Q+=this._lengths[Y]}this._vertices=new Array(B.length);var ae=[t,F],ad=[t+this._bases[0],F],ac=[t+(this._bases[0]-this._bases[this._bases.length-1])/2,F+this._length],ab=[ac[0]+this._bases[this._bases.length-1],ac[1]];function V(ag){var x=(ae[1]-ac[1])/(ae[0]-ac[0]);var v=ae[1]-x*ae[0];var ah=ag+ae[1];return[(ah-v)/x,ah]}function D(ag){var x=(ad[1]-ab[1])/(ad[0]-ab[0]);var v=ad[1]-x*ad[0];var ah=ag+ad[1];return[(ah-v)/x,ah]}var T=w,S=u;var Z=0,m=0;for(Y=0;Y<B.length;Y++){this._vertices[Y]=new Array();var U=this._vertices[Y];var A=this.sectionMargin;if(Y==0){m=0}if(Y==1){m=A/3}else{if(Y>0&&Y<B.length-1){m=A/2}else{if(Y==B.length-1){m=2*A/3}}}U.push(V(Z+m));U.push(D(Z+m));Z+=this._lengths[Y];if(Y==0){m=-2*A/3}else{if(Y>0&&Y<B.length-1){m=-A/2}else{if(Y==B.length-1){m=0}}}U.push(D(Z+m));U.push(V(Z+m))}if(this.shadow){var af="rgba(0,0,0,"+this.shadowAlpha+")";for(var Y=0;Y<B.length;Y++){this.renderer.drawSection.call(this,G,this._vertices[Y],af,true)}}for(var Y=0;Y<B.length;Y++){var U=this._vertices[Y];this.renderer.drawSection.call(this,G,U,this.seriesColors[Y]);if(this.showDataLabels&&B[Y][1]*100>=this.dataLabelThreshold){var K,X;if(this.dataLabels=="label"){K=this.dataLabelFormatString||"%s";X=e.jqplot.sprintf(K,B[Y][0])}else{if(this.dataLabels=="value"){K=this.dataLabelFormatString||"%d";X=e.jqplot.sprintf(K,this.data[Y][1])}else{if(this.dataLabels=="percent"){K=this.dataLabelFormatString||"%d%%";X=e.jqplot.sprintf(K,B[Y][1]*100)}else{if(this.dataLabels.constructor==Array){K=this.dataLabelFormatString||"%s";X=e.jqplot.sprintf(K,this.dataLabels[this._dataIndices[Y]])}}}}var s=(this._radius)*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var T=(U[0][0]+U[1][0])/2+this.canvas._offsets.left;var S=(U[1][1]+U[2][1])/2+this.canvas._offsets.top;var z=e('<span class="jqplot-funnel-series jqplot-data-label" style="position:absolute;">'+X+"</span>").insertBefore(p.eventCanvas._elem);T-=z.width()/2;S-=z.height()/2;T=Math.round(T);S=Math.round(S);z.css({left:T,top:S})}}};e.jqplot.FunnelAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.FunnelAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.FunnelAxisRenderer.prototype.constructor=e.jqplot.FunnelAxisRenderer;e.jqplot.FunnelAxisRenderer.prototype.init=function(m){this.tickRenderer=e.jqplot.FunnelTickRenderer;e.extend(true,this,m);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.FunnelLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.FunnelLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.FunnelLegendRenderer.prototype.constructor=e.jqplot.FunnelLegendRenderer;e.jqplot.FunnelLegendRenderer.prototype.init=function(m){this.numberRows=null;this.numberColumns=null;e.extend(true,this,m)};e.jqplot.FunnelLegendRenderer.prototype.draw=function(){var p=this;if(this.show){var x=this._series;var A="position:absolute;";A+=(this.background)?"background:"+this.background+";":"";A+=(this.border)?"border:"+this.border+";":"";A+=(this.fontSize)?"font-size:"+this.fontSize+";":"";A+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";A+=(this.textColor)?"color:"+this.textColor+";":"";A+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";A+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";A+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";A+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('<table class="jqplot-table-legend" style="'+A+'"></table>');var E=false,w=false,m,u;var y=x[0];var n=new e.jqplot.ColorGenerator(y.seriesColors);if(y.show){var F=y.data;if(this.numberRows){m=this.numberRows;if(!this.numberColumns){u=Math.ceil(F.length/m)}else{u=this.numberColumns}}else{if(this.numberColumns){u=this.numberColumns;m=Math.ceil(F.length/this.numberColumns)}else{m=F.length;u=1}}var D,C,o,r,q,t,v,B;var z=0;for(D=0;D<m;D++){if(w){o=e('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{o=e('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(C=0;C<u;C++){if(z<F.length){t=this.labels[z]||F[z][0].toString();B=n.next();if(!w){if(D>0){E=true}else{E=false}}else{if(D==m-1){E=false}else{E=true}}v=(E)?this.rowSpacing:"0";r=e('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+v+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+B+';"></div></div></td>');q=e('<td class="jqplot-table-legend" style="padding-top:'+v+';"></td>');if(this.escapeHtml){q.text(t)}else{q.html(t)}if(w){q.prependTo(o);r.prependTo(o)}else{r.appendTo(o);q.appendTo(o)}E=true}z++}}}}return this._elem};function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.legend=n.legend||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==e.jqplot.FunnelRenderer){m=true}else{if(n.series){for(var o=0;o<n.series.length;o++){if(n.series[o].renderer==e.jqplot.FunnelRenderer){m=true}}}}if(m){n.axesDefaults.renderer=e.jqplot.FunnelAxisRenderer;n.legend.renderer=e.jqplot.FunnelLegendRenderer;n.legend.preDraw=true;n.sortData=false;n.seriesDefaults.pointLabels={show:false}}}function g(p,o,m){for(var n=0;n<this.series.length;n++){if(this.series[n].renderer.constructor==e.jqplot.FunnelRenderer){if(this.series[n].highlightMouseOver){this.series[n].highlightMouseDown=false}}}}function k(m){for(var n=0;n<this.series.length;n++){this.series[n].seriesColors=this.seriesColors;this.series[n].colorGenerator=e.jqplot.colorGenerator}}function d(q,p,o){var n=q.series[p];var m=q.plugins.funnelRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);n._highlightedPoint=o;q.plugins.funnelRenderer.highlightedSeriesIndex=p;n.renderer.drawSection.call(n,m._ctx,n._vertices[o],n.highlightColors[o],false)}function i(o){var m=o.plugins.funnelRenderer.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.funnelRenderer.highlightedSeriesIndex=null;o.target.trigger("jqplotDataUnhighlight")}function a(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.funnelRenderer.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);d(r,o[0],o[1])}}else{if(s==null){i(r)}}}function b(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.funnelRenderer.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);d(q,n[0],n[1])}}else{if(r==null){i(q)}}}function j(o,n,r,q,p){var m=p.plugins.funnelRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){i(p)}}function f(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.funnelRenderer.highlightedSeriesIndex;if(m!=null&&r.series[m].highlightMouseDown){i(r)}var n=jQuery.Event("jqplotDataRightClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}function h(){if(this.plugins.funnelRenderer&&this.plugins.funnelRenderer.highlightCanvas){this.plugins.funnelRenderer.highlightCanvas.resetCanvas();this.plugins.funnelRenderer.highlightCanvas=null}this.plugins.funnelRenderer={};this.plugins.funnelRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var n=e(this.targetId+" .jqplot-data-label");if(n.length){e(n[0]).before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-funnelRenderer-highlight-canvas",this._plotDimensions,this))}else{this.eventCanvas._elem.before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-funnelRenderer-highlight-canvas",this._plotDimensions,this))}var m=this.plugins.funnelRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(o){i(o.data.plot)})}e.jqplot.preInitHooks.push(c);e.jqplot.FunnelTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.FunnelTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.FunnelTickRenderer.prototype.constructor=e.jqplot.FunnelTickRenderer})(jQuery);
|
@@ -0,0 +1,454 @@
|
|
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
|
+
$.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]);
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Class: $.jqplot.Highlighter
|
35
|
+
* Plugin which will highlight data points when they are moused over.
|
36
|
+
*
|
37
|
+
* To use this plugin, include the js
|
38
|
+
* file in your source:
|
39
|
+
*
|
40
|
+
* > <script type="text/javascript" src="plugins/jqplot.highlighter.js"></script>
|
41
|
+
*
|
42
|
+
* A tooltip providing information about the data point is enabled by default.
|
43
|
+
* To disable the tooltip, set "showTooltip" to false.
|
44
|
+
*
|
45
|
+
* You can control what data is displayed in the tooltip with various
|
46
|
+
* options. The "tooltipAxes" option controls wether the x, y or both
|
47
|
+
* data values are displayed.
|
48
|
+
*
|
49
|
+
* Some chart types (e.g. hi-low-close) have more than one y value per
|
50
|
+
* data point. To display the additional values in the tooltip, set the
|
51
|
+
* "yvalues" option to the desired number of y values present (3 for a hlc chart).
|
52
|
+
*
|
53
|
+
* By default, data values will be formatted with the same formatting
|
54
|
+
* specifiers as used to format the axis ticks. A custom format code
|
55
|
+
* can be supplied with the tooltipFormatString option. This will apply
|
56
|
+
* to all values in the tooltip.
|
57
|
+
*
|
58
|
+
* For more complete control, the "formatString" option can be set. This
|
59
|
+
* Allows conplete control over tooltip formatting. Values are passed to
|
60
|
+
* the format string in an order determined by the "tooltipAxes" and "yvalues"
|
61
|
+
* options. So, if you have a hi-low-close chart and you just want to display
|
62
|
+
* the hi-low-close values in the tooltip, you could set a formatString like:
|
63
|
+
*
|
64
|
+
* > highlighter: {
|
65
|
+
* > tooltipAxes: 'y',
|
66
|
+
* > yvalues: 3,
|
67
|
+
* > formatString:'<table class="jqplot-highlighter">
|
68
|
+
* > <tr><td>hi:</td><td>%s</td></tr>
|
69
|
+
* > <tr><td>low:</td><td>%s</td></tr>
|
70
|
+
* > <tr><td>close:</td><td>%s</td></tr></table>'
|
71
|
+
* > }
|
72
|
+
*
|
73
|
+
*/
|
74
|
+
$.jqplot.Highlighter = function(options) {
|
75
|
+
// Group: Properties
|
76
|
+
//
|
77
|
+
//prop: show
|
78
|
+
// true to show the highlight.
|
79
|
+
this.show = $.jqplot.config.enablePlugins;
|
80
|
+
// prop: markerRenderer
|
81
|
+
// Renderer used to draw the marker of the highlighted point.
|
82
|
+
// Renderer will assimilate attributes from the data point being highlighted,
|
83
|
+
// so no attributes need set on the renderer directly.
|
84
|
+
// Default is to turn off shadow drawing on the highlighted point.
|
85
|
+
this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false});
|
86
|
+
// prop: showMarker
|
87
|
+
// true to show the marker
|
88
|
+
this.showMarker = true;
|
89
|
+
// prop: lineWidthAdjust
|
90
|
+
// Pixels to add to the lineWidth of the highlight.
|
91
|
+
this.lineWidthAdjust = 2.5;
|
92
|
+
// prop: sizeAdjust
|
93
|
+
// Pixels to add to the overall size of the highlight.
|
94
|
+
this.sizeAdjust = 5;
|
95
|
+
// prop: showTooltip
|
96
|
+
// Show a tooltip with data point values.
|
97
|
+
this.showTooltip = true;
|
98
|
+
// prop: tooltipLocation
|
99
|
+
// Where to position tooltip, 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
|
100
|
+
this.tooltipLocation = 'nw';
|
101
|
+
// prop: fadeTooltip
|
102
|
+
// true = fade in/out tooltip, flase = show/hide tooltip
|
103
|
+
this.fadeTooltip = true;
|
104
|
+
// prop: tooltipFadeSpeed
|
105
|
+
// 'slow', 'def', 'fast', or number of milliseconds.
|
106
|
+
this.tooltipFadeSpeed = "fast";
|
107
|
+
// prop: tooltipOffset
|
108
|
+
// Pixel offset of tooltip from the highlight.
|
109
|
+
this.tooltipOffset = 2;
|
110
|
+
// prop: tooltipAxes
|
111
|
+
// Which axes to display in tooltip, 'x', 'y' or 'both', 'xy' or 'yx'
|
112
|
+
// 'both' and 'xy' are equivalent, 'yx' reverses order of labels.
|
113
|
+
this.tooltipAxes = 'both';
|
114
|
+
// prop; tooltipSeparator
|
115
|
+
// String to use to separate x and y axes in tooltip.
|
116
|
+
this.tooltipSeparator = ', ';
|
117
|
+
// prop; tooltipContentEditor
|
118
|
+
// Function used to edit/augment/replace the formatted tooltip contents.
|
119
|
+
// Called as str = tooltipContentEditor(str, seriesIndex, pointIndex)
|
120
|
+
// where str is the generated tooltip html and seriesIndex and pointIndex identify
|
121
|
+
// the data point being highlighted. Should return the html for the tooltip contents.
|
122
|
+
this.tooltipContentEditor = null;
|
123
|
+
// prop: useAxesFormatters
|
124
|
+
// Use the x and y axes formatters to format the text in the tooltip.
|
125
|
+
this.useAxesFormatters = true;
|
126
|
+
// prop: tooltipFormatString
|
127
|
+
// sprintf format string for the tooltip.
|
128
|
+
// Uses Ash Searle's javascript sprintf implementation
|
129
|
+
// found here: http://hexmen.com/blog/2007/03/printf-sprintf/
|
130
|
+
// See http://perldoc.perl.org/functions/sprintf.html for reference.
|
131
|
+
// Additional "p" and "P" format specifiers added by Chris Leonello.
|
132
|
+
this.tooltipFormatString = '%.5P';
|
133
|
+
// prop: formatString
|
134
|
+
// alternative to tooltipFormatString
|
135
|
+
// will format the whole tooltip text, populating with x, y values as
|
136
|
+
// indicated by tooltipAxes option. So, you could have a tooltip like:
|
137
|
+
// 'Date: %s, number of cats: %d' to format the whole tooltip at one go.
|
138
|
+
// If useAxesFormatters is true, values will be formatted according to
|
139
|
+
// Axes formatters and you can populate your tooltip string with
|
140
|
+
// %s placeholders.
|
141
|
+
this.formatString = null;
|
142
|
+
// prop: yvalues
|
143
|
+
// Number of y values to expect in the data point array.
|
144
|
+
// Typically this is 1. Certain plots, like OHLC, will
|
145
|
+
// have more y values in each data point array.
|
146
|
+
this.yvalues = 1;
|
147
|
+
// prop: bringSeriesToFront
|
148
|
+
// This option requires jQuery 1.4+
|
149
|
+
// True to bring the series of the highlighted point to the front
|
150
|
+
// of other series.
|
151
|
+
this.bringSeriesToFront = false;
|
152
|
+
this._tooltipElem;
|
153
|
+
this.isHighlighting = false;
|
154
|
+
this.currentNeighbor = null;
|
155
|
+
|
156
|
+
$.extend(true, this, options);
|
157
|
+
};
|
158
|
+
|
159
|
+
var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
|
160
|
+
var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7};
|
161
|
+
var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];
|
162
|
+
|
163
|
+
// axis.renderer.tickrenderer.formatter
|
164
|
+
|
165
|
+
// called with scope of plot
|
166
|
+
$.jqplot.Highlighter.init = function (target, data, opts){
|
167
|
+
var options = opts || {};
|
168
|
+
// add a highlighter attribute to the plot
|
169
|
+
this.plugins.highlighter = new $.jqplot.Highlighter(options.highlighter);
|
170
|
+
};
|
171
|
+
|
172
|
+
// called within scope of series
|
173
|
+
$.jqplot.Highlighter.parseOptions = function (defaults, options) {
|
174
|
+
// Add a showHighlight option to the series
|
175
|
+
// and set it to true by default.
|
176
|
+
this.showHighlight = true;
|
177
|
+
};
|
178
|
+
|
179
|
+
// called within context of plot
|
180
|
+
// create a canvas which we can draw on.
|
181
|
+
// insert it before the eventCanvas, so eventCanvas will still capture events.
|
182
|
+
$.jqplot.Highlighter.postPlotDraw = function() {
|
183
|
+
// Memory Leaks patch
|
184
|
+
if (this.plugins.highlighter && this.plugins.highlighter.highlightCanvas) {
|
185
|
+
this.plugins.highlighter.highlightCanvas.resetCanvas();
|
186
|
+
this.plugins.highlighter.highlightCanvas = null;
|
187
|
+
}
|
188
|
+
|
189
|
+
if (this.plugins.highlighter && this.plugins.highlighter._tooltipElem) {
|
190
|
+
this.plugins.highlighter._tooltipElem.emptyForce();
|
191
|
+
this.plugins.highlighter._tooltipElem = null;
|
192
|
+
}
|
193
|
+
|
194
|
+
this.plugins.highlighter.highlightCanvas = new $.jqplot.GenericCanvas();
|
195
|
+
|
196
|
+
this.eventCanvas._elem.before(this.plugins.highlighter.highlightCanvas.createElement(this._gridPadding, 'jqplot-highlight-canvas', this._plotDimensions, this));
|
197
|
+
this.plugins.highlighter.highlightCanvas.setContext();
|
198
|
+
|
199
|
+
var elem = document.createElement('div');
|
200
|
+
this.plugins.highlighter._tooltipElem = $(elem);
|
201
|
+
elem = null;
|
202
|
+
this.plugins.highlighter._tooltipElem.addClass('jqplot-highlighter-tooltip');
|
203
|
+
this.plugins.highlighter._tooltipElem.css({position:'absolute', display:'none'});
|
204
|
+
|
205
|
+
this.eventCanvas._elem.before(this.plugins.highlighter._tooltipElem);
|
206
|
+
};
|
207
|
+
|
208
|
+
$.jqplot.preInitHooks.push($.jqplot.Highlighter.init);
|
209
|
+
$.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Highlighter.parseOptions);
|
210
|
+
$.jqplot.postDrawHooks.push($.jqplot.Highlighter.postPlotDraw);
|
211
|
+
|
212
|
+
function draw(plot, neighbor) {
|
213
|
+
var hl = plot.plugins.highlighter;
|
214
|
+
var s = plot.series[neighbor.seriesIndex];
|
215
|
+
var smr = s.markerRenderer;
|
216
|
+
var mr = hl.markerRenderer;
|
217
|
+
mr.style = smr.style;
|
218
|
+
mr.lineWidth = smr.lineWidth + hl.lineWidthAdjust;
|
219
|
+
mr.size = smr.size + hl.sizeAdjust;
|
220
|
+
var rgba = $.jqplot.getColorComponents(smr.color);
|
221
|
+
var newrgb = [rgba[0], rgba[1], rgba[2]];
|
222
|
+
var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
|
223
|
+
mr.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
|
224
|
+
mr.init();
|
225
|
+
mr.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], hl.highlightCanvas._ctx);
|
226
|
+
}
|
227
|
+
|
228
|
+
function showTooltip(plot, series, neighbor) {
|
229
|
+
// neighbor looks like: {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}
|
230
|
+
// gridData should be x,y pixel coords on the grid.
|
231
|
+
// add the plot._gridPadding to that to get x,y in the target.
|
232
|
+
var hl = plot.plugins.highlighter;
|
233
|
+
var elem = hl._tooltipElem;
|
234
|
+
var serieshl = series.highlighter || {};
|
235
|
+
|
236
|
+
var opts = $.extend(true, {}, hl, serieshl);
|
237
|
+
|
238
|
+
if (opts.useAxesFormatters) {
|
239
|
+
var xf = series._xaxis._ticks[0].formatter;
|
240
|
+
var yf = series._yaxis._ticks[0].formatter;
|
241
|
+
var xfstr = series._xaxis._ticks[0].formatString;
|
242
|
+
var yfstr = series._yaxis._ticks[0].formatString;
|
243
|
+
var str;
|
244
|
+
var xstr = xf(xfstr, neighbor.data[0]);
|
245
|
+
var ystrs = [];
|
246
|
+
for (var i=1; i<opts.yvalues+1; i++) {
|
247
|
+
ystrs.push(yf(yfstr, neighbor.data[i]));
|
248
|
+
}
|
249
|
+
if (typeof opts.formatString === 'string') {
|
250
|
+
switch (opts.tooltipAxes) {
|
251
|
+
case 'both':
|
252
|
+
case 'xy':
|
253
|
+
ystrs.unshift(xstr);
|
254
|
+
ystrs.unshift(opts.formatString);
|
255
|
+
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
256
|
+
break;
|
257
|
+
case 'yx':
|
258
|
+
ystrs.push(xstr);
|
259
|
+
ystrs.unshift(opts.formatString);
|
260
|
+
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
261
|
+
break;
|
262
|
+
case 'x':
|
263
|
+
str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString, xstr]);
|
264
|
+
break;
|
265
|
+
case 'y':
|
266
|
+
ystrs.unshift(opts.formatString);
|
267
|
+
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
268
|
+
break;
|
269
|
+
default: // same as xy
|
270
|
+
ystrs.unshift(xstr);
|
271
|
+
ystrs.unshift(opts.formatString);
|
272
|
+
str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
|
273
|
+
break;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
else {
|
277
|
+
switch (opts.tooltipAxes) {
|
278
|
+
case 'both':
|
279
|
+
case 'xy':
|
280
|
+
str = xstr;
|
281
|
+
for (var i=0; i<ystrs.length; i++) {
|
282
|
+
str += opts.tooltipSeparator + ystrs[i];
|
283
|
+
}
|
284
|
+
break;
|
285
|
+
case 'yx':
|
286
|
+
str = '';
|
287
|
+
for (var i=0; i<ystrs.length; i++) {
|
288
|
+
str += ystrs[i] + opts.tooltipSeparator;
|
289
|
+
}
|
290
|
+
str += xstr;
|
291
|
+
break;
|
292
|
+
case 'x':
|
293
|
+
str = xstr;
|
294
|
+
break;
|
295
|
+
case 'y':
|
296
|
+
str = ystrs.join(opts.tooltipSeparator);
|
297
|
+
break;
|
298
|
+
default: // same as 'xy'
|
299
|
+
str = xstr;
|
300
|
+
for (var i=0; i<ystrs.length; i++) {
|
301
|
+
str += opts.tooltipSeparator + ystrs[i];
|
302
|
+
}
|
303
|
+
break;
|
304
|
+
|
305
|
+
}
|
306
|
+
}
|
307
|
+
}
|
308
|
+
else {
|
309
|
+
var str;
|
310
|
+
if (typeof opts.formatString === 'string') {
|
311
|
+
str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString].concat(neighbor.data));
|
312
|
+
}
|
313
|
+
|
314
|
+
else {
|
315
|
+
if (opts.tooltipAxes == 'both' || opts.tooltipAxes == 'xy') {
|
316
|
+
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]);
|
317
|
+
}
|
318
|
+
else if (opts.tooltipAxes == 'yx') {
|
319
|
+
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]);
|
320
|
+
}
|
321
|
+
else if (opts.tooltipAxes == 'x') {
|
322
|
+
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]);
|
323
|
+
}
|
324
|
+
else if (opts.tooltipAxes == 'y') {
|
325
|
+
str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]);
|
326
|
+
}
|
327
|
+
}
|
328
|
+
}
|
329
|
+
if ($.isFunction(opts.tooltipContentEditor)) {
|
330
|
+
// args str, seriesIndex, pointIndex are essential so the hook can look up
|
331
|
+
// extra data for the point.
|
332
|
+
str = opts.tooltipContentEditor(str, neighbor.seriesIndex, neighbor.pointIndex, plot);
|
333
|
+
}
|
334
|
+
elem.html(str);
|
335
|
+
var gridpos = {x:neighbor.gridData[0], y:neighbor.gridData[1]};
|
336
|
+
var ms = 0;
|
337
|
+
var fact = 0.707;
|
338
|
+
if (series.markerRenderer.show == true) {
|
339
|
+
ms = (series.markerRenderer.size + opts.sizeAdjust)/2;
|
340
|
+
}
|
341
|
+
|
342
|
+
var loc = locations;
|
343
|
+
if (series.fillToZero && series.fill && neighbor.data[1] < 0) {
|
344
|
+
loc = oppositeLocations;
|
345
|
+
}
|
346
|
+
|
347
|
+
switch (loc[locationIndicies[opts.tooltipLocation]]) {
|
348
|
+
case 'nw':
|
349
|
+
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
|
350
|
+
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
|
351
|
+
break;
|
352
|
+
case 'n':
|
353
|
+
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
|
354
|
+
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - ms;
|
355
|
+
break;
|
356
|
+
case 'ne':
|
357
|
+
var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms;
|
358
|
+
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
|
359
|
+
break;
|
360
|
+
case 'e':
|
361
|
+
var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + ms;
|
362
|
+
var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
|
363
|
+
break;
|
364
|
+
case 'se':
|
365
|
+
var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms;
|
366
|
+
var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms;
|
367
|
+
break;
|
368
|
+
case 's':
|
369
|
+
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
|
370
|
+
var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + ms;
|
371
|
+
break;
|
372
|
+
case 'sw':
|
373
|
+
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
|
374
|
+
var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms;
|
375
|
+
break;
|
376
|
+
case 'w':
|
377
|
+
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - ms;
|
378
|
+
var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
|
379
|
+
break;
|
380
|
+
default: // same as 'nw'
|
381
|
+
var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
|
382
|
+
var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
|
383
|
+
break;
|
384
|
+
}
|
385
|
+
elem.css('left', x);
|
386
|
+
elem.css('top', y);
|
387
|
+
if (opts.fadeTooltip) {
|
388
|
+
// Fix for stacked up animations. Thnanks Trevor!
|
389
|
+
elem.stop(true,true).fadeIn(opts.tooltipFadeSpeed);
|
390
|
+
}
|
391
|
+
else {
|
392
|
+
elem.show();
|
393
|
+
}
|
394
|
+
elem = null;
|
395
|
+
|
396
|
+
}
|
397
|
+
|
398
|
+
function handleMove(ev, gridpos, datapos, neighbor, plot) {
|
399
|
+
var hl = plot.plugins.highlighter;
|
400
|
+
var c = plot.plugins.cursor;
|
401
|
+
if (hl.show) {
|
402
|
+
if (neighbor == null && hl.isHighlighting) {
|
403
|
+
var ctx = hl.highlightCanvas._ctx;
|
404
|
+
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
405
|
+
if (hl.fadeTooltip) {
|
406
|
+
hl._tooltipElem.fadeOut(hl.tooltipFadeSpeed);
|
407
|
+
}
|
408
|
+
else {
|
409
|
+
hl._tooltipElem.hide();
|
410
|
+
}
|
411
|
+
if (hl.bringSeriesToFront) {
|
412
|
+
plot.restorePreviousSeriesOrder();
|
413
|
+
}
|
414
|
+
hl.isHighlighting = false;
|
415
|
+
hl.currentNeighbor = null;
|
416
|
+
ctx = null;
|
417
|
+
}
|
418
|
+
else if (neighbor != null && plot.series[neighbor.seriesIndex].showHighlight && !hl.isHighlighting) {
|
419
|
+
hl.isHighlighting = true;
|
420
|
+
hl.currentNeighbor = neighbor;
|
421
|
+
if (hl.showMarker) {
|
422
|
+
draw(plot, neighbor);
|
423
|
+
}
|
424
|
+
if (hl.showTooltip && (!c || !c._zoom.started)) {
|
425
|
+
showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor);
|
426
|
+
}
|
427
|
+
if (hl.bringSeriesToFront) {
|
428
|
+
plot.moveSeriesToFront(neighbor.seriesIndex);
|
429
|
+
}
|
430
|
+
}
|
431
|
+
// check to see if we're highlighting the wrong point.
|
432
|
+
else if (neighbor != null && hl.isHighlighting && hl.currentNeighbor != neighbor) {
|
433
|
+
// highlighting the wrong point.
|
434
|
+
|
435
|
+
// if new series allows highlighting, highlight new point.
|
436
|
+
if (plot.series[neighbor.seriesIndex].showHighlight) {
|
437
|
+
var ctx = hl.highlightCanvas._ctx;
|
438
|
+
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
439
|
+
hl.isHighlighting = true;
|
440
|
+
hl.currentNeighbor = neighbor;
|
441
|
+
if (hl.showMarker) {
|
442
|
+
draw(plot, neighbor);
|
443
|
+
}
|
444
|
+
if (hl.showTooltip && (!c || !c._zoom.started)) {
|
445
|
+
showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor);
|
446
|
+
}
|
447
|
+
if (hl.bringSeriesToFront) {
|
448
|
+
plot.moveSeriesToFront(neighbor.seriesIndex);
|
449
|
+
}
|
450
|
+
}
|
451
|
+
}
|
452
|
+
}
|
453
|
+
}
|
454
|
+
})(jQuery);
|