should implement #569 #348 : legend rank detection