Graph: refactoring some stuff with legend values