mirror of
https://github.com/apache/superset.git
synced 2026-04-17 23:25:05 +00:00
fix: Time Comparison Feature Reverts Metric Labels to Metric Keys in Table Charts (#32665)
Co-authored-by: Fardin Mustaque <fardinmustaque@Fardins-Mac-mini.local>
This commit is contained in:
@@ -605,6 +605,8 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
// Calculate the number of placeholder columns needed before the current header
|
||||
const startPosition = value[0];
|
||||
const colSpan = value.length;
|
||||
// Retrieve the originalLabel from the first column in this group
|
||||
const originalLabel = columnsMeta[value[0]]?.originalLabel || key;
|
||||
|
||||
// Add placeholder <th> for columns before this header
|
||||
for (let i = currentColumnIndex; i < startPosition; i += 1) {
|
||||
@@ -620,7 +622,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
// Add the current header <th>
|
||||
headers.push(
|
||||
<th key={`header-${key}`} colSpan={colSpan} style={{ borderBottom: 0 }}>
|
||||
{key}
|
||||
{originalLabel}
|
||||
<span
|
||||
css={css`
|
||||
float: right;
|
||||
@@ -975,7 +977,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
),
|
||||
Footer: totals ? (
|
||||
i === 0 ? (
|
||||
<th>
|
||||
<th key={`footer-summary-${i}`}>
|
||||
<div
|
||||
css={css`
|
||||
display: flex;
|
||||
@@ -997,7 +999,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
</div>
|
||||
</th>
|
||||
) : (
|
||||
<td style={sharedStyle}>
|
||||
<td key={`footer-total-${i}`} style={sharedStyle}>
|
||||
<strong>{formatColumnValue(column, totals[key])[1]}</strong>
|
||||
</td>
|
||||
)
|
||||
|
||||
@@ -347,6 +347,7 @@ const processComparisonColumns = (
|
||||
} = props;
|
||||
const savedFormat = columnFormats?.[col.key];
|
||||
const savedCurrency = currencyFormats?.[col.key];
|
||||
const originalLabel = col.label;
|
||||
if (
|
||||
(col.isMetric || col.isPercentMetric) &&
|
||||
!col.key.includes(comparisonSuffix) &&
|
||||
@@ -355,6 +356,7 @@ const processComparisonColumns = (
|
||||
return [
|
||||
{
|
||||
...col,
|
||||
originalLabel,
|
||||
label: t('Main'),
|
||||
key: `${t('Main')} ${col.key}`,
|
||||
config: getComparisonColConfig(t('Main'), col.key, columnConfig),
|
||||
@@ -368,6 +370,7 @@ const processComparisonColumns = (
|
||||
},
|
||||
{
|
||||
...col,
|
||||
originalLabel,
|
||||
label: `#`,
|
||||
key: `# ${col.key}`,
|
||||
config: getComparisonColConfig(`#`, col.key, columnConfig),
|
||||
@@ -381,6 +384,7 @@ const processComparisonColumns = (
|
||||
},
|
||||
{
|
||||
...col,
|
||||
originalLabel,
|
||||
label: `△`,
|
||||
key: `△ ${col.key}`,
|
||||
config: getComparisonColConfig(`△`, col.key, columnConfig),
|
||||
@@ -394,6 +398,7 @@ const processComparisonColumns = (
|
||||
},
|
||||
{
|
||||
...col,
|
||||
originalLabel,
|
||||
label: `%`,
|
||||
key: `% ${col.key}`,
|
||||
config: getComparisonColConfig(`%`, col.key, columnConfig),
|
||||
|
||||
@@ -56,6 +56,8 @@ export interface DataColumnMeta {
|
||||
key: string;
|
||||
// `label` is verbose column name used for rendering
|
||||
label: string;
|
||||
// `originalLabel` preserves the original label when time comparison transforms the labels
|
||||
originalLabel?: string;
|
||||
dataType: GenericDataType;
|
||||
formatter?:
|
||||
| TimeFormatter
|
||||
|
||||
Reference in New Issue
Block a user