+Many of the functions and methods in the dygraphs source have some form of
+Closure annotations on them ("@param", "@return", "@private", etc.).
+
+These provide some documentation value, but they were largely written by
+developers who had never used the Closure Compiler and so the syntax is
+often not quite correct.
+
+This file tracks which files have been fully "closurized", i.e. compile
+under the Closure Compiler without any errors or warnings.
+
Core:
- dygraph-canvas.js
-- dygraph-gviz.js
- dygraph-interaction-model.js
- dygraph-layout.js
- dygraph-options.js
- dygraph-range-selector.js
- dygraph.js
+x dygraph-gviz.js
x dygraph-tickers.js
x dygraph-options-reference.js
x dygraph-utils.js
- plugins/install.js
- plugins/legend.js
+Here's a command that can be used to build dygraphs using the closure
+compiler:
+java -jar ../../closure-compiler-read-only/build/compiler.jar --js=dygraph-utils.js --js=dashed-canvas.js --js=dygraph-options-reference.js --js=dygraph-tickers.js --js=dygraph-gviz.js --js_output_file=/tmp/out.js --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE --externs dygraph-externs.js
+
+As each file is closurized, it can be added as a "--js" parameter.
Element.prototype.detachEvent = function(type, fn) {};
+/**
+ * @typedef {function(
+ * (number|Date),
+ * number,
+ * function(string):*,
+ * (Dygraph|undefined)
+ * ):string}
+ */
+var AxisLabelFormatter;
+
+
+/**
+ * @typedef {function(number,function(string),Dygraph):string}
+ */
+var ValueFormatter;
+
+
+/**
+ * @typedef {Array.<Array.<string|number|Array.<number>>>}
+ */
+var DygraphDataArray;
+
+/**
+ * @constructor
+ */
+function GVizDataTable() {}
+
// TODO(danvk): move the Dygraph definitions out of here once I closure-ify dygraphs.js
+/**
+ * @param {!HTMLDivElement|string} div
+ * @param {DygraphDataArray|
+ * GVizDataTable|
+ * string|
+ * function():(DygraphDataArray|GVizDataTable|string)} file
+ * @param {Object} attrs
+ * @constructor
+ */
+function Dygraph(div, file, attrs) {}
/**
* @constructor
*/
-function Dygraph() {}
+function DygraphLayout() {}
+
+/**
+ * @type {Array}
+ */
+DygraphLayout.prototype.datasets;
+
+/**
+ * @type {DygraphLayout}
+ */
+Dygraph.prototype.layout_;
/** @type {Array.<{elem:Element,type:string,fn:function(!Event):(boolean|undefined|null)}>} */
Dygraph.prototype.registeredEvents_;
/** @type {Object} */
Dygraph.DEFAULT_ATTRS;
-
-/**
- * @typedef {function(
- * (number|Date),
- * number,
- * function(string):*,
- * (Dygraph|undefined)
- * ):string}
- */
-Dygraph.AxisLabelFormatter;
/**
* 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
/**
* 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) {
/**
* 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() {
* Custom interaction model builders can use it to provide the default
* panning behavior.
*
- * @param { Event } event the event object which led to the startPan call.
- * @param { Dygraph} g The dygraph on which to act.
- * @param { Object} context The dragging context object (with
- * dragStartX/dragStartY/etc. properties). This function modifies the context.
+ * @param {Event} event the event object which led to the startPan call.
+ * @param {Dygraph} g The dygraph on which to act.
+ * @param {Object} context The dragging context object (with
+ * dragStartX/dragStartY/etc. properties). This function modifies the
+ * context.
*/
Dygraph.Interaction.startPan = function(event, g, context) {
var i, axis;
* Custom interaction model builders can use it to provide the default
* panning behavior.
*
- * @param { Event } event the event object which led to the movePan call.
- * @param { Dygraph} g The dygraph on which to act.
- * @param { Object} context The dragging context object (with
- * dragStartX/dragStartY/etc. properties). This function modifies the context.
+ * @param {Event} event the event object which led to the movePan call.
+ * @param {Dygraph} g The dygraph on which to act.
+ * @param {Object} context The dragging context object (with
+ * dragStartX/dragStartY/etc. properties). This function modifies the
+ * context.
*/
Dygraph.Interaction.movePan = function(event, g, context) {
context.dragEndX = g.dragGetX_(event, context);
* Custom interaction model builders can use it to provide the default
* panning behavior.
*
- * @param { Event } event the event object which led to the endPan call.
- * @param { Dygraph} g The dygraph on which to act.
- * @param { Object} context The dragging context object (with
- * dragStartX/dragStartY/etc. properties). This function modifies the context.
+ * @param {Event} event the event object which led to the endPan call.
+ * @param {Dygraph} g The dygraph on which to act.
+ * @param {Object} context The dragging context object (with
+ * dragStartX/dragStartY/etc. properties). This function modifies the
+ * context.
*/
Dygraph.Interaction.endPan = function(event, g, context) {
context.dragEndX = g.dragGetX_(event, context);
* Custom interaction model builders can use it to provide the default
* zooming behavior.
*
- * @param { Event } event the event object which led to the startZoom call.
- * @param { Dygraph} g The dygraph on which to act.
- * @param { Object} context The dragging context object (with
- * dragStartX/dragStartY/etc. properties). This function modifies the context.
+ * @param {Event} event the event object which led to the startZoom call.
+ * @param {Dygraph} g The dygraph on which to act.
+ * @param {Object} context The dragging context object (with
+ * dragStartX/dragStartY/etc. properties). This function modifies the
+ * context.
*/
Dygraph.Interaction.startZoom = function(event, g, context) {
context.isZooming = true;
* Custom interaction model builders can use it to provide the default
* zooming behavior.
*
- * @param { Event } event the event object which led to the moveZoom call.
- * @param { Dygraph} g The dygraph on which to act.
- * @param { Object} context The dragging context object (with
- * dragStartX/dragStartY/etc. properties). This function modifies the context.
+ * @param {Event} event the event object which led to the moveZoom call.
+ * @param {Dygraph} g The dygraph on which to act.
+ * @param {Object} context The dragging context object (with
+ * dragStartX/dragStartY/etc. properties). This function modifies the
+ * context.
*/
Dygraph.Interaction.moveZoom = function(event, g, context) {
context.zoomMoved = true;
context.prevDragDirection = context.dragDirection;
};
+/**
+ * @param {Dygraph} g
+ * @param {Event} event
+ * @param {Object} context
+ */
Dygraph.Interaction.treatMouseOpAsClick = function(g, event, context) {
var clickCallback = g.attr_('clickCallback');
var pointClickCallback = g.attr_('pointClickCallback');
var selectedPoint = null;
- // Find out if the click occurs on a point. This only matters if there's a pointClickCallback.
+ // Find out if the click occurs on a point. This only matters if there's a
+ // pointClickCallback.
if (pointClickCallback) {
var closestIdx = -1;
var closestDistance = Number.MAX_VALUE;
* Custom interaction model builders can use it to provide the default
* zooming behavior.
*
- * @param { Event } event the event object which led to the endZoom call.
- * @param { Dygraph} g The dygraph on which to end the zoom.
- * @param { Object} context The dragging context object (with
- * dragStartX/dragStartY/etc. properties). This function modifies the context.
+ * @param {Event} event the event object which led to the endZoom call.
+ * @param {Dygraph} g The dygraph on which to end the zoom.
+ * @param {Object} context The dragging context object (with
+ * dragStartX/dragStartY/etc. properties). This function modifies the
+ * context.
*/
Dygraph.Interaction.endZoom = function(event, g, context) {
context.isZooming = false;