rusackas commented on code in PR #42910:
URL: https://github.com/apache/superset/pull/42910#discussion_r4250033076
##########
superset-frontend/plugins/plugin-chart-echarts/src/Gauge/types.ts:
##########
@@ -50,7 +50,21 @@ export type EchartsGaugeFormData = QueryFormData & {
endAngle: number;
showPointer: boolean;
intervals: string;
+ /**
+ * @deprecated Legacy 1-indexed positions into `colorScheme`, e.g. "1,2,4".
+ * Superset versions before `intervalColors` existed stored interval colors
+ * this way. Still read at render time (see
+ * `transformProps.ts#getIntervalBoundsAndColors`) so charts saved with
+ * this shape keep rendering identically without a migration.
+ */
intervalColorIndices: string;
+ /**
+ * Real hex/rgb colors for each interval band, positionally matched to the
+ * bounds parsed from `intervals`. Authored via the `IntervalColorsControl`
+ * control panel row. Takes precedence over `intervalColorIndices` when
+ * present.
+ */
+ intervalColors?: string[];
Review Comment:
Good catch, @sadpandajoe. `interval_colors` is now in the preserved
presentation keys on rebind, and an explicit `interval_color_indices` update
drops the saved literal colors so they do not shadow it. Added regression tests
for both.
##########
superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts:
##########
@@ -53,29 +53,52 @@ import { getColtypesMapping } from '../utils/series';
export const getIntervalBoundsAndColors = (
intervals: string,
intervalColorIndices: string,
+ intervalColors: string[] | undefined,
colorFn: CategoricalColorScale,
min: number,
max: number,
): Array<[number, string]> => {
let intervalBoundsNonNormalized;
- let intervalColorIndicesArray;
try {
intervalBoundsNonNormalized = parseNumbersList(intervals, ',');
- intervalColorIndicesArray = parseNumbersList(intervalColorIndices, ',');
} catch (error) {
intervalBoundsNonNormalized = [] as number[];
- intervalColorIndicesArray = [] as number[];
}
const intervalBounds = intervalBoundsNonNormalized.map(
bound => (bound - min) / (max - min),
);
- const intervalColors = intervalColorIndicesArray.map(
+
+ // New-style: `interval_colors` holds real hex/rgb colors chosen through
+ // the Gauge control panel's per-interval `IntervalColorsControl`,
+ // positionally matched to the bounds parsed from `intervals`. Prefer this
+ // whenever it's populated.
+ if (Array.isArray(intervalColors) && intervalColors.length > 0) {
+ return intervalBounds.map((val, idx) => [
+ val,
Review Comment:
Fixed, @sadpandajoe. `_prepare_gauge_preview` now lets explicit
`interval_colors` win, with blank entries falling back to the palette color.
Covered by a new test.
--
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]