Skip to content

Commit

Permalink
fix: strings that are numbers still render as strings (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChitlangeSahas authored Sep 8, 2021
1 parent 29c17bd commit 7c5dfd3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions giraffe/src/components/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ const getStyle = (props: Props) => {
isFixed(isFirstColumnFixed, rowIndex, columnIndex) ||
isTimeData(props) ||
isTimestamp(dataType) ||
isNaN(Number(data))
isNaN(Number(data)) ||
dataType.includes('string')
) {
return style
}
Expand All @@ -114,6 +115,7 @@ const getClassName = (props: Props): string => {
columnIndex,
hoveredRowIndex,
hoveredColumnIndex,
dataType,
} = props
const classes = classnames('table-graph-cell', {
'table-graph-cell__fixed-row': isFixedRow(rowIndex, columnIndex),
Expand All @@ -132,7 +134,8 @@ const getClassName = (props: Props): string => {
columnIndex,
hoveredColumnIndex
),
'table-graph-cell__numerical': !isNaN(Number(data)),
'table-graph-cell__numerical':
!isNaN(Number(data)) && !dataType.includes('string'),
'table-graph-cell__field-name': isFieldName(
isVerticalTimeAxis,
rowIndex,
Expand Down Expand Up @@ -183,7 +186,7 @@ export const getContents = (props: Props): string => {
return defaultTo(getFieldName(props), '').toString()
}

if (!isNaN(+data)) {
if (!isNaN(+data) && !dataType.includes('string')) {
// method needs the first arg to be a number to work properly
return formatStatValue(+data, {decimalPlaces})
}
Expand Down

0 comments on commit 7c5dfd3

Please sign in to comment.