jquery_cheats 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/README.md +19 -2
  2. data/app/assets/javascripts/jqueryCheats.js +36 -1
  3. data/jquery_cheats.gemspec +2 -2
  4. data/lib/jquery_cheats.rb +4 -0
  5. data/vendor/assets/excanvas.js +1438 -0
  6. data/vendor/assets/jquery.jqplot.css +259 -0
  7. data/vendor/assets/jquery.jqplot.js +10901 -0
  8. data/vendor/assets/plugins/jqplot.BezierCurveRenderer.js +312 -0
  9. data/vendor/assets/plugins/jqplot.BezierCurveRenderer.min.js +57 -0
  10. data/vendor/assets/plugins/jqplot.barRenderer.js +747 -0
  11. data/vendor/assets/plugins/jqplot.barRenderer.min.js +57 -0
  12. data/vendor/assets/plugins/jqplot.blockRenderer.js +234 -0
  13. data/vendor/assets/plugins/jqplot.blockRenderer.min.js +57 -0
  14. data/vendor/assets/plugins/jqplot.bubbleRenderer.js +754 -0
  15. data/vendor/assets/plugins/jqplot.bubbleRenderer.min.js +57 -0
  16. data/vendor/assets/plugins/jqplot.canvasAxisLabelRenderer.js +202 -0
  17. data/vendor/assets/plugins/jqplot.canvasAxisLabelRenderer.min.js +57 -0
  18. data/vendor/assets/plugins/jqplot.canvasAxisTickRenderer.js +242 -0
  19. data/vendor/assets/plugins/jqplot.canvasAxisTickRenderer.min.js +57 -0
  20. data/vendor/assets/plugins/jqplot.canvasOverlay.js +864 -0
  21. data/vendor/assets/plugins/jqplot.canvasOverlay.min.js +57 -0
  22. data/vendor/assets/plugins/jqplot.canvasTextRenderer.js +448 -0
  23. data/vendor/assets/plugins/jqplot.canvasTextRenderer.min.js +57 -0
  24. data/vendor/assets/plugins/jqplot.categoryAxisRenderer.js +636 -0
  25. data/vendor/assets/plugins/jqplot.categoryAxisRenderer.min.js +57 -0
  26. data/vendor/assets/plugins/jqplot.ciParser.js +115 -0
  27. data/vendor/assets/plugins/jqplot.ciParser.min.js +57 -0
  28. data/vendor/assets/plugins/jqplot.cursor.js +1093 -0
  29. data/vendor/assets/plugins/jqplot.cursor.min.js +57 -0
  30. data/vendor/assets/plugins/jqplot.dateAxisRenderer.js +702 -0
  31. data/vendor/assets/plugins/jqplot.dateAxisRenderer.min.js +57 -0
  32. data/vendor/assets/plugins/jqplot.donutRenderer.js +800 -0
  33. data/vendor/assets/plugins/jqplot.donutRenderer.min.js +57 -0
  34. data/vendor/assets/plugins/jqplot.dragable.js +224 -0
  35. data/vendor/assets/plugins/jqplot.dragable.min.js +57 -0
  36. data/vendor/assets/plugins/jqplot.enhancedLegendRenderer.js +241 -0
  37. data/vendor/assets/plugins/jqplot.enhancedLegendRenderer.min.js +57 -0
  38. data/vendor/assets/plugins/jqplot.funnelRenderer.js +938 -0
  39. data/vendor/assets/plugins/jqplot.funnelRenderer.min.js +57 -0
  40. data/vendor/assets/plugins/jqplot.highlighter.js +454 -0
  41. data/vendor/assets/plugins/jqplot.highlighter.min.js +57 -0
  42. data/vendor/assets/plugins/jqplot.json2.js +475 -0
  43. data/vendor/assets/plugins/jqplot.json2.min.js +57 -0
  44. data/vendor/assets/plugins/jqplot.logAxisRenderer.js +528 -0
  45. data/vendor/assets/plugins/jqplot.logAxisRenderer.min.js +57 -0
  46. data/vendor/assets/plugins/jqplot.mekkoAxisRenderer.js +610 -0
  47. data/vendor/assets/plugins/jqplot.mekkoAxisRenderer.min.js +57 -0
  48. data/vendor/assets/plugins/jqplot.mekkoRenderer.js +436 -0
  49. data/vendor/assets/plugins/jqplot.mekkoRenderer.min.js +57 -0
  50. data/vendor/assets/plugins/jqplot.meterGaugeRenderer.js +1029 -0
  51. data/vendor/assets/plugins/jqplot.meterGaugeRenderer.min.js +57 -0
  52. data/vendor/assets/plugins/jqplot.ohlcRenderer.js +372 -0
  53. data/vendor/assets/plugins/jqplot.ohlcRenderer.min.js +57 -0
  54. data/vendor/assets/plugins/jqplot.pieRenderer.js +899 -0
  55. data/vendor/assets/plugins/jqplot.pieRenderer.min.js +57 -0
  56. data/vendor/assets/plugins/jqplot.pointLabels.js +362 -0
  57. data/vendor/assets/plugins/jqplot.pointLabels.min.js +57 -0
  58. data/vendor/assets/plugins/jqplot.pyramidAxisRenderer.js +730 -0
  59. data/vendor/assets/plugins/jqplot.pyramidAxisRenderer.min.js +57 -0
  60. data/vendor/assets/plugins/jqplot.pyramidGridRenderer.js +423 -0
  61. data/vendor/assets/plugins/jqplot.pyramidGridRenderer.min.js +57 -0
  62. data/vendor/assets/plugins/jqplot.pyramidRenderer.js +490 -0
  63. data/vendor/assets/plugins/jqplot.pyramidRenderer.min.js +57 -0
  64. data/vendor/assets/plugins/jqplot.trendline.js +222 -0
  65. data/vendor/assets/plugins/jqplot.trendline.min.js +57 -0
  66. metadata +64 -3
