Graph: legend fix for bug when running optimized build, Fixes #1045