closes #1776, fixed legend toggle, headerIcon var was declared before header was rendered
Merge pull request #1779 from jthomassie/fix/legend-toggle

closes #1776, fixed legend toggle