d3_rails 2.8.0 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.DS_Store +0 -0
  2. data/README.md +27 -5
  3. data/lib/d3_rails/version.rb +1 -1
  4. data/vendor/.DS_Store +0 -0
  5. data/vendor/assets/.DS_Store +0 -0
  6. data/vendor/assets/javascripts/.DS_Store +0 -0
  7. data/vendor/assets/javascripts/d3.v2.js +99 -80
  8. data/vendor/assets/javascripts/morris.js +1 -0
  9. data/vendor/assets/javascripts/morris/.DS_Store +0 -0
  10. data/vendor/assets/javascripts/morris/Makefile +10 -0
  11. data/vendor/assets/javascripts/morris/README.md +87 -0
  12. data/vendor/assets/javascripts/morris/examples/_template.html +18 -0
  13. data/vendor/assets/javascripts/morris/examples/days.html +36 -0
  14. data/vendor/assets/javascripts/morris/examples/decimal.html +31 -0
  15. data/vendor/assets/javascripts/morris/examples/lib/example.css +13 -0
  16. data/vendor/assets/javascripts/morris/examples/lib/example.js +4 -0
  17. data/vendor/assets/javascripts/morris/examples/lib/prettify.css +1 -0
  18. data/vendor/assets/javascripts/morris/examples/lib/prettify.js +28 -0
  19. data/vendor/assets/javascripts/morris/examples/months-no-smooth.html +37 -0
  20. data/vendor/assets/javascripts/morris/examples/negative.html +35 -0
  21. data/vendor/assets/javascripts/morris/examples/non-date.html +36 -0
  22. data/vendor/assets/javascripts/morris/examples/quarters.html +53 -0
  23. data/vendor/assets/javascripts/morris/examples/timestamps.html +37 -0
  24. data/vendor/assets/javascripts/morris/examples/weeks.html +52 -0
  25. data/vendor/assets/javascripts/morris/morris.coffee +444 -0
  26. data/vendor/assets/javascripts/morris/morris.js +493 -0
  27. data/vendor/assets/javascripts/morris/morris.min.js +1 -0
  28. data/vendor/assets/javascripts/tesseract.js +1 -0
  29. data/vendor/assets/javascripts/tesseract/.gitignore +2 -0
  30. data/vendor/assets/javascripts/tesseract/LICENSE +12 -0
  31. data/vendor/assets/javascripts/tesseract/Makefile +48 -0
  32. data/vendor/assets/javascripts/tesseract/README.md +11 -0
  33. data/vendor/assets/javascripts/tesseract/index.js +1 -0
  34. data/vendor/assets/javascripts/tesseract/lib/dart/AUTHORS +9 -0
  35. data/vendor/assets/javascripts/tesseract/lib/dart/LICENSE +25 -0
  36. data/vendor/assets/javascripts/tesseract/lib/dart/dual_pivot_quicksort.dart +342 -0
  37. data/vendor/assets/javascripts/tesseract/package.json +11 -0
  38. data/vendor/assets/javascripts/tesseract/src/array.js +32 -0
  39. data/vendor/assets/javascripts/tesseract/src/bisect.js +44 -0
  40. data/vendor/assets/javascripts/tesseract/src/filter.js +19 -0
  41. data/vendor/assets/javascripts/tesseract/src/heap.js +44 -0
  42. data/vendor/assets/javascripts/tesseract/src/heapselect.js +36 -0
  43. data/vendor/assets/javascripts/tesseract/src/identity.js +3 -0
  44. data/vendor/assets/javascripts/tesseract/src/insertionsort.js +18 -0
  45. data/vendor/assets/javascripts/tesseract/src/null.js +3 -0
  46. data/vendor/assets/javascripts/tesseract/src/package.js +14 -0
  47. data/vendor/assets/javascripts/tesseract/src/permute.js +8 -0
  48. data/vendor/assets/javascripts/tesseract/src/quicksort.js +282 -0
  49. data/vendor/assets/javascripts/tesseract/src/reduce.js +19 -0
  50. data/vendor/assets/javascripts/tesseract/src/tesseract.js +663 -0
  51. data/vendor/assets/javascripts/tesseract/src/version.js +1 -0
  52. data/vendor/assets/javascripts/tesseract/src/zero.js +3 -0
  53. data/vendor/assets/javascripts/tesseract/tesseract.js +1177 -0
  54. data/vendor/assets/javascripts/tesseract/tesseract.min.js +1 -0
  55. data/vendor/assets/javascripts/tesseract/test/benchmark.js +177 -0
  56. data/vendor/assets/javascripts/tesseract/test/bisect-test.js +206 -0
  57. data/vendor/assets/javascripts/tesseract/test/heap-test.js +44 -0
  58. data/vendor/assets/javascripts/tesseract/test/permute-test.js +51 -0
  59. data/vendor/assets/javascripts/tesseract/test/select-test.js +63 -0
  60. data/vendor/assets/javascripts/tesseract/test/sort-test.js +83 -0
  61. data/vendor/assets/javascripts/tesseract/test/tesseract-test.js +655 -0
  62. data/vendor/assets/javascripts/tesseract/test/version-test.js +16 -0
  63. metadata +63 -8
