Skip to content

Commit

Permalink
update rounding function for overview dict
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelPesce committed Jul 9, 2024
1 parent 8d68d4e commit a616788
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion electron/ui/src/components/DataTable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export default function DataTable(props) {
},
}

const roundKPI = (value) => {
if (isNaN(value)) return value
else if (value >= 1000) return value.toLocaleString('en-US', {maximumFractionDigits:0})
else if (value >= 100) return value.toLocaleString('en-US', {maximumFractionDigits:1})
else if (value >= 10) return value.toLocaleString('en-US', {maximumFractionDigits:2})
else return value.toLocaleString('en-US', {maximumFractionDigits:3})
}

const handleChangeValue = (event) => {
let inds = event.target.getAttribute('name').split(":")
//ind[0] is the index inside the array
Expand Down Expand Up @@ -286,7 +294,8 @@ const renderOutputTable = () => {
key={"" + index + i}
style={i === 0 ? styles.firstCol : styles.other}>
{(i === (value.length - 1)) ?
cellValue.toLocaleString('en-US', {maximumFractionDigits:0}) :
// cellValue.toLocaleString('en-US', {maximumFractionDigits:0}) :
roundKPI(cellValue) :
cellValue ? CategoryNames[cellValue] ? CategoryNames[cellValue] :
cellValue.replace('v_F_','')
.replace('e_','')
Expand Down

0 comments on commit a616788

Please sign in to comment.