From 28e366cb822b78925ca8f1c7c3357ee5c6104553 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 1 Sep 2013 15:43:40 -0400 Subject: [PATCH] using externs instead of quoting does not work for plugin handler mapping --- dygraph-externs.js | 19 ++++++++++++++++--- plugins/axes.js | 8 ++++++++ plugins/grid.js | 4 ++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/dygraph-externs.js b/dygraph-externs.js index 85a535d..4ec5846 100644 --- a/dygraph-externs.js +++ b/dygraph-externs.js @@ -143,14 +143,27 @@ var DygraphInteractionContext; /** - * @constructor + * @typedef {{ + * clearChart: (function(Object)|undefined), + * deselect: (function(Object)|undefined), + * didDrawChart: (function(Object)|undefined), + * layout: (function(Object)|undefined), + * predraw: (function(Object)|undefined), + * select: (function(Object)|undefined), + * willDrawChart: (function(Object)|undefined) + * }} + */ +var DygraphPluginHandlers; + + +/** + * @interface */ var DygraphPluginType; /** * @param {!Dygraph} dygraph - * TODO(danvk): be more specific than Object - * @return {Object.} Mapping from event -> callback. + * @return {DygraphPluginHandlers} Mapping from event -> callback. */ DygraphPluginType.prototype.activate = function(dygraph) {}; diff --git a/plugins/axes.js b/plugins/axes.js index 2ff2400..88ac546 100644 --- a/plugins/axes.js +++ b/plugins/axes.js @@ -31,16 +31,20 @@ These too. What is the difference between axisLablelWidth and {x,y}AxisLabelWidt * Draws the axes. This includes the labels on the x- and y-axes, as well * as the tick marks on the axes. * It does _not_ draw the grid lines which span the entire chart. + * @constructor + * @implements {DygraphPluginType} */ var axes = function() { this.xlabels_ = []; this.ylabels_ = []; }; +/** @override */ axes.prototype.toString = function() { return "Axes Plugin"; }; +/** @override */ axes.prototype.activate = function(g) { return { 'layout': this.layout, @@ -317,5 +321,9 @@ axes.prototype.willDrawChart = function(e) { context.restore(); }; +/** @override */ +axes.prototype.destroy = function() { +}; + return axes; })(); diff --git a/plugins/grid.js b/plugins/grid.js index 392aec6..e609a62 100644 --- a/plugins/grid.js +++ b/plugins/grid.js @@ -22,15 +22,18 @@ Current bits of jankiness: * Draws the gridlines, i.e. the gray horizontal & vertical lines running the * length of the chart. * + * @implements {DygraphPluginType} * @constructor */ var grid = function() { }; +/** @override */ grid.prototype.toString = function() { return "Gridline Plugin"; }; +/** @override */ grid.prototype.activate = function(g) { return { 'willDrawChart': this.willDrawChart @@ -116,6 +119,7 @@ grid.prototype.willDrawChart = function(e) { } }; +/** @override */ grid.prototype.destroy = function() { }; -- 2.7.4