@@ -691,7 +691,10 @@ void ScatterplotPlugin::loadColors(const Dataset<Points>& pointsColor, const std
691691 }
692692 else if ( // mapping from color data set to position data set
693693 const auto [selectionMapping, numPointsTarget] = getSelectionMappingColorsToPositions (pointsColor, _positionDataset);
694- /* check if valid */ selectionMapping != nullptr && numPointsTarget == _numPoints
694+ /* check if valid */
695+ selectionMapping != nullptr &&
696+ numPointsTarget == _numPoints &&
697+ checkSurjectiveMapping (*selectionMapping, numPointsTarget)
695698 )
696699 {
697700 // Map values like selection
@@ -706,10 +709,12 @@ void ScatterplotPlugin::loadColors(const Dataset<Points>& pointsColor, const std
706709 }
707710 else if ( // mapping from position data set to color data set
708711 const auto [selectionMapping, numPointsTarget] = getSelectionMappingPositionsToColors (_positionDataset, pointsColor);
709- /* check if valid */ selectionMapping != nullptr && numPointsTarget == numColorPoints
712+ /* check if valid */
713+ selectionMapping != nullptr &&
714+ numPointsTarget == numColorPoints &&
715+ checkSurjectiveMapping (*selectionMapping, numPointsTarget)
710716 )
711717 {
712-
713718 // Map values like selection (in reverse, use first value that occurs)
714719 const mv::SelectionMap::Map& mapPositionsToColors = selectionMapping->getMapping ().getMap ();
715720
@@ -724,7 +729,10 @@ void ScatterplotPlugin::loadColors(const Dataset<Points>& pointsColor, const std
724729 }
725730 else if ( // mapping from source of position data set to color data set
726731 const auto [selectionMapping, numPointsTarget] = getSelectionMappingPositionSourceToColors (_positionDataset, pointsColor);
727- /* check if valid */ selectionMapping != nullptr && numPointsTarget == numColorPoints
732+ /* check if valid */
733+ selectionMapping != nullptr &&
734+ numPointsTarget == numColorPoints &&
735+ checkSurjectiveMapping (*selectionMapping, numPointsTarget)
728736 )
729737 {
730738 // the selection map is from full source data of positions data to pointsColor
0 commit comments