rusackas commented on code in PR #36302:
URL: https://github.com/apache/superset/pull/36302#discussion_r2582718368


##########
superset-frontend/plugins/plugin-chart-echarts/src/Heatmap/transformProps.ts:
##########
@@ -144,22 +239,61 @@ export default function transformProps(
       DEFAULT_ECHARTS_BOUNDS[1];
   }
 
+  // Extract and sort unique axis values
+  // Use colnames to get the actual column names in the data
+  const xAxisColumnName = colnames[0];
+  const yAxisColumnName = colnames[1];
+
+  const xAxisValues = extractUniqueValues(data, xAxisColumnName);
+  const yAxisValues = extractUniqueValues(data, yAxisColumnName);
+
+  const sortedXAxisValues = sortAxisValues(
+    xAxisValues,
+    data,
+    sortXAxis,
+    metricLabel,
+    xAxisColumnName,
+  );
+  const sortedYAxisValues = sortAxisValues(
+    yAxisValues,
+    data,
+    sortYAxis,
+    metricLabel,
+    yAxisColumnName,
+  );
+
+  // Create lookup maps for axis indices
+  const xAxisIndexMap = new Map<DataRecordValue, number>(
+    sortedXAxisValues.map((value, index) => [value, index]),
+  );
+  const yAxisIndexMap = new Map<DataRecordValue, number>(
+    sortedYAxisValues.map((value, index) => [value, index]),
+  );
+
   const series: HeatmapSeriesOption[] = [
     {
       name: metricLabel,
       type: 'heatmap',
-      data: data.map(row =>
-        colnames.map(col => {
-          const value = row[col];
-          if (value === null || value === undefined) {
-            return NULL_STRING;
-          }
-          if (typeof value === 'boolean' || typeof value === 'bigint') {
-            return String(value);
-          }
-          return value;
-        }),
-      ),
+      data: data.flatMap(row => {
+        const xValue = row[xAxisColumnName];
+        const yValue = row[yAxisColumnName];
+        const metricValue = row[metricLabel];
+
+        // Convert to axis indices for ECharts when explicit axis data is 
provided
+        const xIndex = xAxisIndexMap.get(xValue);
+        const yIndex = yAxisIndexMap.get(yValue);
+
+        if (xIndex === undefined || yIndex === undefined) {
+          // Log a warning for debugging
+          // eslint-disable-next-line no-console

Review Comment:
   ```suggestion
   ```



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