X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=datahandler%2Fbars.js;h=7100148e5b91e4ba6d9750576049b676537fefa5;hb=c01c6b5cadedea62fbc6dab2457dc67c1201caa4;hp=914ee271d2a3b91ff1a454d9e6997f38bf78b845;hpb=3b3b39e7140cf45dfdc95f636978c5353e3a6c38;p=dygraphs.git diff --git a/datahandler/bars.js b/datahandler/bars.js index 914ee27..7100148 100644 --- a/datahandler/bars.js +++ b/datahandler/bars.js @@ -17,30 +17,61 @@ /*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.} 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.DataHandler.parseFloat(item[2][0]); + point.yval_plus = Dygraph.DataHandler.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); } };