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,634 +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.CategoryAxisRenderer
33
- * A plugin for jqPlot to render a category style axis, with equal pixel spacing between y data values of a series.
34
- *
35
- * To use this renderer, include the plugin in your source
36
- * > <script type="text/javascript" language="javascript" src="plugins/jqplot.categoryAxisRenderer.js"></script>
37
- *
38
- * and supply the appropriate options to your plot
39
- *
40
- * > {axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer}}}
41
- **/
42
- $.jqplot.CategoryAxisRenderer = function(options) {
43
- $.jqplot.LinearAxisRenderer.call(this);
44
- // prop: sortMergedLabels
45
- // True to sort tick labels when labels are created by merging
46
- // x axis values from multiple series. That is, say you have
47
- // two series like:
48
- // > line1 = [[2006, 4], [2008, 9], [2009, 16]];
49
- // > line2 = [[2006, 3], [2007, 7], [2008, 6]];
50
- // If no label array is specified, tick labels will be collected
51
- // from the x values of the series. With sortMergedLabels
52
- // set to true, tick labels will be:
53
- // > [2006, 2007, 2008, 2009]
54
- // With sortMergedLabels set to false, tick labels will be:
55
- // > [2006, 2008, 2009, 2007]
56
- //
57
- // Note, this property is specified on the renderOptions for the
58
- // axes when creating a plot:
59
- // > axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer, rendererOptions:{sortMergedLabels:true}}}
60
- this.sortMergedLabels = false;
61
- };
62
-
63
- $.jqplot.CategoryAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
64
- $.jqplot.CategoryAxisRenderer.prototype.constructor = $.jqplot.CategoryAxisRenderer;
65
-
66
- $.jqplot.CategoryAxisRenderer.prototype.init = function(options){
67
- this.groups = 1;
68
- this.groupLabels = [];
69
- this._groupLabels = [];
70
- this._grouped = false;
71
- this._barsPerGroup = null;
72
- // prop: tickRenderer
73
- // A class of a rendering engine for creating the ticks labels displayed on the plot,
74
- // See <$.jqplot.AxisTickRenderer>.
75
- // this.tickRenderer = $.jqplot.AxisTickRenderer;
76
- // this.labelRenderer = $.jqplot.AxisLabelRenderer;
77
- $.extend(true, this, {tickOptions:{formatString:'%d'}}, options);
78
- var db = this._dataBounds;
79
- // Go through all the series attached to this axis and find
80
- // the min/max bounds for this axis.
81
- for (var i=0; i<this._series.length; i++) {
82
- var s = this._series[i];
83
- if (s.groups) {
84
- this.groups = s.groups;
85
- }
86
- var d = s.data;
87
-
88
- for (var j=0; j<d.length; j++) {
89
- if (this.name == 'xaxis' || this.name == 'x2axis') {
90
- if (d[j][0] < db.min || db.min == null) {
91
- db.min = d[j][0];
92
- }
93
- if (d[j][0] > db.max || db.max == null) {
94
- db.max = d[j][0];
95
- }
96
- }
97
- else {
98
- if (d[j][1] < db.min || db.min == null) {
99
- db.min = d[j][1];
100
- }
101
- if (d[j][1] > db.max || db.max == null) {
102
- db.max = d[j][1];
103
- }
104
- }
105
- }
106
- }
107
-
108
- if (this.groupLabels.length) {
109
- this.groups = this.groupLabels.length;
110
- }
111
- };
112
-
113
-
114
- $.jqplot.CategoryAxisRenderer.prototype.createTicks = function() {
115
- // we're are operating on an axis here
116
- var ticks = this._ticks;
117
- var userTicks = this.ticks;
118
- var name = this.name;
119
- // databounds were set on axis initialization.
120
- var db = this._dataBounds;
121
- var dim, interval;
122
- var min, max;
123
- var pos1, pos2;
124
- var tt, i;
125
-
126
- // if we already have ticks, use them.
127
- if (userTicks.length) {
128
- // adjust with blanks if we have groups
129
- if (this.groups > 1 && !this._grouped) {
130
- var l = userTicks.length;
131
- var skip = parseInt(l/this.groups, 10);
132
- var count = 0;
133
- for (var i=skip; i<l; i+=skip) {
134
- userTicks.splice(i+count, 0, ' ');
135
- count++;
136
- }
137
- this._grouped = true;
138
- }
139
- this.min = 0.5;
140
- this.max = userTicks.length + 0.5;
141
- var range = this.max - this.min;
142
- this.numberTicks = 2*userTicks.length + 1;
143
- for (i=0; i<userTicks.length; i++){
144
- tt = this.min + 2 * i * range / (this.numberTicks-1);
145
- // need a marker before and after the tick
146
- var t = new this.tickRenderer(this.tickOptions);
147
- t.showLabel = false;
148
- // t.showMark = true;
149
- t.setTick(tt, this.name);
150
- this._ticks.push(t);
151
- var t = new this.tickRenderer(this.tickOptions);
152
- t.label = userTicks[i];
153
- // t.showLabel = true;
154
- t.showMark = false;
155
- t.showGridline = false;
156
- t.setTick(tt+0.5, this.name);
157
- this._ticks.push(t);
158
- }
159
- // now add the last tick at the end
160
- var t = new this.tickRenderer(this.tickOptions);
161
- t.showLabel = false;
162
- // t.showMark = true;
163
- t.setTick(tt+1, this.name);
164
- this._ticks.push(t);
165
- }
166
-
167
- // we don't have any ticks yet, let's make some!
168
- else {
169
- if (name == 'xaxis' || name == 'x2axis') {
170
- dim = this._plotDimensions.width;
171
- }
172
- else {
173
- dim = this._plotDimensions.height;
174
- }
175
-
176
- // if min, max and number of ticks specified, user can't specify interval.
177
- if (this.min != null && this.max != null && this.numberTicks != null) {
178
- this.tickInterval = null;
179
- }
180
-
181
- // if max, min, and interval specified and interval won't fit, ignore interval.
182
- if (this.min != null && this.max != null && this.tickInterval != null) {
183
- if (parseInt((this.max-this.min)/this.tickInterval, 10) != (this.max-this.min)/this.tickInterval) {
184
- this.tickInterval = null;
185
- }
186
- }
187
-
188
- // find out how many categories are in the lines and collect labels
189
- var labels = [];
190
- var numcats = 0;
191
- var min = 0.5;
192
- var max, val;
193
- var isMerged = false;
194
- for (var i=0; i<this._series.length; i++) {
195
- var s = this._series[i];
196
- for (var j=0; j<s.data.length; j++) {
197
- if (this.name == 'xaxis' || this.name == 'x2axis') {
198
- val = s.data[j][0];
199
- }
200
- else {
201
- val = s.data[j][1];
202
- }
203
- if ($.inArray(val, labels) == -1) {
204
- isMerged = true;
205
- numcats += 1;
206
- labels.push(val);
207
- }
208
- }
209
- }
210
-
211
- if (isMerged && this.sortMergedLabels) {
212
- labels.sort(function(a,b) { return a - b; });
213
- }
214
-
215
- // keep a reference to these tick labels to use for redrawing plot (see bug #57)
216
- this.ticks = labels;
217
-
218
- // now bin the data values to the right lables.
219
- for (var i=0; i<this._series.length; i++) {
220
- var s = this._series[i];
221
- for (var j=0; j<s.data.length; j++) {
222
- if (this.name == 'xaxis' || this.name == 'x2axis') {
223
- val = s.data[j][0];
224
- }
225
- else {
226
- val = s.data[j][1];
227
- }
228
- // for category axis, force the values into category bins.
229
- // we should have the value in the label array now.
230
- var idx = $.inArray(val, labels)+1;
231
- if (this.name == 'xaxis' || this.name == 'x2axis') {
232
- s.data[j][0] = idx;
233
- }
234
- else {
235
- s.data[j][1] = idx;
236
- }
237
- }
238
- }
239
-
240
- // adjust with blanks if we have groups
241
- if (this.groups > 1 && !this._grouped) {
242
- var l = labels.length;
243
- var skip = parseInt(l/this.groups, 10);
244
- var count = 0;
245
- for (var i=skip; i<l; i+=skip+1) {
246
- labels[i] = ' ';
247
- }
248
- this._grouped = true;
249
- }
250
-
251
- max = numcats + 0.5;
252
- if (this.numberTicks == null) {
253
- this.numberTicks = 2*numcats + 1;
254
- }
255
-
256
- var range = max - min;
257
- this.min = min;
258
- this.max = max;
259
- var track = 0;
260
-
261
- // todo: adjust this so more ticks displayed.
262
- var maxVisibleTicks = parseInt(3+dim/20, 10);
263
- var skip = parseInt(numcats/maxVisibleTicks, 10);
264
-
265
- if (this.tickInterval == null) {
266
-
267
- this.tickInterval = range / (this.numberTicks-1);
268
-
269
- }
270
- // if tickInterval is specified, we will ignore any computed maximum.
271
- for (var i=0; i<this.numberTicks; i++){
272
- tt = this.min + i * this.tickInterval;
273
- var t = new this.tickRenderer(this.tickOptions);
274
- // if even tick, it isn't a category, it's a divider
275
- if (i/2 == parseInt(i/2, 10)) {
276
- t.showLabel = false;
277
- t.showMark = true;
278
- }
279
- else {
280
- if (skip>0 && track<skip) {
281
- t.showLabel = false;
282
- track += 1;
283
- }
284
- else {
285
- t.showLabel = true;
286
- track = 0;
287
- }
288
- t.label = t.formatter(t.formatString, labels[(i-1)/2]);
289
- t.showMark = false;
290
- t.showGridline = false;
291
- }
292
- t.setTick(tt, this.name);
293
- this._ticks.push(t);
294
- }
295
- }
296
-
297
- };
298
-
299
- // called with scope of axis
300
- $.jqplot.CategoryAxisRenderer.prototype.draw = function(ctx) {
301
- if (this.show) {
302
- // populate the axis label and value properties.
303
- // createTicks is a method on the renderer, but
304
- // call it within the scope of the axis.
305
- this.renderer.createTicks.call(this);
306
- // fill a div with axes labels in the right direction.
307
- // Need to pregenerate each axis to get it's bounds and
308
- // position it and the labels correctly on the plot.
309
- var dim=0;
310
- var temp;
311
- // Added for theming.
312
- if (this._elem) {
313
- this._elem.empty();
314
- }
315
-
316
- this._elem = this._elem || $('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>');
317
-
318
- if (this.name == 'xaxis' || this.name == 'x2axis') {
319
- this._elem.width(this._plotDimensions.width);
320
- }
321
- else {
322
- this._elem.height(this._plotDimensions.height);
323
- }
324
-
325
- // create a _label object.
326
- this.labelOptions.axis = this.name;
327
- this._label = new this.labelRenderer(this.labelOptions);
328
- if (this._label.show) {
329
- var elem = this._label.draw(ctx);
330
- elem.appendTo(this._elem);
331
- }
332
-
333
- var t = this._ticks;
334
- for (var i=0; i<t.length; i++) {
335
- var tick = t[i];
336
- if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
337
- var elem = tick.draw(ctx);
338
- elem.appendTo(this._elem);
339
- }
340
- }
341
-
342
- this._groupLabels = [];
343
- // now make group labels
344
- for (var i=0; i<this.groupLabels.length; i++)
345
- {
346
- var elem = $('<div style="position:absolute;" class="jqplot-'+this.name+'-groupLabel"></div>');
347
- elem.html(this.groupLabels[i]);
348
- this._groupLabels.push(elem);
349
- elem.appendTo(this._elem);
350
- }
351
- }
352
- return this._elem;
353
- };
354
-
355
- // called with scope of axis
356
- $.jqplot.CategoryAxisRenderer.prototype.set = function() {
357
- var dim = 0;
358
- var temp;
359
- var w = 0;
360
- var h = 0;
361
- var lshow = (this._label == null) ? false : this._label.show;
362
- if (this.show) {
363
- var t = this._ticks;
364
- for (var i=0; i<t.length; i++) {
365
- var tick = t[i];
366
- if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
367
- if (this.name == 'xaxis' || this.name == 'x2axis') {
368
- temp = tick._elem.outerHeight(true);
369
- }
370
- else {
371
- temp = tick._elem.outerWidth(true);
372
- }
373
- if (temp > dim) {
374
- dim = temp;
375
- }
376
- }
377
- }
378
-
379
- var dim2 = 0;
380
- for (var i=0; i<this._groupLabels.length; i++) {
381
- var l = this._groupLabels[i];
382
- if (this.name == 'xaxis' || this.name == 'x2axis') {
383
- temp = l.outerHeight(true);
384
- }
385
- else {
386
- temp = l.outerWidth(true);
387
- }
388
- if (temp > dim2) {
389
- dim2 = temp;
390
- }
391
- }
392
-
393
- if (lshow) {
394
- w = this._label._elem.outerWidth(true);
395
- h = this._label._elem.outerHeight(true);
396
- }
397
- if (this.name == 'xaxis') {
398
- dim += dim2 + h;
399
- this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'});
400
- }
401
- else if (this.name == 'x2axis') {
402
- dim += dim2 + h;
403
- this._elem.css({'height':dim+'px', left:'0px', top:'0px'});
404
- }
405
- else if (this.name == 'yaxis') {
406
- dim += dim2 + w;
407
- this._elem.css({'width':dim+'px', left:'0px', top:'0px'});
408
- if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
409
- this._label._elem.css('width', w+'px');
410
- }
411
- }
412
- else {
413
- dim += dim2 + w;
414
- this._elem.css({'width':dim+'px', right:'0px', top:'0px'});
415
- if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
416
- this._label._elem.css('width', w+'px');
417
- }
418
- }
419
- }
420
- };
421
-
422
- // called with scope of axis
423
- $.jqplot.CategoryAxisRenderer.prototype.pack = function(pos, offsets) {
424
- var ticks = this._ticks;
425
- var max = this.max;
426
- var min = this.min;
427
- var offmax = offsets.max;
428
- var offmin = offsets.min;
429
- var lshow = (this._label == null) ? false : this._label.show;
430
- var i;
431
-
432
- for (var p in pos) {
433
- this._elem.css(p, pos[p]);
434
- }
435
-
436
- this._offsets = offsets;
437
- // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left.
438
- var pixellength = offmax - offmin;
439
- var unitlength = max - min;
440
-
441
- // point to unit and unit to point conversions references to Plot DOM element top left corner.
442
- this.p2u = function(p){
443
- return (p - offmin) * unitlength / pixellength + min;
444
- };
445
-
446
- this.u2p = function(u){
447
- return (u - min) * pixellength / unitlength + offmin;
448
- };
449
-
450
- if (this.name == 'xaxis' || this.name == 'x2axis'){
451
- this.series_u2p = function(u){
452
- return (u - min) * pixellength / unitlength;
453
- };
454
- this.series_p2u = function(p){
455
- return p * unitlength / pixellength + min;
456
- };
457
- }
458
-
459
- else {
460
- this.series_u2p = function(u){
461
- return (u - max) * pixellength / unitlength;
462
- };
463
- this.series_p2u = function(p){
464
- return p * unitlength / pixellength + max;
465
- };
466
- }
467
-
468
- if (this.show) {
469
- if (this.name == 'xaxis' || this.name == 'x2axis') {
470
- for (i=0; i<ticks.length; i++) {
471
- var t = ticks[i];
472
- if (t.show && t.showLabel) {
473
- var shim;
474
-
475
- if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
476
- // will need to adjust auto positioning based on which axis this is.
477
- var temp = (this.name == 'xaxis') ? 1 : -1;
478
- switch (t.labelPosition) {
479
- case 'auto':
480
- // position at end
481
- if (temp * t.angle < 0) {
482
- shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
483
- }
484
- // position at start
485
- else {
486
- shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
487
- }
488
- break;
489
- case 'end':
490
- shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
491
- break;
492
- case 'start':
493
- shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
494
- break;
495
- case 'middle':
496
- shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
497
- break;
498
- default:
499
- shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
500
- break;
501
- }
502
- }
503
- else {
504
- shim = -t.getWidth()/2;
505
- }
506
- var val = this.u2p(t.value) + shim + 'px';
507
- t._elem.css('left', val);
508
- t.pack();
509
- }
510
- }
511
-
512
- var labeledge=['bottom', 0];
513
- if (lshow) {
514
- var w = this._label._elem.outerWidth(true);
515
- this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px');
516
- if (this.name == 'xaxis') {
517
- this._label._elem.css('bottom', '0px');
518
- labeledge = ['bottom', this._label._elem.outerHeight(true)];
519
- }
520
- else {
521
- this._label._elem.css('top', '0px');
522
- labeledge = ['top', this._label._elem.outerHeight(true)];
523
- }
524
- this._label.pack();
525
- }
526
-
527
- // draw the group labels
528
- var step = parseInt(this._ticks.length/this.groups, 10);
529
- for (i=0; i<this._groupLabels.length; i++) {
530
- var mid = 0;
531
- var count = 0;
532
- for (var j=i*step; j<=(i+1)*step; j++) {
533
- if (this._ticks[j]._elem && this._ticks[j].label != " ") {
534
- var t = this._ticks[j]._elem;
535
- var p = t.position();
536
- mid += p.left + t.outerWidth(true)/2;
537
- count++;
538
- }
539
- }
540
- mid = mid/count;
541
- this._groupLabels[i].css({'left':(mid - this._groupLabels[i].outerWidth(true)/2)});
542
- this._groupLabels[i].css(labeledge[0], labeledge[1]);
543
- }
544
- }
545
- else {
546
- for (i=0; i<ticks.length; i++) {
547
- var t = ticks[i];
548
- if (t.show && t.showLabel) {
549
- var shim;
550
- if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
551
- // will need to adjust auto positioning based on which axis this is.
552
- var temp = (this.name == 'yaxis') ? 1 : -1;
553
- switch (t.labelPosition) {
554
- case 'auto':
555
- // position at end
556
- case 'end':
557
- if (temp * t.angle < 0) {
558
- shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
559
- }
560
- else {
561
- shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
562
- }
563
- break;
564
- case 'start':
565
- if (t.angle > 0) {
566
- shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
567
- }
568
- else {
569
- shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
570
- }
571
- break;
572
- case 'middle':
573
- // if (t.angle > 0) {
574
- // shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
575
- // }
576
- // else {
577
- // shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
578
- // }
579
- shim = -t.getHeight()/2;
580
- break;
581
- default:
582
- shim = -t.getHeight()/2;
583
- break;
584
- }
585
- }
586
- else {
587
- shim = -t.getHeight()/2;
588
- }
589
-
590
- var val = this.u2p(t.value) + shim + 'px';
591
- t._elem.css('top', val);
592
- t.pack();
593
- }
594
- }
595
-
596
- var labeledge=['left', 0];
597
- if (lshow) {
598
- var h = this._label._elem.outerHeight(true);
599
- this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px');
600
- if (this.name == 'yaxis') {
601
- this._label._elem.css('left', '0px');
602
- labeledge = ['left', this._label._elem.outerWidth(true)];
603
- }
604
- else {
605
- this._label._elem.css('right', '0px');
606
- labeledge = ['right', this._label._elem.outerWidth(true)];
607
- }
608
- this._label.pack();
609
- }
610
-
611
- // draw the group labels, position top here, do left after label position.
612
- var step = parseInt(this._ticks.length/this.groups, 10);
613
- for (i=0; i<this._groupLabels.length; i++) {
614
- var mid = 0;
615
- var count = 0;
616
- for (var j=i*step; j<=(i+1)*step; j++) {
617
- if (this._ticks[j]._elem && this._ticks[j].label != " ") {
618
- var t = this._ticks[j]._elem;
619
- var p = t.position();
620
- mid += p.top + t.outerHeight()/2;
621
- count++;
622
- }
623
- }
624
- mid = mid/count;
625
- this._groupLabels[i].css({'top':mid - this._groupLabels[i].outerHeight()/2});
626
- this._groupLabels[i].css(labeledge[0], labeledge[1]);
627
-
628
- }
629
- }
630
- }
631
- };
632
-
633
-
634
- })(jQuery);