From 7c6a8087138919dc300af6f73d6e8acddab1ebeb Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Thu, 12 Sep 2013 20:34:44 -0400 Subject: [PATCH] continue fixing warnings --- closure-todo.txt | 14 ++++++++++++++ dygraph-canvas.js | 2 +- dygraph-exports.js | 1 + dygraph-externs.js | 9 ++++++++- dygraph-interaction-model.js | 4 ++-- dygraph-layout.js | 1 + generate-combined.sh | 2 -- plugins/annotations.js | 11 +++++++++++ tests/annotation.html | 4 ++-- 9 files changed, 40 insertions(+), 8 deletions(-) diff --git a/closure-todo.txt b/closure-todo.txt index 387020b..27b848e 100644 --- a/closure-todo.txt +++ b/closure-todo.txt @@ -50,3 +50,17 @@ NOTES - plugin-free code is 59756 compiled; for uglifyjs it's 83031 (30% savings) - How to deal with types for callback attributes? Always repeat? Any way to declare these statically? + + +TODO: +- Make all plugins @implements DygraphPluginType +- plugins/annotations.js -- annotation properties are likely getting mangled. +- don't forget to remove "--formatting PRETTY_PRINT" before pulling. +- Some of the changing from method -> local function is unnecessary now: + DygraphOptions.axisToIndex_ + various methods in DygraphCanvas +- Need to export symbols within Dygraph.Plotters ? +- Really need a single canonical source of JS files. + -> Has to be dygraph-dev.js, since shell can read JS but not vice versa. +- Anything else to move into dygraph-constant.js? +- Big question: does Dygraph.toRGB_ work in IE? diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 53eed63..102d051 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -466,7 +466,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function(opt_seriesName, opt_ } var color = this.colors[setName]; - var strokeWidth = /** @type{number}*/(this.dygraph_.getOption("strokeWidth", setName)); + var strokeWidth = this.dygraph_.getNumericOption("strokeWidth", setName); ctx.save(); ctx.strokeStyle = color; diff --git a/dygraph-exports.js b/dygraph-exports.js index f542c45..7c0b2c6 100644 --- a/dygraph-exports.js +++ b/dygraph-exports.js @@ -19,6 +19,7 @@ goog.exportSymbol('Dygraph.prototype.isZoomed', Dygraph.prototype.isZoomed); goog.exportSymbol('Dygraph.prototype.numAxes', Dygraph.prototype.numAxes); goog.exportSymbol('Dygraph.prototype.numColumns', Dygraph.prototype.numColumns); goog.exportSymbol('Dygraph.prototype.numRows', Dygraph.prototype.numRows); +goog.exportSymbol('Dygraph.prototype.ready', Dygraph.prototype.ready); goog.exportSymbol('Dygraph.prototype.resetZoom', Dygraph.prototype.resetZoom); goog.exportSymbol('Dygraph.prototype.resize', Dygraph.prototype.resize); goog.exportSymbol('Dygraph.prototype.rollPeriod', Dygraph.prototype.rollPeriod); diff --git a/dygraph-externs.js b/dygraph-externs.js index 3cc89b7..1a052e6 100644 --- a/dygraph-externs.js +++ b/dygraph-externs.js @@ -54,7 +54,13 @@ var DygraphDataArray; * width: (number|undefined), * height: (number|undefined), * shortText: (string|undefined), - * text: (string|undefined) + * text: (string|undefined), + * attachAtBottom: (boolean|undefined), + * div: (!HTMLDivElement|undefined), + * cssClass: (string|undefined), + * tickHeight: (number|undefined), + * canvasx: (number|undefined), + * canvasy: (number|undefined) * }} */ var DygraphAnnotationType; @@ -178,3 +184,4 @@ DygraphPluginType.prototype.destroy = function() {}; var console = {}; /** @param {...} varargs */ console.log = function(varargs) {}; + diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 5bb491f..544d9cc 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -45,7 +45,7 @@ Dygraph.Interaction.startPan = function(event, g, context) { if (g.attr_("panEdgeFraction")) { var size = g.size(); - var maxXPixelsToDraw = size.width * /**@type{number}*/(g.getOption("panEdgeFraction")); + var maxXPixelsToDraw = size.width * g.getNumericOption("panEdgeFraction"); var xExtremes = g.xAxisExtremes(); // I REALLY WANT TO CALL THIS xTremes! var boundedLeftX = g.toDomXCoord(xExtremes[0]) - maxXPixelsToDraw; @@ -56,7 +56,7 @@ Dygraph.Interaction.startPan = function(event, g, context) { context.boundedDates = [boundedLeftDate, boundedRightDate]; var boundedValues = []; - var maxYPixelsToDraw = size.height * /**@type{number}*/(g.attr_("panEdgeFraction")); + var maxYPixelsToDraw = size.height * g.getNumericOption("panEdgeFraction"); for (i = 0; i < g.axes_.length; i++) { axis = g.axes_[i]; diff --git a/dygraph-layout.js b/dygraph-layout.js index e428af2..5910eaf 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -346,6 +346,7 @@ DygraphLayout.prototype._evaluateAnnotations = function() { // Add the annotations to the point to which they belong. // Make a map from (setName, xval) to annotation for quick lookups. var i; + /** @type {Object.} */ var annotations = {}; for (i = 0; i < this.annotations.length; i++) { var a = this.annotations[i]; diff --git a/generate-combined.sh b/generate-combined.sh index 9839502..2efdb7c 100755 --- a/generate-combined.sh +++ b/generate-combined.sh @@ -29,8 +29,6 @@ GetSources () { echo "$F" done } -# plugins/*.js \ -# dygraph-plugin-install.js # Pack all the JS together. CatSources () { diff --git a/plugins/annotations.js b/plugins/annotations.js index f6fcb87..e911a1a 100644 --- a/plugins/annotations.js +++ b/plugins/annotations.js @@ -23,14 +23,21 @@ TODO(danvk): cache DOM elements. */ +/** + * @constructor + * @implements DygraphPluginType + */ var annotations = function() { + /** @type {Array.} */ this.annotations_ = []; }; +/** @override */ annotations.prototype.toString = function() { return "Annotations Plugin"; }; +/** @override */ annotations.prototype.activate = function(g) { return { 'clearChart': this.clearChart, @@ -55,9 +62,12 @@ annotations.prototype.didDrawChart = function(e) { var g = e.dygraph; // Early out in the (common) case of zero annotations. + /** @type {Array.} */ var points = g.layout_.annotated_points; if (!points || points.length === 0) return; + console.log(points); + var containerDiv = e.canvas.parentNode; var annotationStyle = { "position": "absolute", @@ -173,6 +183,7 @@ annotations.prototype.didDrawChart = function(e) { } }; +/** @override */ annotations.prototype.destroy = function() { this.detachLabels(); }; diff --git a/tests/annotation.html b/tests/annotation.html index 6191436..3fb0ba0 100644 --- a/tests/annotation.html +++ b/tests/annotation.html @@ -11,9 +11,9 @@ --> + --> +