X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=4adb7164760aca3d0a0d540d4e6cfb9572c21f74;hb=e99fde0585bfc07ff26c9dc3a5ca30ea339cc81f;hp=4d2d3d074a6fe07ddfa087b2ad72a2fd7e950e93;hpb=2ad87eaa004e722037fba951f4fe418d09c209cc;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 4d2d3d0..4adb716 100644 --- a/dygraph.js +++ b/dygraph.js @@ -352,6 +352,32 @@ Dygraph.prototype.toDataCoords = function(x, y) { return ret; }; +/** + * Returns the number of columns (including the independent variable). + */ +Dygraph.prototype.numColumns = function() { + return this.rawData_[0].length; +}; + +/** + * Returns the number of rows (excluding any header/label row). + */ +Dygraph.prototype.numRows = function() { + return this.rawData_.length; +}; + +/** + * Returns the value in the given row and column. If the row and column exceed + * the bounds on the data, returns null. Also returns null if the value is + * missing. + */ +Dygraph.prototype.getValue = function(row, col) { + if (row < 0 || row > this.rawData_.length) return null; + if (col < 0 || col > this.rawData_[row].length) return null; + + return this.rawData_[row][col]; +}; + Dygraph.addEvent = function(el, evt, fn) { var normed_fn = function(e) { if (!e) var e = window.event; @@ -803,7 +829,8 @@ Dygraph.prototype.createDragInterface_ = function() { var regionWidth = Math.abs(dragEndX - dragStartX); var regionHeight = Math.abs(dragEndY - dragStartY); - if (regionWidth < 2 && regionHeight < 2 && self.lastx_ != undefined) { + if (regionWidth < 2 && regionHeight < 2 && + self.lastx_ != undefined && self.lastx_ != -1) { // TODO(danvk): pass along more info about the points, e.g. 'x' if (self.attr_('clickCallback') != null) { self.attr_('clickCallback')(event, self.lastx_, self.selPoints_);