X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-gviz.js;h=d2d7a0d2c40bf7acbe78d7d0c050929a3559fdfa;hb=05f0c949e08dc94bb8cbaab4502a9e7c547c6d81;hp=5b81d7fca1aa273bcae27096e1e6885e8dc7566c;hpb=88e95c462340958bdfd0ac4c0736b94c5fd21024;p=dygraphs.git diff --git a/dygraph-gviz.js b/dygraph-gviz.js index 5b81d7f..d2d7a0d 100644 --- a/dygraph-gviz.js +++ b/dygraph-gviz.js @@ -17,14 +17,24 @@ * - http://dygraphs.com/tests/annotation-gviz.html */ +(function() { +/*global Dygraph:false */ +"use strict"; + /** * A wrapper around Dygraph that implements the gviz API. - * @param {Object} container The DOM object the visualization should live in. + * @param {!HTMLDivElement} container The DOM object the visualization should + * live in. + * @constructor */ Dygraph.GVizChart = function(container) { this.container = container; -} +}; +/** + * @param {GVizDataTable} data + * @param {Object.<*>} options + */ Dygraph.GVizChart.prototype.draw = function(data, options) { // Clear out any existing dygraph. // TODO(danvk): would it make more sense to simply redraw using the current @@ -35,12 +45,12 @@ Dygraph.GVizChart.prototype.draw = function(data, options) { } this.date_graph = new Dygraph(this.container, data, options); -} +}; /** * Google charts compatible setSelection * Only row selection is supported, all points in the row will be highlighted - * @param {Array} array of the selected cells + * @param {Array.<{row:number}>} selection_array array of the selected cells * @public */ Dygraph.GVizChart.prototype.setSelection = function(selection_array) { @@ -49,11 +59,11 @@ Dygraph.GVizChart.prototype.setSelection = function(selection_array) { row = selection_array[0].row; } this.date_graph.setSelection(row); -} +}; /** * Google charts compatible getSelection implementation - * @return {Array} array of the selected cells + * @return {Array.<{row:number,column:number}>} array of the selected cells * @public */ Dygraph.GVizChart.prototype.getSelection = function() { @@ -63,12 +73,12 @@ Dygraph.GVizChart.prototype.getSelection = function() { if (row < 0) return selection; - col = 1; - for (var i in this.date_graph.layout_.datasets) { - selection.push({row: row, column: col}); - col++; + var points = this.date_graph.layout_.points; + for (var setIdx = 0; setIdx < points.length; ++setIdx) { + selection.push({row: row, column: setIdx + 1}); } return selection; -} +}; +})();