@@ -0,0 +1,493 @@
1
+ (function() {
2
+ var $, Morris,
3
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
4
+
5
+ $ = jQuery;
6
+
7
+ Morris = {};
8
+
9
+ Morris.Line = (function() {
10
+
11
+ function Line(options) {
12
+ this.updateHilight = __bind(this.updateHilight, this);
13
+ this.hilight = __bind(this.hilight, this);
14
+ this.updateHover = __bind(this.updateHover, this);
15
+ this.transY = __bind(this.transY, this);
16
+ this.transX = __bind(this.transX, this); if (!(this instanceof Morris.Line)) return new Morris.Line(options);
17
+ if (typeof options.element === 'string') {
18
+ this.el = $(document.getElementById(options.element));
19
+ } else {
20
+ this.el = $(options.element);
21
+ }
22
+ this.options = $.extend({}, this.defaults, options);
23
+ if (this.options.data === void 0 || this.options.data.length === 0) return;
24
+ this.el.addClass('graph-initialised');
25
+ this.precalc();
26
+ this.redraw();
27
+ }
28
+
29
+ Line.prototype.defaults = {
30
+ lineWidth: 3,
31
+ pointSize: 4,
32
+ lineColors: ['#0b62a4', '#7A92A3', '#4da74d', '#afd8f8', '#edc240', '#cb4b4b', '#9440ed'],
33
+ ymax: 'auto',
34
+ ymin: 'auto 0',
35
+ marginTop: 25,
36
+ marginRight: 25,
37
+ marginBottom: 30,
38
+ marginLeft: 25,
39
+ numLines: 5,
40
+ gridLineColor: '#aaa',
41
+ gridTextColor: '#888',
42
+ gridTextSize: 12,
43
+ gridStrokeWidth: 0.5,
44
+ hoverPaddingX: 10,
45
+ hoverPaddingY: 5,
46
+ hoverMargin: 10,
47
+ hoverFillColor: '#fff',
48
+ hoverBorderColor: '#ccc',
49
+ hoverBorderWidth: 2,
50
+ hoverOpacity: 0.95,
51
+ hoverLabelColor: '#444',
52
+ hoverFontSize: 12,
53
+ smooth: true,
54
+ hideHover: false,
55
+ parseTime: true,
56
+ units: '',
57
+ dateFormat: function(x) {
58
+ return new Date(x).toString();
59
+ }
60
+ };
61
+
62
+ Line.prototype.precalc = function() {
63
+ var d, series_data, touchHandler, ykey, ymax, ymin, _i, _j, _k, _len, _len2, _ref, _ref2, _ref3, _results,
64
+ _this = this;
65
+ this.options.data.sort(function(a, b) {
66
+ return (a[_this.options.xkey] < b[_this.options.xkey]) - (b[_this.options.xkey] < a[_this.options.xkey]);
67
+ });
68
+ this.columnLabels = $.map(this.options.data, function(d) {
69
+ return d[_this.options.xkey];
70
+ });
71
+ this.seriesLabels = this.options.labels;
72
+ this.series = [];
73
+ _ref = this.options.ykeys;
74
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
75
+ ykey = _ref[_i];
76
+ series_data = [];
77
+ _ref2 = this.options.data;
78
+ for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
79
+ d = _ref2[_j];
80
+ series_data.push(d[ykey]);
81
+ }
82
+ this.series.push(series_data);
83
+ }
84
+ if (this.options.parseTime) {
85
+ this.xvals = $.map(this.columnLabels, function(x) {
86
+ return _this.parseYear(x);
87
+ });
88
+ } else {
89
+ this.xvals = (function() {
90
+ _results = [];
91
+ for (var _k = _ref3 = this.columnLabels.length - 1; _ref3 <= 0 ? _k <= 0 : _k >= 0; _ref3 <= 0 ? _k++ : _k--){ _results.push(_k); }
92
+ return _results;
93
+ }).apply(this);
94
+ }
95
+ if (this.options.parseTime) {
96
+ this.columnLabels = $.map(this.columnLabels, function(d) {
97
+ if (typeof d === 'number') {
98
+ return _this.options.dateFormat(d);
99
+ } else {
100
+ return d;
101
+ }
102
+ });
103
+ }
104
+ this.xmin = Math.min.apply(null, this.xvals);
105
+ this.xmax = Math.max.apply(null, this.xvals);
106
+ if (this.xmin === this.xmax) {
107
+ this.xmin -= 1;
108
+ this.xmax += 1;
109
+ }
110
+ if (typeof this.options.ymax === 'string' && this.options.ymax.slice(0, 4) === 'auto') {
111
+ ymax = Math.max.apply(null, Array.prototype.concat.apply([], this.series));
112
+ if (this.options.ymax.length > 5) {
113
+ this.options.ymax = Math.max(parseInt(this.options.ymax.slice(5), 10), ymax);
114
+ } else {
115
+ this.options.ymax = ymax;
116
+ }
117
+ }
118
+ if (typeof this.options.ymin === 'string' && this.options.ymin.slice(0, 4) === 'auto') {
119
+ ymin = Math.min.apply(null, Array.prototype.concat.apply([], this.series));
120
+ if (this.options.ymin.length > 5) {
121
+ this.options.ymin = Math.min(parseInt(this.options.ymin.slice(5), 10), ymin);
122
+ } else {
123
+ this.options.ymin = ymin;
124
+ }
125
+ }
126
+ this.pointGrow = Raphael.animation({
127
+ r: this.options.pointSize + 3
128
+ }, 25, 'linear');
129
+ this.pointShrink = Raphael.animation({
130
+ r: this.options.pointSize
131
+ }, 25, 'linear');
132
+ this.elementWidth = null;
133
+ this.elementHeight = null;
134
+ this.prevHilight = null;
135
+ this.el.mousemove(function(evt) {
136
+ return _this.updateHilight(evt.pageX);
137
+ });
138
+ if (this.options.hideHover) {
139
+ this.el.mouseout(function(evt) {
140
+ return _this.hilight(null);
141
+ });
142
+ }
143
+ touchHandler = function(evt) {
144
+ var touch;
145
+ touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0];
146
+ _this.updateHilight(touch.pageX);
147
+ return touch;
148
+ };
149
+ this.el.bind('touchstart', touchHandler);
150
+ this.el.bind('touchmove', touchHandler);
151
+ return this.el.bind('touchend', touchHandler);
152
+ };
153
+
154
+ Line.prototype.calc = function() {
155
+ var h, s, scoords, w, x, _i, _len, _ref,
156
+ _this = this;
157
+ w = this.el.width();
158
+ h = this.el.height();
159
+ if (this.elementWidth !== w || this.elementHeight !== h) {
160
+ this.maxYLabelWidth = Math.max(this.measureText(this.options.ymin + this.options.units, this.options.gridTextSize).width, this.measureText(this.options.ymax + this.options.units, this.options.gridTextSize).width);
161
+ this.left = this.maxYLabelWidth + this.options.marginLeft;
162
+ this.width = this.el.width() - this.left - this.options.marginRight;
163
+ this.height = this.el.height() - this.options.marginTop - this.options.marginBottom;
164
+ this.dx = this.width / (this.xmax - this.xmin);
165
+ this.dy = this.height / (this.options.ymax - this.options.ymin);
166
+ this.columns = (function() {
167
+ var _i, _len, _ref, _results;
168
+ _ref = this.xvals;
169
+ _results = [];
170
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
171
+ x = _ref[_i];
172
+ _results.push(this.transX(x));
173
+ }
174
+ return _results;
175
+ }).call(this);
176
+ this.seriesCoords = [];
177
+ _ref = this.series;
178
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
179
+ s = _ref[_i];
180
+ scoords = [];
181
+ $.each(s, function(i, y) {
182
+ if (y === null) {
183
+ return scoords.push(null);
184
+ } else {
185
+ return scoords.push({
186
+ x: _this.columns[i],
187
+ y: _this.transY(y)
188
+ });
189
+ }
190
+ });
191
+ this.seriesCoords.push(scoords);
192
+ }
193
+ return this.hoverMargins = $.map(this.columns.slice(1), function(x, i) {
194
+ return (x + _this.columns[i]) / 2;
195
+ });
196
+ }
197
+ };
198
+
199
+ Line.prototype.transX = function(x) {
200
+ if (this.xvals.length === 1) {
201
+ return this.left + this.width / 2;
202
+ } else {
203
+ return this.left + (x - this.xmin) * this.dx;
204
+ }
205
+ };
206
+
207
+ Line.prototype.transY = function(y) {
208
+ return this.options.marginTop + this.height - (y - this.options.ymin) * this.dy;
209
+ };
210
+
211
+ Line.prototype.redraw = function() {
212
+ this.el.empty();
213
+ this.r = new Raphael(this.el[0]);
214
+ this.calc();
215
+ this.drawGrid();
216
+ this.drawSeries();
217
+ this.drawHover();
218
+ return this.hilight(this.options.hideHover ? null : 0);
219
+ };
220
+
221
+ Line.prototype.drawGrid = function() {
222
+ var firstY, i, label, labelBox, labelText, lastY, lineY, prevLabelMargin, v, x1, x2, xLabelMargin, xpos, y, yInterval, _results;
223
+ yInterval = (this.options.ymax - this.options.ymin) / (this.options.numLines - 1);
224
+ firstY = Math.ceil(this.options.ymin / yInterval) * yInterval;
225
+ lastY = Math.floor(this.options.ymax / yInterval) * yInterval;
226
+ for (lineY = firstY; firstY <= lastY ? lineY <= lastY : lineY >= lastY; lineY += yInterval) {
227
+ v = Math.floor(lineY);
228
+ y = this.transY(v);
229
+ this.r.text(this.left - this.options.marginLeft / 2, y, this.commas(v) + this.options.units).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor).attr('text-anchor', 'end');
230
+ this.r.path("M" + this.left + "," + y + "H" + (this.left + this.width)).attr('stroke', this.options.gridLineColor).attr('stroke-width', this.options.gridStrokeWidth);
231
+ }
232
+ prevLabelMargin = null;
233
+ xLabelMargin = 50;
234
+ if (this.options.parseTime) {
235
+ x1 = new Date(this.xmin).getFullYear();
236
+ x2 = new Date(this.xmax).getFullYear();
237
+ } else {
238
+ x1 = this.xmin;
239
+ x2 = this.xmax;
240
+ }
241
+ _results = [];
242
+ for (i = x1; x1 <= x2 ? i <= x2 : i >= x2; x1 <= x2 ? i++ : i--) {
243
+ if (this.options.parseTime) {
244
+ xpos = new Date(i, 0, 1).getTime();
245
+ if (xpos < this.xmin) continue;
246
+ } else {
247
+ xpos = i;
248
+ }
249
+ labelText = this.options.parseTime ? i : this.columnLabels[this.columnLabels.length - i - 1];
250
+ label = this.r.text(this.transX(xpos), this.options.marginTop + this.height + this.options.marginBottom / 2, labelText).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor);
251
+ labelBox = label.getBBox();
252
+ if (prevLabelMargin === null || prevLabelMargin <= labelBox.x) {
253
+ _results.push(prevLabelMargin = labelBox.x + labelBox.width + xLabelMargin);
254
+ } else {
255
+ _results.push(label.remove());
256
+ }
257
+ }
258
+ return _results;
259
+ };
260
+
261
+ Line.prototype.drawSeries = function() {
262
+ var c, circle, coords, i, path, _ref, _ref2, _results;
263
+ for (i = _ref = this.seriesCoords.length - 1; _ref <= 0 ? i <= 0 : i >= 0; _ref <= 0 ? i++ : i--) {
264
+ coords = this.seriesCoords[i];
265
+ if (coords.length > 1) {
266
+ path = this.createPath(coords, this.options.marginTop, this.left, this.options.marginTop + this.height, this.left + this.width);
267
+ this.r.path(path).attr('stroke', this.options.lineColors[i]).attr('stroke-width', this.options.lineWidth);
268
+ }
269
+ }
270
+ this.seriesPoints = (function() {
271
+ var _ref2, _results;
272
+ _results = [];
273
+ for (i = 0, _ref2 = this.seriesCoords.length - 1; 0 <= _ref2 ? i <= _ref2 : i >= _ref2; 0 <= _ref2 ? i++ : i--) {
274
+ _results.push([]);
275
+ }
276
+ return _results;
277
+ }).call(this);
278
+ _results = [];
279
+ for (i = _ref2 = this.seriesCoords.length - 1; _ref2 <= 0 ? i <= 0 : i >= 0; _ref2 <= 0 ? i++ : i--) {
280
+ _results.push((function() {
281
+ var _i, _len, _ref3, _results2;
282
+ _ref3 = this.seriesCoords[i];
283
+ _results2 = [];
284
+ for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
285
+ c = _ref3[_i];
286
+ if (c === null) {
287
+ circle = null;
288
+ } else {
289
+ circle = this.r.circle(c.x, c.y, this.options.pointSize).attr('fill', this.options.lineColors[i]).attr('stroke-width', 1).attr('stroke', '#ffffff');
290
+ }
291
+ _results2.push(this.seriesPoints[i].push(circle));
292
+ }
293
+ return _results2;
294
+ }).call(this));
295
+ }
296
+ return _results;
297
+ };
298
+
299
+ Line.prototype.createPath = function(all_coords, top, left, bottom, right) {
300
+ var c, coords, g, grads, i, ix, lc, lg, path, x1, x2, y1, y2, _ref;
301
+ path = "";
302
+ coords = $.map(all_coords, function(c) {
303
+ return c;
304
+ });
305
+ if (this.options.smooth) {
306
+ grads = this.gradients(coords);
307
+ for (i = 0, _ref = coords.length - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
308
+ c = coords[i];
309
+ if (i === 0) {
310
+ path += "M" + c.x + "," + c.y;
311
+ } else {
312
+ g = grads[i];
313
+ lc = coords[i - 1];
314
+ lg = grads[i - 1];
315
+ ix = (c.x - lc.x) / 4;
316
+ x1 = lc.x + ix;
317
+ y1 = Math.min(bottom, lc.y + ix * lg);
318
+ x2 = c.x - ix;
319
+ y2 = Math.min(bottom, c.y - ix * g);
320
+ path += "C" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + c.x + "," + c.y;
321
+ }
322
+ }
323
+ } else {
324
+ path = "M" + $.map(coords, function(c) {
325
+ return "" + c.x + "," + c.y;
326
+ }).join("L");
327
+ }
328
+ return path;
329
+ };
330
+
331
+ Line.prototype.gradients = function(coords) {
332
+ return $.map(coords, function(c, i) {
333
+ if (i === 0) {
334
+ return (coords[1].y - c.y) / (coords[1].x - c.x);
335
+ } else if (i === (coords.length - 1)) {
336
+ return (c.y - coords[i - 1].y) / (c.x - coords[i - 1].x);
337
+ } else {
338
+ return (coords[i + 1].y - coords[i - 1].y) / (coords[i + 1].x - coords[i - 1].x);
339
+ }
340
+ });
341
+ };
342
+
343
+ Line.prototype.drawHover = function() {
344
+ var i, yLabel, _ref, _results;
345
+ this.hoverHeight = this.options.hoverFontSize * 1.5 * (this.series.length + 1);
346
+ this.hover = this.r.rect(-10, -this.hoverHeight / 2 - this.options.hoverPaddingY, 20, this.hoverHeight + this.options.hoverPaddingY * 2, 10).attr('fill', this.options.hoverFillColor).attr('stroke', this.options.hoverBorderColor).attr('stroke-width', this.options.hoverBorderWidth).attr('opacity', this.options.hoverOpacity);
347
+ this.xLabel = this.r.text(0, (this.options.hoverFontSize * 0.75) - this.hoverHeight / 2, '').attr('fill', this.options.hoverLabelColor).attr('font-weight', 'bold').attr('font-size', this.options.hoverFontSize);
348
+ this.hoverSet = this.r.set();
349
+ this.hoverSet.push(this.hover);
350
+ this.hoverSet.push(this.xLabel);
351
+ this.yLabels = [];
352
+ _results = [];
353
+ for (i = 0, _ref = this.series.length - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
354
+ yLabel = this.r.text(0, this.options.hoverFontSize * 1.5 * (i + 1.5) - this.hoverHeight / 2, '').attr('fill', this.options.lineColors[i]).attr('font-size', this.options.hoverFontSize);
355
+ this.yLabels.push(yLabel);
356
+ _results.push(this.hoverSet.push(yLabel));
357
+ }
358
+ return _results;
359
+ };
360
+
361
+ Line.prototype.updateHover = function(index) {
362
+ var i, maxLabelWidth, xloc, yloc, _ref,
363
+ _this = this;
364
+ this.hoverSet.show();
365
+ this.xLabel.attr('text', this.columnLabels[index]);
366
+ for (i = 0, _ref = this.series.length - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
367
+ this.yLabels[i].attr('text', "" + this.seriesLabels[i] + ": " + (this.commas(this.series[i][index])) + this.options.units);
368
+ }
369
+ maxLabelWidth = Math.max.apply(null, $.map(this.yLabels, function(l) {
370
+ return l.getBBox().width;
371
+ }));
372
+ maxLabelWidth = Math.max(maxLabelWidth, this.xLabel.getBBox().width);
373
+ this.hover.attr('width', maxLabelWidth + this.options.hoverPaddingX * 2);
374
+ this.hover.attr('x', -this.options.hoverPaddingX - maxLabelWidth / 2);
375
+ yloc = Math.min.apply(null, $.map(this.series, function(s) {
376
+ return _this.transY(s[index]);
377
+ }));
378
+ if (yloc > this.hoverHeight + this.options.hoverPaddingY * 2 + this.options.hoverMargin + this.options.marginTop) {
379
+ yloc = yloc - this.hoverHeight / 2 - this.options.hoverPaddingY - this.options.hoverMargin;
380
+ } else {
381
+ yloc = yloc + this.hoverHeight / 2 + this.options.hoverPaddingY + this.options.hoverMargin;
382
+ }
383
+ yloc = Math.max(this.options.marginTop + this.hoverHeight / 2 + this.options.hoverPaddingY, yloc);
384
+ yloc = Math.min(this.options.marginTop + this.height - this.hoverHeight / 2 - this.options.hoverPaddingY, yloc);
385
+ xloc = Math.min(this.left + this.width - maxLabelWidth / 2 - this.options.hoverPaddingX, this.columns[index]);
386
+ xloc = Math.max(this.left + maxLabelWidth / 2 + this.options.hoverPaddingX, xloc);
387
+ return this.hoverSet.attr('transform', "t" + xloc + "," + yloc);
388
+ };
389
+
390
+ Line.prototype.hideHover = function() {
391
+ return this.hoverSet.hide();
392
+ };
393
+
394
+ Line.prototype.hilight = function(index) {
395
+ var i, _ref, _ref2;
396
+ if (this.prevHilight !== null && this.prevHilight !== index) {
397
+ for (i = 0, _ref = this.seriesPoints.length - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
398
+ if (this.seriesPoints[i][this.prevHilight]) {
399
+ this.seriesPoints[i][this.prevHilight].animate(this.pointShrink);
400
+ }
401
+ }
402
+ }
403
+ if (index !== null && this.prevHilight !== index) {
404
+ for (i = 0, _ref2 = this.seriesPoints.length - 1; 0 <= _ref2 ? i <= _ref2 : i >= _ref2; 0 <= _ref2 ? i++ : i--) {
405
+ if (this.seriesPoints[i][index]) {
406
+ this.seriesPoints[i][index].animate(this.pointGrow);
407
+ }
408
+ }
409
+ this.updateHover(index);
410
+ }
411
+ this.prevHilight = index;
412
+ if (index === null) return this.hideHover();
413
+ };
414
+
415
+ Line.prototype.updateHilight = function(x) {
416
+ var hoverIndex, _ref, _results;
417
+ x -= this.el.offset().left;
418
+ _results = [];
419
+ for (hoverIndex = _ref = this.hoverMargins.length; _ref <= 0 ? hoverIndex <= 0 : hoverIndex >= 0; _ref <= 0 ? hoverIndex++ : hoverIndex--) {
420
+ if (hoverIndex === 0 || this.hoverMargins[hoverIndex - 1] > x) {
421
+ this.hilight(hoverIndex);
422
+ break;
423
+ } else {
424
+ _results.push(void 0);
425
+ }
426
+ }
427
+ return _results;
428
+ };
429
+
430
+ Line.prototype.measureText = function(text, fontSize) {
431
+ var ret, tt;
432
+ if (fontSize == null) fontSize = 12;
433
+ tt = this.r.text(100, 100, text).attr('font-size', fontSize);
434
+ ret = tt.getBBox();
435
+ tt.remove();
436
+ return ret;
437
+ };
438
+
439
+ Line.prototype.parseYear = function(date) {
440
+ var isecs, m, msecs, n, o, p, q, r, ret, secs;
441
+ if (typeof date === 'number') return date;
442
+ m = date.match(/^(\d+) Q(\d)$/);
443
+ n = date.match(/^(\d+)-(\d+)$/);
444
+ o = date.match(/^(\d+)-(\d+)-(\d+)$/);
445
+ p = date.match(/^(\d+) W(\d+)$/);
446
+ q = date.match(/^(\d+)-(\d+)-(\d+) (\d+):(\d+)$/);
447
+ r = date.match(/^(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+(\.\d+)?)$/);
448
+ if (m) {
449
+ return new Date(parseInt(m[1], 10), parseInt(m[2], 10) * 3 - 1, 1).getTime();
450
+ } else if (n) {
451
+ return new Date(parseInt(n[1], 10), parseInt(n[2], 10) - 1, 1).getTime();
452
+ } else if (o) {
453
+ return new Date(parseInt(o[1], 10), parseInt(o[2], 10) - 1, parseInt(o[3], 10)).getTime();
454
+ } else if (p) {
455
+ ret = new Date(parseInt(p[1], 10), 0, 1);
456
+ if (ret.getDay() !== 4) ret.setMonth(0, 1 + ((4 - ret.getDay()) + 7) % 7);
457
+ return ret.getTime() + parseInt(p[2], 10) * 604800000;
458
+ } else if (q) {
459
+ return new Date(parseInt(q[1], 10), parseInt(q[2], 10) - 1, parseInt(q[3], 10), parseInt(q[4], 10), parseInt(q[5], 10)).getTime();
460
+ } else if (r) {
461
+ secs = parseFloat(r[6]);
462
+ isecs = Math.floor(secs);
463
+ msecs = Math.floor((secs - isecs) * 1000);
464
+ return new Date(parseInt(r[1], 10), parseInt(r[2], 10) - 1, parseInt(r[3], 10), parseInt(r[4], 10), parseInt(r[5], 10), isecs, msecs).getTime();
465
+ } else {
466
+ return new Date(parseInt(date, 10), 0, 1);
467
+ }
468
+ };
469
+
470
+ Line.prototype.commas = function(num) {
471
+ var absnum, intnum, ret, strabsnum;
472
+ if (num === null) {
473
+ return "n/a";
474
+ } else {
475
+ ret = num < 0 ? "-" : "";
476
+ absnum = Math.abs(num);
477
+ intnum = Math.floor(absnum).toFixed(0);
478
+ ret += intnum.replace(/(?=(?:\d{3})+$)(?!^)/g, ',');
479
+ strabsnum = absnum.toString();
480
+ if (strabsnum.length > intnum.length) {
481
+ ret += strabsnum.slice(intnum.length);
482
+ }
483
+ return ret;
484
+ }
485
+ };
486
+
487
+ return Line;
488
+
489
+ })();
490
+
491
+ window.Morris = Morris;
492
+
493
+ }).call(this);