3 * Copyright 2006 Dan Vanderkam (danvdk@gmail.com)
4 * MIT-licensed (http://opensource.org/licenses/MIT)
8 * @fileoverview Based on PlotKit.CanvasRenderer, but modified to meet the
11 * In particular, support for:
14 * - dygraphs attribute system
18 * The DygraphCanvasRenderer class does the actual rendering of the chart onto
19 * a canvas. It's based on PlotKit.CanvasRenderer.
20 * @param {Object} element The canvas to attach to
21 * @param {Object} elementContext The 2d context of the canvas (injected so it
22 * can be mocked for testing.)
23 * @param {Layout} layout The DygraphLayout object for this graph.
27 /*jshint globalstrict: true */
28 /*global Dygraph:false,RGBColorParser:false */
35 * This gets called when there are "new points" to chart. This is generally the
36 * case when the underlying data being charted has changed. It is _not_ called
37 * in the common case that the user has zoomed or is panning the view.
39 * The chart canvas has already been created by the Dygraph object. The
40 * renderer simply gets a drawing context.
42 * @param {Dygraph} dygraph The chart to which this renderer belongs.
43 * @param {HTMLCanvasElement} element The <canvas> DOM element on which to draw.
44 * @param {CanvasRenderingContext2D} elementContext The drawing context.
45 * @param {DygraphLayout} layout The chart's DygraphLayout object.
47 * TODO(danvk): remove the elementContext property.
49 var DygraphCanvasRenderer
= function(dygraph
, element
, elementContext
, layout
) {
50 this.dygraph_
= dygraph
;
53 this.element
= element
;
54 this.elementContext
= elementContext
;
55 this.container
= this.element
.parentNode
;
57 this.height
= this.element
.height
;
58 this.width
= this.element
.width
;
60 // --- check whether everything is ok before we return
61 // NOTE(konigsberg): isIE is never defined in this object. Bug of some sort.
62 if (!this.isIE
&& !(DygraphCanvasRenderer
.isSupported(this.element
)))
63 throw "Canvas is not supported.";
66 this.area
= layout
.getPlotArea();
67 this.container
.style
.position
= "relative";
68 this.container
.style
.width
= this.width
+ "px";
70 // Set up a clipping area for the canvas (and the interaction canvas).
71 // This ensures that we don't overdraw.
72 if (this.dygraph_
.isUsingExcanvas_
) {
73 this._createIEClipArea();
75 // on Android 3 and 4, setting a clipping area on a canvas prevents it from
76 // displaying anything.
77 if (!Dygraph
.isAndroid()) {
78 var ctx
= this.dygraph_
.canvas_ctx_
;
80 ctx
.rect(this.area
.x
, this.area
.y
, this.area
.w
, this.area
.h
);
83 ctx
= this.dygraph_
.hidden_ctx_
;
85 ctx
.rect(this.area
.x
, this.area
.y
, this.area
.w
, this.area
.h
);
92 * Clears out all chart content and DOM elements.
93 * This is called immediately before render() on every frame, including
94 * during zooms and pans.
97 DygraphCanvasRenderer
.prototype.clear
= function() {
100 // VML takes a while to start up, so we just poll every this.IEDelay
102 if (this.clearDelay
) {
103 this.clearDelay
.cancel();
104 this.clearDelay
= null;
106 context
= this.elementContext
;
109 // TODO(danvk): this is broken, since MochiKit.Async is gone.
110 // this.clearDelay = MochiKit.Async.wait(this.IEDelay);
111 // this.clearDelay.addCallback(bind(this.clear, this));
116 context
= this.elementContext
;
117 context
.clearRect(0, 0, this.width
, this.height
);
121 * Checks whether the browser supports the <canvas> tag.
124 DygraphCanvasRenderer
.isSupported
= function(canvasName
) {
127 if (typeof(canvasName
) == 'undefined' || canvasName
=== null) {
128 canvas
= document
.createElement("canvas");
132 canvas
.getContext("2d");
135 var ie
= navigator
.appVersion
.match(/MSIE (\d\.\d)/);
136 var opera
= (navigator
.userAgent
.toLowerCase().indexOf("opera") != -1);
137 if ((!ie
) || (ie
[1] < 6) || (opera
))
145 * This method is responsible for drawing everything on the chart, including
146 * lines, error bars, fills and axes.
147 * It is called immediately after clear() on every frame, including during pans
151 DygraphCanvasRenderer
.prototype.render
= function() {
152 // attaches point.canvas{x,y}
153 this._updatePoints();
155 // actually draws the chart.
156 this._renderLineChart();
159 DygraphCanvasRenderer
.prototype._createIEClipArea
= function() {
160 var className
= 'dygraph-clip-div';
161 var graphDiv
= this.dygraph_
.graphDiv
;
163 // Remove old clip divs.
164 for (var i
= graphDiv
.childNodes
.length
-1; i
>= 0; i
--) {
165 if (graphDiv
.childNodes
[i
].className
== className
) {
166 graphDiv
.removeChild(graphDiv
.childNodes
[i
]);
170 // Determine background color to give clip divs.
171 var backgroundColor
= document
.bgColor
;
172 var element
= this.dygraph_
.graphDiv
;
173 while (element
!= document
) {
174 var bgcolor
= element
.currentStyle
.backgroundColor
;
175 if (bgcolor
&& bgcolor
!= 'transparent') {
176 backgroundColor
= bgcolor
;
179 element
= element
.parentNode
;
182 function createClipDiv(area
) {
183 if (area
.w
=== 0 || area
.h
=== 0) {
186 var elem
= document
.createElement('div');
187 elem
.className
= className
;
188 elem
.style
.backgroundColor
= backgroundColor
;
189 elem
.style
.position
= 'absolute';
190 elem
.style
.left
= area
.x
+ 'px';
191 elem
.style
.top
= area
.y
+ 'px';
192 elem
.style
.width
= area
.w
+ 'px';
193 elem
.style
.height
= area
.h
+ 'px';
194 graphDiv
.appendChild(elem
);
197 var plotArea
= this.area
;
208 w
: this.width
- plotArea
.x
,
214 x
: plotArea
.x
+ plotArea
.w
, y
: 0,
215 w
: this.width
-plotArea
.x
- plotArea
.w
,
222 y
: plotArea
.y
+ plotArea
.h
,
223 w
: this.width
- plotArea
.x
,
224 h
: this.height
- plotArea
.h
- plotArea
.y
230 * Returns a predicate to be used with an iterator, which will
231 * iterate over points appropriately, depending on whether
232 * connectSeparatedPoints is true. When it's false, the predicate will
233 * skip over points with missing yVals.
235 DygraphCanvasRenderer
._getIteratorPredicate
= function(connectSeparatedPoints
) {
236 return connectSeparatedPoints
?
237 DygraphCanvasRenderer
._predicateThatSkipsEmptyPoints
:
241 DygraphCanvasRenderer
._predicateThatSkipsEmptyPoints
=
242 function(array
, idx
) {
243 return array
[idx
].yval
!== null;
247 * Draws a line with the styles passed in and calls all the drawPointCallbacks.
248 * @param {Object} e The dictionary passed to the plotter function.
251 DygraphCanvasRenderer
._drawStyledLine
= function(e
,
252 color
, strokeWidth
, strokePattern
, drawPoints
,
253 drawPointCallback
, pointSize
) {
255 // TODO(konigsberg): Compute attributes outside this method call.
256 var stepPlot
= g
.getBooleanOption("stepPlot", e
.setName
);
258 if (!Dygraph
.isArrayLike(strokePattern
)) {
259 strokePattern
= null;
262 var drawGapPoints
= g
.getBooleanOption('drawGapEdgePoints', e
.setName
);
264 var points
= e
.points
;
265 var setName
= e
.setName
;
266 var iter
= Dygraph
.createIterator(points
, 0, points
.length
,
267 DygraphCanvasRenderer
._getIteratorPredicate(
268 g
.getBooleanOption("connectSeparatedPoints", setName
)));
270 var stroking
= strokePattern
&& (strokePattern
.length
>= 2);
272 var ctx
= e
.drawingContext
;
275 ctx
.installPattern(strokePattern
);
278 var pointsOnLine
= DygraphCanvasRenderer
._drawSeries(
279 e
, iter
, strokeWidth
, pointSize
, drawPoints
, drawGapPoints
, stepPlot
, color
);
280 DygraphCanvasRenderer
._drawPointsOnLine(
281 e
, pointsOnLine
, drawPointCallback
, color
, pointSize
);
284 ctx
.uninstallPattern();
291 * This does the actual drawing of lines on the canvas, for just one series.
292 * Returns a list of [canvasx, canvasy] pairs for points for which a
293 * drawPointCallback should be fired. These include isolated points, or all
294 * points if drawPoints=true.
295 * @param {Object} e The dictionary passed to the plotter function.
298 DygraphCanvasRenderer
._drawSeries
= function(e
,
299 iter
, strokeWidth
, pointSize
, drawPoints
, drawGapPoints
, stepPlot
, color
) {
301 var prevCanvasX
= null;
302 var prevCanvasY
= null;
303 var nextCanvasY
= null;
304 var isIsolated
; // true if this point is isolated (no line segments)
305 var point
; // the point being processed in the while loop
306 var pointsOnLine
= []; // Array of [canvasx, canvasy] pairs.
307 var first
= true; // the first cycle through the while loop
309 var ctx
= e
.drawingContext
;
311 ctx
.strokeStyle
= color
;
312 ctx
.lineWidth
= strokeWidth
;
314 // NOTE: we break the iterator's encapsulation here for about a 25% speedup.
315 var arr
= iter
.array_
;
316 var limit
= iter
.end_
;
317 var predicate
= iter
.predicate_
;
319 for (var i
= iter
.start_
; i
< limit
; i
++) {
322 while (i
< limit
&& !predicate(arr
, i
)) {
325 if (i
== limit
) break;
329 // FIXME: The 'canvasy != canvasy' test here catches NaN values but the test
330 // doesn't catch Infinity values. Could change this to
331 // !isFinite(point.canvasy), but I assume it avoids isNaN for performance?
332 if (point
.canvasy
=== null || point
.canvasy
!= point
.canvasy
) {
333 if (stepPlot
&& prevCanvasX
!== null) {
334 // Draw a horizontal line to the start of the missing data
335 ctx
.moveTo(prevCanvasX
, prevCanvasY
);
336 ctx
.lineTo(point
.canvasx
, prevCanvasY
);
338 prevCanvasX
= prevCanvasY
= null;
341 if (drawGapPoints
|| !prevCanvasX
) {
344 nextCanvasY
= iter
.hasNext
? iter
.peek
.canvasy
: null;
346 var isNextCanvasYNullOrNaN
= nextCanvasY
=== null ||
347 nextCanvasY
!= nextCanvasY
;
348 isIsolated
= (!prevCanvasX
&& isNextCanvasYNullOrNaN
);
350 // Also consider a point to be "isolated" if it's adjacent to a
351 // null point, excluding the graph edges.
352 if ((!first
&& !prevCanvasX
) ||
353 (iter
.hasNext
&& isNextCanvasYNullOrNaN
)) {
359 if (prevCanvasX
!== null) {
362 ctx
.moveTo(prevCanvasX
, prevCanvasY
);
363 ctx
.lineTo(point
.canvasx
, prevCanvasY
);
366 ctx
.lineTo(point
.canvasx
, point
.canvasy
);
369 ctx
.moveTo(point
.canvasx
, point
.canvasy
);
371 if (drawPoints
|| isIsolated
) {
372 pointsOnLine
.push([point
.canvasx
, point
.canvasy
, point
.idx
]);
374 prevCanvasX
= point
.canvasx
;
375 prevCanvasY
= point
.canvasy
;
384 * This fires the drawPointCallback functions, which draw dots on the points by
385 * default. This gets used when the "drawPoints" option is set, or when there
386 * are isolated points.
387 * @param {Object} e The dictionary passed to the plotter function.
390 DygraphCanvasRenderer
._drawPointsOnLine
= function(
391 e
, pointsOnLine
, drawPointCallback
, color
, pointSize
) {
392 var ctx
= e
.drawingContext
;
393 for (var idx
= 0; idx
< pointsOnLine
.length
; idx
++) {
394 var cb
= pointsOnLine
[idx
];
397 e
.dygraph
, e
.setName
, ctx
, cb
[0], cb
[1], color
, pointSize
, cb
[2]);
403 * Attaches canvas coordinates to the points array.
406 DygraphCanvasRenderer
.prototype._updatePoints
= function() {
410 // TODO(bhs): this loop is a hot-spot for high-point-count charts. These
411 // transformations can be pushed into the canvas via linear transformation
413 // NOTE(danvk): this is trickier than it sounds at first. The transformation
414 // needs to be done before the .moveTo() and .lineTo() calls, but must be
415 // undone before the .stroke() call to ensure that the stroke width is
416 // unaffected. An alternative is to reduce the stroke width in the
417 // transformed coordinate space, but you can't specify different values for
418 // each dimension (as you can with .scale()). The speedup here is ~12%.
419 var sets
= this.layout
.points
;
420 for (var i
= sets
.length
; i
--;) {
421 var points
= sets
[i
];
422 for (var j
= points
.length
; j
--;) {
423 var point
= points
[j
];
424 point
.canvasx
= this.area
.w
* point
.x
+ this.area
.x
;
425 point
.canvasy
= this.area
.h
* point
.y
+ this.area
.y
;
431 * Add canvas Actually draw the lines chart, including error bars.
433 * This function can only be called if DygraphLayout's points array has been
434 * updated with canvas{x,y} attributes, i.e. by
435 * DygraphCanvasRenderer._updatePoints.
437 * @param {string=} opt_seriesName when specified, only that series will
438 * be drawn. (This is used for expedited redrawing with highlightSeriesOpts)
439 * @param {CanvasRenderingContext2D} opt_ctx when specified, the drawing
440 * context. However, lines are typically drawn on the object's
444 DygraphCanvasRenderer
.prototype._renderLineChart
= function(opt_seriesName
, opt_ctx
) {
445 var ctx
= opt_ctx
|| this.elementContext
;
448 var sets
= this.layout
.points
;
449 var setNames
= this.layout
.setNames
;
452 this.colors
= this.dygraph_
.colorsMap_
;
454 // Determine which series have specialized plotters.
455 var plotter_attr
= this.dygraph_
.getOption("plotter");
456 var plotters
= plotter_attr
;
457 if (!Dygraph
.isArrayLike(plotters
)) {
458 plotters
= [plotters
];
461 var setPlotters
= {}; // series name -> plotter fn.
462 for (i
= 0; i
< setNames
.length
; i
++) {
463 setName
= setNames
[i
];
464 var setPlotter
= this.dygraph_
.getOption("plotter", setName
);
465 if (setPlotter
== plotter_attr
) continue; // not specialized.
467 setPlotters
[setName
] = setPlotter
;
470 for (i
= 0; i
< plotters
.length
; i
++) {
471 var plotter
= plotters
[i
];
472 var is_last
= (i
== plotters
.length
- 1);
474 for (var j
= 0; j
< sets
.length
; j
++) {
475 setName
= setNames
[j
];
476 if (opt_seriesName
&& setName
!= opt_seriesName
) continue;
478 var points
= sets
[j
];
480 // Only throw in the specialized plotters on the last iteration.
482 if (setName
in setPlotters
) {
484 p
= setPlotters
[setName
];
486 // Don't use the standard plotters in this case.
491 var color
= this.colors
[setName
];
492 var strokeWidth
= this.dygraph_
.getOption("strokeWidth", setName
);
495 ctx
.strokeStyle
= color
;
496 ctx
.lineWidth
= strokeWidth
;
502 strokeWidth
: strokeWidth
,
503 dygraph
: this.dygraph_
,
504 axis
: this.dygraph_
.axisPropertiesForSeries(setName
),
507 seriesCount
: sets
.length
,
508 singleSeriesName
: opt_seriesName
,
509 allSeriesPoints
: sets
517 * Standard plotters. These may be used by clients via Dygraph.Plotters.
518 * See comments there for more details.
520 DygraphCanvasRenderer
._Plotters
= {
521 linePlotter
: function(e
) {
522 DygraphCanvasRenderer
._linePlotter(e
);
525 fillPlotter
: function(e
) {
526 DygraphCanvasRenderer
._fillPlotter(e
);
529 errorPlotter
: function(e
) {
530 DygraphCanvasRenderer
._errorPlotter(e
);
535 * Plotter which draws the central lines for a series.
538 DygraphCanvasRenderer
._linePlotter
= function(e
) {
540 var setName
= e
.setName
;
541 var strokeWidth
= e
.strokeWidth
;
543 // TODO(danvk): Check if there's any performance impact of just calling
544 // getOption() inside of _drawStyledLine. Passing in so many parameters makes
545 // this code a bit nasty.
546 var borderWidth
= g
.getNumericOption("strokeBorderWidth", setName
);
547 var drawPointCallback
= g
.getOption("drawPointCallback", setName
) ||
548 Dygraph
.Circles
.DEFAULT
;
549 var strokePattern
= g
.getOption("strokePattern", setName
);
550 var drawPoints
= g
.getBooleanOption("drawPoints", setName
);
551 var pointSize
= g
.getNumericOption("pointSize", setName
);
553 if (borderWidth
&& strokeWidth
) {
554 DygraphCanvasRenderer
._drawStyledLine(e
,
555 g
.getOption("strokeBorderColor", setName
),
556 strokeWidth
+ 2 * borderWidth
,
564 DygraphCanvasRenderer
._drawStyledLine(e
,
575 * Draws the shaded error bars/confidence intervals for each series.
576 * This happens before the center lines are drawn, since the center lines
577 * need to be drawn on top of the error bars for all series.
580 DygraphCanvasRenderer
._errorPlotter
= function(e
) {
582 var setName
= e
.setName
;
583 var errorBars
= g
.getBooleanOption("errorBars") ||
584 g
.getBooleanOption("customBars");
585 if (!errorBars
) return;
587 var fillGraph
= g
.getBooleanOption("fillGraph", setName
);
589 g
.warn("Can't use fillGraph option with error bars");
592 var ctx
= e
.drawingContext
;
594 var fillAlpha
= g
.getNumericOption('fillAlpha', setName
);
595 var stepPlot
= g
.getBooleanOption("stepPlot", setName
);
596 var points
= e
.points
;
598 var iter
= Dygraph
.createIterator(points
, 0, points
.length
,
599 DygraphCanvasRenderer
._getIteratorPredicate(
600 g
.getBooleanOption("connectSeparatedPoints", setName
)));
604 // setup graphics context
607 var prevYs
= [-1, -1];
608 // should be same color as the lines but only 15% opaque.
609 var rgb
= new RGBColorParser(color
);
611 'rgba(' + rgb
.r
+ ',' + rgb
.g
+ ',' + rgb
.b
+ ',' + fillAlpha
+ ')';
612 ctx
.fillStyle
= err_color
;
615 var isNullUndefinedOrNaN
= function(x
) {
616 return (x
=== null ||
621 while (iter
.hasNext
) {
622 var point
= iter
.next();
623 if ((!stepPlot
&& isNullUndefinedOrNaN(point
.y
)) ||
624 (stepPlot
&& !isNaN(prevY
) && isNullUndefinedOrNaN(prevY
))) {
630 newYs
= [ point
.y_bottom
, point
.y_top
];
633 newYs
= [ point
.y_bottom
, point
.y_top
];
635 newYs
[0] = e
.plotArea
.h
* newYs
[0] + e
.plotArea
.y
;
636 newYs
[1] = e
.plotArea
.h
* newYs
[1] + e
.plotArea
.y
;
639 ctx
.moveTo(prevX
, prevYs
[0]);
640 ctx
.lineTo(point
.canvasx
, prevYs
[0]);
641 ctx
.lineTo(point
.canvasx
, prevYs
[1]);
643 ctx
.moveTo(prevX
, prevYs
[0]);
644 ctx
.lineTo(point
.canvasx
, newYs
[0]);
645 ctx
.lineTo(point
.canvasx
, newYs
[1]);
647 ctx
.lineTo(prevX
, prevYs
[1]);
651 prevX
= point
.canvasx
;
657 * Draws the shaded regions when "fillGraph" is set. Not to be confused with
660 * For stacked charts, it's more convenient to handle all the series
661 * simultaneously. So this plotter plots all the points on the first series
662 * it's asked to draw, then ignores all the other series.
666 DygraphCanvasRenderer
._fillPlotter
= function(e
) {
667 // Skip if we're drawing a single series for interactive highlight overlay.
668 if (e
.singleSeriesName
) return;
670 // We'll handle all the series at once, not one-by-one.
671 if (e
.seriesIndex
!== 0) return;
674 var setNames
= g
.getLabels().slice(1); // remove x-axis
676 // getLabels() includes names for invisible series, which are not included in
677 // allSeriesPoints. We remove those to make the two match.
678 // TODO(danvk): provide a simpler way to get this information.
679 for (var i
= setNames
.length
; i
>= 0; i
--) {
680 if (!g
.visibility()[i
]) setNames
.splice(i
, 1);
683 var anySeriesFilled
= (function() {
684 for (var i
= 0; i
< setNames
.length
; i
++) {
685 if (g
.getBooleanOption("fillGraph", setNames
[i
])) return true;
690 if (!anySeriesFilled
) return;
692 var ctx
= e
.drawingContext
;
693 var area
= e
.plotArea
;
694 var sets
= e
.allSeriesPoints
;
695 var setCount
= sets
.length
;
697 var fillAlpha
= g
.getNumericOption('fillAlpha');
698 var stackedGraph
= g
.getBooleanOption("stackedGraph");
699 var colors
= g
.getColors();
701 // For stacked graphs, track the baseline for filling.
703 // The filled areas below graph lines are trapezoids with two
704 // vertical edges. The top edge is the line segment being drawn, and
705 // the baseline is the bottom edge. Each baseline corresponds to the
706 // top line segment from the previous stacked line. In the case of
707 // step plots, the trapezoids are rectangles.
710 var prevStepPlot
; // for different line drawing modes (line/step) per series
712 // process sets in reverse order (needed for stacked graphs)
713 for (var setIdx
= setCount
- 1; setIdx
>= 0; setIdx
--) {
714 var setName
= setNames
[setIdx
];
715 if (!g
.getBooleanOption('fillGraph', setName
)) continue;
717 var stepPlot
= g
.getBooleanOption('stepPlot', setName
);
718 var color
= colors
[setIdx
];
719 var axis
= g
.axisPropertiesForSeries(setName
);
720 var axisY
= 1.0 + axis
.minyval
* axis
.yscale
;
721 if (axisY
< 0.0) axisY
= 0.0;
722 else if (axisY
> 1.0) axisY
= 1.0;
723 axisY
= area
.h
* axisY
+ area
.y
;
725 var points
= sets
[setIdx
];
726 var iter
= Dygraph
.createIterator(points
, 0, points
.length
,
727 DygraphCanvasRenderer
._getIteratorPredicate(
728 g
.getBooleanOption("connectSeparatedPoints", setName
)));
730 // setup graphics context
732 var prevYs
= [-1, -1];
734 // should be same color as the lines but only 15% opaque.
735 var rgb
= new RGBColorParser(color
);
737 'rgba(' + rgb
.r
+ ',' + rgb
.g
+ ',' + rgb
.b
+ ',' + fillAlpha
+ ')';
738 ctx
.fillStyle
= err_color
;
740 var last_x
, is_first
= true;
741 while (iter
.hasNext
) {
742 var point
= iter
.next();
743 if (!Dygraph
.isOK(point
.y
)) {
745 if (point
.y_stacked
!== null && !isNaN(point
.y_stacked
)) {
746 baseline
[point
.canvasx
] = area
.h
* point
.y_stacked
+ area
.y
;
751 if (!is_first
&& last_x
== point
.xval
) {
758 currBaseline
= baseline
[point
.canvasx
];
760 if (currBaseline
=== undefined
) {
764 lastY
= currBaseline
[0];
766 lastY
= currBaseline
;
769 newYs
= [ point
.canvasy
, lastY
];
772 // Step plots must keep track of the top and bottom of
773 // the baseline at each point.
774 if(prevYs
[0] === -1) {
775 baseline
[point
.canvasx
] = [ point
.canvasy
, axisY
];
777 baseline
[point
.canvasx
] = [ point
.canvasy
, prevYs
[0] ];
780 baseline
[point
.canvasx
] = point
.canvasy
;
784 newYs
= [ point
.canvasy
, axisY
];
787 ctx
.moveTo(prevX
, prevYs
[0]);
789 // Move to top fill point
791 ctx
.lineTo(point
.canvasx
, prevYs
[0]);
793 ctx
.lineTo(point
.canvasx
, newYs
[0]);
795 // Move to bottom fill point
796 if (prevStepPlot
&& currBaseline
) {
797 // Draw to the bottom of the baseline
798 ctx
.lineTo(point
.canvasx
, currBaseline
[1]);
800 ctx
.lineTo(point
.canvasx
, newYs
[1]);
803 ctx
.lineTo(prevX
, prevYs
[1]);
807 prevX
= point
.canvasx
;
809 prevStepPlot
= stepPlot
;