core: save legend with references