Skip to content

Commit

Permalink
fix: fix decimal fold error
Browse files Browse the repository at this point in the history
  • Loading branch information
liihuu committed May 10, 2024
1 parent 0afcd52 commit dc982f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function formatThousands (value: string | number, sign: string): string {

export function formatFoldDecimal (value: string | number, threshold: number): string {
const vl = `${value}`
const reg = new RegExp('.0{' + threshold + ',}[1-9]\\d*$')
const reg = new RegExp('\\.0{' + threshold + ',}[1-9][0-9]*$')
if (reg.test(vl)) {
const result = vl.split('.')
const v = result[result.length - 1]
Expand Down
2 changes: 1 addition & 1 deletion src/store/ChartStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default class ChartStore {
if (isString(thousandsSeparator)) {
this._thousandsSeparator = thousandsSeparator
}
if (isNumber(decimalFoldThreshold)) {
if (isNumber(decimalFoldThreshold) && decimalFoldThreshold > 0) {
this._decimalFoldThreshold = decimalFoldThreshold
}
}
Expand Down

0 comments on commit dc982f2

Please sign in to comment.