X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=datahandler%2Fbars.js;h=914ee271d2a3b91ff1a454d9e6997f38bf78b845;hb=refs%2Fheads%2Ftyped-options;hp=5b84b69c68f63c8699724033800d85a1df9e67ef;hpb=a49c164ae4b251553a87517ef7d1dc57f3f2ad4c;p=dygraphs.git diff --git a/datahandler/bars.js b/datahandler/bars.js index 5b84b69..914ee27 100644 --- a/datahandler/bars.js +++ b/datahandler/bars.js @@ -12,63 +12,66 @@ */ (function() { - /*global Dygraph:false */ - /*global DygraphLayout:false */ - "use strict"; - - var BarsHandler = Dygraph.DataHandler(); - Dygraph.DataHandlers.registerHandler("bars", BarsHandler); - // errorBars - BarsHandler.prototype.extractSeries = function(rawData, i, options) { - // Not implemented here must be extended - }; - - BarsHandler.prototype.rollingAverage = function(originalData, rollPeriod, - options) { - // Not implemented here, must be extended. - }; - - 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]); - } - }; - - BarsHandler.prototype.getExtremeYValues = function(series, dateWindow, options) { - var minY = null, maxY = null, y; - - var firstIdx = 0; - var lastIdx = series.length - 1; - - for ( var j = firstIdx; j <= lastIdx; j++) { - y = series[j][1]; - if (y === null || isNaN(y)) continue; - - var low = series[j][2][0]; - var high = series[j][2][1]; - - if (low > y) low = y; // this can happen with custom bars, - if (high < y) high = y; // e.g. in tests/custom-bars.html - - if (maxY === null || high > maxY) maxY = high; - if (minY === null || low < minY) minY = low; - } - - return [ minY, maxY ]; - }; - - 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); - } - }; + +/*global Dygraph:false */ +/*global DygraphLayout:false */ +"use strict"; + +Dygraph.DataHandlers.BarsHandler = Dygraph.DataHandler(); +var BarsHandler = Dygraph.DataHandlers.BarsHandler; + +// errorBars +BarsHandler.prototype.extractSeries = function(rawData, i, options) { + // Not implemented here must be extended +}; + +BarsHandler.prototype.rollingAverage = + function(originalData, rollPeriod, options) { + // Not implemented here, must be extended. +}; + +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]); + } +}; + +BarsHandler.prototype.getExtremeYValues = function(series, dateWindow, options) { + var minY = null, maxY = null, y; + + var firstIdx = 0; + var lastIdx = series.length - 1; + + for ( var j = firstIdx; j <= lastIdx; j++) { + y = series[j][1]; + if (y === null || isNaN(y)) continue; + + var low = series[j][2][0]; + var high = series[j][2][1]; + + if (low > y) low = y; // this can happen with custom bars, + if (high < y) high = y; // e.g. in tests/custom-bars.html + + if (maxY === null || high > maxY) maxY = high; + if (minY === null || low < minY) minY = low; + } + + return [ minY, maxY ]; +}; + +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); + } +}; + })();