danvk/dygraphs — pull request #462 by danvk (2014-11-11 22:57:47+00:00)
Title: Fast Fill

Fixes #346

There are two main "innovations" here:

1. The chart fill is now drawn in a sane order (see my comment on issue #346 for a chart)
1. I created an optimizing canvas renderer, which drops superfluous points on their way to the canvas.

I took screenshots of `tests/dense-fill.html` both with and without the optimization. There were a few differences with the antialiasing along the edges, but nothing visually distinguishable.

The performance improvement can be dramatic. For a 10,000 point series in a 480x320 chart (i.e. the benchmark), I see a drop from ~700ms/draw → 25ms/draw, which is roughly in line with the performance w/o `fillGraph` set.

The speedup is entirely explained by the number of line segments being sent to the canvas. `tests/dense-fill.html` draws a 10,000 point series on an 800px wide canvas. Before, it issued 40,000 `moveTo` and `lineTo` calls. After, it issues ~1490.