Ensure graph SVG element layers above the legend

Fix #1671