copy datahandler changes over from full-closure branch
[dygraphs.git] / datahandler / bars.js
index 914ee27..a6b0cc5 100644 (file)
 /*global DygraphLayout:false */
 "use strict";
 
-Dygraph.DataHandlers.BarsHandler = Dygraph.DataHandler();
+/**
+ * @constructor
+ * @extends {Dygraph.DataHandler}
+ */
+Dygraph.DataHandlers.BarsHandler = function() {
+  Dygraph.DataHandler.call(this);
+};
+Dygraph.DataHandlers.BarsHandler.prototype = new Dygraph.DataHandler();
+
+// alias for the rest of the implementation
 var BarsHandler = Dygraph.DataHandlers.BarsHandler;
 
-// errorBars
-BarsHandler.prototype.extractSeries = function(rawData, i, options) {
+// TODO(danvk): figure out why the jsdoc has to be copy/pasted from superclass.
+//   (I get closure compiler errors if this isn't here.)
+/**
+ * @override
+ * @param {!Array.<Array>} rawData The raw data passed into dygraphs where 
+ *     rawData[i] = [x,ySeries1,...,ySeriesN].
+ * @param {!number} seriesIndex Index of the series to extract. All other
+ *     series should be ignored.
+ * @param {!DygraphOptions} options Dygraph options.
+ * @return {Array.<[!number,?number,?]>} The series in the unified data format
+ *     where series[i] = [x,y,{extras}]. 
+ */
+BarsHandler.prototype.extractSeries = function(rawData, seriesIndex, options) {
   // Not implemented here must be extended
 };
 
+/**
+ * @override
+ * @param {!Array.<[!number,?number,?]>} series The series in the unified 
+ *          data format where series[i] = [x,y,{extras}].
+ * @param {!number} rollPeriod The number of points over which to average the data
+ * @param {!DygraphOptions} options The dygraph options.
+ * TODO(danvk): be more specific than "Array" here.
+ * @return {!Array.<[!number,?number,?]>} the rolled series.
+ */
 BarsHandler.prototype.rollingAverage =
-    function(originalData, rollPeriod, options) {
+    function(series, rollPeriod, options) {
   // Not implemented here, must be extended.
 };
 
+/** @inheritDoc */
 BarsHandler.prototype.onPointsCreated_ = function(series, points) {
   for (var i = 0; i < series.length; ++i) {
     var item = series[i];
     var point = points[i];
     point.y_top = NaN;
     point.y_bottom = NaN;
-    point.yval_minus = DygraphLayout.parseFloat_(item[2][0]);
-    point.yval_plus = DygraphLayout.parseFloat_(item[2][1]);
+    point.yval_minus = Dygraph.parseFloat(item[2][0]);
+    point.yval_plus = Dygraph.parseFloat(item[2][1]);
   }
 };
 
+/** @inheritDoc */
 BarsHandler.prototype.getExtremeYValues = function(series, dateWindow, options) {
   var minY = null, maxY = null, y;
 
@@ -64,13 +95,14 @@ BarsHandler.prototype.getExtremeYValues = function(series, dateWindow, options)
   return [ minY, maxY ];
 };
 
+/** @inheritDoc */
 BarsHandler.prototype.onLineEvaluated = function(points, axis, logscale) {
   var point;
   for (var j = 0; j < points.length; j++) {
     // Copy over the error terms
     point = points[j];
-    point.y_top = DygraphLayout._calcYNormal(axis, point.yval_minus, logscale);
-    point.y_bottom = DygraphLayout._calcYNormal(axis, point.yval_plus, logscale);
+    point.y_top = DygraphLayout.calcYNormal_(axis, point.yval_minus, logscale);
+    point.y_bottom = DygraphLayout.calcYNormal_(axis, point.yval_plus, logscale);
   }
 };