From d4b2390fc15b41739cb267415ba476bdc37456ac Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Wed, 6 Mar 2024 14:08:43 +0000 Subject: [PATCH] Small change limiting the number of decimal places to 12 digits. (#9298) Format numbers in the ag-grid so we don't get loads on pointless digits. ![image](https://github.com/enso-org/enso/assets/4699705/0731af47-1e7e-46f5-8bf3-5503ab74a8e3) --- .../src/components/visualizations/TableVisualization.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/gui2/src/components/visualizations/TableVisualization.vue b/app/gui2/src/components/visualizations/TableVisualization.vue index d202b8487cc..d28c190bc8d 100644 --- a/app/gui2/src/components/visualizations/TableVisualization.vue +++ b/app/gui2/src/components/visualizations/TableVisualization.vue @@ -72,7 +72,7 @@ import { useAutoBlur } from '@/util/autoBlur' import { VisualizationContainer } from '@/util/visualizationBuiltins' import '@ag-grid-community/styles/ag-grid.css' import '@ag-grid-community/styles/ag-theme-alpine.css' -import { Grid, type ColumnResizedEvent } from 'ag-grid-community' +import { Grid, type ColumnResizedEvent, type ICellRendererParams } from 'ag-grid-community' import type { ColDef, GridOptions, HeaderValueGetterParams } from 'ag-grid-enterprise' import { computed, onMounted, onUnmounted, reactive, ref, watchEffect, type Ref } from 'vue' const { LicenseManager } = await import('ag-grid-enterprise') @@ -152,10 +152,12 @@ function escapeHTML(str: string) { return str.replace(/[&<>"']/g, (m) => mapping[m]!) } -function cellRenderer(params: { value: string | null }) { +function cellRenderer(params: ICellRendererParams) { if (params.value === null) return 'Nothing' else if (params.value === undefined) return '' else if (params.value === '') return 'Empty' + else if (typeof params.value === 'number') + return params.value.toLocaleString(undefined, { maximumFractionDigits: 12 }) else return escapeHTML(params.value.toString()) }