plotArea: this.area,
seriesIndex: j,
seriesCount: sets.length,
+ singleSeriesName: opt_seriesName,
allSeriesPoints: sets
});
ctx.restore();
* @private
*/
DygraphCanvasRenderer._fillPlotter = function(e) {
+ // Skip if we're drawing a single series for interactive highlight overlay.
+ if (e.singleSeriesName) return;
+
// We'll handle all the series at once, not one-by-one.
if (e.seriesIndex !== 0) return;
var setCount = sets.length;
var fillAlpha = g.getOption('fillAlpha');
- var stepPlot = g.getOption('stepPlot', e.setName);
var stackedGraph = g.getOption("stackedGraph");
var colors = g.getColors();
var baseline = {}; // for stacked graphs: baseline for filling
var currBaseline;
+ var prevStepPlot; // for different line drawing modes (line/step) per series
// process sets in reverse order (needed for stacked graphs)
for (var setIdx = setCount - 1; setIdx >= 0; setIdx--) {
var setName = setNames[setIdx];
if (!g.getOption('fillGraph', setName)) continue;
-
+
+ var stepPlot = g.getOption('stepPlot', setName);
var color = colors[setIdx];
var axis = g.axisPropertiesForSeries(setName);
var axisY = 1.0 + axis.minyval * axis.yscale;
'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + fillAlpha + ')';
ctx.fillStyle = err_color;
ctx.beginPath();
- while(iter.hasNext) {
+ var last_x, is_first = true;
+ while (iter.hasNext) {
var point = iter.next();
if (!Dygraph.isOK(point.y)) {
prevX = NaN;
continue;
}
if (stackedGraph) {
+ if (!is_first && last_x == point.xval) {
+ continue;
+ } else {
+ is_first = false;
+ last_x = point.xval;
+ }
+
currBaseline = baseline[point.canvasx];
var lastY;
if (currBaseline === undefined) {
lastY = axisY;
} else {
- if(stepPlot) {
+ if(prevStepPlot) {
lastY = currBaseline[0];
} else {
lastY = currBaseline;
}
if (!isNaN(prevX)) {
ctx.moveTo(prevX, prevYs[0]);
-
+
+ // Move to top fill point
if (stepPlot) {
ctx.lineTo(point.canvasx, prevYs[0]);
- if(currBaseline) {
- // Draw to the bottom of the baseline
- ctx.lineTo(point.canvasx, currBaseline[1]);
- } else {
- ctx.lineTo(point.canvasx, newYs[1]);
- }
} else {
ctx.lineTo(point.canvasx, newYs[0]);
+ }
+ // Move to bottom fill point
+ if (prevStepPlot && currBaseline) {
+ // Draw to the bottom of the baseline
+ ctx.lineTo(point.canvasx, currBaseline[1]);
+ } else {
ctx.lineTo(point.canvasx, newYs[1]);
}
prevYs = newYs;
prevX = point.canvasx;
}
+ prevStepPlot = stepPlot;
ctx.fill();
}
};