File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 12
12
export let loading = false ;
13
13
14
14
$: scaled = value != null && ! Number .isNaN (value) ? value * factor : null ;
15
+ $: digitsPow = Math .pow (10 , digits);
16
+ $: roundedValue = Math .round (Math .abs (scaled) * digitsPow);
15
17
16
18
$: hasFraction = loading || (scaled != null && digits > 0 && Math .floor (scaled) !== scaled);
17
- $: base = loading ? ' 00' : scaled == null ? ' N/A' : Math .floor (scaled);
18
- $: digitsPow = Math .pow (10 , digits);
19
- $: fraction = ! loading && hasFraction ? Math .round (Math .abs (scaled) * digitsPow) % digitsPow : 0 ;
19
+ $: base = loading ? ' 00' : scaled == null ? ' N/A' : Math .floor (roundedValue / digitsPow);
20
+ $: fraction = ! loading && hasFraction ? roundedValue % digitsPow : 0 ;
20
21
</script >
21
22
22
23
<KPI text ={base .toLocaleString ()} sub ={hasFraction ? ` .${fraction } ` : null } {loading } />
You can’t perform that action at this time.
0 commit comments