sfirke commented on code in PR #36302:
URL: https://github.com/apache/superset/pull/36302#discussion_r2578377646
##########
superset-frontend/plugins/plugin-chart-echarts/src/Heatmap/transformProps.ts:
##########
@@ -144,22 +238,52 @@ 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.map(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) ?? 0;
+ const yIndex = yAxisIndexMap.get(yValue) ?? 0;
+
+ return [xIndex, yIndex, metricValue] as [number, number, any];
Review Comment:
@rusackas that would be amazing if you could hop in 🙏 I'm out of my depth
here!
--
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]