madhushreeag commented on code in PR #37531:
URL: https://github.com/apache/superset/pull/37531#discussion_r2848823964


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -373,6 +375,53 @@ export default function transformProps(
     }
   });
 
+  // Add x-axis color legend when showColorByXAxis is enabled
+  if (showColorByXAxis && groupBy.length === 0 && series.length > 0) {
+    // Hide original series from legend
+    series.forEach(s => {
+      s.legendHoverLink = false;
+    });
+
+    // Get x-axis values from the first series
+    const firstSeries = series[0];
+    if (firstSeries && Array.isArray(firstSeries.data)) {
+      const xAxisValues: (string | number)[] = [];
+
+      // Extract x-axis values
+      (firstSeries.data as any[]).forEach(point => {
+        let xValue;
+        if (point && typeof point === 'object' && 'value' in point) {
+          const val = point.value;
+          xValue = Array.isArray(val) ? val[0] : val;
+        } else if (Array.isArray(point)) {
+          xValue = point[0];
+        } else {
+          xValue = point;
+        }
+        xAxisValues.push(xValue);
+      });
+
+      // Create hidden series for legend (using 'line' type to not affect bar 
width)
+      xAxisValues.forEach(xValue => {
+        const colorKey = String(xValue);
+        series.push({
+          name: String(xValue),

Review Comment:
   Fixed - The fix deduplicates x-axis values with Array.from(new Set(...)) 
before creating the hidden legend series, so each unique x-axis value gets 
exactly one hidden series regardless of   
     how many data points share that value.      



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