fix(charts): fix engineering notation formatter locale issue
This MR tidies up the engineeringNotation function, in accordance with the proposed fix on this bug ticket: #717 (closed)
Changes:
- No longer use special parsing for strings containing digit grouping characters, as this was not locale-aware and could cause unexpected behaviour.
- Add a specification to cover the case where a number-parseable string is passed as an input.
- More closely follow the behaviour of
Intl.NumberFormat.prototype.format()
:- Parse string inputs according to
Number(string)
rather thanparseFloat(string)
- Return
"NaN"
when string is unparseable
- Parse string inputs according to
Note: A scan of the @gitlab-ui
and gitlab-org/gitlab
codebases shows that we never call this function with a string as an input, so we should be ok to change the behaviour.
Related MR: !1222 (merged)
Edited by Tristan Read