Setting options.legend.type to "canvas" (default is "html") will now draw the
whole legend into the canvas (and also not display the HTML version).
This allows the legend to be visible when converting the canvas into an image.
The code was mostly taken from the flotCanvasText plugin for flot by Andre
Lessa (http://lessaworld.com). The redundant parts were removed, and the code
The whole change is encapsulated within a single function. Apart from this, an
extra option has been added (options.legend.type), and the legend hooks updated
accordingly. (Note that the insertLegend method had to be moved to a later
stage of the drawing process, since the canvas legend was otherwise getting
Signed-off-by: Rok Strnisa <email@example.com>