Slight rearrangement of the JS file, so that add_plot, add_geom, etc. are all in the same part of the file and auxiliary functions (getlinetype2dasharray, isArray, etc.) are at the bottom of the file.

Attempt to add legends (doesn't work well currently)
Move legend doodles into examples - it can be deleted later once legends work.
Fix of legend export for multiple-legends