Skip to content

Commit 074d123

Browse files
authored
[Feat] Add display format setting for table/tooltip (#2826)
- [Feat] Add display format setting for table/tooltip - ts changes Signed-off-by: Ihor Dykhta <[email protected]>
1 parent aec75d8 commit 074d123

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/actions/src/vis-state-actions.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,8 @@ export type SetColumnDisplayFormatUpdaterAction = {
773773
* @public
774774
*/
775775
export function setColumnDisplayFormat(
776-
dataId: string,
777-
formats: {
778-
[key: string]: string;
779-
}
776+
dataId: SetColumnDisplayFormatUpdaterAction['dataId'],
777+
formats: SetColumnDisplayFormatUpdaterAction['formats']
780778
): Merge<
781779
SetColumnDisplayFormatUpdaterAction,
782780
{type: typeof ActionTypes.SET_COLUMN_DISPLAY_FORMAT}

src/types/schemas.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export type SavedLayer = {
6060
columns: {
6161
[key: string]: string;
6262
};
63+
columnMode: string;
6364
isVisible: boolean;
6465
visConfig: Record<string, any>;
6566
hidden: boolean;
6667
textLabel: Merge<LayerTextLabel, {field: {name: string; type: string} | null}>;
67-
columnMode: string;
6868
};
6969
visualChannels: SavedVisualChannels;
7070
};

src/utils/src/data-scale-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function getScaleLabels(
206206
});
207207
}
208208

209-
const customScaleLabelFormat = d => String(d);
209+
const customScaleLabelFormat = n => (n ? formatNumber(n, 'real') : 'no value');
210210
/**
211211
* Get linear / quant scale color breaks
212212
*/

src/utils/src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ export function findById(id: string): <X extends {id: string}>(arr: X[]) => X |
230230
* Returns array difference from
231231
*/
232232
export function arrayDifference<X extends {id: string}>(source: X[]): (compare: X[]) => X[] {
233+
const initial: X[] = [];
233234
return compare =>
234235
source.reduce((acc, element) => {
235236
const foundElement = findById(element.id)(compare);
236237
return foundElement ? [...acc, foundElement] : acc;
237-
}, [] as X[]);
238+
}, initial);
238239
}

0 commit comments

Comments
 (0)