Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Feat] Add display format setting for table/tooltip (#2826)

Igor Dykhta074d123dd1a4
diff --git a/src/actions/src/vis-state-actions.ts b/src/actions/src/vis-state-actions.ts
index 73c2b7774..9cdf7d329 100644
--- a/src/actions/src/vis-state-actions.ts
+++ b/src/actions/src/vis-state-actions.ts
@@ -773,10 +773,8 @@ export type SetColumnDisplayFormatUpdaterAction = {
* @public
*/
export function setColumnDisplayFormat(
- dataId: string,
- formats: {
- [key: string]: string;
- }
+ dataId: SetColumnDisplayFormatUpdaterAction['dataId'],
+ formats: SetColumnDisplayFormatUpdaterAction['formats']
): Merge<
SetColumnDisplayFormatUpdaterAction,
{type: typeof ActionTypes.SET_COLUMN_DISPLAY_FORMAT}
diff --git a/src/types/schemas.d.ts b/src/types/schemas.d.ts
index 0357400dd..b64e8d510 100644
--- a/src/types/schemas.d.ts
+++ b/src/types/schemas.d.ts
@@ -60,11 +60,11 @@ export type SavedLayer = {
columns: {
[key: string]: string;
};
+ columnMode: string;
isVisible: boolean;
visConfig: Record<string, any>;
hidden: boolean;
textLabel: Merge<LayerTextLabel, {field: {name: string; type: string} | null}>;
- columnMode: string;
};
visualChannels: SavedVisualChannels;
};
diff --git a/src/utils/src/data-scale-utils.ts b/src/utils/src/data-scale-utils.ts
index 9a5dec6bc..8ff5aef7f 100644
--- a/src/utils/src/data-scale-utils.ts
+++ b/src/utils/src/data-scale-utils.ts
@@ -206,7 +206,7 @@ function getScaleLabels(
});
}
-const customScaleLabelFormat = d => String(d);
+const customScaleLabelFormat = n => (n ? formatNumber(n, 'real') : 'no value');
/**
* Get linear / quant scale color breaks
*/
diff --git a/src/utils/src/utils.ts b/src/utils/src/utils.ts
index 174ce34b0..d8c99513c 100644
--- a/src/utils/src/utils.ts
+++ b/src/utils/src/utils.ts
@@ -230,9 +230,10 @@ export function findById(id: string): <X extends {id: string}>(arr: X[]) => X |
* Returns array difference from
*/
export function arrayDifference<X extends {id: string}>(source: X[]): (compare: X[]) => X[] {
+ const initial: X[] = [];
return compare =>
source.reduce((acc, element) => {
const foundElement = findById(element.id)(compare);
return foundElement ? [...acc, foundElement] : acc;
- }, [] as X[]);
+ }, initial);
}