bindEvt('clickHandler', 'annotationClickHandler', p, this));
bindEvt('clickHandler', 'annotationClickHandler', p, this));
bindEvt('mouseOverHandler', 'annotationMouseOverHandler', p, this));
bindEvt('mouseOverHandler', 'annotationMouseOverHandler', p, this));
bindEvt('mouseOutHandler', 'annotationMouseOutHandler', p, this));
bindEvt('mouseOutHandler', 'annotationMouseOutHandler', p, this));
bindEvt('dblClickHandler', 'annotationDblClickHandler', p, this));
this.container.appendChild(div);
bindEvt('dblClickHandler', 'annotationDblClickHandler', p, this));
this.container.appendChild(div);
+DygraphCanvasRenderer.makeNextPointStep_ = function(
+ connect, points, start, end) {
+ if (connect) {
+ return function(j) {
+ while (++j + start < end) {
+ if (!(points[start + j].yval === null)) break;
+ }
+ return j;
+ }
+ } else {
+ return function(j) { return j + 1 };
+ }
+};
+
DygraphCanvasRenderer.prototype._drawStyledLine = function(
ctx, i, setName, color, strokeWidth, strokePattern, drawPoints,
drawPointCallback, pointSize) {
DygraphCanvasRenderer.prototype._drawStyledLine = function(
ctx, i, setName, color, strokeWidth, strokePattern, drawPoints,
drawPointCallback, pointSize) {
var pointsOnLine = []; // Array of [canvasx, canvasy] pairs.
if (!Dygraph.isArrayLike(strokePattern)) {
strokePattern = null;
}
var pointsOnLine = []; // Array of [canvasx, canvasy] pairs.
if (!Dygraph.isArrayLike(strokePattern)) {
strokePattern = null;
}
- for (var j = firstIndexInSet; j < afterLastIndexInSet; j++) {
- point = points[j];
+ for (var j = 0; j < setLength; j = next(j)) {
+ point = points[firstIndexInSet + j];
+ nextY = (next(j) < setLength) ?
+ points[firstIndexInSet + next(j)].canvasy : null;
if (isNullOrNaN(point.canvasy)) {
if (stepPlot && prevX !== null) {
// Draw a horizontal line to the start of the missing data
if (isNullOrNaN(point.canvasy)) {
if (stepPlot && prevX !== null) {
// Draw a horizontal line to the start of the missing data
- var isIsolated = (!prevX && (j == points.length - 1 ||
- isNullOrNaN(points[j+1].canvasy)));
+ var isIsolated = (!prevX && isNullOrNaN(nextY));
+ if (drawGapPoints) {
+ // 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 && isNullOrNaN(nextY))) {
+ isIsolated = true;
+ }
+ }
this.dygraph_, setName, ctx, cb[0], cb[1], color, pointSize);
ctx.restore();
}
this.dygraph_, setName, ctx, cb[0], cb[1], color, pointSize);
ctx.restore();
}
+ var firstIndexInSet = this.layout.setPointsOffsets[i];
+ var setLength = this.layout.setPointsLengths[i];
+ var afterLastIndexInSet = firstIndexInSet + setLength;
+
+ var next = DygraphCanvasRenderer.makeNextPointStep_(
+ this.attr_('connectSeparatedPoints'), points,
+ afterLastIndexInSet);
+
if (axisY < 0.0) axisY = 0.0;
else if (axisY > 1.0) axisY = 1.0;
axisY = this.area.h * axisY + this.area.y;
if (axisY < 0.0) axisY = 0.0;
else if (axisY > 1.0) axisY = 1.0;
axisY = this.area.h * axisY + this.area.y;
+ var firstIndexInSet = this.layout.setPointsOffsets[i];
+ var setLength = this.layout.setPointsLengths[i];
+ var afterLastIndexInSet = firstIndexInSet + setLength;
+
+ var next = DygraphCanvasRenderer.makeNextPointStep_(
+ this.attr_('connectSeparatedPoints'), points,
+ afterLastIndexInSet);
- var lastY = baseline[point.canvasx];
- if (lastY === undefined) lastY = axisY;
- baseline[point.canvasx] = point.canvasy;
+ currBaseline = baseline[point.canvasx];
+ var lastY;
+ if (currBaseline === undefined) {
+ lastY = axisY;
+ } else {
+ if(stepPlot) {
+ lastY = currBaseline[0];
+ } else {
+ lastY = currBaseline;
+ }
+ }
+
+ if(stepPlot) {
+ // Step plots must keep track of the top and bottom of
+ // the baseline at each point.
+ if(prevYs[0] === -1) {
+ baseline[point.canvasx] = [ point.canvasy, axisY ];
+ } else {
+ baseline[point.canvasx] = [ point.canvasy, prevYs[0] ];
+ }
+ } else {
+ baseline[point.canvasx] = point.canvasy;
+ }
+
} else {
newYs = [ point.canvasy, axisY ];
}
if (!isNaN(prevX)) {
ctx.moveTo(prevX, prevYs[0]);
} else {
newYs = [ point.canvasy, axisY ];
}
if (!isNaN(prevX)) {
ctx.moveTo(prevX, prevYs[0]);