flot/flot — pull request #1097 by jBouyoud (2013-07-28 09:13:12+00:00)
Title: Cleaning drawing instructions

Simplify drawing lines methods
--
It was possible to simplify lines drawing function. The biggest part of these functions is the clipping stuff.
By let the canvas clipping lines we won a lot of lines of codes for the same functionnality.
To let canvas clips lines just add:

ctx.save();
ctx.translate(plotOffset.left, plotOffset.top);
ctx.rect(0, 0, plotWidth, plotHeight);
ctx.clip();

Architecture concerns
--
**drawSeries hook** able to draw anything on any part of canvas.
If user want to draw anything on canvas just use the **draw hook**.
I'm thinking a **drawSeries hook** just able to draw series thing in plot bounds.
So canvas translations (with plot offesets) and canvas clipping area is now in main draw method.

This is included in the pull request.
If you don't want to change the **drawSeries hook** just reset on each drawing method :

ctx.translate(plotOffset.left, plotOffset.top);

And add 4 clipping instructions in drawLines method :

ctx.save();
ctx.translate(plotOffset.left, plotOffset.top);
ctx.rect(0, 0, plotWidth, plotHeight);
ctx.clip();