You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ar...@apache.org on 2024/03/25 17:17:19 UTC
(superset) 04/10: Table with Time Comparison:
This is an automated email from the ASF dual-hosted git repository.
arivero pushed a commit to branch table-time-comparison
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 4decb160cfc475aaf1d2cfd6e3a533687e5fc005
Author: Antonio Rivero <an...@gmail.com>
AuthorDate: Mon Mar 4 13:09:08 2024 +0100
Table with Time Comparison:
- Handle columns name with with spaces
---
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx | 2 +-
superset-frontend/plugins/plugin-chart-table/src/consts.ts | 2 ++
superset-frontend/plugins/plugin-chart-table/src/transformProps.ts | 3 +--
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
index d4d5de970a..0fca8cfd79 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
@@ -431,7 +431,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
// Check if element's label is one of the comparison labels
if (comparisonLabels.includes(element.label)) {
// Extract the key portion after the space, assuming the format is always "label key"
- const keyPortion = element.key.split(' ')[1];
+ const keyPortion = element.key.substring(element.label.length);
// If the key portion is not in the map, initialize it with the current index
if (!resultMap[keyPortion]) {
diff --git a/superset-frontend/plugins/plugin-chart-table/src/consts.ts b/superset-frontend/plugins/plugin-chart-table/src/consts.ts
index e370c4b029..1f173be403 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/consts.ts
+++ b/superset-frontend/plugins/plugin-chart-table/src/consts.ts
@@ -30,3 +30,5 @@ export const PAGE_SIZE_OPTIONS = formatSelectOptions<number>([
100,
200,
]);
+
+export const COMPARISON_PREFIX = 'prev_';
diff --git a/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts b/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
index e36684baff..00ff94504f 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
@@ -47,12 +47,11 @@ import {
TableChartProps,
TableChartTransformedProps,
} from './types';
+import { COMPARISON_PREFIX } from './consts';
const { PERCENT_3_POINT } = NumberFormats;
const { DATABASE_DATETIME } = TimeFormats;
-const COMPARISON_PREFIX = 'prev_';
-
function isNumeric(key: string, data: DataRecord[] = []) {
return data.every(
x => x[key] === null || x[key] === undefined || typeof x[key] === 'number',