adds legend with line on/off functionality