bito-code-review[bot] commented on PR #43180:
URL: https://github.com/apache/superset/pull/43180#issuecomment-5297396825

   <!-- Bito Reply -->
   The flagged issue is correct. The current implementation of 
`CategoricalColorScale` fails to reserve colors already assigned to other 
labels when a `sliceId` is missing in dashboard mode, leading to inconsistent 
color assignments across repeated lookups. The proposed fix introduces a 
`getReservedColors` method to identify colors already owned by other labels 
(via `forcedColors` or the shared dashboard map) and updates 
`getNextAvailableColor` to avoid these reserved colors when selecting a new 
one. This ensures that labels consistently receive distinct colors even when 
the shared map is incomplete.
   
   
**superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts**
   ```
   getReservedColors(currentLabel: string): Set<string> {
       const reservedColors = new Set<string>();
   
       Object.entries(this.forcedColors).forEach(([label, color]) => {
         if (label !== currentLabel) {
           reservedColors.add(color);
         }
       });
   
       // outside of a dashboard there is no shared map to reserve colors from
       if (this.labelsColorMapInstance.source === 
LabelsColorMapSource.Dashboard) {
         this.labelsColorMapInstance.getColorMap().forEach((color, label) => {
           if (label !== currentLabel) {
             reservedColors.add(color);
           }
         });
       }
   
       return reservedColors;
     }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to