Fix crash on legend icon with offset generation (#4790)