sunrise-votes 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -4
- data/Rakefile +0 -22
- data/app/controllers/manage/ballot_box/votes_controller.rb +4 -0
- data/app/views/manage/ballot_box/votes/show.html.erb +211 -81
- data/lib/generators/sunrise/votes/install_generator.rb +1 -1
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.js +170 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.src.js +11428 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.js +22 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.src.js +711 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-blue.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-green.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/gray.js +262 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/grid.js +96 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/skies.js +89 -0
- data/lib/sunrise/votes/version.rb +1 -1
- metadata +33 -79
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/excanvas.min.js +0 -35
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.css +0 -226
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.js +0 -312
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.js +0 -702
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.js +0 -234
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.js +0 -748
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.js +0 -238
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js +0 -614
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.js +0 -420
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.js +0 -634
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.js +0 -115
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.js +0 -1002
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.js +0 -439
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.js +0 -904
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.js +0 -218
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.js +0 -932
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.js +0 -406
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.js +0 -475
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.js +0 -446
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.js +0 -607
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.js +0 -432
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.js +0 -1142
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.js +0 -372
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.js +0 -797
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js +0 -337
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js +0 -220
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.min.js +0 -30
@@ -1,30 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
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(f){var d=function(m){return Math.max.apply(Math,m)};var j=function(m){return Math.min.apply(Math,m)};f.jqplot.BubbleRenderer=function(){f.jqplot.LineRenderer.call(this)};f.jqplot.BubbleRenderer.prototype=new f.jqplot.LineRenderer();f.jqplot.BubbleRenderer.prototype.constructor=f.jqplot.BubbleRenderer;f.jqplot.BubbleRenderer.prototype.init=function(w,t){this.varyBubbleColors=true;this.autoscaleBubbles=true;this.autoscaleMultiplier=1;this.autoscalePointsFactor=-0.07;this.escapeHtml=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.bubbleAlpha=1;this.highlightAlpha=null;this.bubbleGradients=false;this.showLabels=true;this.radii=[];this.maxRadius=0;this._highlightedPoint=null;this.labels=[];this.bubbleCanvases=[];this._type="bubble";if(w.highlightMouseDown&&w.highlightMouseOver==null){w.highlightMouseOver=false}f.extend(true,this,w);if(this.highlightAlpha==null){this.highlightAlpha=this.bubbleAlpha;if(this.bubbleGradients){this.highlightAlpha=0.35}}this.autoscaleMultiplier=this.autoscaleMultiplier*Math.pow(this.data.length,this.autoscalePointsFactor);this._highlightedPoint=null;var n;for(var r=0;r<this.data.length;r++){var p=null;var v=this.data[r];this.maxRadius=Math.max(this.maxRadius,v[2]);if(v[3]){if(typeof(v[3])=="object"){p=v[3]["color"]}}if(p==null){if(this.seriesColors[r]!=null){p=this.seriesColors[r]}}if(p&&this.bubbleAlpha<1){n=f.jqplot.getColorComponents(p);p="rgba("+n[0]+", "+n[1]+", "+n[2]+", "+this.bubbleAlpha+")"}if(p){this.seriesColors[r]=p}}if(!this.varyBubbleColors){this.seriesColors=[this.color]}this.colorGenerator=new f.jqplot.ColorGenerator(this.seriesColors);if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var o=f.jqplot.getColorComponents(this.seriesColors[r]);var u=[o[0],o[1],o[2]];var s=u[0]+u[1]+u[2];for(var q=0;q<3;q++){u[q]=(s>570)?u[q]*0.8:u[q]+0.3*(255-u[q]);u[q]=parseInt(u[q],10)}this.highlightColors.push("rgba("+u[0]+","+u[1]+","+u[2]+", "+this.highlightAlpha+")")}}this.highlightColorGenerator=new f.jqplot.ColorGenerator(this.highlightColors);var m={fill:true,isarc:true,angle:this.shadowAngle,alpha:this.shadowAlpha,closePath:true};this.renderer.shadowRenderer.init(m);this.canvas=new f.jqplot.DivCanvas();this.canvas._plotDimensions=this._plotDimensions;t.eventListenerHooks.addOnce("jqplotMouseMove",a);t.eventListenerHooks.addOnce("jqplotMouseDown",b);t.eventListenerHooks.addOnce("jqplotMouseUp",k);t.eventListenerHooks.addOnce("jqplotClick",g);t.eventListenerHooks.addOnce("jqplotRightClick",l);t.postDrawHooks.addOnce(h)};f.jqplot.BubbleRenderer.prototype.setGridData=function(w){var q=this._xaxis.series_u2p;var m=this._yaxis.series_u2p;var t=this._plotData;this.gridData=[];var s=[];this.radii=[];var v=Math.min(w._height,w._width);for(var u=0;u<this.data.length;u++){if(t[u]!=null){this.gridData.push([q.call(this._xaxis,t[u][0]),m.call(this._yaxis,t[u][1]),t[u][2]]);this.radii.push([u,t[u][2]]);s.push(t[u][2])}}var n,o,x=this.maxRadius=d(s);var p=this.gridData.length;if(this.autoscaleBubbles){for(var u=0;u<p;u++){o=s[u]/x;n=this.autoscaleMultiplier*v/6;this.gridData[u][2]=n*o}}this.radii.sort(function(y,r){return r[1]-y[1]})};f.jqplot.BubbleRenderer.prototype.makeGridData=function(t,w){var q=this._xaxis.series_u2p;var n=this._yaxis.series_u2p;var x=[];var s=[];this.radii=[];var v=Math.min(w._height,w._width);for(var u=0;u<t.length;u++){if(t[u]!=null){x.push([q.call(this._xaxis,t[u][0]),n.call(this._yaxis,t[u][1]),t[u][2]]);s.push(t[u][2]);this.radii.push([u,t[u][2]])}}var m,o,y=this.maxRadius=d(s);var p=this.gridData.length;if(this.autoscaleBubbles){for(var u=0;u<p;u++){o=s[u]/y;m=this.autoscaleMultiplier*v/6;x[u][2]=m*o}}this.radii.sort(function(z,r){return r[1]-z[1]});return x};f.jqplot.BubbleRenderer.prototype.draw=function(D,J,n){if(this.plugins.pointLabels){this.plugins.pointLabels.show=false}var A=(n!=undefined)?n:{};var r=(A.shadow!=undefined)?A.shadow:this.shadow;this.canvas._elem.empty();for(var G=0;G<this.radii.length;G++){var C=this.radii[G][0];var z=null;var F=null;var m=null;var p=null;var I=this.data[C];var J=this.gridData[C];if(I[3]){if(typeof(I[3])=="object"){z=I[3]["label"]}else{if(typeof(I[3])=="string"){z=I[3]}}}F=this.colorGenerator.get(C);var E=J[2];var q,K;if(this.shadow){q=(0.7+J[2]/40).toFixed(1);K=1+Math.ceil(J[2]/15);E+=q*K}this.bubbleCanvases[C]=new f.jqplot.BubbleCanvas();this.canvas._elem.append(this.bubbleCanvases[C].createElement(J[0],J[1],E));this.bubbleCanvases[C].setContext();var D=this.bubbleCanvases[C]._ctx;var u=D.canvas.width/2;var s=D.canvas.height/2;if(this.shadow){this.renderer.shadowRenderer.draw(D,[u,s,J[2],0,2*Math.PI],{offset:q,depth:K})}this.bubbleCanvases[C].draw(J[2],F,this.bubbleGradients,this.shadowAngle/180*Math.PI);if(z&&this.showLabels){p=f('<div style="position:absolute;" class="jqplot-bubble-label"></div>');if(this.escapeHtml){p.text(z)}else{p.html(z)}this.canvas._elem.append(p);var H=f(p).outerHeight();var v=f(p).outerWidth();var B=J[1]-0.5*H;var o=J[0]-0.5*v;p.css({top:B,left:o});this.labels[C]=f(p)}}};f.jqplot.DivCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.DivCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.DivCanvas.prototype.constructor=f.jqplot.DivCanvas;f.jqplot.DivCanvas.prototype.createElement=function(s,p,n){this._offsets=s;var m="jqplot-DivCanvas";if(p!=undefined){m=p}var r;if(this._elem){r=this._elem.get(0)}else{r=document.createElement("div")}if(n!=undefined){this._plotDimensions=n}var o=this._plotDimensions.width-this._offsets.left-this._offsets.right+"px";var q=this._plotDimensions.height-this._offsets.top-this._offsets.bottom+"px";this._elem=f(r);this._elem.css({position:"absolute",width:o,height:q,left:this._offsets.left,top:this._offsets.top});this._elem.addClass(m);return this._elem};f.jqplot.DivCanvas.prototype.setContext=function(){this._ctx={canvas:{width:0,height:0},clearRect:function(){return null}};return this._ctx};f.jqplot.BubbleCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.BubbleCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.BubbleCanvas.prototype.constructor=f.jqplot.BubbleCanvas;f.jqplot.BubbleCanvas.prototype.createElement=function(n,u,s){var m="jqplot-bubble-point";var q;if(this._elem){q=this._elem.get(0)}else{q=document.createElement("canvas")}q.width=(s!=null)?2*s:q.width;q.height=(s!=null)?2*s:q.height;this._elem=f(q);var o=(n!=null&&s!=null)?n-s:this._elem.css("left");var p=(u!=null&&s!=null)?u-s:this._elem.css("top");this._elem.css({position:"absolute",left:o,top:p});this._elem.addClass(m);if(f.jqplot.use_excanvas){window.G_vmlCanvasManager.init_(document);q=window.G_vmlCanvasManager.initElement(q)}return this._elem};f.jqplot.BubbleCanvas.prototype.draw=function(m,s,v,p){var D=this._ctx;var B=D.canvas.width/2;var z=D.canvas.height/2;D.save();if(v&&!f.jqplot.use_excanvas){m=m*1.04;var o=f.jqplot.getColorComponents(s);var u="rgba("+Math.round(o[0]+0.8*(255-o[0]))+", "+Math.round(o[1]+0.8*(255-o[1]))+", "+Math.round(o[2]+0.8*(255-o[2]))+", "+o[3]+")";var t="rgba("+o[0]+", "+o[1]+", "+o[2]+", 0)";var C=0.35*m;var A=B-Math.cos(p)*0.33*m;var n=z-Math.sin(p)*0.33*m;var w=D.createRadialGradient(A,n,C,B,z,m);w.addColorStop(0,u);w.addColorStop(0.93,s);w.addColorStop(0.96,t);w.addColorStop(1,t);D.fillStyle=w;D.fillRect(0,0,D.canvas.width,D.canvas.height)}else{D.fillStyle=s;D.strokeStyle=s;D.lineWidth=1;D.beginPath();var q=2*Math.PI;D.arc(B,z,m,0,q,0);D.closePath();D.fill()}D.restore()};f.jqplot.BubbleCanvas.prototype.setContext=function(){this._ctx=this._elem.get(0).getContext("2d");return this._ctx};f.jqplot.BubbleAxisRenderer=function(){f.jqplot.LinearAxisRenderer.call(this)};f.jqplot.BubbleAxisRenderer.prototype=new f.jqplot.LinearAxisRenderer();f.jqplot.BubbleAxisRenderer.prototype.constructor=f.jqplot.BubbleAxisRenderer;f.jqplot.BubbleAxisRenderer.prototype.init=function(n){f.extend(true,this,n);var I=this._dataBounds;var H=0,v=0,m=0,y=0,q=0,r=0,D=0,t=0,F=0,z=0;for(var E=0;E<this._series.length;E++){var x=this._series[E];var G=x._plotData;for(var B=0;B<G.length;B++){if(this.name=="xaxis"||this.name=="x2axis"){if(G[B][0]<I.min||I.min==null){I.min=G[B][0];H=E;v=B;r=G[B][2];D=x.maxRadius;z=x.autoscaleMultiplier}if(G[B][0]>I.max||I.max==null){I.max=G[B][0];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}else{if(G[B][1]<I.min||I.min==null){I.min=G[B][1];H=E;v=B;r=G[B][2];D=x.maxRadius;z=x.autoscaleMultiplier}if(G[B][1]>I.max||I.max==null){I.max=G[B][1];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}}}var o=r/D;var w=q/t;var C=I.max-I.min;var A=Math.min(this._plotDimensions.width,this._plotDimensions.height);var p=o*z/3*C;var u=w*F/3*C;I.max+=u;I.min-=p};function e(p,v,q){p.plugins.bubbleRenderer.highlightLabelCanvas.empty();var z=p.series[v];var n=p.plugins.bubbleRenderer.highlightCanvas;var w=n._ctx;w.clearRect(0,0,w.canvas.width,w.canvas.height);z._highlightedPoint=q;p.plugins.bubbleRenderer.highlightedSeriesIndex=v;var o=z.highlightColorGenerator.get(q);var u=z.gridData[q][0],t=z.gridData[q][1],m=z.gridData[q][2];w.save();w.fillStyle=o;w.strokeStyle=o;w.lineWidth=1;w.beginPath();w.arc(u,t,m,0,2*Math.PI,0);w.closePath();w.fill();w.restore();if(z.labels[q]){p.plugins.bubbleRenderer.highlightLabel=z.labels[q].clone();p.plugins.bubbleRenderer.highlightLabel.appendTo(p.plugins.bubbleRenderer.highlightLabelCanvas);p.plugins.bubbleRenderer.highlightLabel.addClass("jqplot-bubble-label-highlight")}}function i(p){var m=p.plugins.bubbleRenderer.highlightCanvas;var o=p.plugins.bubbleRenderer.highlightedSeriesIndex;p.plugins.bubbleRenderer.highlightLabelCanvas.empty();m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n<p.series.length;n++){p.series[n]._highlightedPoint=null}p.plugins.bubbleRenderer.highlightedSeriesIndex=null;p.target.trigger("jqplotDataUnhighlight")}function a(s,p,m,v,r){if(v){var n=v.seriesIndex;var o=v.pointIndex;var q=[n,o,v.data,r.series[n].gridData[o][2]];var t=jQuery.Event("jqplotDataMouseOver");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q);if(r.series[q[0]].highlightMouseOver&&!(q[0]==r.plugins.bubbleRenderer.highlightedSeriesIndex&&q[1]==r.series[q[0]]._highlightedPoint)){var u=jQuery.Event("jqplotDataHighlight");u.pageX=s.pageX;u.pageY=s.pageY;r.target.trigger(u,q);e(r,q[0],q[1])}}else{if(v==null){i(r)}}}function b(s,p,m,u,r){if(u){var n=u.seriesIndex;var o=u.pointIndex;var q=[n,o,u.data,r.series[n].gridData[o][2]];if(r.series[q[0]].highlightMouseDown&&!(q[0]==r.plugins.bubbleRenderer.highlightedSeriesIndex&&q[1]==r.series[q[0]]._highlightedPoint)){var t=jQuery.Event("jqplotDataHighlight");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q);e(r,q[0],q[1])}}else{if(u==null){i(r)}}}function k(o,n,r,q,p){var m=p.plugins.bubbleRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){i(p)}}function g(s,p,m,u,r){if(u){var n=u.seriesIndex;var o=u.pointIndex;var q=[n,o,u.data,r.series[n].gridData[o][2]];var t=jQuery.Event("jqplotDataClick");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q)}}function l(s,p,m,v,r){if(v){var n=v.seriesIndex;var o=v.pointIndex;var q=[n,o,v.data,r.series[n].gridData[o][2]];var t=r.plugins.bubbleRenderer.highlightedSeriesIndex;if(t!=null&&r.series[t].highlightMouseDown){i(r)}var u=jQuery.Event("jqplotDataRightClick");u.pageX=s.pageX;u.pageY=s.pageY;r.target.trigger(u,q)}}function h(){this.plugins.bubbleRenderer={highlightedSeriesIndex:null};this.plugins.bubbleRenderer.highlightCanvas=new f.jqplot.GenericCanvas();this.plugins.bubbleRenderer.highlightLabel=null;this.plugins.bubbleRenderer.highlightLabelCanvas=f('<div style="position:absolute;"></div>');var q=this._gridPadding.top;var p=this._gridPadding.left;var n=this._plotDimensions.width-this._gridPadding.left-this._gridPadding.right;var m=this._plotDimensions.height-this._gridPadding.top-this._gridPadding.bottom;this.plugins.bubbleRenderer.highlightLabelCanvas.css({top:q,left:p,width:n+"px",height:m+"px"});this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-bubbleRenderer-highlight-canvas",this._plotDimensions));this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightLabelCanvas);var o=this.plugins.bubbleRenderer.highlightCanvas.setContext()}function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==f.jqplot.BubbleRenderer){m=true}else{if(n.series){for(var o=0;o<n.series.length;o++){if(n.series[o].renderer==f.jqplot.BubbleRenderer){m=true}}}}if(m){n.axesDefaults.renderer=f.jqplot.BubbleAxisRenderer;n.sortData=false}}f.jqplot.preInitHooks.push(c)})(jQuery);
|
@@ -1,199 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
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.CanvasAxisLabelRenderer
|
33
|
-
* Renderer to draw axis labels with a canvas element to support advanced
|
34
|
-
* featrues such as rotated text. This renderer uses a separate rendering engine
|
35
|
-
* to draw the text on the canvas. Two modes of rendering the text are available.
|
36
|
-
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
37
|
-
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
38
|
-
* You do so by setting the "enableFontSupport" option to true.
|
39
|
-
*
|
40
|
-
* Browsers lacking native font support will have the text drawn on the canvas
|
41
|
-
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
42
|
-
* non-supporting browsers will still render with the Hershey font.
|
43
|
-
*
|
44
|
-
*/
|
45
|
-
$.jqplot.CanvasAxisLabelRenderer = function(options) {
|
46
|
-
// Group: Properties
|
47
|
-
|
48
|
-
// prop: angle
|
49
|
-
// angle of text, measured clockwise from x axis.
|
50
|
-
this.angle = 0;
|
51
|
-
// name of the axis associated with this tick
|
52
|
-
this.axis;
|
53
|
-
// prop: show
|
54
|
-
// wether or not to show the tick (mark and label).
|
55
|
-
this.show = true;
|
56
|
-
// prop: showLabel
|
57
|
-
// wether or not to show the label.
|
58
|
-
this.showLabel = true;
|
59
|
-
// prop: label
|
60
|
-
// label for the axis.
|
61
|
-
this.label = '';
|
62
|
-
// prop: fontFamily
|
63
|
-
// CSS spec for the font-family css attribute.
|
64
|
-
// Applies only to browsers supporting native font rendering in the
|
65
|
-
// canvas tag. Currently Mozilla 3.5 and Safari 4.
|
66
|
-
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
67
|
-
// prop: fontSize
|
68
|
-
// CSS spec for font size.
|
69
|
-
this.fontSize = '11pt';
|
70
|
-
// prop: fontWeight
|
71
|
-
// CSS spec for fontWeight: normal, bold, bolder, lighter or a number 100 - 900
|
72
|
-
this.fontWeight = 'normal';
|
73
|
-
// prop: fontStretch
|
74
|
-
// Multiplier to condense or expand font width.
|
75
|
-
// Applies only to browsers which don't support canvas native font rendering.
|
76
|
-
this.fontStretch = 1.0;
|
77
|
-
// prop: textColor
|
78
|
-
// css spec for the color attribute.
|
79
|
-
this.textColor = '#666666';
|
80
|
-
// prop: enableFontSupport
|
81
|
-
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
82
|
-
// If true, label will be drawn with canvas tag native support for fonts.
|
83
|
-
// If false, label will be drawn with Hershey font metrics.
|
84
|
-
this.enableFontSupport = true;
|
85
|
-
// prop: pt2px
|
86
|
-
// Point to pixel scaling factor, used for computing height of bounding box
|
87
|
-
// around a label. The labels text renderer has a default setting of 1.4, which
|
88
|
-
// should be suitable for most fonts. Leave as null to use default. If tops of
|
89
|
-
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
90
|
-
// This is an issue only with the native font renderering capabilities of Mozilla
|
91
|
-
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
92
|
-
this.pt2px = null;
|
93
|
-
|
94
|
-
this._elem;
|
95
|
-
this._ctx;
|
96
|
-
this._plotWidth;
|
97
|
-
this._plotHeight;
|
98
|
-
this._plotDimensions = {height:null, width:null};
|
99
|
-
|
100
|
-
$.extend(true, this, options);
|
101
|
-
|
102
|
-
if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') {
|
103
|
-
this.angle = -90;
|
104
|
-
}
|
105
|
-
|
106
|
-
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
107
|
-
if (this.pt2px) {
|
108
|
-
ropts.pt2px = this.pt2px;
|
109
|
-
}
|
110
|
-
|
111
|
-
if (this.enableFontSupport) {
|
112
|
-
|
113
|
-
function support_canvas_text() {
|
114
|
-
return !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function');
|
115
|
-
}
|
116
|
-
|
117
|
-
if (support_canvas_text()) {
|
118
|
-
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
119
|
-
}
|
120
|
-
|
121
|
-
else {
|
122
|
-
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
123
|
-
}
|
124
|
-
}
|
125
|
-
else {
|
126
|
-
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
127
|
-
}
|
128
|
-
};
|
129
|
-
|
130
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) {
|
131
|
-
$.extend(true, this, options);
|
132
|
-
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
133
|
-
};
|
134
|
-
|
135
|
-
// return width along the x axis
|
136
|
-
// will check first to see if an element exists.
|
137
|
-
// if not, will return the computed text box width.
|
138
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) {
|
139
|
-
if (this._elem) {
|
140
|
-
return this._elem.outerWidth(true);
|
141
|
-
}
|
142
|
-
else {
|
143
|
-
var tr = this._textRenderer;
|
144
|
-
var l = tr.getWidth(ctx);
|
145
|
-
var h = tr.getHeight(ctx);
|
146
|
-
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
147
|
-
return w;
|
148
|
-
}
|
149
|
-
};
|
150
|
-
|
151
|
-
// return height along the y axis.
|
152
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) {
|
153
|
-
if (this._elem) {
|
154
|
-
return this._elem.outerHeight(true);
|
155
|
-
}
|
156
|
-
else {
|
157
|
-
var tr = this._textRenderer;
|
158
|
-
var l = tr.getWidth(ctx);
|
159
|
-
var h = tr.getHeight(ctx);
|
160
|
-
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
161
|
-
return w;
|
162
|
-
}
|
163
|
-
};
|
164
|
-
|
165
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() {
|
166
|
-
var a = this.angle * Math.PI/180;
|
167
|
-
return a;
|
168
|
-
};
|
169
|
-
|
170
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx) {
|
171
|
-
// create a canvas here, but can't draw on it untill it is appended
|
172
|
-
// to dom for IE compatability.
|
173
|
-
var domelem = document.createElement('canvas');
|
174
|
-
this._textRenderer.setText(this.label, ctx);
|
175
|
-
var w = this.getWidth(ctx);
|
176
|
-
var h = this.getHeight(ctx);
|
177
|
-
domelem.width = w;
|
178
|
-
domelem.height = h;
|
179
|
-
domelem.style.width = w;
|
180
|
-
domelem.style.height = h;
|
181
|
-
// domelem.style.textAlign = 'center';
|
182
|
-
domelem.style.position = 'absolute';
|
183
|
-
this._domelem = domelem;
|
184
|
-
this._elem = $(domelem);
|
185
|
-
this._elem.addClass('jqplot-'+this.axis+'-label');
|
186
|
-
|
187
|
-
domelem = null;
|
188
|
-
return this._elem;
|
189
|
-
};
|
190
|
-
|
191
|
-
$.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() {
|
192
|
-
if ($.jqplot.use_excanvas) {
|
193
|
-
window.G_vmlCanvasManager.init_(document);
|
194
|
-
this._domelem = window.G_vmlCanvasManager.initElement(this._domelem);
|
195
|
-
}
|
196
|
-
this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
|
197
|
-
};
|
198
|
-
|
199
|
-
})(jQuery);
|
@@ -1,30 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
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(a){a.jqplot.CanvasAxisLabelRenderer=function(b){this.angle=0;this.axis;this.show=true;this.showLabel=true;this.label="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="11pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);if(b.angle==null&&this.axis!="xaxis"&&this.axis!="x2axis"){this.angle=-90}var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){function d(){return !!(document.createElement("canvas").getContext&&typeof document.createElement("canvas").getContext("2d").fillText=="function")}if(d()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisLabelRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisLabelRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisLabelRenderer.prototype.draw=function(c){var e=document.createElement("canvas");this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e.style.position="absolute";this._domelem=e;this._elem=a(e);this._elem.addClass("jqplot-"+this.axis+"-label");e=null;return this._elem};a.jqplot.CanvasAxisLabelRenderer.prototype.pack=function(){if(a.jqplot.use_excanvas){window.G_vmlCanvasManager.init_(document);this._domelem=window.G_vmlCanvasManager.initElement(this._domelem)}this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery);
|
@@ -1,238 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
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.CanvasAxisTickRenderer
|
33
|
-
* Renderer to draw axis ticks with a canvas element to support advanced
|
34
|
-
* featrues such as rotated text. This renderer uses a separate rendering engine
|
35
|
-
* to draw the text on the canvas. Two modes of rendering the text are available.
|
36
|
-
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
37
|
-
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
38
|
-
* You do so by setting the "enableFontSupport" option to true.
|
39
|
-
*
|
40
|
-
* Browsers lacking native font support will have the text drawn on the canvas
|
41
|
-
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
42
|
-
* non-supporting browsers will still render with the Hershey font.
|
43
|
-
*/
|
44
|
-
$.jqplot.CanvasAxisTickRenderer = function(options) {
|
45
|
-
// Group: Properties
|
46
|
-
|
47
|
-
// prop: mark
|
48
|
-
// tick mark on the axis. One of 'inside', 'outside', 'cross', '' or null.
|
49
|
-
this.mark = 'outside';
|
50
|
-
// prop: showMark
|
51
|
-
// wether or not to show the mark on the axis.
|
52
|
-
this.showMark = true;
|
53
|
-
// prop: showGridline
|
54
|
-
// wether or not to draw the gridline on the grid at this tick.
|
55
|
-
this.showGridline = true;
|
56
|
-
// prop: isMinorTick
|
57
|
-
// if this is a minor tick.
|
58
|
-
this.isMinorTick = false;
|
59
|
-
// prop: angle
|
60
|
-
// angle of text, measured clockwise from x axis.
|
61
|
-
this.angle = 0;
|
62
|
-
// prop: markSize
|
63
|
-
// Length of the tick marks in pixels. For 'cross' style, length
|
64
|
-
// will be stoked above and below axis, so total length will be twice this.
|
65
|
-
this.markSize = 4;
|
66
|
-
// prop: show
|
67
|
-
// wether or not to show the tick (mark and label).
|
68
|
-
this.show = true;
|
69
|
-
// prop: showLabel
|
70
|
-
// wether or not to show the label.
|
71
|
-
this.showLabel = true;
|
72
|
-
// prop: labelPosition
|
73
|
-
// 'auto', 'start', 'middle' or 'end'.
|
74
|
-
// Whether tick label should be positioned so the start, middle, or end
|
75
|
-
// of the tick mark.
|
76
|
-
this.labelPosition = 'auto';
|
77
|
-
this.label = '';
|
78
|
-
this.value = null;
|
79
|
-
this._styles = {};
|
80
|
-
// prop: formatter
|
81
|
-
// A class of a formatter for the tick text.
|
82
|
-
// The default $.jqplot.DefaultTickFormatter uses sprintf.
|
83
|
-
this.formatter = $.jqplot.DefaultTickFormatter;
|
84
|
-
// prop: formatString
|
85
|
-
// string passed to the formatter.
|
86
|
-
this.formatString = '';
|
87
|
-
// prop: prefix
|
88
|
-
// string appended to the tick label if no formatString is specified.
|
89
|
-
this.prefix = '';
|
90
|
-
// prop: fontFamily
|
91
|
-
// css spec for the font-family css attribute.
|
92
|
-
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
93
|
-
// prop: fontSize
|
94
|
-
// CSS spec for font size.
|
95
|
-
this.fontSize = '10pt';
|
96
|
-
// prop: fontWeight
|
97
|
-
// CSS spec for fontWeight
|
98
|
-
this.fontWeight = 'normal';
|
99
|
-
// prop: fontStretch
|
100
|
-
// Multiplier to condense or expand font width.
|
101
|
-
// Applies only to browsers which don't support canvas native font rendering.
|
102
|
-
this.fontStretch = 1.0;
|
103
|
-
// prop: textColor
|
104
|
-
// css spec for the color attribute.
|
105
|
-
this.textColor = '#666666';
|
106
|
-
// prop: enableFontSupport
|
107
|
-
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
108
|
-
// If true, tick label will be drawn with canvas tag native support for fonts.
|
109
|
-
// If false, tick label will be drawn with Hershey font metrics.
|
110
|
-
this.enableFontSupport = true;
|
111
|
-
// prop: pt2px
|
112
|
-
// Point to pixel scaling factor, used for computing height of bounding box
|
113
|
-
// around a label. The labels text renderer has a default setting of 1.4, which
|
114
|
-
// should be suitable for most fonts. Leave as null to use default. If tops of
|
115
|
-
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
116
|
-
// This is an issue only with the native font renderering capabilities of Mozilla
|
117
|
-
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
118
|
-
this.pt2px = null;
|
119
|
-
|
120
|
-
this._elem;
|
121
|
-
this._ctx;
|
122
|
-
this._plotWidth;
|
123
|
-
this._plotHeight;
|
124
|
-
this._plotDimensions = {height:null, width:null};
|
125
|
-
|
126
|
-
$.extend(true, this, options);
|
127
|
-
|
128
|
-
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
129
|
-
if (this.pt2px) {
|
130
|
-
ropts.pt2px = this.pt2px;
|
131
|
-
}
|
132
|
-
|
133
|
-
if (this.enableFontSupport) {
|
134
|
-
|
135
|
-
function support_canvas_text() {
|
136
|
-
return !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function');
|
137
|
-
}
|
138
|
-
|
139
|
-
if (support_canvas_text()) {
|
140
|
-
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
141
|
-
}
|
142
|
-
|
143
|
-
else {
|
144
|
-
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
145
|
-
}
|
146
|
-
}
|
147
|
-
else {
|
148
|
-
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
149
|
-
}
|
150
|
-
};
|
151
|
-
|
152
|
-
$.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) {
|
153
|
-
$.extend(true, this, options);
|
154
|
-
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
155
|
-
};
|
156
|
-
|
157
|
-
// return width along the x axis
|
158
|
-
// will check first to see if an element exists.
|
159
|
-
// if not, will return the computed text box width.
|
160
|
-
$.jqplot.CanvasAxisTickRenderer.prototype.getWidth = function(ctx) {
|
161
|
-
if (this._elem) {
|
162
|
-
return this._elem.outerWidth(true);
|
163
|
-
}
|
164
|
-
else {
|
165
|
-
var tr = this._textRenderer;
|
166
|
-
var l = tr.getWidth(ctx);
|
167
|
-
var h = tr.getHeight(ctx);
|
168
|
-
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
169
|
-
return w;
|
170
|
-
}
|
171
|
-
};
|
172
|
-
|
173
|
-
// return height along the y axis.
|
174
|
-
$.jqplot.CanvasAxisTickRenderer.prototype.getHeight = function(ctx) {
|
175
|
-
if (this._elem) {
|
176
|
-
return this._elem.outerHeight(true);
|
177
|
-
}
|
178
|
-
else {
|
179
|
-
var tr = this._textRenderer;
|
180
|
-
var l = tr.getWidth(ctx);
|
181
|
-
var h = tr.getHeight(ctx);
|
182
|
-
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
183
|
-
return w;
|
184
|
-
}
|
185
|
-
};
|
186
|
-
|
187
|
-
$.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad = function() {
|
188
|
-
var a = this.angle * Math.PI/180;
|
189
|
-
return a;
|
190
|
-
};
|
191
|
-
|
192
|
-
|
193
|
-
$.jqplot.CanvasAxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
|
194
|
-
this.value = value;
|
195
|
-
if (isMinor) {
|
196
|
-
this.isMinorTick = true;
|
197
|
-
}
|
198
|
-
return this;
|
199
|
-
};
|
200
|
-
|
201
|
-
$.jqplot.CanvasAxisTickRenderer.prototype.draw = function(ctx) {
|
202
|
-
if (!this.label) {
|
203
|
-
this.label = this.formatter(this.formatString, this.value);
|
204
|
-
}
|
205
|
-
// add prefix if needed
|
206
|
-
if (this.prefix && !this.formatString) {
|
207
|
-
this.label = this.prefix + this.label;
|
208
|
-
}
|
209
|
-
// create a canvas here, but can't draw on it untill it is appended
|
210
|
-
// to dom for IE compatability.
|
211
|
-
var domelem = document.createElement('canvas');
|
212
|
-
this._textRenderer.setText(this.label, ctx);
|
213
|
-
var w = this.getWidth(ctx);
|
214
|
-
var h = this.getHeight(ctx);
|
215
|
-
domelem.width = w;
|
216
|
-
domelem.height = h;
|
217
|
-
domelem.style.width = w;
|
218
|
-
domelem.style.height = h;
|
219
|
-
domelem.style.textAlign = 'left';
|
220
|
-
domelem.style.position = 'absolute';
|
221
|
-
this._domelem = domelem;
|
222
|
-
this._elem = $(domelem);
|
223
|
-
this._elem.css(this._styles);
|
224
|
-
this._elem.addClass('jqplot-'+this.axis+'-tick');
|
225
|
-
|
226
|
-
domelem = null;
|
227
|
-
return this._elem;
|
228
|
-
};
|
229
|
-
|
230
|
-
$.jqplot.CanvasAxisTickRenderer.prototype.pack = function() {
|
231
|
-
if ($.jqplot.use_excanvas) {
|
232
|
-
window.G_vmlCanvasManager.init_(document);
|
233
|
-
this._domelem = window.G_vmlCanvasManager.initElement(this._domelem);
|
234
|
-
}
|
235
|
-
this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
|
236
|
-
};
|
237
|
-
|
238
|
-
})(jQuery);
|