*/
-/*jshint globalstrict: true */
/*global DygraphLayout:false, DygraphCanvasRenderer:false, DygraphOptions:false, G_vmlCanvasManager:false,ActiveXObject:false */
-"use strict";
/**
* Creates an interactive, zoomable chart.
* list of options, see http://dygraphs.com/options.html.
*/
function Dygraph(div, file, opt_attrs) {
+ "use strict";
+ this.init_(div, file, opt_attrs);
+}
+
+/**
+ * Point structure.
+ *
+ * xval_* and yval_* are the original unscaled data values,
+ * while x_* and y_* are scaled to the range (0.0-1.0) for plotting.
+ * yval_stacked is the cumulative Y value used for stacking graphs,
+ * and bottom/top/minus/plus are used for error bar graphs.
+ *
+ * @typedef {{
+ * idx: number,
+ * name: string,
+ * x: ?number,
+ * xval: ?number,
+ * y_bottom: ?number,
+ * y: ?number,
+ * y_stacked: ?number,
+ * y_top: ?number,
+ * yval_minus: ?number,
+ * yval: ?number,
+ * yval_plus: ?number,
+ * yval_stacked
+ * }}
+ */
+Dygraph.PointType = undefined;
+
+(function() {
+
+"use strict";
+
+/**
+ * (see comments on Dygraph constructor)
+ * @param {!HTMLDivElement|string} div
+ * @param {DygraphDataArray|
+ * google.visualization.DataTable|
+ * string|
+ * function():(DygraphDataArray|google.visualization.DataTable|string)}
+ * file
+ * @param {Object=} opt_attrs
+ * @private
+ */
+Dygraph.prototype.init_ = function(div, file, opt_attrs) {
// Support two-argument constructor
var attrs = opt_attrs || {};
document.readyState != 'complete') {
var self = this;
setTimeout(function() {
- Dygraph.call(self, div, file, attrs);
+ self.init_(div, file, attrs);
}, 100);
return;
}
this.start_();
};
+
Dygraph.NAME = "Dygraph";
Dygraph.VERSION = "1.0.1";
Dygraph.__repr__ = function() {
};
/**
- * Point structure.
- *
- * xval_* and yval_* are the original unscaled data values,
- * while x_* and y_* are scaled to the range (0.0-1.0) for plotting.
- * yval_stacked is the cumulative Y value used for stacking graphs,
- * and bottom/top/minus/plus are used for error bar graphs.
- *
- * @typedef {{
- * idx: number,
- * name: string,
- * x: ?number,
- * xval: ?number,
- * y_bottom: ?number,
- * y: ?number,
- * y_stacked: ?number,
- * y_top: ?number,
- * yval_minus: ?number,
- * yval: ?number,
- * yval_plus: ?number,
- * yval_stacked
- * }}
- */
-Dygraph.PointType = undefined;
-
-/**
* Calculates point stacking for stackedGraph=true.
*
* For stacking purposes, interpolate or extend neighboring data across
callback(this);
}
};
+
+})();
a.div = div;
g.addAndTrackEvent(div, 'click',
- bindEvt('clickHandler', 'annotationClickHandler', p, this));
+ bindEvt('clickHandler', 'annotationClickHandler', p));
g.addAndTrackEvent(div, 'mouseover',
- bindEvt('mouseOverHandler', 'annotationMouseOverHandler', p, this));
+ bindEvt('mouseOverHandler', 'annotationMouseOverHandler', p));
g.addAndTrackEvent(div, 'mouseout',
- bindEvt('mouseOutHandler', 'annotationMouseOutHandler', p, this));
+ bindEvt('mouseOutHandler', 'annotationMouseOutHandler', p));
g.addAndTrackEvent(div, 'dblclick',
- bindEvt('dblClickHandler', 'annotationDblClickHandler', p, this));
+ bindEvt('dblClickHandler', 'annotationDblClickHandler', p));
containerDiv.appendChild(div);
this.annotations_.push(div);
y2 : makeLabelStyle('y2')
};
+ /**
+ * @param {string} txt
+ * @param {string} axis
+ * @param {?string=} prec_axis
+ * @return {!HTMLDivElement}
+ */
var makeDiv = function(txt, axis, prec_axis) {
/*
* This seems to be called with the following three sets of axis/prec_axis:
* y: y1
* y: y2
*/
- var div = document.createElement("div");
+ var div = /**@type{!HTMLDivElement}*/(document.createElement("div"));
var labelStyle = labelStyles[prec_axis == 'y2' ? 'y2' : axis];
for (var name in labelStyle) {
if (labelStyle.hasOwnProperty(name)) {
if (g.getOption('drawYGrid')) {
var axes = ["y", "y2"];
var strokeStyles = [], lineWidths = [], drawGrid = [], stroking = [], strokePattern = [];
- for (var i = 0; i < axes.length; i++) {
+ for (i = 0; i < axes.length; i++) {
drawGrid[i] = g.getOptionForAxis("drawGrid", axes[i]);
if (drawGrid[i]) {
strokeStyles[i] = g.getOptionForAxis('gridLineColor', axes[i]);
* - Registering event listeners
*
* @param {Dygraph} g Graph instance.
- * @return {object.<string, function(ev)>} Mapping of event names to callbacks.
+ * @return {Object.<function(Event)>} Mapping of event names to callbacks.
*/
legend.prototype.activate = function(g) {
var div;
- var divWidth = g.getOption('labelsDivWidth');
+ var divWidth = g.getNumericOption('labelsDivWidth');
var userLabelsDiv = g.getOption('labelsDiv');
- if (userLabelsDiv && null !== userLabelsDiv) {
- if (typeof(userLabelsDiv) == "string" || userLabelsDiv instanceof String) {
+ if (userLabelsDiv) {
+ if (typeof(userLabelsDiv) == "string") {
div = document.getElementById(userLabelsDiv);
} else {
div = userLabelsDiv;
"overflow": "hidden"};
// TODO(danvk): get rid of labelsDivStyles? CSS is better.
- Dygraph.update(messagestyle, g.getOption('labelsDivStyles'));
+ Dygraph.update(messagestyle, /**@type{!Object}*/(g.getOption('labelsDivStyles')));
div = document.createElement("div");
div.className = "dygraph-legend";
for (var name in messagestyle) {
*/
rangeSelector.prototype.initInteraction_ = function() {
var self = this;
- var topElem = this.isIE_ ? document : window;
+ // TODO(danvk): ask Paul why this is here.
+ // var topElem = this.isIE_ ? document : window;
+ var topElem = document;
var clientXLast = 0;
var handle = null;
var isZooming = false;