@@ -0,0 +1,702 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.0b2_r1012
6
+ *
7
+ * Copyright (c) 2009-2011 Chris Leonello
8
+ * jqPlot is currently available for use in all personal or commercial projects
9
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
10
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
11
+ * choose the license that best suits your project and use it accordingly.
12
+ *
13
+ * Although not required, the author would appreciate an email letting him
14
+ * know of any substantial use of jqPlot. You can reach the author at:
15
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
16
+ *
17
+ * If you are feeling kind and generous, consider supporting the project by
18
+ * making a donation at: http://www.jqplot.com/donate.php .
19
+ *
20
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
21
+ *
22
+ * version 2007.04.27
23
+ * author Ash Searle
24
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
25
+ * http://hexmen.com/js/sprintf.js
26
+ * The author (Ash Searle) has placed this code in the public domain:
27
+ * "This code is unrestricted: you are free to use it however you like."
28
+ *
29
+ */
30
+ (function($) {
31
+ /**
32
+ * Class: $.jqplot.DateAxisRenderer
33
+ * A plugin for a jqPlot to render an axis as a series of date values.
34
+ * This renderer has no options beyond those supplied by the <Axis> class.
35
+ * It supplies it's own tick formatter, so the tickOptions.formatter option
36
+ * should not be overridden.
37
+ *
38
+ * Thanks to Ken Synder for his enhanced Date instance methods which are
39
+ * included with this code <http://kendsnyder.com/sandbox/date/>.
40
+ *
41
+ * To use this renderer, include the plugin in your source
42
+ * > <script type="text/javascript" language="javascript" src="plugins/jqplot.dateAxisRenderer.js"></script>
43
+ *
44
+ * and supply the appropriate options to your plot
45
+ *
46
+ * > {axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}}}
47
+ *
48
+ * Dates can be passed into the axis in almost any recognizable value and
49
+ * will be parsed. They will be rendered on the axis in the format
50
+ * specified by tickOptions.formatString. e.g. tickOptions.formatString = '%Y-%m-%d'.
51
+ *
52
+ * Accecptable format codes
53
+ * are:
54
+ *
55
+ * > Code Result Description
56
+ * > == Years ==
57
+ * > %Y 2008 Four-digit year
58
+ * > %y 08 Two-digit year
59
+ * > == Months ==
60
+ * > %m 09 Two-digit month
61
+ * > %#m 9 One or two-digit month
62
+ * > %B September Full month name
63
+ * > %b Sep Abbreviated month name
64
+ * > == Days ==
65
+ * > %d 05 Two-digit day of month
66
+ * > %#d 5 One or two-digit day of month
67
+ * > %e 5 One or two-digit day of month
68
+ * > %A Sunday Full name of the day of the week
69
+ * > %a Sun Abbreviated name of the day of the week
70
+ * > %w 0 Number of the day of the week (0 = Sunday, 6 = Saturday)
71
+ * > %o th The ordinal suffix string following the day of the month
72
+ * > == Hours ==
73
+ * > %H 23 Hours in 24-hour format (two digits)
74
+ * > %#H 3 Hours in 24-hour integer format (one or two digits)
75
+ * > %I 11 Hours in 12-hour format (two digits)
76
+ * > %#I 3 Hours in 12-hour integer format (one or two digits)
77
+ * > %p PM AM or PM
78
+ * > == Minutes ==
79
+ * > %M 09 Minutes (two digits)
80
+ * > %#M 9 Minutes (one or two digits)
81
+ * > == Seconds ==
82
+ * > %S 02 Seconds (two digits)
83
+ * > %#S 2 Seconds (one or two digits)
84
+ * > %s 1206567625723 Unix timestamp (Seconds past 1970-01-01 00:00:00)
85
+ * > == Milliseconds ==
86
+ * > %N 008 Milliseconds (three digits)
87
+ * > %#N 8 Milliseconds (one to three digits)
88
+ * > == Timezone ==
89
+ * > %O 360 difference in minutes between local time and GMT
90
+ * > %Z Mountain Standard Time Name of timezone as reported by browser
91
+ * > %G -06:00 Hours and minutes between GMT
92
+ * > == Shortcuts ==
93
+ * > %F 2008-03-26 %Y-%m-%d
94
+ * > %T 05:06:30 %H:%M:%S
95
+ * > %X 05:06:30 %H:%M:%S
96
+ * > %x 03/26/08 %m/%d/%y
97
+ * > %D 03/26/08 %m/%d/%y
98
+ * > %#c Wed Mar 26 15:31:00 2008 %a %b %e %H:%M:%S %Y
99
+ * > %v 3-Sep-2008 %e-%b-%Y
100
+ * > %R 15:31 %H:%M
101
+ * > %r 3:31:00 PM %I:%M:%S %p
102
+ * > == Characters ==
103
+ * > %n \n Newline
104
+ * > %t \t Tab
105
+ * > %% % Percent Symbol
106
+ */
107
+ $.jqplot.DateAxisRenderer = function() {
108
+ $.jqplot.LinearAxisRenderer.call(this);
109
+ this.date = new $.jsDate();
110
+ };
111
+
112
+ var second = 1000;
113
+ var minute = 60 * second;
114
+ var hour = 60 * minute;
115
+ var day = 24 * hour;
116
+ var week = 7 * day;
117
+
118
+ // these are less definitive
119
+ var month = 30.4368499 * day;
120
+ var year = 365.242199 * day;
121
+
122
+ var daysInMonths = [31,28,31,30,31,30,31,30,31,30,31,30];
123
+ // array of consistent nice intervals. Longer intervals
124
+ // will depend on days in month, days in year, etc.
125
+ var niceFormatStrings = ['%M:%S.%#N', '%M:%S.%#N', '%M:%S.%#N', '%M:%S', '%M:%S', '%M:%S', '%M:%S', '%H:%M:%S', '%H:%M:%S', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%H:%M', '%a %H:%M', '%a %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%b %e %H:%M', '%v', '%v', '%v', '%v', '%v', '%v', '%v'];
126
+ var niceIntervals = [0.1*second, 0.2*second, 0.5*second, second, 2*second, 5*second, 10*second, 15*second, 30*second, minute, 2*minute, 5*minute, 10*minute, 15*minute, 30*minute, hour, 2*hour, 4*hour, 6*hour, 8*hour, 12*hour, day, 2*day, 3*day, 4*day, 5*day, week, 2*week];
127
+
128
+ var niceMonthlyIntervals = [];
129
+
130
+ function bestDateInterval(min, max, titarget) {
131
+ // iterate through niceIntervals to find one closest to titarget
132
+ var badness = Number.MAX_VALUE;
133
+ var temp, bestTi, bestfmt;
134
+ for (var i=0, l=niceIntervals.length; i < l; i++) {
135
+ temp = Math.abs(titarget - niceIntervals[i]);
136
+ if (temp < badness) {
137
+ badness = temp;
138
+ bestTi = niceIntervals[i];
139
+ bestfmt = niceFormatStrings[i];
140
+ }
141
+ }
142
+
143
+ return [bestTi, bestfmt];
144
+ }
145
+
146
+ $.jqplot.DateAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
147
+ $.jqplot.DateAxisRenderer.prototype.constructor = $.jqplot.DateAxisRenderer;
148
+
149
+ $.jqplot.DateTickFormatter = function(format, val) {
150
+ if (!format) {
151
+ format = '%Y/%m/%d';
152
+ }
153
+ return $.jsDate.strftime(val, format);
154
+ };
155
+
156
+ $.jqplot.DateAxisRenderer.prototype.init = function(options){
157
+ // prop: tickRenderer
158
+ // A class of a rendering engine for creating the ticks labels displayed on the plot,
159
+ // See <$.jqplot.AxisTickRenderer>.
160
+ // this.tickRenderer = $.jqplot.AxisTickRenderer;
161
+ // this.labelRenderer = $.jqplot.AxisLabelRenderer;
162
+ this.tickOptions.formatter = $.jqplot.DateTickFormatter;
163
+ // prop: tickInset
164
+ // Controls the amount to inset the first and last ticks from
165
+ // the edges of the grid, in multiples of the tick interval.
166
+ // 0 is no inset, 0.5 is one half a tick interval, 1 is a full
167
+ // tick interval, etc.
168
+ this.tickInset = 0;
169
+ // prop: drawBaseline
170
+ // True to draw the axis baseline.
171
+ this.drawBaseline = true;
172
+ // prop: baselineWidth
173
+ // width of the baseline in pixels.
174
+ this.baselineWidth = null;
175
+ // prop: baselineColor
176
+ // CSS color spec for the baseline.
177
+ this.baselineColor = null;
178
+ this.daTickInterval = null;
179
+ this._daTickInterval = null;
180
+
181
+ $.extend(true, this, options);
182
+
183
+ var db = this._dataBounds,
184
+ stats,
185
+ sum,
186
+ s,
187
+ d,
188
+ pd,
189
+ sd,
190
+ intv;
191
+
192
+ // Go through all the series attached to this axis and find
193
+ // the min/max bounds for this axis.
194
+ for (var i=0; i<this._series.length; i++) {
195
+ stats = {intervals:[], frequencies:{}, sortedIntervals:[], min:null, max:null, mean:null};
196
+ sum = 0;
197
+ s = this._series[i];
198
+ d = s.data;
199
+ pd = s._plotData;
200
+ sd = s._stackData;
201
+ intv = 0;
202
+
203
+ for (var j=0; j<d.length; j++) {
204
+ if (this.name == 'xaxis' || this.name == 'x2axis') {
205
+ d[j][0] = new $.jsDate(d[j][0]).getTime();
206
+ pd[j][0] = new $.jsDate(d[j][0]).getTime();
207
+ sd[j][0] = new $.jsDate(d[j][0]).getTime();
208
+ if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) {
209
+ db.min = d[j][0];
210
+ }
211
+ if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) {
212
+ db.max = d[j][0];
213
+ }
214
+ if (j>0) {
215
+ intv = Math.abs(d[j][0] - d[j-1][0]);
216
+ stats.intervals.push(intv);
217
+ if (stats.frequencies.hasOwnProperty(intv)) {
218
+ stats.frequencies[intv] += 1;
219
+ }
220
+ else {
221
+ stats.frequencies[intv] = 1;
222
+ }
223
+ }
224
+ sum += intv;
225
+
226
+ }
227
+ else {
228
+ d[j][1] = new $.jsDate(d[j][1]).getTime();
229
+ pd[j][1] = new $.jsDate(d[j][1]).getTime();
230
+ sd[j][1] = new $.jsDate(d[j][1]).getTime();
231
+ if ((d[j][1] != null && d[j][1] < db.min) || db.min == null) {
232
+ db.min = d[j][1];
233
+ }
234
+ if ((d[j][1] != null && d[j][1] > db.max) || db.max == null) {
235
+ db.max = d[j][1];
236
+ }
237
+ if (j>0) {
238
+ intv = Math.abs(d[j][1] - d[j-1][1]);
239
+ stats.intervals.push(intv);
240
+ if (stats.frequencies.hasOwnProperty(intv)) {
241
+ stats.frequencies[intv] += 1;
242
+ }
243
+ else {
244
+ stats.frequencies[intv] = 1;
245
+ }
246
+ }
247
+ }
248
+ sum += intv;
249
+ }
250
+
251
+ if (s.renderer.bands) {
252
+ if (s.renderer.bands.hiData.length) {
253
+ var bd = s.renderer.bands.hiData;
254
+ for (var j=0, l=bd.length; j < l; j++) {
255
+ if (this.name === 'xaxis' || this.name === 'x2axis') {
256
+ bd[j][0] = new $.jsDate(bd[j][0]).getTime();
257
+ if ((bd[j][0] != null && bd[j][0] > db.max) || db.max == null) {
258
+ db.max = bd[j][0];
259
+ }
260
+ }
261
+ else {
262
+ bd[j][1] = new $.jsDate(bd[j][1]).getTime();
263
+ if ((bd[j][1] != null && bd[j][1] > db.max) || db.max == null) {
264
+ db.max = bd[j][1];
265
+ }
266
+ }
267
+ }
268
+ }
269
+ if (s.renderer.bands.lowData.length) {
270
+ var bd = s.renderer.bands.lowData;
271
+ for (var j=0, l=bd.length; j < l; j++) {
272
+ if (this.name === 'xaxis' || this.name === 'x2axis') {
273
+ bd[j][0] = new $.jsDate(bd[j][0]).getTime();
274
+ if ((bd[j][0] != null && bd[j][0] < db.min) || db.min == null) {
275
+ db.min = bd[j][0];
276
+ }
277
+ }
278
+ else {
279
+ bd[j][1] = new $.jsDate(bd[j][1]).getTime();
280
+ if ((bd[j][1] != null && bd[j][1] < db.min) || db.min == null) {
281
+ db.min = bd[j][1];
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+
288
+ var tempf = 0,
289
+ tempn=0;
290
+ for (var n in stats.frequencies) {
291
+ stats.sortedIntervals.push({interval:n, frequency:stats.frequencies[n]});
292
+ }
293
+ stats.sortedIntervals.sort(function(a, b){
294
+ return b.frequency - a.frequency;
295
+ });
296
+
297
+ stats.min = $.jqplot.arrayMin(stats.intervals);
298
+ stats.max = $.jqplot.arrayMax(stats.intervals);
299
+ stats.mean = sum/d.length;
300
+ this._intervalStats.push(stats);
301
+ stats = sum = s = d = pd = sd = null;
302
+ }
303
+ db = null;
304
+
305
+ };
306
+
307
+ // called with scope of an axis
308
+ $.jqplot.DateAxisRenderer.prototype.reset = function() {
309
+ this.min = this._options.min;
310
+ this.max = this._options.max;
311
+ this.tickInterval = this._options.tickInterval;
312
+ this.numberTicks = this._options.numberTicks;
313
+ this._autoFormatString = '';
314
+ if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
315
+ this.tickOptions.formatString = '';
316
+ }
317
+ this.daTickInterval = this._daTickInterval;
318
+ // this._ticks = this.__ticks;
319
+ };
320
+
321
+ $.jqplot.DateAxisRenderer.prototype.createTicks = function(plot) {
322
+ // we're are operating on an axis here
323
+ var ticks = this._ticks;
324
+ var userTicks = this.ticks;
325
+ var name = this.name;
326
+ // databounds were set on axis initialization.
327
+ var db = this._dataBounds;
328
+ var iv = this._intervalStats;
329
+ var dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height;
330
+ var interval;
331
+ var min, max;
332
+ var pos1, pos2;
333
+ var tt, i;
334
+ var threshold = 30;
335
+ var insetMult = 1;
336
+
337
+ var tickInterval = this.tickInterval;
338
+
339
+ // if we already have ticks, use them.
340
+ // ticks must be in order of increasing value.
341
+
342
+ min = ((this.min != null) ? new $.jsDate(this.min).getTime() : db.min);
343
+ max = ((this.max != null) ? new $.jsDate(this.max).getTime() : db.max);
344
+
345
+ // see if we're zooming. if we are, don't use the min and max we're given,
346
+ // but compute some nice ones. They will be reset later.
347
+
348
+ var cursor = plot.plugins.cursor;
349
+
350
+ if (cursor && cursor._zoom && cursor._zoom.zooming) {
351
+ this.min = null;
352
+ this.max = null;
353
+ }
354
+
355
+ var range = max - min;
356
+
357
+ if (this.tickOptions == null || !this.tickOptions.formatString) {
358
+ this._overrideFormatString = true;
359
+ }
360
+
361
+ if (userTicks.length) {
362
+ // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
363
+ for (i=0; i<userTicks.length; i++){
364
+ var ut = userTicks[i];
365
+ var t = new this.tickRenderer(this.tickOptions);
366
+ if (ut.constructor == Array) {
367
+ t.value = new $.jsDate(ut[0]).getTime();
368
+ t.label = ut[1];
369
+ if (!this.showTicks) {
370
+ t.showLabel = false;
371
+ t.showMark = false;
372
+ }
373
+ else if (!this.showTickMarks) {
374
+ t.showMark = false;
375
+ }
376
+ t.setTick(t.value, this.name);
377
+ this._ticks.push(t);
378
+ }
379
+
380
+ else {
381
+ t.value = new $.jsDate(ut).getTime();
382
+ if (!this.showTicks) {
383
+ t.showLabel = false;
384
+ t.showMark = false;
385
+ }
386
+ else if (!this.showTickMarks) {
387
+ t.showMark = false;
388
+ }
389
+ t.setTick(t.value, this.name);
390
+ this._ticks.push(t);
391
+ }
392
+ }
393
+ this.numberTicks = userTicks.length;
394
+ this.min = this._ticks[0].value;
395
+ this.max = this._ticks[this.numberTicks-1].value;
396
+ this.daTickInterval = [(this.max - this.min) / (this.numberTicks - 1)/1000, 'seconds'];
397
+ }
398
+
399
+ ////////
400
+ // We don't have any ticks yet, let's make some!
401
+ ////////
402
+
403
+ // if user specified min and max are null, we set those to make best ticks.
404
+ else if (this.min == null && this.max == null) {
405
+ var opts = $.extend(true, {}, this.tickOptions, {name: this.name, value: null});
406
+ // want to find a nice interval
407
+ var nttarget,
408
+ titarget;
409
+
410
+ // if no tickInterval or numberTicks options specified, make a good guess.
411
+ if (!this.tickInterval && !this.numberTicks) {
412
+ var tdim = Math.max(dim, threshold+1);
413
+ // how many ticks to put on the axis?
414
+ // date labels tend to be long. If ticks not rotated,
415
+ // don't use too many and have a high spacing factor.
416
+ // If we are rotating ticks, use a lower factor.
417
+ var spacingFactor = 115;
418
+ if (this.tickRenderer === $.jqplot.CanvasAxisTickRenderer && this.tickOptions.angle) {
419
+ spacingFactor = 115 - 40 * Math.abs(Math.sin(this.tickOptions.angle/180*Math.PI));
420
+ }
421
+
422
+ nttarget = Math.ceil((tdim-threshold)/spacingFactor + 1);
423
+ titarget = (max - min) / (nttarget - 1);
424
+ }
425
+
426
+ // If tickInterval is specified, we'll try to honor it.
427
+ // Not gauranteed to get this interval, but we'll get as close as
428
+ // we can.
429
+ // tickInterval will be used before numberTicks, that is if
430
+ // both are specified, numberTicks will be ignored.
431
+ else if (this.tickInterval) {
432
+ titarget = this.tickInterval;
433
+ }
434
+
435
+ // if numberTicks specified, try to honor it.
436
+ // Not gauranteed, but will try to get close.
437
+ else if (this.numberTicks) {
438
+ nttarget = this.numberTicks;
439
+ titarget = (max - min) / (nttarget - 1);
440
+ }
441
+
442
+ // If we can use an interval of 2 weeks or less, pick best one
443
+ if (titarget <= 19*day) {
444
+ var ret = bestDateInterval(min, max, titarget);
445
+ var tempti = ret[0];
446
+ this._autoFormatString = ret[1];
447
+
448
+ min = Math.floor(min/tempti) * tempti;
449
+ min = new $.jsDate(min);
450
+ min = min.getTime() + min.getUtcOffset();
451
+
452
+ nttarget = Math.ceil((max - min) / tempti) + 1;
453
+ this.min = min;
454
+ this.max = min + (nttarget - 1) * tempti;
455
+
456
+ // if max is less than max, add an interval
457
+ if (this.max < max) {
458
+ this.max += tempti;
459
+ nttarget += 1;
460
+ }
461
+ this.tickInterval = tempti;
462
+ this.numberTicks = nttarget;
463
+
464
+ for (var i=0; i<nttarget; i++) {
465
+ opts.value = this.min + i * tempti;
466
+ t = new this.tickRenderer(opts);
467
+
468
+ if (this._overrideFormatString && this._autoFormatString != '') {
469
+ t.formatString = this._autoFormatString;
470
+ }
471
+ if (!this.showTicks) {
472
+ t.showLabel = false;
473
+ t.showMark = false;
474
+ }
475
+ else if (!this.showTickMarks) {
476
+ t.showMark = false;
477
+ }
478
+ this._ticks.push(t);
479
+ }
480
+
481
+ insetMult = this.tickInterval;
482
+ }
483
+
484
+ // should we use a monthly interval?
485
+ else if (titarget <= 9 * month) {
486
+
487
+ this._autoFormatString = '%v';
488
+
489
+ // how many months in an interval?
490
+ var intv = Math.round(titarget/month);
491
+ if (intv < 1) {
492
+ intv = 1;
493
+ }
494
+ else if (intv > 6) {
495
+ intv = 6;
496
+ }
497
+
498
+ // figure out the starting month and ending month.
499
+ var mstart = new $.jsDate(min).setDate(1).setHours(0,0,0,0);
500
+
501
+ // See if max ends exactly on a month
502
+ var tempmend = new $.jsDate(max);
503
+ var mend = new $.jsDate(max).setDate(1).setHours(0,0,0,0);
504
+
505
+ if (tempmend.getTime() !== mend.getTime()) {
506
+ mend = mend.add(1, 'month');
507
+ }
508
+
509
+ var nmonths = mend.diff(mstart, 'month');
510
+
511
+ nttarget = Math.ceil(nmonths/intv) + 1;
512
+
513
+ this.min = mstart.getTime();
514
+ this.max = mstart.clone().add((nttarget - 1) * intv, 'month').getTime();
515
+ this.numberTicks = nttarget;
516
+
517
+ for (var i=0; i<nttarget; i++) {
518
+ if (i === 0) {
519
+ opts.value = mstart.getTime();
520
+ }
521
+ else {
522
+ opts.value = mstart.add(intv, 'month').getTime();
523
+ }
524
+ t = new this.tickRenderer(opts);
525
+
526
+ if (this._overrideFormatString && this._autoFormatString != '') {
527
+ t.formatString = this._autoFormatString;
528
+ }
529
+ if (!this.showTicks) {
530
+ t.showLabel = false;
531
+ t.showMark = false;
532
+ }
533
+ else if (!this.showTickMarks) {
534
+ t.showMark = false;
535
+ }
536
+ this._ticks.push(t);
537
+ }
538
+
539
+ insetMult = intv * month;
540
+ }
541
+
542
+ // use yearly intervals
543
+ else {
544
+
545
+ this._autoFormatString = '%v';
546
+
547
+ // how many years in an interval?
548
+ var intv = Math.round(titarget/year);
549
+ if (intv < 1) {
550
+ intv = 1;
551
+ }
552
+
553
+ // figure out the starting and ending years.
554
+ var mstart = new $.jsDate(min).setMonth(0, 1).setHours(0,0,0,0);
555
+ var mend = new $.jsDate(max).add(1, 'year').setMonth(0, 1).setHours(0,0,0,0);
556
+
557
+ var nyears = mend.diff(mstart, 'year');
558
+
559
+ nttarget = Math.ceil(nyears/intv) + 1;
560
+
561
+ this.min = mstart.getTime();
562
+ this.max = mstart.clone().add((nttarget - 1) * intv, 'year').getTime();
563
+ this.numberTicks = nttarget;
564
+
565
+ for (var i=0; i<nttarget; i++) {
566
+ if (i === 0) {
567
+ opts.value = mstart.getTime();
568
+ }
569
+ else {
570
+ opts.value = mstart.add(intv, 'year').getTime();
571
+ }
572
+ t = new this.tickRenderer(opts);
573
+
574
+ if (this._overrideFormatString && this._autoFormatString != '') {
575
+ t.formatString = this._autoFormatString;
576
+ }
577
+ if (!this.showTicks) {
578
+ t.showLabel = false;
579
+ t.showMark = false;
580
+ }
581
+ else if (!this.showTickMarks) {
582
+ t.showMark = false;
583
+ }
584
+ this._ticks.push(t);
585
+ }
586
+
587
+ insetMult = intv * year;
588
+ }
589
+ }
590
+
591
+ ////////
592
+ // Some option(s) specified, work around that.
593
+ ////////
594
+
595
+ else {
596
+ if (name == 'xaxis' || name == 'x2axis') {
597
+ dim = this._plotDimensions.width;
598
+ }
599
+ else {
600
+ dim = this._plotDimensions.height;
601
+ }
602
+
603
+ // if min, max and number of ticks specified, user can't specify interval.
604
+ if (this.min != null && this.max != null && this.numberTicks != null) {
605
+ this.tickInterval = null;
606
+ }
607
+
608
+ // if user specified a tick interval, convert to usable.
609
+ if (this.tickInterval != null)
610
+ {
611
+ // if interval is a number or can be converted to one, use it.
612
+ // Assume it is in SECONDS!!!
613
+ if (Number(this.tickInterval)) {
614
+ this.daTickInterval = [Number(this.tickInterval), 'seconds'];
615
+ }
616
+ // else, parse out something we can build from.
617
+ else if (typeof this.tickInterval == "string") {
618
+ var parts = this.tickInterval.split(' ');
619
+ if (parts.length == 1) {
620
+ this.daTickInterval = [1, parts[0]];
621
+ }
622
+ else if (parts.length == 2) {
623
+ this.daTickInterval = [parts[0], parts[1]];
624
+ }
625
+ }
626
+ }
627
+
628
+ // if min and max are same, space them out a bit
629
+ if (min == max) {
630
+ var adj = 24*60*60*500; // 1/2 day
631
+ min -= adj;
632
+ max += adj;
633
+ }
634
+
635
+ range = max - min;
636
+
637
+ var optNumTicks = 2 + parseInt(Math.max(0, dim-100)/100, 10);
638
+
639
+
640
+ var rmin, rmax;
641
+
642
+ rmin = (this.min != null) ? new $.jsDate(this.min).getTime() : min - range/2*(this.padMin - 1);
643
+ rmax = (this.max != null) ? new $.jsDate(this.max).getTime() : max + range/2*(this.padMax - 1);
644
+ this.min = rmin;
645
+ this.max = rmax;
646
+ range = this.max - this.min;
647
+
648
+ if (this.numberTicks == null){
649
+ // if tickInterval is specified by user, we will ignore computed maximum.
650
+ // max will be equal or greater to fit even # of ticks.
651
+ if (this.daTickInterval != null) {
652
+ var nc = new $.jsDate(this.max).diff(this.min, this.daTickInterval[1], true);
653
+ this.numberTicks = Math.ceil(nc/this.daTickInterval[0]) +1;
654
+ // this.max = new $.jsDate(this.min).add(this.numberTicks-1, this.daTickInterval[1]).getTime();
655
+ this.max = new $.jsDate(this.min).add((this.numberTicks-1) * this.daTickInterval[0], this.daTickInterval[1]).getTime();
656
+ }
657
+ else if (dim > 200) {
658
+ this.numberTicks = parseInt(3+(dim-200)/100, 10);
659
+ }
660
+ else {
661
+ this.numberTicks = 2;
662
+ }
663
+ }
664
+
665
+ insetMult = range / (this.numberTicks-1)/1000;
666
+
667
+ if (this.daTickInterval == null) {
668
+ this.daTickInterval = [insetMult, 'seconds'];
669
+ }
670
+
671
+
672
+ for (var i=0; i<this.numberTicks; i++){
673
+ var min = new $.jsDate(this.min);
674
+ tt = min.add(i*this.daTickInterval[0], this.daTickInterval[1]).getTime();
675
+ var t = new this.tickRenderer(this.tickOptions);
676
+ // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
677
+ if (!this.showTicks) {
678
+ t.showLabel = false;
679
+ t.showMark = false;
680
+ }
681
+ else if (!this.showTickMarks) {
682
+ t.showMark = false;
683
+ }
684
+ t.setTick(tt, this.name);
685
+ this._ticks.push(t);
686
+ }
687
+ }
688
+
689
+ if (this.tickInset) {
690
+ this.min = this.min - this.tickInset * insetMult;
691
+ this.max = this.max + this.tickInset * insetMult;
692
+ }
693
+
694
+ if (this._daTickInterval == null) {
695
+ this._daTickInterval = this.daTickInterval;
696
+ }
697
+
698
+ ticks = null;
699
+ };
700
+
701
+ })(jQuery);
702
+