Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal in table viz #10439

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/gui2/src/components/visualizations/TableVisualization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,14 @@ const numberFormat = new Intl.NumberFormat(undefined, {

function formatNumber(params: ICellRendererParams) {
const valueType = params.value?.type
const value = valueType === 'BigInt' ? BigInt(params.value?.value) : params.value
let value
if (valueType === 'BigInt') {
value = BigInt(params.value?.value)
} else if (valueType === 'Decimal') {
value = Number(params.value?.value)
} else {
value = params.value
}
const needsGrouping = dataGroupingMap.value?.get(params.colDef?.field || '')
return needsGrouping ? numberFormatGroupped.format(value) : numberFormat.format(value)
}
Expand Down Expand Up @@ -262,7 +269,8 @@ function cellClass(params: CellClassParams) {
if (typeof params.value === 'number' || params.value === null) return 'ag-right-aligned-cell'
if (typeof params.value === 'object') {
const valueType = params.value?.type
if (valueType === 'BigInt' || valueType === 'Float') return 'ag-right-aligned-cell'
if (valueType === 'BigInt' || valueType === 'Float' || valueType === 'Decimal')
return 'ag-right-aligned-cell'
}
return null
}
Expand All @@ -277,6 +285,7 @@ function cellRenderer(params: ICellRendererParams) {
else if (typeof params.value === 'object') {
const valueType = params.value?.type
if (valueType === 'BigInt') return formatNumber(params)
else if (valueType === 'Decimal') return formatNumber(params)
else if (valueType === 'Float')
return `<span style="color:grey; font-style: italic;">${params.value?.value ?? 'Unknown'}</span>`
else if ('_display_text_' in params.value && params.value['_display_text_'])
Expand Down
Loading