Generate legend and groupings from JSON.