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.
Files changed (71) hide show
  1. data/README.rdoc +2 -4
  2. data/Rakefile +0 -22
  3. data/app/controllers/manage/ballot_box/votes_controller.rb +4 -0
  4. data/app/views/manage/ballot_box/votes/show.html.erb +211 -81
  5. data/lib/generators/sunrise/votes/install_generator.rb +1 -1
  6. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.js +170 -0
  7. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.src.js +11428 -0
  8. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.js +22 -0
  9. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.src.js +711 -0
  10. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-blue.js +263 -0
  11. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-green.js +263 -0
  12. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/gray.js +262 -0
  13. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/grid.js +96 -0
  14. data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/skies.js +89 -0
  15. data/lib/sunrise/votes/version.rb +1 -1
  16. metadata +33 -79
  17. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/excanvas.min.js +0 -35
  18. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.css +0 -226
  19. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.min.js +0 -30
  20. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.js +0 -312
  21. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.min.js +0 -30
  22. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.js +0 -702
  23. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.min.js +0 -30
  24. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.js +0 -234
  25. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.min.js +0 -30
  26. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.js +0 -748
  27. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.min.js +0 -30
  28. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.js +0 -199
  29. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.min.js +0 -30
  30. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.js +0 -238
  31. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.min.js +0 -30
  32. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js +0 -614
  33. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.min.js +0 -30
  34. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.js +0 -420
  35. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.min.js +0 -30
  36. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.js +0 -634
  37. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.min.js +0 -30
  38. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.js +0 -115
  39. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.min.js +0 -30
  40. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.js +0 -1002
  41. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.min.js +0 -30
  42. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.js +0 -439
  43. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.min.js +0 -30
  44. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.js +0 -904
  45. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.min.js +0 -30
  46. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.js +0 -218
  47. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.min.js +0 -30
  48. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.js +0 -199
  49. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.min.js +0 -30
  50. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.js +0 -932
  51. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.min.js +0 -30
  52. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.js +0 -406
  53. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.min.js +0 -30
  54. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.js +0 -475
  55. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.min.js +0 -30
  56. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.js +0 -446
  57. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.min.js +0 -30
  58. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.js +0 -607
  59. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.min.js +0 -30
  60. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.js +0 -432
  61. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.min.js +0 -30
  62. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.js +0 -1142
  63. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.min.js +0 -30
  64. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.js +0 -372
  65. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.min.js +0 -30
  66. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.js +0 -797
  67. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js +0 -30
  68. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js +0 -337
  69. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js +0 -30
  70. data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js +0 -220
  71. 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(a){a.jqplot.MekkoAxisRenderer=function(){};a.jqplot.MekkoAxisRenderer.prototype.init=function(c){this.tickMode;this.barLabelRenderer=a.jqplot.AxisLabelRenderer;this.barLabels=this.barLabels||[];this.barLabelOptions={};this.tickOptions=a.extend(true,{showGridline:false},this.tickOptions);this._barLabels=[];a.extend(true,this,c);if(this.name=="yaxis"){this.tickOptions.formatString=this.tickOptions.formatString||"%d%"}var b=this._dataBounds;b.min=0;if(this.name=="yaxis"||this.name=="y2axis"){b.max=100;this.tickMode="even"}else{if(this.name=="xaxis"){this.tickMode=(this.tickMode==null)?"bar":this.tickMode;for(var d=0;d<this._series.length;d++){b.max+=this._series[d]._sumy}}else{if(this.name=="x2axis"){this.tickMode=(this.tickMode==null)?"even":this.tickMode;for(var d=0;d<this._series.length;d++){b.max+=this._series[d]._sumy}}}}};a.jqplot.MekkoAxisRenderer.prototype.draw=function(b){if(this.show){this.renderer.createTicks.call(this);var h=0;var c;this._elem=a('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>');if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var g=this._label.draw(b);g.appendTo(this._elem)}var f,e,g;if(this.showTicks){f=this._ticks;for(var d=0;d<f.length;d++){e=f[d];if(e.showLabel&&(!e.isMinorTick||this.showMinorTicks)){g=e.draw(b);g.appendTo(this._elem)}}}for(d=0;d<this.barLabels.length;d++){this.barLabelOptions.axis=this.name;this.barLabelOptions.label=this.barLabels[d];this._barLabels.push(new this.barLabelRenderer(this.barLabelOptions));if(this.tickMode!="bar"){this._barLabels[d].show=false}if(this._barLabels[d].show){var g=this._barLabels[d].draw(b);g.removeClass("jqplot-"+this.name+"-label");g.addClass("jqplot-"+this.name+"-tick");g.addClass("jqplot-mekko-barLabel");g.appendTo(this._elem)}}}return this._elem};a.jqplot.MekkoAxisRenderer.prototype.reset=function(){this.min=this._min;this.max=this._max;this.tickInterval=this._tickInterval;this.numberTicks=this._numberTicks};a.jqplot.MekkoAxisRenderer.prototype.set=function(){var k=0;var d;var c=0;var j=0;var b=(this._label==null)?false:this._label.show;if(this.show&&this.showTicks){var g=this._ticks;for(var f=0;f<g.length;f++){var e=g[f];if(e.showLabel&&(!e.isMinorTick||this.showMinorTicks)){if(this.name=="xaxis"||this.name=="x2axis"){d=e._elem.outerHeight(true)}else{d=e._elem.outerWidth(true)}if(d>k){k=d}}}if(b){c=this._label._elem.outerWidth(true);j=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){k=k+j;this._elem.css({height:k+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){k=k+j;this._elem.css({height:k+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){k=k+c;this._elem.css({width:k+"px",left:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}else{k=k+c;this._elem.css({width:k+"px",right:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}}}}};a.jqplot.MekkoAxisRenderer.prototype.createTicks=function(){var z=this._ticks;var w=this.ticks;var B=this.name;var y=this._dataBounds;var p,x;var n,r;var d,c;var h,b,s,q;if(w.length){for(s=0;s<w.length;s++){var e=w[s];var h=new this.tickRenderer(this.tickOptions);if(e.constructor==Array){h.value=e[0];h.label=e[1];if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(e[0],this.name);this._ticks.push(h)}else{h.value=e;if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(e,this.name);this._ticks.push(h)}}this.numberTicks=w.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.tickInterval=(this.max-this.min)/(this.numberTicks-1)}else{if(B=="xaxis"||B=="x2axis"){p=this._plotDimensions.width}else{p=this._plotDimensions.height}if(this.min!=null&&this.max!=null&&this.numberTicks!=null){this.tickInterval=null}n=(this.min!=null)?this.min:y.min;r=(this.max!=null)?this.max:y.max;if(n==r){var g=0.05;if(n>0){g=Math.max(Math.log(n)/Math.LN10,0.05)}n-=g;r+=g}var k=r-n;var m,o;var v,l,u;var f=[3,5,6,11,21];if(this.name=="yaxis"||this.name=="y2axis"){this.min=0;this.max=100;if(!this.numberTicks){if(this.tickInterval){this.numberTicks=3+Math.ceil(k/this.tickInterval)}else{v=2+Math.ceil((p-(this.tickSpacing-1))/this.tickSpacing);for(s=0;s<f.length;s++){u=v/f[s];if(u==1){this.numberTicks=f[s];break}else{if(u>1){l=u;continue}else{if(u<1){if(Math.abs(l-1)<Math.abs(u-1)){this.numberTicks=f[s-1];break}else{this.numberTicks=f[s];break}}else{if(s==f.length-1){this.numberTicks=f[s]}}}}}this.tickInterval=k/(this.numberTicks-1)}}else{this.tickInterval=k/(this.numberTicks-1)}for(var s=0;s<this.numberTicks;s++){b=this.min+s*this.tickInterval;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(b,this.name);this._ticks.push(h)}}else{if(this.tickMode=="bar"){this.min=0;this.numberTicks=this._series.length+1;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(0,this.name);this._ticks.push(h);v=0;for(s=1;s<this.numberTicks;s++){v+=this._series[s-1]._sumy;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(v,this.name);this._ticks.push(h)}this.max=this.max||v;if(this.max>v){h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(this.max,this.name);this._ticks.push(h)}}else{if(this.tickMode=="even"){this.min=0;this.max=this.max||y.max;var A=2+Math.ceil((p-(this.tickSpacing-1))/this.tickSpacing);k=this.max-this.min;this.numberTicks=A;this.tickInterval=k/(this.numberTicks-1);for(s=0;s<this.numberTicks;s++){b=this.min+s*this.tickInterval;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(b,this.name);this._ticks.push(h)}}}}}};a.jqplot.MekkoAxisRenderer.prototype.pack=function(e,d){var C=this._ticks;var x=this.max;var v=this.min;var m=d.max;var j=d.min;var o=(this._label==null)?false:this._label.show;for(var s in e){this._elem.css(s,e[s])}this._offsets=d;var f=m-j;var g=x-v;this.p2u=function(b){return(b-j)*g/f+v};this.u2p=function(b){return(b-v)*f/g+j};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(b){return(b-v)*f/g};this.series_p2u=function(b){return b*g/f+v}}else{this.series_u2p=function(b){return(b-x)*f/g};this.series_p2u=function(b){return b*g/f+x}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(var y=0;y<C.length;y++){var n=C[y];if(n.show&&n.showLabel){var c;if(n.constructor==a.jqplot.CanvasAxisTickRenderer&&n.angle){var A=(this.name=="xaxis")?1:-1;switch(n.labelPosition){case"auto":if(A*n.angle<0){c=-n.getWidth()+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2}else{c=-n._textRenderer.height*Math.sin(n._textRenderer.angle)/2}break;case"end":c=-n.getWidth()+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break;case"start":c=-n._textRenderer.height*Math.sin(n._textRenderer.angle)/2;break;case"middle":c=-n.getWidth()/2+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break;default:c=-n.getWidth()/2+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break}}else{c=-n.getWidth()/2}var D=this.u2p(n.value)+c+"px";n._elem.css("left",D);n.pack()}}var k;if(o){k=this._label._elem.outerWidth(true);this._label._elem.css("left",j+f/2-k/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px")}else{this._label._elem.css("top","0px")}this._label.pack()}var B,u,q;for(var y=0;y<this.barLabels.length;y++){B=this._barLabels[y];if(B.show){k=B.getWidth();u=this._ticks[y].getLeft()+this._ticks[y].getWidth();q=this._ticks[y+1].getLeft();B._elem.css("left",(q+u-k)/2+"px");B._elem.css("top",this._ticks[y]._elem.css("top"));B.pack()}}}else{for(var y=0;y<C.length;y++){var n=C[y];if(n.show&&n.showLabel){var c;if(n.constructor==a.jqplot.CanvasAxisTickRenderer&&n.angle){var A=(this.name=="yaxis")?1:-1;switch(n.labelPosition){case"auto":case"end":if(A*n.angle<0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"start":if(n.angle>0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"middle":c=-n.getHeight()/2;break;default:c=-n.getHeight()/2;break}}else{c=-n.getHeight()/2}var D=this.u2p(n.value)+c+"px";n._elem.css("top",D);n.pack()}}if(o){var z=this._label._elem.outerHeight(true);this._label._elem.css("top",m-f/2-z/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}}})(jQuery);
@@ -1,432 +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.MekkoRenderer
33
- * Draws a Mekko style chart which shows 3 dimensional data on a 2 dimensional graph.
34
- * the <$.jqplot.MekkoAxisRenderer> should be used with mekko charts. The mekko renderer
35
- * overrides the default legend renderer with it's own $.jqplot.MekkoLegendRenderer
36
- * which allows more flexibility to specify number of rows and columns in the legend.
37
- *
38
- * Data is specified per bar in the chart. You can specify data as an array of y values, or as
39
- * an array of [label, value] pairs. Note that labels are used only on the first series.
40
- * Labels on subsequent series are ignored:
41
- *
42
- * > bar1 = [['shirts', 8],['hats', 14],['shoes', 6],['gloves', 16],['dolls', 12]];
43
- * > bar2 = [15,6,9,13,6];
44
- * > bar3 = [['grumpy',4],['sneezy',2],['happy',7],['sleepy',9],['doc',7]];
45
- *
46
- * If you want to place labels for each bar under the axis, you use the barLabels option on
47
- * the axes. The bar labels can be styled with the ".jqplot-mekko-barLabel" css class.
48
- *
49
- * > barLabels = ['Mickey Mouse', 'Donald Duck', 'Goofy'];
50
- * > axes:{xaxis:{barLabels:barLabels}}
51
- *
52
- */
53
-
54
-
55
- $.jqplot.MekkoRenderer = function(){
56
- this.shapeRenderer = new $.jqplot.ShapeRenderer();
57
- // prop: borderColor
58
- // color of the borders between areas on the chart
59
- this.borderColor = null;
60
- // prop: showBorders
61
- // True to draw borders lines between areas on the chart.
62
- // False will draw borders lines with the same color as the area.
63
- this.showBorders = true;
64
- };
65
-
66
- // called with scope of series.
67
- $.jqplot.MekkoRenderer.prototype.init = function(options, plot) {
68
- this.fill = false;
69
- this.fillRect = true;
70
- this.strokeRect = true;
71
- this.shadow = false;
72
- // width of bar on x axis.
73
- this._xwidth = 0;
74
- this._xstart = 0;
75
- $.extend(true, this.renderer, options);
76
- // set the shape renderer options
77
- var opts = {lineJoin:'miter', lineCap:'butt', isarc:false, fillRect:this.fillRect, strokeRect:this.strokeRect};
78
- this.renderer.shapeRenderer.init(opts);
79
- plot.axes.x2axis._series.push(this);
80
- this._type = 'mekko';
81
- };
82
-
83
- // Method: setGridData
84
- // converts the user data values to grid coordinates and stores them
85
- // in the gridData array. Will convert user data into appropriate
86
- // rectangles.
87
- // Called with scope of a series.
88
- $.jqplot.MekkoRenderer.prototype.setGridData = function(plot) {
89
- // recalculate the grid data
90
- var xp = this._xaxis.series_u2p;
91
- var yp = this._yaxis.series_u2p;
92
- var data = this._plotData;
93
- this.gridData = [];
94
- // figure out width on x axis.
95
- // this._xwidth = this._sumy / plot._sumy * this.canvas.getWidth();
96
- this._xwidth = xp(this._sumy) - xp(0);
97
- if (this.index>0) {
98
- this._xstart = plot.series[this.index-1]._xstart + plot.series[this.index-1]._xwidth;
99
- }
100
- var totheight = this.canvas.getHeight();
101
- var sumy = 0;
102
- var cury;
103
- var curheight;
104
- for (var i=0; i<data.length; i++) {
105
- if (data[i] != null) {
106
- sumy += data[i][1];
107
- cury = totheight - (sumy / this._sumy * totheight);
108
- curheight = data[i][1] / this._sumy * totheight;
109
- this.gridData.push([this._xstart, cury, this._xwidth, curheight]);
110
- }
111
- }
112
- };
113
-
114
- // Method: makeGridData
115
- // converts any arbitrary data values to grid coordinates and
116
- // returns them. This method exists so that plugins can use a series'
117
- // linerenderer to generate grid data points without overwriting the
118
- // grid data associated with that series.
119
- // Called with scope of a series.
120
- $.jqplot.MekkoRenderer.prototype.makeGridData = function(data, plot) {
121
- // recalculate the grid data
122
- // figure out width on x axis.
123
- var xp = this._xaxis.series_u2p;
124
- var totheight = this.canvas.getHeight();
125
- var sumy = 0;
126
- var cury;
127
- var curheight;
128
- var gd = [];
129
- for (var i=0; i<data.length; i++) {
130
- if (data[i] != null) {
131
- sumy += data[i][1];
132
- cury = totheight - (sumy / this._sumy * totheight);
133
- curheight = data[i][1] / this._sumy * totheight;
134
- gd.push([this._xstart, cury, this._xwidth, curheight]);
135
- }
136
- }
137
- return gd;
138
- };
139
-
140
-
141
- // called within scope of series.
142
- $.jqplot.MekkoRenderer.prototype.draw = function(ctx, gd, options) {
143
- var i;
144
- var opts = (options != undefined) ? options : {};
145
- var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
146
- var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
147
- ctx.save();
148
- if (gd.length) {
149
- if (showLine) {
150
- for (i=0; i<gd.length; i++){
151
- opts.fillStyle = colorGenerator.next();
152
- if (this.renderer.showBorders) {
153
- opts.strokeStyle = this.renderer.borderColor;
154
- }
155
- else {
156
- opts.strokeStyle = opts.fillStyle;
157
- }
158
- this.renderer.shapeRenderer.draw(ctx, gd[i], opts);
159
- }
160
- }
161
- }
162
-
163
- ctx.restore();
164
- };
165
-
166
- $.jqplot.MekkoRenderer.prototype.drawShadow = function(ctx, gd, options) {
167
- // This is a no-op, no shadows on mekko charts.
168
- };
169
-
170
- /**
171
- * Class: $.jqplot.MekkoLegendRenderer
172
- * Legend renderer used by mekko charts with options for
173
- * controlling number or rows and columns as well as placement
174
- * outside of plot area.
175
- *
176
- */
177
- $.jqplot.MekkoLegendRenderer = function(){
178
- //
179
- };
180
-
181
- $.jqplot.MekkoLegendRenderer.prototype.init = function(options) {
182
- // prop: numberRows
183
- // Maximum number of rows in the legend. 0 or null for unlimited.
184
- this.numberRows = null;
185
- // prop: numberColumns
186
- // Maximum number of columns in the legend. 0 or null for unlimited.
187
- this.numberColumns = null;
188
- // this will override the placement option on the Legend object
189
- this.placement = "outside";
190
- $.extend(true, this, options);
191
- };
192
-
193
- // called with scope of legend
194
- $.jqplot.MekkoLegendRenderer.prototype.draw = function() {
195
- var legend = this;
196
- if (this.show) {
197
- var series = this._series;
198
- var ss = 'position:absolute;';
199
- ss += (this.background) ? 'background:'+this.background+';' : '';
200
- ss += (this.border) ? 'border:'+this.border+';' : '';
201
- ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
202
- ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
203
- ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
204
- this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
205
- // Mekko charts legends don't go by number of series, but by number of data points
206
- // in the series. Refactor things here for that.
207
-
208
- var pad = false,
209
- reverse = true, // mekko charts are always stacked, so reverse
210
- nr, nc;
211
- var s = series[0];
212
- var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
213
-
214
- if (s.show) {
215
- var pd = s.data;
216
- if (this.numberRows) {
217
- nr = this.numberRows;
218
- if (!this.numberColumns){
219
- nc = Math.ceil(pd.length/nr);
220
- }
221
- else{
222
- nc = this.numberColumns;
223
- }
224
- }
225
- else if (this.numberColumns) {
226
- nc = this.numberColumns;
227
- nr = Math.ceil(pd.length/this.numberColumns);
228
- }
229
- else {
230
- nr = pd.length;
231
- nc = 1;
232
- }
233
-
234
- var i, j, tr, td1, td2, lt, rs, color;
235
- var idx = 0;
236
-
237
- for (i=0; i<nr; i++) {
238
- if (reverse){
239
- tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
240
- }
241
- else{
242
- tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
243
- }
244
- for (j=0; j<nc; j++) {
245
- if (idx < pd.length) {
246
- lt = this.labels[idx] || pd[idx][0].toString();
247
- color = colorGenerator.next();
248
- if (!reverse){
249
- if (i>0){
250
- pad = true;
251
- }
252
- else{
253
- pad = false;
254
- }
255
- }
256
- else{
257
- if (i == nr -1){
258
- pad = false;
259
- }
260
- else{
261
- pad = true;
262
- }
263
- }
264
- rs = (pad) ? this.rowSpacing : '0';
265
-
266
- td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
267
- '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
268
- '</div></td>');
269
- td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
270
- if (this.escapeHtml){
271
- td2.text(lt);
272
- }
273
- else {
274
- td2.html(lt);
275
- }
276
- if (reverse) {
277
- td2.prependTo(tr);
278
- td1.prependTo(tr);
279
- }
280
- else {
281
- td1.appendTo(tr);
282
- td2.appendTo(tr);
283
- }
284
- pad = true;
285
- }
286
- idx++;
287
- }
288
- }
289
- }
290
- }
291
- return this._elem;
292
- };
293
-
294
- $.jqplot.MekkoLegendRenderer.prototype.pack = function(offsets) {
295
- if (this.show) {
296
- // fake a grid for positioning
297
- var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom};
298
- if (this.placement == 'insideGrid') {
299
- switch (this.location) {
300
- case 'nw':
301
- var a = grid._left + this.xoffset;
302
- var b = grid._top + this.yoffset;
303
- this._elem.css('left', a);
304
- this._elem.css('top', b);
305
- break;
306
- case 'n':
307
- var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
308
- var b = grid._top + this.yoffset;
309
- this._elem.css('left', a);
310
- this._elem.css('top', b);
311
- break;
312
- case 'ne':
313
- var a = offsets.right + this.xoffset;
314
- var b = grid._top + this.yoffset;
315
- this._elem.css({right:a, top:b});
316
- break;
317
- case 'e':
318
- var a = offsets.right + this.xoffset;
319
- var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
320
- this._elem.css({right:a, top:b});
321
- break;
322
- case 'se':
323
- var a = offsets.right + this.xoffset;
324
- var b = offsets.bottom + this.yoffset;
325
- this._elem.css({right:a, bottom:b});
326
- break;
327
- case 's':
328
- var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
329
- var b = offsets.bottom + this.yoffset;
330
- this._elem.css({left:a, bottom:b});
331
- break;
332
- case 'sw':
333
- var a = grid._left + this.xoffset;
334
- var b = offsets.bottom + this.yoffset;
335
- this._elem.css({left:a, bottom:b});
336
- break;
337
- case 'w':
338
- var a = grid._left + this.xoffset;
339
- var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
340
- this._elem.css({left:a, top:b});
341
- break;
342
- default: // same as 'se'
343
- var a = grid._right - this.xoffset;
344
- var b = grid._bottom + this.yoffset;
345
- this._elem.css({right:a, bottom:b});
346
- break;
347
- }
348
-
349
- }
350
- else {
351
- switch (this.location) {
352
- case 'nw':
353
- var a = this._plotDimensions.width - grid._left + this.xoffset;
354
- var b = grid._top + this.yoffset;
355
- this._elem.css('right', a);
356
- this._elem.css('top', b);
357
- break;
358
- case 'n':
359
- var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
360
- var b = this._plotDimensions.height - grid._top + this.yoffset;
361
- this._elem.css('left', a);
362
- this._elem.css('bottom', b);
363
- break;
364
- case 'ne':
365
- var a = this._plotDimensions.width - offsets.right + this.xoffset;
366
- var b = grid._top + this.yoffset;
367
- this._elem.css({left:a, top:b});
368
- break;
369
- case 'e':
370
- var a = this._plotDimensions.width - offsets.right + this.xoffset;
371
- var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
372
- this._elem.css({left:a, top:b});
373
- break;
374
- case 'se':
375
- var a = this._plotDimensions.width - offsets.right + this.xoffset;
376
- var b = offsets.bottom + this.yoffset;
377
- this._elem.css({left:a, bottom:b});
378
- break;
379
- case 's':
380
- var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
381
- var b = this._plotDimensions.height - offsets.bottom + this.yoffset;
382
- this._elem.css({left:a, top:b});
383
- break;
384
- case 'sw':
385
- var a = this._plotDimensions.width - grid._left + this.xoffset;
386
- var b = offsets.bottom + this.yoffset;
387
- this._elem.css({right:a, bottom:b});
388
- break;
389
- case 'w':
390
- var a = this._plotDimensions.width - grid._left + this.xoffset;
391
- var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
392
- this._elem.css({right:a, top:b});
393
- break;
394
- default: // same as 'se'
395
- var a = grid._right - this.xoffset;
396
- var b = grid._bottom + this.yoffset;
397
- this._elem.css({right:a, bottom:b});
398
- break;
399
- }
400
- }
401
- }
402
- };
403
-
404
- // setup default renderers for axes and legend so user doesn't have to
405
- // called with scope of plot
406
- function preInit(target, data, options) {
407
- options = options || {};
408
- options.axesDefaults = options.axesDefaults || {};
409
- options.legend = options.legend || {};
410
- options.seriesDefaults = options.seriesDefaults || {};
411
- var setopts = false;
412
- if (options.seriesDefaults.renderer == $.jqplot.MekkoRenderer) {
413
- setopts = true;
414
- }
415
- else if (options.series) {
416
- for (var i=0; i < options.series.length; i++) {
417
- if (options.series[i].renderer == $.jqplot.MekkoRenderer) {
418
- setopts = true;
419
- }
420
- }
421
- }
422
-
423
- if (setopts) {
424
- options.axesDefaults.renderer = $.jqplot.MekkoAxisRenderer;
425
- options.legend.renderer = $.jqplot.MekkoLegendRenderer;
426
- options.legend.preDraw = true;
427
- }
428
- }
429
-
430
- $.jqplot.preInitHooks.push(preInit);
431
-
432
- })(jQuery);