3 * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)
4 * MIT-licensed (http://opensource.org/licenses/MIT)
8 * @fileoverview DataHandler base implementation for the "bar"
9 * data formats. This implementation must be extended and the
10 * extractSeries and rollingAverage must be implemented.
11 * @author David Eberlein (david.eberlein@ch.sauter-bc.com)
16 /*global Dygraph:false */
17 /*global DygraphLayout:false */
20 Dygraph
.DataHandlers
.BarsHandler
= Dygraph
.DataHandler();
21 var BarsHandler
= Dygraph
.DataHandlers
.BarsHandler
;
24 BarsHandler
.prototype.extractSeries
= function(rawData
, i
, options
) {
25 // Not implemented here must be extended
28 BarsHandler
.prototype.rollingAverage
=
29 function(originalData
, rollPeriod
, options
) {
30 // Not implemented here, must be extended.
33 BarsHandler
.prototype.onPointsCreated_
= function(series
, points
) {
34 for (var i
= 0; i
< series
.length
; ++i
) {
36 var point
= points
[i
];
39 point
.yval_minus
= DygraphLayout
.parseFloat_(item
[2][0]);
40 point
.yval_plus
= DygraphLayout
.parseFloat_(item
[2][1]);
44 BarsHandler
.prototype.getExtremeYValues
= function(series
, dateWindow
, options
) {
45 var minY
= null, maxY
= null, y
;
48 var lastIdx
= series
.length
- 1;
50 for ( var j
= firstIdx
; j
<= lastIdx
; j
++) {
52 if (y
=== null || isNaN(y
)) continue;
54 var low
= series
[j
][2][0];
55 var high
= series
[j
][2][1];
57 if (low
> y
) low
= y
; // this can happen with custom bars,
58 if (high
< y
) high
= y
; // e.g. in tests/custom-bars
.html
60 if (maxY
=== null || high
> maxY
) maxY
= high
;
61 if (minY
=== null || low
< minY
) minY
= low
;
64 return [ minY
, maxY
];
67 BarsHandler
.prototype.onLineEvaluated
= function(points
, axis
, logscale
) {
69 for (var j
= 0; j
< points
.length
; j
++) {
70 // Copy over the error terms
72 point
.y_top
= DygraphLayout
._calcYNormal(axis
, point
.yval_minus
, logscale
);
73 point
.y_bottom
= DygraphLayout
._calcYNormal(axis
, point
.yval_plus
, logscale
);