From: David Eberlein Date: Fri, 3 May 2013 07:05:11 +0000 (+0200) Subject: REFACTORING: fixed code style and lint warnings. Readded jsdoc lost in merge. X-Git-Tag: v1.0.0~31^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=141064ff3e89156104c14e80f05b8c6dd33267de;p=dygraphs.git REFACTORING: fixed code style and lint warnings. Readded jsdoc lost in merge. --- diff --git a/dygraph-layout.js b/dygraph-layout.js index 9e042f2..4b600f7 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -52,6 +52,12 @@ DygraphLayout.prototype.addDataset = function(setname, set_xy) { this.setNames.push(setname); }; +/** + * Returns the box which the chart should be drawn in. This is the canvas's + * box, less space needed for the axis and chart labels. + * + * @return {{x: number, y: number, w: number, h: number}} + */ DygraphLayout.prototype.getPlotArea = function() { return this.area_; }; diff --git a/dygraph.js b/dygraph.js index 34d01b9..44214ad 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2278,6 +2278,17 @@ Dygraph.prototype.gatherDatasets_ = function(rolledSeries, dateWindow) { var datasets = []; var extremes = {}; // series name -> [low, high] var i, j, k; + var errorBars = this.attr_("errorBars"); + var customBars = this.attr_("customBars"); + var bars = errorBars || customBars; + var isValueNull = function(sample) { + if (!bars) { + return sample[1] === null; + } else { + return customBars ? sample[1][1] === null : + errorBars ? sample[1][0] === null : false; + } + }; // Loop over the fields (series). Go from the last to the first, // because if they're stacked that's how we accumulate the values. @@ -2296,21 +2307,10 @@ Dygraph.prototype.gatherDatasets_ = function(rolledSeries, dateWindow) { // Prune down to the desired range, if necessary (for zooming) // Because there can be lines going to points outside of the visible area, // we actually prune to visible points, plus one on either side. - var errorBars = this.attr_("errorBars"); - var customBars = this.attr_("customBars"); - var bars = errorBars || customBars; if (dateWindow) { var low = dateWindow[0]; var high = dateWindow[1]; var pruned = []; - var isValueNull = function(sample) { - if (!bars) { - return sample[1] === null; - } else { - return customBars ? sample[1][1] === null : - errorBars ? sample[1][0] === null : false; - } - }; // TODO(danvk): do binary search instead of linear search. // TODO(danvk): pass firstIdx and lastIdx directly to the renderer. diff --git a/tests/independent-series.html b/tests/independent-series.html index 6665e73..bddcc6b 100644 --- a/tests/independent-series.html +++ b/tests/independent-series.html @@ -101,6 +101,80 @@ ); +

Encoding a gap

+

There's one extra wrinkle. What if one of the series has a missing + value, i.e. what if your series are something like

+ + + + +
+ +
+ + + + + + +
xA
22
44
6(gap)
88
1010
+
+ + + + + +
xB
13
35
57
+
+ +
+

The gap would normally be encoded as a null, or missing value. But when you use connectSeparatedPoints, that has a special meaning. Instead, you have to use NaN. This is a bit of a hack, but it gets the job done.

+ + + + + + +
+ (CSV) +
x,A,B
+1,,3
+2,2,
+3,,5
+4,4,
+5,,7
+6,NaN,
+8,8,
+10,10,
+
+ (native) +
[ [1, null, 3],
+  [2, 2, null],
+  [3, null, 5],
+  [4, 4, null],
+  [5, null, 7],
+  [6, NaN, null],
+  [8, 8, null],
+  [10, 10, null] ]
+
+

Behavior at the edges of the panel for independent series

In case only a part of the whole data is visible (e.g. after zooming in) the lines are drawn to the respective next valid point outside the visible area.

@@ -201,80 +275,6 @@ [8, 4, 2] ] - -

Encoding a gap

-

There's one extra wrinkle. What if one of the series has a missing - value, i.e. what if your series are something like

- - - - -
- -
- - - - - - -
xA
22
44
6(gap)
88
1010
-
- - - - - -
xB
13
35
57
-
- -
-

The gap would normally be encoded as a null, or missing value. But when you use connectSeparatedPoints, that has a special meaning. Instead, you have to use NaN. This is a bit of a hack, but it gets the job done.

- - - - - - -
- (CSV) -
x,A,B
-1,,3
-2,2,
-3,,5
-4,4,
-5,,7
-6,NaN,
-8,8,
-10,10,
-
- (native) -
[ [1, null, 3],
-  [2, 2, null],
-  [3, null, 5],
-  [4, 4, null],
-  [5, null, 7],
-  [6, NaN, null],
-  [8, 8, null],
-  [10, 10, null] ]
-