A key function computes a stable identity for each datum so D3 can keep data-bound elements matched with the same data across updates. Without one, D3 matches elements and data by position: the first circle receives the first updated datum, the second receives the second, and so on. With a key such as each cetacean’s uid, circles that remain visible continue representing the same cetacean. section 7.4.2
Keep filtered scatterplot points attached to their data
Pass the key function as the second argument to data(): innerChart .selectAll("circle") .data(updatedData, d => d.uid) .join("circle"); When filters change the cetacean dataset, circles that remain on the scatterplot keep their associated data instead of changing identity. New points enter, existing points update, and removed points exit.

