2 * @fileoverview Test cases for the option "connectSeparatedPoints" especially for the scenario where not every series has a value for each timestamp.
4 * @author julian.eichstaedt@ch.sauter-bc.com (Fr. Sauter AG)
6 var ConnectSeparatedPointsTestCase
= TestCase("connect-separated-points");
8 ConnectSeparatedPointsTestCase
.prototype.setUp
= function() {
9 document
.body
.innerHTML
= "<div id='graph'></div>";
12 ConnectSeparatedPointsTestCase
.origFunc
= Dygraph
.getContext
;
14 ConnectSeparatedPointsTestCase
.prototype.setUp
= function() {
15 document
.body
.innerHTML
= "<div id='graph'></div>";
16 Dygraph
.getContext
= function(canvas
) {
17 return new Proxy(ConnectSeparatedPointsTestCase
.origFunc(canvas
));
21 ConnectSeparatedPointsTestCase
.prototype.tearDown
= function() {
22 Dygraph
.getContext
= ConnectSeparatedPointsTestCase
.origFunc
;
25 ConnectSeparatedPointsTestCase
.prototype.testEdgePointsSimple
= function() {
34 labels
: ["x", "series1", "series2", "series3"],
35 connectSeparatedPoints
: true,
59 var graph
= document
.getElementById("graph");
60 var g
= new Dygraph(graph
, data
, opts
);
66 //Test if series1 is drawn correctly.
67 //------------------------------------
69 // The first point of the first series
72 var xy1
= g
.toDomCoords(x1
, y1
);
74 // The third (the second valid) point of the first series
75 // This series has no value at the second position.
78 var xy2
= g
.toDomCoords(x2
, y2
);
80 // Check if both points are connected at the left edge of the canvas and if the option "connectSeparatedPoints" works properly
81 // even if the point is outside the visible range and only one series has a valid value for this point.
82 CanvasAssertions
.assertLineDrawn(htx
, xy1
, xy2
, attrs
);
84 //Test if series2 is drawn correctly.
85 //------------------------------------
87 // The sixth point of the second series
88 // Use the sixth and NOT the seventh point despite this series has eight points
89 // since this series has no value at the seventh position.
92 var xy1
= g
.toDomCoords(x1
, y1
);
94 // The last point of the second series.
97 var xy2
= g
.toDomCoords(x2
, y2
);
99 // Check if both points are connected at the right edge of the canvas and if the option "connectSeparatedPoints" works properly
100 // even if the point is outside the visible range and only one series has a valid value for this point.
101 CanvasAssertions
.assertLineDrawn(htx
, xy1
, xy2
, attrs
);
104 ConnectSeparatedPointsTestCase
.prototype.testEdgePointsStacked
= function() {
113 labels
: ["x", "series1", "series2", "series3"],
114 connectSeparatedPoints
: true,
117 dateWindow
: [1.5,6.5]
139 var graph
= document
.getElementById("graph");
140 var g
= new Dygraph(graph
, data
, opts
);
146 //Test if series1 is drawn correctly.
147 //------------------------------------
149 // The first point of the first series
152 var xy1
= g
.toDomCoords(x1
, y1
);
154 // The third (the second valid) point of the first series
155 // This series has no value at the second position.
158 var xy2
= g
.toDomCoords(x2
, y2
);
160 // Check if both points are connected at the left edge of the canvas and if the option "connectSeparatedPoints" works properly
161 // even if the point is outside the visible range and only one series has a valid value for this point.
162 CanvasAssertions
.assertLineDrawn(htx
, xy1
, xy2
, attrs
);
164 //Test if series2 is drawn correctly.
165 //------------------------------------
167 // The sixth point of the second series
168 // Use the sixth and NOT the seventh point despite this series has eight points
169 // since this series has no value at the seventh position.
170 var x1
= data
[13][0];
171 var y1
= data
[13][2];
172 var xy1
= g
.toDomCoords(x1
, y1
);
174 // The last point of the second series.
175 var x2
= data
[15][0];
176 var y2
= data
[15][2];
177 var xy2
= g
.toDomCoords(x2
, y2
);
179 // Check if both points are connected at the right edge of the canvas and if the option "connectSeparatedPoints" works properly
180 // even if the point is outside the visible range and only one series has a valid value for this point.
181 CanvasAssertions
.assertLineDrawn(htx
, xy1
, xy2
, attrs
);