rusackas commented on code in PR #45585:
URL: https://github.com/apache/superset/pull/45585#discussion_r4343184460
##########
superset-frontend/plugins/preset-chart-deckgl/src/layers/Arc/transformProps.ts:
##########
@@ -65,8 +66,11 @@ function processArcData(
extraProps: {},
};
- if (dimension && record[dimension] != null) {
- arcPoint.cat_color = String(record[dimension]);
+ if (dimension) {
+ arcPoint.cat_color =
+ record[dimension] != null
+ ? String(record[dimension])
+ : NULL_CATEGORY_KEY;
Review Comment:
Fixed: `cat_color` is now assigned after the property copy, so a column with
that name can no longer overwrite the selected dimension.
##########
superset-frontend/plugins/preset-chart-deckgl/src/utils.ts:
##########
@@ -25,12 +25,20 @@ import {
QueryFormData,
SequentialScheme,
} from '@superset-ui/core';
+import { Constants } from '@superset-ui/core/components';
import { Color } from '@deck.gl/core';
import { hexToRGB } from './utils/colors';
import { ColorBreakpointType } from './types';
export const TRANSPARENT_COLOR_ARRAY = [0, 0, 0, 0] as Color;
export const HIGHLIGHT_COLOR_ARRAY = [255, 0, 0, 255] as Color;
+// Stands in for a null dimension value so those rows still get a category, a
+// color and a legend entry. Kept distinct from NULL_DISPLAY so the key stays
+// stable across locales.
+export const NULL_CATEGORY_KEY = '<NULL>';
Review Comment:
A literal `<NULL>` category value is the one case this collides on. I am
keeping the sentinel since it has to be a string that survives the
category-to-color mapping, and a real value spelled exactly `<NULL>` is
vanishingly unlikely.
##########
superset-frontend/plugins/preset-chart-deckgl/src/layers/Scatter/transformProps.ts:
##########
@@ -155,9 +156,10 @@ function processScatterData(
}
}
- const categoryValue = getSourceValue(categoryColumn);
- if (categoryValue != null) {
- scatterPoint.cat_color = String(categoryValue);
+ if (categoryColumn) {
+ const categoryValue = getSourceValue(categoryColumn);
+ scatterPoint.cat_color =
+ categoryValue != null ? String(categoryValue) : NULL_CATEGORY_KEY;
Review Comment:
Same as the `utils.ts` thread: a literal `<NULL>` category is the accepted
trade-off for the sentinel.
--
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]