aminghadersohi commented on code in PR #42910:
URL: https://github.com/apache/superset/pull/42910#discussion_r4408225340


##########
superset/mcp_service/chart/chart_utils.py:
##########
@@ -3844,6 +3854,15 @@ def merge_bullet_form_data(
     for values_key, labels_key in dependent_controls.items():
         if values_key in new_form_data and labels_key not in new_form_data:
             new_form_data[labels_key] = ""
+    # Per-band colors are applied by position, so replacing the thresholds
+    # without colors must not re-apply the old colors to the new bands. 
Repeating
+    # the saved thresholds leaves the bands unchanged, so their colors are 
kept.
+    if (
+        "ranges" in new_form_data
+        and "range_colors" not in new_form_data
+        and new_form_data["ranges"] != existing_form_data.get("ranges")

Review Comment:
   This compares raw strings, but Explore saves `ranges` as typed. A chart 
saved as `50, 100` (or `50.0,100`, or with a trailing comma) and updated with 
`ranges=[50,100]` still loses its `range_colors`, though Explore draws the same 
bands.



##########
superset-frontend/src/explore/components/controls/IntervalColorsControl/legacyColors.ts:
##########
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import {
+  getCategoricalSchemeRegistry,
+  validateNumber,
+} from '@superset-ui/core';
+
+export const parseIntervalBounds = (intervals?: string): number[] =>
+  (intervals ?? '')
+    .split(',')
+    .map(part => part.trim())
+    .filter(part => part !== '')
+    .map(Number)
+    .filter(bound => Number.isFinite(bound));
+
+/**
+ * Resolves the legacy `interval_color_indices` control (comma-separated,
+ * 1-indexed positions into the chosen categorical color scheme) into real
+ * hex colors, one per interval band (`boundCount` entries). Shared by the
+ * control panel (display-only fallback while a legacy chart is being edited)
+ * and by `handleDeprecatedControls` (which, on request, migrates the value
+ * into `interval_colors`).

Review Comment:
   Nit: `handleDeprecatedControls` no longer calls this, so the docstring 
describes a migration that never runs.
   
   ```suggestion
    * hex colors, one per interval band (`boundCount` entries). Used by the
    * Gauge `IntervalColorsControl` as a display-only fallback while a legacy
    * chart is being edited.
   ```



-- 
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