[4, 14]],
{ colors: ['blue']});
var htx = g.hidden_ctx_;
+ /*
var num_lines = 0;
var lines = CanvasAssertions.getLinesDrawn(htx);
for (var idx = 0; idx < lines.length; idx++) {
console.log(line[0].args, line[1].args, color);
}
}
+ */
assertEquals(2, CanvasAssertions.numLinesDrawn(htx, '#0000ff'));
+ CanvasAssertions.assertLineDrawn(htx, [56, 275], [161, 212],
+ { strokeStyle: '#0000ff', });
CanvasAssertions.assertLineDrawn(htx, [370, 87], [475, 25],
{ strokeStyle: '#0000ff', });
+}
+
+SimpleDrawingTestCase.prototype.testSeparatedPointsDontDraw_expanded_connected = function() {
+ var graph = document.getElementById("graph");
+ var g = new Dygraph(
+ graph,
+ [[0, 10],
+ [1, 11],
+ [2, null],
+ [3, 13],
+ [4, 14]],
+ { colors: ['blue'], connectSeparatedPoints: true});
+ var htx = g.hidden_ctx_;
+ var num_lines = 0;
+ var lines = CanvasAssertions.getLinesDrawn(htx);
+ for (var idx = 0; idx < lines.length; idx++) {
+ var line = lines[idx];
+ var color = line[1].properties.strokeStyle;
+ if (color === "#ff0000" || color === "#0000ff") {
+ console.log(line[0].args, line[1].args, color);
+ }
+ }
+
+ assertEquals(3, CanvasAssertions.numLinesDrawn(htx, '#0000ff'));
CanvasAssertions.assertLineDrawn(htx, [56, 275], [161, 212],
{ strokeStyle: '#0000ff', });
+ CanvasAssertions.assertLineDrawn(htx, [161, 212], [370, 87],
+ { strokeStyle: '#0000ff', });
+ CanvasAssertions.assertLineDrawn(htx, [370, 87], [475, 25],
+ { strokeStyle: '#0000ff', });
}
*
* @private
*/
-DygraphCanvasRenderer.makeNextPointStep_ = function(
+DygraphCanvasRenderer.makePointIteratorFunction_ = function(
connectSeparatedPoints, points, start, end) {
if (connectSeparatedPoints) {
return function(j) {
var nextY = null;
var point, nextPoint;
var pointsOnLine = []; // Array of [canvasx, canvasy] pairs.
- var next = DygraphCanvasRenderer.makeNextPointStep_(
+ var nextFunc = DygraphCanvasRenderer.makePointIteratorFunction_(
this.attr_('connectSeparatedPoints'), points, firstIndexInSet,
firstIndexInSet + setLength);
- for (var j = 0; j < setLength; j = next(j)) {
+ for (var j = 0; j < setLength; j = nextFunc(j)) {
point = points[firstIndexInSet + j];
- nextY = (next(j) < setLength) ?
- points[firstIndexInSet + next(j)].canvasy : null;
+ nextY = (nextFunc(j) < setLength) ?
+ points[firstIndexInSet + nextFunc(j)].canvasy : null;
if (DygraphCanvasRenderer.isNullOrNaN_(point.canvasy)) {
if (stepPlot && prevX !== null) {
// Draw a horizontal line to the start of the missing data
// Also consider a point to be is "isolated" if it's adjacent to a
// null point, excluding the graph edges.
if ((j > 0 && !prevX) ||
- (next(j) < setLength && DygraphCanvasRenderer.isNullOrNaN_(nextY))) {
+ (nextFunc(j) < setLength && DygraphCanvasRenderer.isNullOrNaN_(nextY))) {
isIsolated = true;
}
}
ctx.beginPath();
ctx.strokeStyle = color;
ctx.lineWidth = strokeWidth;
- for (var j = firstIndexInSet; j < firstIndexInSet + setLength; ++j) {
+ var nextFunc = DygraphCanvasRenderer.makePointIteratorFunction_(
+ this.attr_('connectSeparatedPoints'), points, firstIndexInSet,
+ firstIndexInSet + setLength);
+ for (var j = firstIndexInSet; j < firstIndexInSet + setLength; j = nextFunc(j)) {
+ var nextJ = nextFunc(j);
var point = points[j];
- nextY = (j + 1 < firstIndexInSet + setLength) ? points[j + 1].canvasy : null;
+ nextY = (nextJ < firstIndexInSet + setLength) ? points[nextJ].canvasy : null;
if (DygraphCanvasRenderer.isNullOrNaN_(point.canvasy)) {
prevX = prevY = null;
} else {
// Also consider a point to be is "isolated" if it's adjacent to a
// null point, excluding the graph edges.
if ((j > firstIndexInSet && !prevX) ||
- ((j + 1 < firstIndexInSet + setLength) && DygraphCanvasRenderer.isNullOrNaN_(nextY))) {
+ ((nextJ < firstIndexInSet + setLength) && DygraphCanvasRenderer.isNullOrNaN_(nextY))) {
isIsolated = true;
}
}
var setLength = this.layout.setPointsLengths[i];
var afterLastIndexInSet = firstIndexInSet + setLength;
- var next = DygraphCanvasRenderer.makeNextPointStep_(
+ var nextFunc = DygraphCanvasRenderer.makePointIteratorFunction_(
this.attr_('connectSeparatedPoints'), points,
afterLastIndexInSet);
fillAlpha + ')';
ctx.fillStyle = err_color;
ctx.beginPath();
- for (j = firstIndexInSet; j < afterLastIndexInSet; j = next(j)) {
+ for (j = firstIndexInSet; j < afterLastIndexInSet; j = nextFunc(j)) {
point = points[j];
if (point.name == setName) { // TODO(klausw): this is always true
if (!Dygraph.isOK(point.y)) {
var setLength = this.layout.setPointsLengths[i];
var afterLastIndexInSet = firstIndexInSet + setLength;
- var next = DygraphCanvasRenderer.makeNextPointStep_(
+ var nextFunc = DygraphCanvasRenderer.makePointIteratorFunction_(
this.attr_('connectSeparatedPoints'), points,
afterLastIndexInSet);
fillAlpha + ')';
ctx.fillStyle = err_color;
ctx.beginPath();
- for (j = firstIndexInSet; j < afterLastIndexInSet; j = next(j)) {
+ for (j = firstIndexInSet; j < afterLastIndexInSet; j = nextFunc(j)) {
point = points[j];
if (point.name == setName) { // TODO(klausw): this is always true
if (!Dygraph.isOK(point.y)) {