DRY code for graphs + improvements for labels