MCPcopy
hub / github.com/ElemeFE/v-charts / getFormated

Function getFormated

src/utils.js:4–24  ·  view source on GitHub ↗
(val, type, digit, defaultVal = '-')

Source from the content-addressed store, hash-verified

2import { isFunction } from 'utils-lite'
3
4export const getFormated = (val, type, digit, defaultVal = '-') => {
5 if (isNaN(val)) return defaultVal
6 if (!type) return val
7 if (isFunction(type)) return type(val, numerify)
8
9 digit = isNaN(digit) ? 0 : ++digit
10 const digitStr = `.[${new Array(digit).join(0)}]`
11 let formatter = type
12 switch (type) {
13 case 'KMB':
14 formatter = digit ? `0,0${digitStr}a` : '0,0a'
15 break
16 case 'normal':
17 formatter = digit ? `0,0${digitStr}` : '0,0'
18 break
19 case 'percent':
20 formatter = digit ? `0,0${digitStr}%` : '0,0.[00]%'
21 break
22 }
23 return numerify(val, formatter)
24}
25
26export const getStackMap = (stack) => {
27 const stackMap = {}

Callers 14

formatterFunction · 0.90
getTooltipContentFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90
formatterFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected