X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-gviz.js;h=988e0ace10d7c71e20d13c0b929045aedb86aea9;hb=160183e57e3e5c39fab0a2952e56ed6cf7d3caf3;hp=110ded24e1bc2f503a20ec09fdce0b6f694beefe;hpb=2d9596f2fd2a3c8d8d064c0f68a22c69ef82626b;p=dygraphs.git diff --git a/dygraph-gviz.js b/dygraph-gviz.js index 110ded2..988e0ac 100644 --- a/dygraph-gviz.js +++ b/dygraph-gviz.js @@ -1,5 +1,8 @@ -// Copyright 2011 Dan Vanderkam (danvdk@gmail.com) -// All Rights Reserved. +/** + * @license + * Copyright 2011 Dan Vanderkam (danvdk@gmail.com) + * MIT-licensed (http://opensource.org/licenses/MIT) + */ /** * @fileoverview A wrapper around the Dygraph class which implements the @@ -14,14 +17,24 @@ * - http://dygraphs.com/tests/annotation-gviz.html */ +/*jshint globalstrict: true */ +/*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 @@ -32,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) { @@ -46,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() { @@ -60,12 +73,10 @@ 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; -} - +};