data/weaver/js/plugins/morris/morris.js in weaver-0.1.9 vs data/weaver/js/plugins/morris/morris.js in weaver-0.2.0

- old
+ new

@@ -1,5 +1,12 @@ +/* @license +morris.js v0.5.0 +Copyright 2014 Olly Smith All rights reserved. +Licensed under the BSD-2-Clause License. +*/ + + (function() { var $, Morris, minutesSpecHelper, secondsSpecHelper, __slice = [].slice, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -118,12 +125,11 @@ }); this.el.bind('touchstart touchmove touchend', function(evt) { var offset, touch; touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0]; offset = _this.el.offset(); - _this.fire('hover', touch.pageX - offset.left, touch.pageY - offset.top); - return touch; + return _this.fire('hovermove', touch.pageX - offset.left, touch.pageY - offset.top); }); this.el.bind('click', function(evt) { var offset; offset = _this.el.offset(); return _this.fire('gridclick', evt.pageX - offset.left, evt.pageY - offset.top); @@ -151,10 +157,11 @@ window.clearTimeout(_this.timeoutId); } return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100); }); } + this.el.css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)'); if (this.postInit) { this.postInit(); } } @@ -654,13 +661,17 @@ this.el.hide(); this.options.parent.append(this.el); } Hover.prototype.update = function(html, x, y) { - this.html; - this.show(); - return this.moveTo(x, y); + if (!html) { + return this.hide(); + } else { + this.html(html); + this.show(); + return this.moveTo(x, y); + } }; Hover.prototype.html = function(content) { return this.el.html(content); }; @@ -735,11 +746,10 @@ pointFillColors: [], smooth: true, xLabels: 'auto', xLabelFormat: null, xLabelMargin: 24, - continuousLine: true, hideHover: false }; Line.prototype.calc = function() { this.calcPoints(); @@ -841,11 +851,11 @@ } return [content, row._x, row._ymax]; }; Line.prototype.generatePaths = function() { - var c, coords, i, r, smooth; + var coords, i, r, smooth; return this.paths = (function() { var _i, _ref, _ref1, _results; _results = []; for (i = _i = 0, _ref = this.options.ykeys.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { smooth = typeof this.options.smooth === "boolean" ? this.options.smooth : (_ref1 = this.options.ykeys[i], __indexOf.call(this.options.smooth, _ref1) >= 0); @@ -862,23 +872,10 @@ }); } } return _results1; }).call(this); - if (this.options.continuousLine) { - coords = (function() { - var _j, _len, _results1; - _results1 = []; - for (_j = 0, _len = coords.length; _j < _len; _j++) { - c = coords[_j]; - if (c.y !== null) { - _results1.push(c); - } - } - return _results1; - })(); - } if (coords.length > 1) { _results.push(Morris.Line.createPath(coords, smooth, this.bottom)); } else { _results.push(null); } @@ -1485,15 +1482,19 @@ } return _results; }; Bar.prototype.drawSeries = function() { - var barWidth, bottom, groupWidth, idx, lastTop, left, leftPadding, numBars, row, sidx, size, top, ypos, zeroPos; + var barWidth, bottom, groupWidth, idx, lastTop, left, leftPadding, numBars, row, sidx, size, spaceLeft, top, ypos, zeroPos; groupWidth = this.width / this.options.data.length; - numBars = this.options.stacked != null ? 1 : this.options.ykeys.length; + numBars = this.options.stacked ? 1 : this.options.ykeys.length; barWidth = (groupWidth * this.options.barSizeRatio - this.options.barGap * (numBars - 1)) / numBars; - leftPadding = groupWidth * (1 - this.options.barSizeRatio) / 2; + if (this.options.barSize) { + barWidth = Math.min(barWidth, this.options.barSize); + } + spaceLeft = groupWidth - barWidth * numBars - this.options.barGap * (numBars - 1); + leftPadding = spaceLeft / 2; zeroPos = this.ymin <= 0 && this.ymax >= 0 ? this.transY(0) : null; return this.bars = (function() { var _i, _len, _ref, _results; _ref = this.data; _results = []; @@ -1517,9 +1518,12 @@ left = this.left + idx * groupWidth + leftPadding; if (!this.options.stacked) { left += sidx * (barWidth + this.options.barGap); } size = bottom - top; + if (this.options.verticalGridCondition && this.options.verticalGridCondition(row.x)) { + this.drawBar(this.left + idx * groupWidth, this.top, groupWidth, Math.abs(this.top - this.bottom), this.options.verticalGridColor, this.options.verticalGridOpacity, this.options.barRadius); + } if (this.options.stacked) { top -= lastTop; } this.drawBar(left, top, barWidth, size, this.colorFor(row, sidx, 'bar'), this.options.barOpacity, this.options.barRadius); _results1.push(lastTop += size);