Skip to content

Commit

Permalink
[Feat] Add display format setting for table/tooltip (#2826)
Browse files Browse the repository at this point in the history
- [Feat] Add display format setting for table/tooltip
- ts changes

Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta authored Dec 10, 2024
1 parent aec75d8 commit 074d123
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/actions/src/vis-state-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion src/types/schemas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/src/data-scale-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 2 additions & 1 deletion src/utils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 074d123

Please sign in to comment.