outfielding-jqplot-rails 1.0.4.1121

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